From 7f3eba5899f7cb43f356155f16aa7fbf2370d142 Mon Sep 17 00:00:00 2001 From: Mike Date: Wed, 3 Apr 2024 06:03:49 +0100 Subject: [PATCH] Free some esp8266 RAM (#2752) This PR frees some esp8266 RAM consumed by the `.rodata` segment. This can be examined with `objdump -s -j .rodata out/Esp8266/debug/build/app_0.out` **Store `http-parser` method strings in flash** Also remove unused `http_status_str()` function, consumes RAM even though it's never called. Saves 1100 bytes RAM. **More http-parser strings into flash** No need for these to be in RAM. **Update `http-parser` lib to final version** **Put WS parser error strings in flash** **Remove `EspDigitalPin`** Only MUX addresses are required, and that only needs 1 byte. Saves up to 196 byte RAM. **Optimise rapidxml lookup tables** Saves 2020 bytes RAM **Add python script to scan/compare CI build logs** Savings: ``` samples/Basic_Blink log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ---- ---------- -------------- -------- --------- log-0e46891-develop.txt 58 712 1336 7265 55932 2106 79814 25521 log-9c72d313-flashstrings.txt 58 536 1336 7269 55932 1930 79990 25517 Difference -176 +4 -176 +176 -4 samples/Basic_Capsense log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1316 916 25416 25570 209856 27648 54272 7216 log-9c72d313-flashstrings.txt 1316 740 25416 25574 209856 27472 54448 7212 Difference -176 +4 -176 +176 -4 samples/Basic_HwPWM log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1329 924 25760 26122 219520 28013 53907 6664 log-9c72d313-flashstrings.txt 1329 764 25760 26122 219636 27853 54067 6664 Difference -160 +116 -160 +160 samples/Basic_IFS log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1952 2616 25984 26453 399202 30552 51368 6333 log-9c72d313-flashstrings.txt 1952 1248 25976 26453 399834 29176 52744 6333 Difference -1368 -8 +632 -1376 +1376 samples/Basic_Interrupts log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ---- ---------- -------------- -------- --------- log-0e46891-develop.txt 64 720 1712 7977 62256 2496 79424 24809 log-9c72d313-flashstrings.txt 64 544 1712 7981 62256 2320 79600 24805 Difference -176 +4 -176 +176 -4 samples/Basic_NFC log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ---- ---------- -------------- -------- --------- log-0e46891-develop.txt 66 728 1536 8077 66232 2330 79590 24709 log-9c72d313-flashstrings.txt 66 552 1536 8081 66232 2154 79766 24705 Difference -176 +4 -176 +176 -4 samples/Basic_Neopixel log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1320 960 25696 26838 222488 27976 53944 5948 log-9c72d313-flashstrings.txt 1320 784 25696 26842 222488 27800 54120 5944 Difference -176 +4 -176 +176 -4 samples/Basic_Ota log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1608 2408 25584 26110 314125 29600 52320 6676 log-9c72d313-flashstrings.txt 1608 1016 25584 26110 314817 28208 53712 6676 Difference -1392 +692 -1392 +1392 samples/Basic_Servo log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ---- ---------- -------------- -------- --------- log-0e46891-develop.txt 64 812 1888 8457 65064 2764 79156 24329 log-9c72d313-flashstrings.txt 64 636 1888 8461 65064 2588 79332 24325 Difference -176 +4 -176 +176 -4 samples/Basic_Ssl log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1948 3020 25856 26122 332594 30824 51096 6664 log-9c72d313-flashstrings.txt 1948 1632 25856 26122 333286 29436 52484 6664 Difference -1388 +692 -1388 +1388 samples/Basic_WebSkeletonApp log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1644 2468 25816 26106 331133 29928 51992 6680 log-9c72d313-flashstrings.txt 1644 1084 25808 26106 331765 28536 53384 6680 Difference -1384 -8 +632 -1392 +1392 samples/Basic_WebSkeletonApp_LTS log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1644 2456 25856 26106 326425 29956 51964 6680 log-9c72d313-flashstrings.txt 1644 1072 25848 26106 327049 28564 53356 6680 Difference -1384 -8 +624 -1392 +1392 samples/CanBus log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1336 1000 25488 26286 217156 27824 54096 6500 log-9c72d313-flashstrings.txt 1336 824 25488 26290 217156 27648 54272 6496 Difference -176 +4 -176 +176 -4 samples/DFPlayerMini log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ---- ---------- -------------- -------- --------- log-0e46891-develop.txt 65 732 1544 8353 62536 2341 79579 24433 log-9c72d313-flashstrings.txt 65 556 1544 8357 62536 2165 79755 24429 Difference -176 +4 -176 +176 -4 samples/Display_TM1637 log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ---- ---------- -------------- -------- --------- log-0e46891-develop.txt 57 748 1288 7089 56900 2093 79827 25697 log-9c72d313-flashstrings.txt 57 572 1288 7093 56900 1917 80003 25693 Difference -176 +4 -176 +176 -4 samples/DnsCaptivePortal log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1572 2232 25664 25966 271856 29468 52452 6820 log-9c72d313-flashstrings.txt 1572 848 25656 25966 272488 28076 53844 6820 Difference -1384 -8 +632 -1392 +1392 samples/HttpClient log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1584 2564 25536 26039 407804 29684 52236 6747 log-9c72d313-flashstrings.txt 1584 1172 25536 26039 408504 28292 53628 6747 Difference -1392 +700 -1392 +1392 samples/HttpClient_Instapush log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1644 2388 25632 26014 268429 29664 52256 6772 log-9c72d313-flashstrings.txt 1644 996 25632 26014 269121 28272 53648 6772 Difference -1392 +692 -1392 +1392 samples/HttpClient_ThingSpeak log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1576 2268 25592 26014 265477 29436 52484 6772 log-9c72d313-flashstrings.txt 1576 876 25592 26014 266169 28044 53876 6772 Difference -1392 +692 -1392 +1392 samples/HttpServer_AJAX log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1652 2444 25920 25986 332858 30016 51904 6800 log-9c72d313-flashstrings.txt 1652 1060 25928 25986 333490 28640 53280 6800 Difference -1384 +8 +632 -1376 +1376 samples/HttpServer_Bootstrap log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1576 2620 25824 26334 327765 30020 51900 6452 log-9c72d313-flashstrings.txt 1576 1060 25832 26338 328457 28468 53452 6448 Difference -1560 +8 +4 +692 -1552 +1552 -4 samples/HttpServer_ConfigNetwork log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1644 2664 26016 26106 341734 30324 51596 6680 log-9c72d313-flashstrings.txt 1644 1288 26016 26106 342366 28948 52972 6680 Difference -1376 +632 -1376 +1376 samples/HttpServer_FirmwareUpload log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1600 2288 25592 26106 348349 29480 52440 6680 log-9c72d313-flashstrings.txt 1600 920 25600 26106 348973 28120 53800 6680 Difference -1368 +8 +624 -1360 +1360 samples/HttpServer_Plugins log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1572 2392 25504 25938 274500 29468 52452 6848 log-9c72d313-flashstrings.txt 1572 1008 25496 25938 275132 28076 53844 6848 Difference -1384 -8 +632 -1392 +1392 samples/HttpServer_WebSockets log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1572 2504 25920 26222 330085 29996 51924 6564 log-9c72d313-flashstrings.txt 1572 988 25912 26222 330861 28472 53448 6564 Difference -1516 -8 +776 -1524 +1524 samples/Humidity_AM2321 log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ---- ---------- -------------- -------- --------- log-0e46891-develop.txt 64 732 1552 7949 65937 2348 79572 24837 log-9c72d313-flashstrings.txt 64 556 1552 7953 65937 2172 79748 24833 Difference -176 +4 -176 +176 -4 samples/Humidity_BME280 log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ---- ---------- -------------- -------- --------- log-0e46891-develop.txt 308 796 1624 8073 74220 2728 79192 24713 log-9c72d313-flashstrings.txt 308 620 1624 8077 74220 2552 79368 24709 Difference -176 +4 -176 +176 -4 samples/Humidity_DHT22 log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ---- ---------- -------------- -------- --------- log-0e46891-develop.txt 308 792 1512 7997 74528 2612 79308 24789 log-9c72d313-flashstrings.txt 308 616 1512 8001 74528 2436 79484 24785 Difference -176 +4 -176 +176 -4 samples/IR_lib log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ---- ---------- -------------- -------- --------- log-0e46891-develop.txt 64 2552 1824 8951 107664 4440 77480 23835 log-9c72d313-flashstrings.txt 64 2376 1824 8955 107664 4264 77656 23831 Difference -176 +4 -176 +176 -4 samples/LED_WS2812 log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ---- ---------- -------------- -------- --------- log-0e46891-develop.txt 68 724 1272 7041 55876 2064 79856 25745 log-9c72d313-flashstrings.txt 68 548 1272 7045 55876 1888 80032 25741 Difference -176 +4 -176 +176 -4 samples/LiveDebug log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 316 2672 3000 10101 97068 5988 75932 22685 log-9c72d313-flashstrings.txt 316 2496 3000 10105 97068 5812 76108 22681 Difference -176 +4 -176 +176 -4 samples/MeteoControl log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 2080 3280 26248 27049 361489 31608 50312 5737 log-9c72d313-flashstrings.txt 2080 1716 26256 27053 362189 30052 51868 5733 Difference -1564 +8 +4 +700 -1556 +1556 -4 samples/Nextion_Button log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ---- ---------- -------------- -------- --------- log-0e46891-develop.txt 76 796 1504 7949 62336 2376 79544 24837 log-9c72d313-flashstrings.txt 76 620 1504 7953 62336 2200 79720 24833 Difference -176 +4 -176 +176 -4 samples/Radio_RCSwitch log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ---- ---------- -------------- -------- --------- log-0e46891-develop.txt 68 812 2184 8913 63160 3064 78856 23873 log-9c72d313-flashstrings.txt 68 636 2184 8917 63160 2888 79032 23869 Difference -176 +4 -176 +176 -4 samples/Radio_nRF24L01 log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ---- ---------- -------------- -------- --------- log-0e46891-develop.txt 64 732 1488 7949 67900 2284 79636 24837 log-9c72d313-flashstrings.txt 64 556 1488 7953 67900 2108 79812 24833 Difference -176 +4 -176 +176 -4 samples/Radio_si4432 log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ---- ---------- -------------- -------- --------- log-0e46891-develop.txt 100 760 1448 7997 67468 2308 79612 24789 log-9c72d313-flashstrings.txt 100 584 1448 8001 67468 2132 79788 24785 Difference -176 +4 -176 +176 -4 samples/SDCard log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ---- ---------- -------------- -------- --------- log-0e46891-develop.txt 65 792 1424 7725 76596 2281 79639 25061 log-9c72d313-flashstrings.txt 65 616 1424 7729 76596 2105 79815 25057 Difference -176 +4 -176 +176 -4 samples/ScreenLCD_5110 log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ---- ---------- -------------- -------- --------- log-0e46891-develop.txt 568 732 1432 7725 67512 2732 79188 25061 log-9c72d313-flashstrings.txt 568 556 1432 7729 67512 2556 79364 25057 Difference -176 +4 -176 +176 -4 samples/ScreenOLED_SSD1306 log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ---- ---------- -------------- -------- --------- log-0e46891-develop.txt 64 736 1640 8277 74684 2440 79480 24509 log-9c72d313-flashstrings.txt 64 560 1640 8281 74684 2264 79656 24505 Difference -176 +4 -176 +176 -4 samples/ScreenTFT_ILI9163C log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ---- ---------- -------------- -------- --------- log-0e46891-develop.txt 64 732 1472 7725 69540 2268 79652 25061 log-9c72d313-flashstrings.txt 64 556 1472 7729 69540 2092 79828 25057 Difference -176 +4 -176 +176 -4 samples/ScreenTFT_ILI9340-ILI9341 log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ---- ---------- -------------- -------- --------- log-0e46891-develop.txt 88 788 1640 8077 112385 2516 79404 24709 log-9c72d313-flashstrings.txt 88 612 1640 8081 112385 2340 79580 24705 Difference -176 +4 -176 +176 -4 samples/ScreenTFT_ST7735 log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ---- ---------- -------------- -------- --------- log-0e46891-develop.txt 68 1200 1568 8293 120205 2836 79084 24493 log-9c72d313-flashstrings.txt 68 1024 1568 8297 120205 2660 79260 24489 Difference -176 +4 -176 +176 -4 samples/Temperature_DS1820 log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ---- ---------- -------------- -------- --------- log-0e46891-develop.txt 64 736 1632 8025 67700 2432 79488 24761 log-9c72d313-flashstrings.txt 64 560 1632 8029 67700 2256 79664 24757 Difference -176 +4 -176 +176 -4 samples/UdpServer_mDNS log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1580 2332 25824 25938 326909 29736 52184 6848 log-9c72d313-flashstrings.txt 1580 952 25832 25938 327533 28364 53556 6848 Difference -1380 +8 +624 -1372 +1372 samples/Ultrasonic_HCSR04 log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ---- ---------- -------------- -------- --------- log-0e46891-develop.txt 64 720 1472 7949 62208 2256 79664 24837 log-9c72d313-flashstrings.txt 64 544 1472 7953 62208 2080 79840 24833 Difference -176 +4 -176 +176 -4 samples/WebcamServer log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1936 2324 25616 25966 316965 29876 52044 6820 log-9c72d313-flashstrings.txt 1936 940 25608 25966 317589 28484 53436 6820 Difference -1384 -8 +624 -1392 +1392 samples/Websocket_Client log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1572 2448 25912 26126 273761 29932 51988 6660 log-9c72d313-flashstrings.txt 1572 924 25912 26126 274597 28408 53512 6660 Difference -1524 +836 -1524 +1524 samples/Basic_Blink log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ---- ---------- -------------- -------- --------- log-0e46891-develop.txt 58 596 1232 7685 55964 1886 80034 25101 log-9c72d313-flashstrings.txt 58 420 1232 7689 55964 1710 80210 25097 Difference -176 +4 -176 +176 -4 samples/HttpServer_ConfigNetwork log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1640 4044 26360 27558 345208 32044 49876 5228 log-9c72d313-flashstrings.txt 1640 2672 26360 27558 345840 30672 51248 5228 Difference -1372 +632 -1372 +1372 Components/Hosted/samples/serial log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ---- ---------- -------------- -------- --------- log-0e46891-develop.txt 64 728 1480 7773 80500 2272 79648 25013 log-9c72d313-flashstrings.txt 64 552 1480 7777 80500 2096 79824 25009 Difference -176 +4 -176 +176 -4 Components/Hosted/samples/tcp log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1324 1052 25344 26146 232324 27720 54200 6640 log-9c72d313-flashstrings.txt 1324 876 25344 26150 232324 27544 54376 6636 Difference -176 +4 -176 +176 -4 Libraries/AnimatedGIF/samples/Basic_AnimatedGIF log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 64 936 2096 11069 106647 3096 78824 21717 log-9c72d313-flashstrings.txt 64 760 2096 11069 106647 2920 79000 21717 Difference -176 -176 +176 Libraries/CS5460/samples/generic log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1320 1020 25448 26238 214396 27788 54132 6548 log-9c72d313-flashstrings.txt 1320 844 25448 26242 214396 27612 54308 6544 Difference -176 +4 -176 +176 -4 Libraries/CommandProcessing/samples/Arducam log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1572 3104 26160 26194 338417 30836 51084 6592 log-9c72d313-flashstrings.txt 1572 1548 26160 26198 339049 29280 52640 6588 Difference -1556 +4 +632 -1556 +1556 -4 Libraries/DIAL/samples/DIAL_Client log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1576 4760 25824 26138 320971 32160 49760 6648 log-9c72d313-flashstrings.txt 1576 1072 25816 26138 322119 28464 53456 6648 Difference -3688 -8 +1148 -3696 +3696 Libraries/Graphics/samples/Advanced_Animation log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 64 936 2936 11125 93719 3936 77984 21661 log-9c72d313-flashstrings.txt 64 760 2936 11125 93719 3760 78160 21661 Difference -176 -176 +176 Libraries/Graphics/samples/Basic_Animation log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 64 1056 2984 11185 105707 4104 77816 21601 log-9c72d313-flashstrings.txt 64 880 2984 11185 105707 3928 77992 21601 Difference -176 -176 +176 Libraries/Graphics/samples/Basic_Graphics log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1556 4400 2464 11461 301788 8420 73500 21325 log-9c72d313-flashstrings.txt 1556 1920 2464 11461 302248 5940 75980 21325 Difference -2480 +460 -2480 +2480 Libraries/Graphics/samples/Basic_Touch log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 72 1168 2304 11185 141239 3544 78376 21601 log-9c72d313-flashstrings.txt 72 992 2304 11185 141239 3368 78552 21601 Difference -176 -176 +176 Libraries/Graphics/samples/Bresenham log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 308 1668 2232 11193 176901 4208 77712 21593 log-9c72d313-flashstrings.txt 308 1492 2232 11193 176901 4032 77888 21593 Difference -176 -176 +176 Libraries/Graphics/samples/Color_Test log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 64 1080 2160 11185 104647 3304 78616 21601 log-9c72d313-flashstrings.txt 64 904 2160 11185 104647 3128 78792 21601 Difference -176 -176 +176 Libraries/Graphics/samples/Custom_Object log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 68 1156 2240 11241 108263 3464 78456 21545 log-9c72d313-flashstrings.txt 68 980 2240 11241 108263 3288 78632 21545 Difference -176 -176 +176 Libraries/HueEmulator/samples/Basic_Alexa log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1644 2820 26208 26574 333055 30672 51248 6212 log-9c72d313-flashstrings.txt 1644 1256 26208 26578 333855 29108 52812 6208 Difference -1564 +4 +800 -1564 +1564 -4 Libraries/IOControl/samples/Basic_RS485 log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ---- ---- ---------- -------------- -------- --------- log-0e46891-develop.txt 152 924 1648 8217 100833 2724 79196 24569 log-9c72d313-flashstrings.txt 152 748 1648 8221 100833 2548 79372 24565 Difference -176 +4 -176 +176 -4 Libraries/ModbusMaster/samples/generic log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1320 1012 25840 26238 214772 28172 53748 6548 log-9c72d313-flashstrings.txt 1320 836 25840 26242 214772 27996 53924 6544 Difference -176 +4 -176 +176 -4 Libraries/MultipartParser/samples/Conditional_Upload log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1600 2348 25600 25966 314529 29548 52372 6820 log-9c72d313-flashstrings.txt 1600 972 25600 25966 315153 28172 53748 6820 Difference -1376 +624 -1376 +1376 Libraries/RingTone/samples/RingTonePlayer log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 2016 2872 26200 27361 355532 31088 50832 5425 log-9c72d313-flashstrings.txt 2016 1356 26192 27361 356308 29564 52356 5425 Difference -1516 -8 +776 -1524 +1524 Libraries/UPnP/samples/Basic_ControlPoint log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1576 4852 25864 26194 409155 32292 49628 6592 log-9c72d313-flashstrings.txt 1576 1164 25856 26194 410323 28596 53324 6592 Difference -3688 -8 +1168 -3696 +3696 Libraries/UPnP/samples/Basic_UPnP log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1940 5260 26192 26430 361963 33392 48528 6356 log-9c72d313-flashstrings.txt 1940 1396 26200 26434 363127 29536 52384 6352 Difference -3864 +8 +4 +1164 -3856 +3856 -4 Libraries/jerryscript/samples/Advanced_Jsvm log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1964 5168 26848 26155 382821 33980 47940 6631 log-9c72d313-flashstrings.txt 1964 3800 26856 26155 383453 32620 49300 6631 Difference -1368 +8 +632 -1360 +1360 Libraries/modbusino/samples/generic log data rodata bss text irom0_text Total Used RAM Free RAM Free IRam ----------------------------- ---- ------ ----- ----- ---------- -------------- -------- --------- log-0e46891-develop.txt 1320 1020 25736 26238 214080 28076 53844 6548 log-9c72d313-flashstrings.txt 1320 844 25736 26242 214080 27900 54020 6544 Difference -176 +4 -176 +176 -4 ``` --- Sming/Arch/Esp8266/Core/Digital.cpp | 63 ++++-- Sming/Arch/Esp8266/Core/ESP8266EX.cpp | 48 ---- Sming/Arch/Esp8266/Core/ESP8266EX.h | 38 ---- Sming/Arch/Esp8266/Core/HardwarePWM.cpp | 24 +- Sming/Components/.patches/http-parser.patch | 207 +++++++++++++++--- Sming/Components/.patches/ws_parser.patch | 18 +- .../Network/src/Network/Http/HttpCommon.h | 3 +- Sming/Components/http-parser | 2 +- Sming/Libraries/RapidXML | 2 +- Tools/ci/scanlog.py | 193 ++++++++++++++++ 10 files changed, 449 insertions(+), 149 deletions(-) delete mode 100644 Sming/Arch/Esp8266/Core/ESP8266EX.cpp delete mode 100644 Sming/Arch/Esp8266/Core/ESP8266EX.h create mode 100644 Tools/ci/scanlog.py diff --git a/Sming/Arch/Esp8266/Core/Digital.cpp b/Sming/Arch/Esp8266/Core/Digital.cpp index d8bb1e6021..7a7af26d1e 100644 --- a/Sming/Arch/Esp8266/Core/Digital.cpp +++ b/Sming/Arch/Esp8266/Core/Digital.cpp @@ -9,19 +9,42 @@ ****/ #include -#include "ESP8266EX.h" #include #include #include #include +#define TOTAL_PINS 16 + +#define PINMUX_OFFSET(addr) uint8_t((addr)-PERIPHS_IO_MUX) + +// Used for pullup/noPullup +extern const uint8_t esp8266_pinmuxOffset[] = { + PINMUX_OFFSET(PERIPHS_IO_MUX_GPIO0_U), // 0 FLASH + PINMUX_OFFSET(PERIPHS_IO_MUX_U0TXD_U), // 1 TXD0 + PINMUX_OFFSET(PERIPHS_IO_MUX_GPIO2_U), // 2 TXD1 + PINMUX_OFFSET(PERIPHS_IO_MUX_U0RXD_U), // 3 RXD0 + PINMUX_OFFSET(PERIPHS_IO_MUX_GPIO4_U), // 4 + PINMUX_OFFSET(PERIPHS_IO_MUX_GPIO5_U), // 5 + PINMUX_OFFSET(PERIPHS_IO_MUX_SD_CLK_U), // 6 SD_CLK_U + PINMUX_OFFSET(PERIPHS_IO_MUX_SD_DATA0_U), // 7 SD_DATA0_U + PINMUX_OFFSET(PERIPHS_IO_MUX_SD_DATA1_U), // 8 SD_DATA1_U + PINMUX_OFFSET(PERIPHS_IO_MUX_SD_DATA2_U), // 9 + PINMUX_OFFSET(PERIPHS_IO_MUX_SD_DATA3_U), // 10 + PINMUX_OFFSET(PERIPHS_IO_MUX_SD_CMD_U), // 11 SD_CMD_U + PINMUX_OFFSET(PERIPHS_IO_MUX_MTDI_U), // 12 HSPIQ + PINMUX_OFFSET(PERIPHS_IO_MUX_MTCK_U), // 13 HSPID + PINMUX_OFFSET(PERIPHS_IO_MUX_MTMS_U), // 14 HSPICLK + PINMUX_OFFSET(PERIPHS_IO_MUX_MTDO_U), // 15 HSPICS +}; + // Prototype declared in esp8266-peri.h -const uint8_t esp8266_gpioToFn[16] = {0x34, 0x18, 0x38, 0x14, 0x3C, 0x40, 0x1C, 0x20, - 0x24, 0x28, 0x2C, 0x30, 0x04, 0x08, 0x0C, 0x10}; +const uint8_t esp8266_gpioToFn[TOTAL_PINS] = {0x34, 0x18, 0x38, 0x14, 0x3C, 0x40, 0x1C, 0x20, + 0x24, 0x28, 0x2C, 0x30, 0x04, 0x08, 0x0C, 0x10}; void pinMode(uint16_t pin, uint8_t mode) { - if(pin < 16) { + if(pin < TOTAL_PINS) { if(mode == SPECIAL) { GPC(pin) = (GPC(pin) & (0xF << GPCI)); //SOURCE(GPIO) | DRIVER(NORMAL) | INT_TYPE(UNCHANGED) | WAKEUP_ENABLE(DISABLED) @@ -100,38 +123,32 @@ void digitalWrite(uint16_t pin, uint8_t val) pullup(pin); else noPullup(pin); - } else { - if(pin != 16) - GPIO_REG_WRITE((((val != LOW) ? GPIO_OUT_W1TS_ADDRESS : GPIO_OUT_W1TC_ADDRESS)), (1 << pin)); - else - WRITE_PERI_REG(RTC_GPIO_OUT, (READ_PERI_REG(RTC_GPIO_OUT) & (uint32_t)0xfffffffe) | (uint32_t)(val & 1)); - - //GPIO_OUTPUT_SET(pin, (val ? 0xFF : 00)); - } + } else if(pin != 16) + GPIO_REG_WRITE((((val != LOW) ? GPIO_OUT_W1TS_ADDRESS : GPIO_OUT_W1TC_ADDRESS)), (1 << pin)); + else + WRITE_PERI_REG(RTC_GPIO_OUT, (READ_PERI_REG(RTC_GPIO_OUT) & (uint32_t)0xfffffffe) | (uint32_t)(val & 1)); } uint8_t digitalRead(uint16_t pin) { - if(pin != 16) + if(pin != 16) { return ((GPIO_REG_READ(GPIO_IN_ADDRESS) >> pin) & 1); - else - return (uint8_t)(READ_PERI_REG(RTC_GPIO_IN_DATA) & 1); - - //return GPIO_INPUT_GET(pin); + } + return (uint8_t)(READ_PERI_REG(RTC_GPIO_IN_DATA) & 1); } void pullup(uint16_t pin) { - if(pin >= 16) - return; - PIN_PULLUP_EN((EspDigitalPins[pin].mux)); + if(pin < TOTAL_PINS) { + PIN_PULLUP_EN(PERIPHS_IO_MUX + esp8266_pinmuxOffset[pin]); + } } void noPullup(uint16_t pin) { - if(pin >= 16) - return; - PIN_PULLUP_DIS((EspDigitalPins[pin].mux)); + if(pin < TOTAL_PINS) { + PIN_PULLUP_DIS(PERIPHS_IO_MUX + esp8266_pinmuxOffset[pin]); + } } /* Measures the length (in microseconds) of a pulse on the pin; state is HIGH diff --git a/Sming/Arch/Esp8266/Core/ESP8266EX.cpp b/Sming/Arch/Esp8266/Core/ESP8266EX.cpp deleted file mode 100644 index 59e8bd4250..0000000000 --- a/Sming/Arch/Esp8266/Core/ESP8266EX.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * ESP8266EX.cpp - * - ****/ - -#include "Digital.h" -#include "ESP8266EX.h" -#include "Digital.h" -#include - -const EspDigitalPin EspDigitalPins[] = { - {0, PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0}, // FLASH - {1, PERIPHS_IO_MUX_U0TXD_U, FUNC_GPIO1}, // TXD0 - {2, PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2}, // TXD1 - {3, PERIPHS_IO_MUX_U0RXD_U, FUNC_GPIO3}, // RXD0 - {4, PERIPHS_IO_MUX_GPIO4_U, FUNC_GPIO4}, - {5, PERIPHS_IO_MUX_GPIO5_U, FUNC_GPIO5}, - {6, 0, 0}, // SD_CLK_U - {7, 0, 0}, // SD_DATA0_U - {8, 0, 0}, // SD_DATA1_U - {9, PERIPHS_IO_MUX_SD_DATA2_U, FUNC_GPIO9}, - {10, PERIPHS_IO_MUX_SD_DATA3_U, FUNC_GPIO10}, - {11, 0, 0}, // SD_CMD_U - {12, PERIPHS_IO_MUX_MTDI_U, FUNC_GPIO12}, // HSPIQ - {13, PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO13}, // HSPID - {14, PERIPHS_IO_MUX_MTMS_U, FUNC_GPIO14}, // HSPICLK - {15, PERIPHS_IO_MUX_MTDO_U, FUNC_GPIO15}, // HSPICS -}; - -void EspDigitalPin::mode(uint8_t mode) const -{ - pinMode(id, mode); -} - -void EspDigitalPin::write(uint8_t val) const -{ - digitalWrite(id, val); -} - -uint8_t EspDigitalPin::read() const -{ - return digitalRead(id); -} diff --git a/Sming/Arch/Esp8266/Core/ESP8266EX.h b/Sming/Arch/Esp8266/Core/ESP8266EX.h deleted file mode 100644 index 6d83620d37..0000000000 --- a/Sming/Arch/Esp8266/Core/ESP8266EX.h +++ /dev/null @@ -1,38 +0,0 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * ESP8266EX.h - * - ****/ - -#pragma once - -#include - -#define TOTAL_PINS 16 -#define NUM_DIGITAL_PINS TOTAL_PINS - -/** @brief ESP GPIO pin configuration - * @ingroup constants - */ -struct EspDigitalPin { - uint8_t id; - uint32_t mux; - uint8_t gpioFunc; - - operator const int() const - { - return id; - } - void mode(uint8_t mode) const; - void write(uint8_t val) const; - uint8_t read() const; -}; - -/** @brief ESP GPIO pin configuration - * @ingroup gpio - */ -extern const EspDigitalPin EspDigitalPins[]; diff --git a/Sming/Arch/Esp8266/Core/HardwarePWM.cpp b/Sming/Arch/Esp8266/Core/HardwarePWM.cpp index 585f5b813e..13aa43764a 100644 --- a/Sming/Arch/Esp8266/Core/HardwarePWM.cpp +++ b/Sming/Arch/Esp8266/Core/HardwarePWM.cpp @@ -25,11 +25,14 @@ #include #include -#include "ESP8266EX.h" #include +#include "pins_arduino.h" +#include #define PERIOD_TO_MAX_DUTY(x) (x * 25) +extern const uint8_t esp8266_pinmuxOffset[]; + HardwarePWM::HardwarePWM(uint8_t* pins, uint8_t noOfPins) : channel_count(noOfPins) { if(noOfPins == 0) { @@ -38,15 +41,22 @@ HardwarePWM::HardwarePWM(uint8_t* pins, uint8_t noOfPins) : channel_count(noOfPi uint32_t ioInfo[PWM_CHANNEL_NUM_MAX][3]; // pin information uint32_t pwmDutyInit[PWM_CHANNEL_NUM_MAX]; // pwm duty + unsigned pinCount = 0; for(uint8_t i = 0; i < noOfPins; i++) { - ioInfo[i][0] = EspDigitalPins[pins[i]].mux; - ioInfo[i][1] = EspDigitalPins[pins[i]].gpioFunc; - ioInfo[i][2] = EspDigitalPins[pins[i]].id; - pwmDutyInit[i] = 0; // Start with zero output - channels[i] = pins[i]; + auto pin = pins[i]; + assert(pin < 16); + if(pin >= 16) { + continue; + } + ioInfo[pinCount][0] = PERIPHS_IO_MUX + esp8266_pinmuxOffset[pin]; + ioInfo[pinCount][1] = esp8266_gpioToFn[pin]; + ioInfo[pinCount][2] = pin; + pwmDutyInit[pinCount] = 0; // Start with zero output + channels[pinCount] = pin; + ++pinCount; } const int initialPeriod = 1000; - pwm_init(initialPeriod, pwmDutyInit, noOfPins, ioInfo); + pwm_init(initialPeriod, pwmDutyInit, pinCount, ioInfo); update(); maxduty = PERIOD_TO_MAX_DUTY(initialPeriod); // for period of 1000 } diff --git a/Sming/Components/.patches/http-parser.patch b/Sming/Components/.patches/http-parser.patch index ce1eee4d48..8469a2dc19 100644 --- a/Sming/Components/.patches/http-parser.patch +++ b/Sming/Components/.patches/http-parser.patch @@ -1,8 +1,8 @@ diff --git a/http_parser.h b/http_parser.h -index df88252..5935bcf 100644 +index 3772b39..a1f4d38 100644 --- a/http_parser.h +++ b/http_parser.h -@@ -153,7 +153,7 @@ typedef int (*http_cb) (http_parser*); +@@ -155,7 +155,7 @@ typedef int (*http_cb) (http_parser*); enum http_status { @@ -11,7 +11,7 @@ index df88252..5935bcf 100644 HTTP_STATUS_MAP(XX) #undef XX }; -@@ -206,7 +206,7 @@ enum http_status +@@ -208,7 +208,7 @@ enum http_status enum http_method { @@ -20,7 +20,7 @@ index df88252..5935bcf 100644 HTTP_METHOD_MAP(XX) #undef XX }; -@@ -282,17 +282,13 @@ enum flags +@@ -283,17 +283,13 @@ enum flags /* Define HPE_* values for each errno value above */ @@ -39,8 +39,24 @@ index df88252..5935bcf 100644 struct http_parser { /** PRIVATE **/ unsigned int type : 2; /* enum http_parser_type */ +@@ -417,15 +413,6 @@ int http_should_keep_alive(const http_parser *parser); + /* Returns a string version of the HTTP method. */ + const char *http_method_str(enum http_method m); + +-/* Returns a string version of the HTTP status code. */ +-const char *http_status_str(enum http_status s); +- +-/* Return a string name of the given error */ +-const char *http_errno_name(enum http_errno err); +- +-/* Return a string description of the given error */ +-const char *http_errno_description(enum http_errno err); +- + /* Initialize all http_parser_url members to 0 */ + void http_parser_url_init(struct http_parser_url *u); + diff --git a/http_parser.c b/http_parser.c -index 95ff42f..beaf1f7 100644 +index 9be003e..e6b0051 100644 --- a/http_parser.c +++ b/http_parser.c @@ -20,11 +20,19 @@ @@ -65,7 +81,43 @@ index 95ff42f..beaf1f7 100644 static uint32_t max_header_size = HTTP_MAX_HEADER_SIZE; #ifndef ULLONG_MAX -@@ -186,7 +194,7 @@ static const char *method_strings[] = +@@ -160,7 +168,6 @@ do { \ + } \ + } while (0) + +- + #define PROXY_CONNECTION "proxy-connection" + #define CONNECTION "connection" + #define CONTENT_LENGTH "content-length" +@@ -170,10 +177,25 @@ do { \ + #define KEEP_ALIVE "keep-alive" + #define CLOSE "close" + ++static const char STR_PROXY_CONNECTION[] PROGMEM_PSTR = "proxy-connection"; ++static const char STR_CONNECTION[] PROGMEM_PSTR = "connection"; ++static const char STR_CONTENT_LENGTH[] PROGMEM_PSTR = "content-length"; ++static const char STR_TRANSFER_ENCODING[] PROGMEM_PSTR = "transfer-encoding"; ++static const char STR_UPGRADE[] PROGMEM_PSTR = "upgrade"; ++static const char STR_CHUNKED[] PROGMEM_PSTR = "chunked"; ++static const char STR_KEEP_ALIVE[] PROGMEM_PSTR = "keep-alive"; ++static const char STR_CLOSE[] PROGMEM_PSTR = "close"; + +-static const char *method_strings[] = ++#define get_pstr_char(name, index) (char)pgm_read_byte(&STR_##name[index]) ++ ++ ++#define XX(num, name, string) static const char method_string_##name[] PROGMEM_PSTR = #string; ++ HTTP_METHOD_MAP(XX) ++#undef XX ++ ++static const char *method_strings[] PROGMEM_PSTR = + { +-#define XX(num, name, string) #string, ++#define XX(num, name, string) method_string_##name, + HTTP_METHOD_MAP(XX) + #undef XX + }; +@@ -186,7 +208,7 @@ static const char *method_strings[] = * | "/" | "[" | "]" | "?" | "=" * | "{" | "}" | SP | HT */ @@ -74,7 +126,7 @@ index 95ff42f..beaf1f7 100644 /* 0 nul 1 soh 2 stx 3 etx 4 eot 5 enq 6 ack 7 bel */ 0, 0, 0, 0, 0, 0, 0, 0, /* 8 bs 9 ht 10 nl 11 vt 12 np 13 cr 14 so 15 si */ -@@ -220,19 +228,10 @@ static const char tokens[256] = { +@@ -220,19 +242,10 @@ static const char tokens[256] = { /* 120 x 121 y 122 z 123 { 124 | 125 } 126 ~ 127 del */ 'x', 'y', 'z', 0, '|', 0, '~', 0 }; @@ -98,7 +150,7 @@ index 95ff42f..beaf1f7 100644 #if HTTP_PARSER_STRICT # define T(v) 0 #else -@@ -428,14 +427,14 @@ enum http_host_state +@@ -428,14 +441,14 @@ enum http_host_state (c) == ';' || (c) == ':' || (c) == '&' || (c) == '=' || (c) == '+' || \ (c) == '$' || (c) == ',') @@ -115,7 +167,7 @@ index 95ff42f..beaf1f7 100644 #define IS_URL_CHAR(c) \ (BIT_AT(normal_url_char, (unsigned char)c) || ((c) & 0x80)) #define IS_HOST_CHAR(c) \ -@@ -467,16 +466,6 @@ do { \ +@@ -467,16 +480,6 @@ do { \ #endif @@ -132,7 +184,7 @@ index 95ff42f..beaf1f7 100644 int http_message_needs_eof(const http_parser *parser); /* Our URL parser. -@@ -758,7 +747,7 @@ reexecute: +@@ -760,7 +763,7 @@ reexecute: } parser->type = HTTP_REQUEST; @@ -141,7 +193,7 @@ index 95ff42f..beaf1f7 100644 parser->index = 2; UPDATE_STATE(s_req_method); } -@@ -938,23 +927,23 @@ reexecute: +@@ -940,23 +943,23 @@ reexecute: parser->method = (enum http_method) 0; parser->index = 1; switch (ch) { @@ -180,7 +232,18 @@ index 95ff42f..beaf1f7 100644 default: SET_ERRNO(HPE_INVALID_METHOD); goto error; -@@ -983,8 +972,8 @@ reexecute: +@@ -977,16 +980,17 @@ reexecute: + } + + matcher = method_strings[parser->method]; +- if (ch == ' ' && matcher[parser->index] == '\0') { ++ char matcher_char = pgm_read_byte(&matcher[parser->index]); ++ if (ch == ' ' && matcher_char == '\0') { + UPDATE_STATE(s_req_spaces_before_url); +- } else if (ch == matcher[parser->index]) { ++ } else if (ch == matcher_char) { + ; /* nada */ + } else if ((ch >= 'A' && ch <= 'Z') || ch == '-') { switch (parser->method << 16 | parser->index << 8 | ch) { #define XX(meth, pos, ch, new_meth) \ @@ -191,7 +254,7 @@ index 95ff42f..beaf1f7 100644 XX(POST, 1, 'U', PUT) XX(POST, 1, 'A', PATCH) -@@ -1024,7 +1013,7 @@ reexecute: +@@ -1026,7 +1030,7 @@ reexecute: if (ch == ' ') break; MARK(url); @@ -200,7 +263,7 @@ index 95ff42f..beaf1f7 100644 UPDATE_STATE(s_req_server_start); } -@@ -1100,7 +1089,7 @@ reexecute: +@@ -1102,7 +1106,7 @@ reexecute: UPDATE_STATE(s_req_http_H); break; case 'I': @@ -209,7 +272,88 @@ index 95ff42f..beaf1f7 100644 UPDATE_STATE(s_req_http_I); break; } -@@ -1826,7 +1815,7 @@ reexecute: +@@ -1303,7 +1307,7 @@ reexecute: + case h_matching_connection: + parser->index++; + if (parser->index > sizeof(CONNECTION)-1 +- || c != CONNECTION[parser->index]) { ++ || c != get_pstr_char(CONNECTION, parser->index)) { + parser->header_state = h_general; + } else if (parser->index == sizeof(CONNECTION)-2) { + parser->header_state = h_connection; +@@ -1315,7 +1319,7 @@ reexecute: + case h_matching_proxy_connection: + parser->index++; + if (parser->index > sizeof(PROXY_CONNECTION)-1 +- || c != PROXY_CONNECTION[parser->index]) { ++ || c != get_pstr_char(PROXY_CONNECTION, parser->index)) { + parser->header_state = h_general; + } else if (parser->index == sizeof(PROXY_CONNECTION)-2) { + parser->header_state = h_connection; +@@ -1327,7 +1331,7 @@ reexecute: + case h_matching_content_length: + parser->index++; + if (parser->index > sizeof(CONTENT_LENGTH)-1 +- || c != CONTENT_LENGTH[parser->index]) { ++ || c != get_pstr_char(CONTENT_LENGTH, parser->index)) { + parser->header_state = h_general; + } else if (parser->index == sizeof(CONTENT_LENGTH)-2) { + parser->header_state = h_content_length; +@@ -1339,7 +1343,7 @@ reexecute: + case h_matching_transfer_encoding: + parser->index++; + if (parser->index > sizeof(TRANSFER_ENCODING)-1 +- || c != TRANSFER_ENCODING[parser->index]) { ++ || c != get_pstr_char(TRANSFER_ENCODING, parser->index)) { + parser->header_state = h_general; + } else if (parser->index == sizeof(TRANSFER_ENCODING)-2) { + parser->header_state = h_transfer_encoding; +@@ -1352,7 +1356,7 @@ reexecute: + case h_matching_upgrade: + parser->index++; + if (parser->index > sizeof(UPGRADE)-1 +- || c != UPGRADE[parser->index]) { ++ || c != get_pstr_char(UPGRADE, parser->index)) { + parser->header_state = h_general; + } else if (parser->index == sizeof(UPGRADE)-2) { + parser->header_state = h_upgrade; +@@ -1597,7 +1601,7 @@ reexecute: + case h_matching_transfer_encoding_chunked: + parser->index++; + if (parser->index > sizeof(CHUNKED)-1 +- || c != CHUNKED[parser->index]) { ++ || c != get_pstr_char(CHUNKED, parser->index)) { + h_state = h_matching_transfer_encoding_token; + } else if (parser->index == sizeof(CHUNKED)-2) { + h_state = h_transfer_encoding_chunked; +@@ -1633,7 +1637,7 @@ reexecute: + case h_matching_connection_keep_alive: + parser->index++; + if (parser->index > sizeof(KEEP_ALIVE)-1 +- || c != KEEP_ALIVE[parser->index]) { ++ || c != get_pstr_char(KEEP_ALIVE, parser->index)) { + h_state = h_matching_connection_token; + } else if (parser->index == sizeof(KEEP_ALIVE)-2) { + h_state = h_connection_keep_alive; +@@ -1643,7 +1647,7 @@ reexecute: + /* looking for 'Connection: close' */ + case h_matching_connection_close: + parser->index++; +- if (parser->index > sizeof(CLOSE)-1 || c != CLOSE[parser->index]) { ++ if (parser->index > sizeof(CLOSE)-1 || c != get_pstr_char(CLOSE, parser->index)) { + h_state = h_matching_connection_token; + } else if (parser->index == sizeof(CLOSE)-2) { + h_state = h_connection_close; +@@ -1654,7 +1658,7 @@ reexecute: + case h_matching_connection_upgrade: + parser->index++; + if (parser->index > sizeof(UPGRADE) - 1 || +- c != UPGRADE[parser->index]) { ++ c != get_pstr_char(UPGRADE, parser->index)) { + h_state = h_matching_connection_token; + } else if (parser->index == sizeof(UPGRADE)-2) { + h_state = h_connection_upgrade; +@@ -1833,7 +1837,7 @@ reexecute: parser->upgrade = (parser->type == HTTP_REQUEST || parser->status_code == 101); } else { @@ -218,7 +362,7 @@ index 95ff42f..beaf1f7 100644 } /* Here we call the headers_complete callback. This is somewhat -@@ -1874,7 +1863,7 @@ reexecute: +@@ -1881,7 +1885,7 @@ reexecute: hasBody = parser->flags & F_CHUNKED || (parser->content_length > 0 && parser->content_length != ULLONG_MAX); @@ -227,7 +371,7 @@ index 95ff42f..beaf1f7 100644 (parser->flags & F_SKIPBODY) || !hasBody)) { /* Exit, the rest of the message is in a different protocol. */ UPDATE_STATE(NEW_MESSAGE()); -@@ -1991,7 +1980,7 @@ reexecute: +@@ -1998,7 +2002,7 @@ reexecute: assert(nread == 1); assert(parser->flags & F_CHUNKED); @@ -236,7 +380,7 @@ index 95ff42f..beaf1f7 100644 if (UNLIKELY(unhex_val == -1)) { SET_ERRNO(HPE_INVALID_CHUNK_SIZE); goto error; -@@ -2013,7 +2002,7 @@ reexecute: +@@ -2020,7 +2024,7 @@ reexecute: break; } @@ -245,16 +389,27 @@ index 95ff42f..beaf1f7 100644 if (unhex_val == -1) { if (ch == ';' || ch == ' ') { -@@ -2207,7 +2196,7 @@ const char * - http_status_str (enum http_status s) +@@ -2207,18 +2211,7 @@ http_should_keep_alive (const http_parser *parser) + const char * + http_method_str (enum http_method m) { - switch (s) { +- return ELEM_AT(method_strings, m, ""); +-} +- +-const char * +-http_status_str (enum http_status s) +-{ +- switch (s) { -#define XX(num, name, string) case HTTP_STATUS_##name: return #string; -+#define XX(num, name, string) case HTTP_STATUS_CODE_##name: return #string; - HTTP_STATUS_MAP(XX) - #undef XX - default: return ""; -@@ -2231,18 +2220,6 @@ http_parser_settings_init(http_parser_settings *settings) +- HTTP_STATUS_MAP(XX) +-#undef XX +- default: return ""; +- } ++ return ELEM_AT(method_strings, m, PSTR("")); + } + + void +@@ -2238,18 +2231,6 @@ http_parser_settings_init(http_parser_settings *settings) memset(settings, 0, sizeof(*settings)); } diff --git a/Sming/Components/.patches/ws_parser.patch b/Sming/Components/.patches/ws_parser.patch index b1ff2037ef..c1231824dc 100644 --- a/Sming/Components/.patches/ws_parser.patch +++ b/Sming/Components/.patches/ws_parser.patch @@ -1,16 +1,17 @@ diff --git a/ws_parser.c b/ws_parser.c -index d43adbe..beeb611 100644 +index d43adbe..17040e3 100644 --- a/ws_parser.c +++ b/ws_parser.c -@@ -3,6 +3,7 @@ +@@ -3,6 +3,8 @@ #endif #include "ws_parser.h" +#include ++#include enum { S_OPCODE = 0, -@@ -27,6 +28,7 @@ enum { +@@ -27,6 +29,7 @@ enum { void ws_parser_init(ws_parser_t* parser) { @@ -18,7 +19,7 @@ index d43adbe..beeb611 100644 parser->state = S_OPCODE; parser->fragment = 0; } -@@ -247,7 +249,8 @@ ws_parser_execute( +@@ -247,7 +250,8 @@ ws_parser_execute( } if(parser->mask_flag) { @@ -28,3 +29,12 @@ index d43adbe..beeb611 100644 buff[i] ^= parser->mask[parser->mask_pos++]; } } +@@ -302,7 +306,7 @@ ws_parser_execute( + const char* + ws_parser_error(int rc) + { +- #define XX(name, code) if(rc == code) return #name; ++ #define XX(name, code) if(rc == code) return PSTR(#name); + WS_PARSER_ERROR_CODES(XX) + #undef XX + diff --git a/Sming/Components/Network/src/Network/Http/HttpCommon.h b/Sming/Components/Network/src/Network/Http/HttpCommon.h index 6ee5181b36..57c0785044 100644 --- a/Sming/Components/Network/src/Network/Http/HttpCommon.h +++ b/Sming/Components/Network/src/Network/Http/HttpCommon.h @@ -121,7 +121,8 @@ inline String httpGetStatusText(unsigned code) */ inline String toString(HttpMethod method) { - return http_method_str(http_method(method)); + auto fstr = reinterpret_cast(http_method_str(http_method(method))); + return String(fstr); } /** @} */ diff --git a/Sming/Components/http-parser b/Sming/Components/http-parser index 2343fd6b52..ec8b5ee63f 160000 --- a/Sming/Components/http-parser +++ b/Sming/Components/http-parser @@ -1 +1 @@ -Subproject commit 2343fd6b5214b2ded2cdcf76de2bf60903bb90cd +Subproject commit ec8b5ee63f0e51191ea43bb0c6eac7bfbff3141d diff --git a/Sming/Libraries/RapidXML b/Sming/Libraries/RapidXML index 4a1fe56b85..1e9f276c65 160000 --- a/Sming/Libraries/RapidXML +++ b/Sming/Libraries/RapidXML @@ -1 +1 @@ -Subproject commit 4a1fe56b851fef63b99a1433c743e5ca0043b08d +Subproject commit 1e9f276c656c3319a09ac956d3acf53e74988e85 diff --git a/Tools/ci/scanlog.py b/Tools/ci/scanlog.py new file mode 100644 index 0000000000..80f1d7a12f --- /dev/null +++ b/Tools/ci/scanlog.py @@ -0,0 +1,193 @@ +#!/usr/bin/env python +# +# Python application to scan CI build logs and extract useful information +# +# Github action logs must be in raw (text) format for processing. +# +# Use cases: +# +# Generate table of esp8266 memory usage +# Take two log files (cut & paste usually) +# Run scanlog on both +# Use kdiff3 to compare +# + +import argparse +import os +from enum import Enum + + +class State(Enum): + searching = 1 + building = 2 + linking = 3 + + +class Table: + COL_SEP = ' ' + + def __init__(self, name: str): + self.name = name + self.headings = [] + self.rows = [] + self.col_widths = [] + + def append(self, row_data: dict): + for k in row_data.keys(): + if k in self.headings: + continue + self.headings.append(k) + self.col_widths.append(len(k)) + row = ['' for x in self.headings] + for k, v in row_data.items(): + i = self.headings.index(k) + row[i] = v + self.col_widths[i] = max(self.col_widths[i], len(v)) + self.rows.append(row) + + def _format_values(self, values: list): + return self.COL_SEP.join(str(v).ljust(self.col_widths[i]) for i, v in enumerate(values)) + + def format_headings(self): + return self._format_values(self.headings) + + def format_separator(self): + return self.COL_SEP.join(''.ljust(w, '-') for w in self.col_widths) + + def format_row(self, row: int | list): + if isinstance(row, int): + row = self.rows[row] + return self._format_values(row) + + def find_row(self, name: str): + return next((i for i, row in enumerate(self.rows) if row[0] == name), -1) + + def __iter__(self): + return TableFormatter(self) + + +class TableFormatter: + def __init__(self, table: Table): + self.table = table + self.row_index = -2 + + def __next__(self): + table = self.table + idx = self.row_index + if idx == -2: + self.row_index = -1 + return table.format_headings() + if idx == -1: + self.row_index = 0 + return table.format_separator() + if idx < len(table.rows): + self.row_index = idx + 1 + return table.format_row(idx) + raise StopIteration + + +def scan_log(filename: str): + state = State.searching + table = Table(os.path.basename(filename)) + target = None + row = None + log = open(filename, 'rb') + for line in log: + line = line.decode('utf-8-sig') + dtstr, _, line = line.strip().partition(' ') + if not dtstr: + continue + _, sep, c = line.partition('** Building ') + if sep: + target, _, _ = c.partition(' ') + target = target.removeprefix('/home/runner/projects/') + row = { + 'target': target + } + state = State.building + continue + if state == State.building: + if line.startswith(f'{os.path.basename(target)}: Linking'): + state = State.linking + continue + if state == State.linking: + if 'Section' in line: + continue + if line.startswith('----'): + continue + if '|' in line: + cols = line.split('|') + k, v = cols[0], cols[4] + elif ' : ' in line: + k, v = line.split(':') + else: + table.append(row) + row = None + state = State.searching + continue + k, v = k.strip(), v.strip() + row[k] = v + continue + + return table + + +def print_table(table: Table): + print(f'{table.name}') + for line in table: + print(' ', line) + print() + + +def main(): + parser = argparse.ArgumentParser(description='Sming CI log parser') + parser.add_argument('filename', help='Log filename') + parser.add_argument('-c', '--compare', help='Second log to compare') + + args = parser.parse_args() + + table1 = scan_log(args.filename) + if args.compare is None: + print_table(table1) + return + + table2 = scan_log(args.compare) + + for row1 in table1.rows: + target = row1[0] + i = table2.find_row(target) + if i < 0: + print(f'** {target} NOT found in {table2.name}') + continue + row2 = table2.rows.pop(i) + if row2 == row1: + continue + + diff_table = Table(target) + + data = {'log': table1.name} + for k, v in zip(table1.headings[1:], row1[1:]): + data[k] = v + diff_table.append(data) + data = {'log': table2.name} + for k, v in zip(table2.headings[1:], row2[1:]): + data[k] = v + diff_table.append(data) + + data = {'log': 'Difference'} + for name, v1, v2 in zip(table1.headings[1:], row1[1:], row2[1:]): + if v1 == v2: + continue + v1, v2 = int(v1, 0), int(v2, 0) + data[name] = f'{v2-v1:+}' + diff_table.append(data) + + print_table(diff_table) + + if table2.rows: + print(f'** Targets not in {table1.name}') + print_table(table2) + + +if __name__ == "__main__": + main()