Skip to content

Build the firmware with ESP-IDF 6.1.1, and the StickC Plus2's with 6.0.3 - #92

Open
JC-000 wants to merge 16 commits into
Armitage64:mainfrom
JC-000:idf6-move
Open

JC-000 wants to merge 16 commits into
Armitage64:mainfrom
JC-000:idf6-move

Conversation

@JC-000

@JC-000 JC-000 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Part of #17: the move to ESP-IDF 6, the two RAM options deferred there from #48, a change to where Mbed TLS takes its memory on the ESP32-S3, which those options make necessary, and two TLS hardening changes.

It builds on #90 (esp_driver_uart in REQUIRES, which ESP-IDF 6 needs), whose one commit, 30f2abc, is the first in this branch; until #90 merges, review from 71f6032 onward. main is merged in (c6a19c2) for #94's build instructions; the only conflict was README.md's list of what building needs. Nothing compiled changed, so the builds and bench runs below stand.

Which ESP-IDF

Build ESP-IDF
StickS3 6.1.1
Generic ESP32-S3 6.1.1
StickC Plus2 6.0.3

#17 chose 6.0.3 because v6.1 shipped Mbed TLS 4.1.0, older than 6.0.3's 4.1.1. v6.1.1 (2026-11-16) carries exactly 6.0.3's Mbed TLS (espressif/mbedtls ce3f3485a121, 4.1.1), with 6.1's fixes on top. Its listed breaking changes don't touch nesp32: the esp_http_server Content-Length cap (nothing in firmware/ runs an HTTP server), BLE Audio and ISO, and the Key Manager and MAC_EXT changes on other chips (C5, P4, S31, H21).

The Plus2 stays on 6.0.3 because M5GFX doesn't compile for the classic ESP32 on 6.1.1, in any version, develop included. Its Panel_CVBS calls the DAC LL functions that ESP-IDF commit 3e279c2a1df renamed; that commit is in v6.1.1, not v6.1. It's reported as m5stack/M5GFX#425, and release.yml says so beside the Plus2's step. The Plus2 moves to 6.1.x when M5GFX has a fix. 6.0.3 has the same Mbed TLS, so all three builds have Mbed TLS 4.1.1.

Changes

  • release.yml: the releases are built with the versions above, in place of 5.5.5. CHANGELOG.md has a line for it.
  • sdkconfig.defaults: CONFIG_FREERTOS_IN_IRAM and CONFIG_RINGBUF_IN_IRAM are on (next section). CONFIG_NEWLIB_NANO_FORMAT comes out: ESP-IDF 6 builds with Picolibc, and the option's new name (CONFIG_LIBC_NEWLIB_NANO_FORMAT) depends on Newlib, so 6.0.3 and 6.1.1 pass over it (on 6.0.3, the same sdkconfigs and sizes with it and without it). Mbed TLS is built as a client only, without renegotiation and without four curves nothing uses (see "TLS hardening").
  • sdkconfig.defaults.esp32s3: CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC=y, for the StickS3 and the generic ESP32-S3 only (see "Mbed TLS's memory on the S3").
  • main/idf_component.yml: idf: ">=6.0", in place of ">=5.1".
  • components/esp_hid: now ESP-IDF 6.1.1's esp_hid, plus nesp32's three changes in nimble_hidh.c, each marked nesp32:. 6.1.1's nimble_hidh.c differs from the previous copy only by those changes, so 6.1.1 has the NimBLE discovery fix (56f1ae2) that the old copy took from ESP-IDF master. The copy also picks up 6.1.1's esp_hid_common.c, which checks a report map's sizes and counts for overflow. The Plus2 has no Bluetooth, so it compiles only esp_hid_common.c, esp_hidd.c and esp_hidh.c.
  • main/CMakeLists.txt: esp_partition is now in REQUIRES. usb.c includes esp_partition.h, and main had the header only because wear_levelling requires esp_partition publicly: the same kind of gap as esp_driver_uart in Require esp_driver_uart, which ESP-IDF 6 no longer brings in through driver #90. The images come out the same size, from the same sdkconfig.
  • Two tests, tests/test_firmware_requires.py and tests/test_firmware_sdkconfig.py (see "Tests in the repo").
  • READMEs, firmware/CMakeLists.txt and deploy.sh's header: 6.x where they said 5.x, and 6.0 or later where main's new build instructions (deploy.sh: say what is wrong when ESP-IDF is missing #94) say 5.1 or later, with a note that the StickC Plus2 doesn't build with 6.1.1 until M5GFX#425 is fixed. deploy.sh's usage now prints its whole header, which deploy.sh: say what is wrong when ESP-IDF is missing #94 had lengthened past the lines it printed. firmware/README.md gives the image sizes of the release builds: about 1.68 MB for a StickS3 (6.1.1) and 1.27 MB for a StickC Plus2 (6.0.3).

FreeRTOS and the ring buffer in RAM

ESP-IDF 6 puts FreeRTOS's functions and the ring buffer's in flash by default, and keeps in RAM only those that interrupts and the scheduler call. The link task's path through a request is not among them: the wait on the UART's event queue, and the driver's ring buffers that the request is read from and the reply written to. The two options put those functions back where 5.5 had them.

This replaces a6dc84b from #48, which was reverted there (a1ffeaf). The comment in sdkconfig.defaults says what 5.5 does: FreeRTOS is in RAM through a hidden option that defaults to y, and the ring buffer because RINGBUF_PLACE_FUNCTIONS_INTO_FLASH defaults to n.

What they cost. The 5.5.5 column is from #90's builds; the others are this branch's release builds before the TLS hardening (f0d09ff), without the two options and with them:

5.5.5 6.x 6.x + the two options
Plus2 IRAM used (6.0.3) 118,111 108,083 119,359
Plus2 IRAM free (6.0.3) 12,961 22,989 11,713
S3 DIRAM used (6.1.1, StickS3 and generic) 207,343 202,170 213,690

On the Plus2 the two options cost 11,276 bytes of IRAM, leaving 11,713 free, 1,248 less than on 5.5.5. On the S3s they cost 11,520 bytes of DIRAM. The images get slightly smaller (788 bytes on the S3, 1,184 on the Plus2), since that code moves out of flash. All three release builds pass with no warnings.

Image size (#17's risk 6): at this branch's head (d4e1ec5) a StickS3 image is 1,673,534 bytes, which leaves 423,618 bytes free in its 2 MB app slot, against 491,981 bytes on 5.5.5 and 444,947 on 6.0.3. Before the TLS hardening it was 1,682,762: 6.1.1 cost about 31 KB more than 6.0.3 on the S3. The Plus2's image is 1,264,558 bytes at the head.

Mbed TLS's memory on the S3

On the ESP32-S3, IRAM and DRAM share one block of internal RAM, so the options' 11.5 KB comes out of the heap that Wi-Fi, Bluetooth and Mbed TLS allocate from. Mbed TLS's memory was internal, ESP-IDF's default on 5.5.5 as on 6, including its record buffers of 16 KB in and 4 KB out for each connection. With the options and that default, an HTTPS fetch while Bluetooth was scanning left as little as 2 KB of internal heap, and the Wi-Fi driver failed to allocate (see "Wi-Fi and TLS").

CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC makes Mbed TLS allocate with plain calloc, so malloc's rules decide where its memory goes. With the PSRAM settings this firmware builds with (SPIRAM_USE_MALLOC, and SPIRAM_MALLOC_ALWAYSINTERNAL at 16,384), allocations over 16 KB, chiefly the 16 KB record in-buffer, go to PSRAM first. The rest stays internal: the 4 KB out-buffer, the handshake state, the PSA key slots and the Wi-Fi supplicant's crypto. Each falls back to the other memory if its first choice is full. In the same worst case the least internal heap free was 21,191 and 21,491 bytes, about 3 times 5.5.5's 7.3 KB, and the Wi-Fi driver didn't fail to allocate.

Without PSRAM, Mbed TLS takes all its memory from internal RAM. That was tested on the classic devkit, which has none: built with 6.0.3, the options and this setting, it boots, rejoins the network, and an HTTPS GET returns 200 (26de2efaa432…). Every S3 board this is built for has 8 MB of octal PSRAM.

Tested and not chosen: CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC, which puts every Mbed TLS allocation in PSRAM. It left the most internal heap (33,235 and 34,911 bytes), but its allocations have no fallback. Mbed TLS's PSA crypto is set up during startup, so a board without working PSRAM aborts at boot and resets in a loop. On the classic devkit, built with that setting (f7853ecebb46…), it logged "init function … has failed, aborting" 15 times in 12 s.

The Plus2 is left as it is. On the classic ESP32, IRAM is apart from the heap that Wi-Fi and Mbed TLS allocate from, so the options don't take from it (see "Classic ESP32").

TLS hardening

Mbed TLS 4.1.2 and TF-PSA-Crypto 1.1.2 (2026-11-16) fix 22 advisories; ESP-IDF 6.1.1 and 6.0.3 ship Mbed TLS 4.1.1. The firmware's TLS is a TLS 1.2 client only, through esp_http_client with ESP-IDF's certificate bundle. As built, we found none of the 22 that reaches it:

  • CVE-2026-115490, a TLS 1.3 version confusion: with TLS 1.3 off (ESP-IDF's default), a ServerHello claiming 1.3 is rejected as above the client's highest version.
  • CVE-2026-93844 and CVE-2026-115488, in renegotiation: both need MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, which is off.
  • CVE-2026-90470 (a URI as the name to check), 90471 (a group policy set with mbedtls_ssl_conf_groups()), 115489 (mbedtls_x509_dn_gets()), 93845 (the p256-m driver) and 50582 (decrypting a PKCS#8 key): nothing in esp-tls or the firmware uses these.
  • The four Spectre-PHT side channels (CVE-2026-115493, 93833, 93835, 93842) need speculative execution, which, as far as we know, the ESP32's and ESP32-S3's cores don't do.
  • CVE-2026-115492, a timing side channel through AES tables read from flash: the TLS records use the chips' AES hardware, but a software AES with its tables in flash is still linked. Moving them to RAM (CONFIG_MBEDTLS_AES_ROM_TABLES=n) would cost internal heap, so they are left in place.
  • The rest are TLS 1.3, the server side, EC J-PAKE or CRLs, none of which the firmware uses.

So the two commits here are hardening, and they make the code smaller. They don't fix an exposure.

  • 27c1b03 builds Mbed TLS as a TLS client only (CONFIG_MBEDTLS_TLS_CLIENT_ONLY); nothing in the firmware or its components is a TLS server. It also turns renegotiation off (CONFIG_MBEDTLS_SSL_RENEGOTIATION=n). esp-tls turns renegotiation on for every connection whenever Mbed TLS has it. Without it, a server's HelloRequest gets a no_renegotiation warning and the connection carries on.
  • d4e1ec5 leaves out secp256k1 and the three Brainpool curves. X25519, P-256, P-384 and P-521 stay. None of the certificate bundle's roots (142 in 6.1.1, 144 in 6.0.3) has a key on a curve that was left out, and none of the servers the firmware talks to uses one: they choose X25519 for the key exchange, or P-256 when X25519 isn't offered (checked from a computer with openssl s_client -tls1_2; the device's own runs are below).

The cost: a program can ask for any address, so a server elsewhere that needs a Brainpool or secp256k1 curve can't be reached.

Release builds, no warnings:

Image Before (f0d09ff) d4e1ec5 Change
StickS3 (6.1.1) 1,682,762 1,673,534 −9,228
Generic ESP32-S3 (6.1.1) 1,682,430 1,673,206 −9,224
StickC Plus2 (6.0.3) 1,274,142 1,264,558 −9,584

On the bench, the S3 on 6.1.1 ran d4e1ec5 with the bench patch (3a702c691186…), and the classic devkit on 6.0.3 ran d4e1ec5 with the classic bench patch and DEFAULT_MEM_ALLOC (c90805cbd14e…):

  • All 18 HTTPS addresses the firmware and the NPR program use, 9 services and 9 stations, answered on both boards: 17 with 200, and one with 404 for its root path.
  • S3: NESpedia, the HTTP request, the radio and the worst-case test (a NESpedia search and an HTTPS GET during a KBD scan) passed. In two runs of the worst-case test the least free internal heap was 20,215 and 21,407 bytes (largest block 21,504), against 21,191 and 21,491 before these commits. The first run made the 18 HTTPS connections just before it. The second ran the same steps as before and was 84 bytes lower, and static DIRAM is 16 bytes smaller (213,674), so the difference is run-to-run variation.
  • Classic devkit, which has no PSRAM: boots without an abort, joins, and an HTTPS GET returns 200.
  • No m f null, no esp-tls or Mbed TLS errors, and no renegotiation lines. The only error and warning lines at boot were the classic board's PSRAM not being found (it has none) and the S3 board's 16 MB of flash being more than the image's header says.

Testing

Tests in the repo

Two new pytest files, run by make test, with no ESP-IDF needed:

  • tests/test_firmware_requires.py checks that main/CMakeLists.txt requires the component behind every header main includes, so a header that arrives only through another component's public requirements is caught. On this branch it fails without esp_driver_uart (Require esp_driver_uart, which ESP-IDF 6 no longer brings in through driver #90), without esp_partition, or with an include it doesn't know, written with "" or <>. A component commented out doesn't count. A component appended for the S3 only counts for every target, so the test can't tell when one is moved into that list.

  • tests/test_firmware_sdkconfig.py merges the defaults files for each release build, in ESP-IDF's order, and checks the settings this PR relies on:

    • the two IRAM options;
    • the Mbed TLS memory setting on each board;
    • the TLS hardening;
    • TLS 1.3 and variable buffer length off, which the CVE analysis above relies on;
    • the S3s' PSRAM settings.

    For a Kconfig choice it also checks that the choice's other members are off, since a later line wins. It fails on main's defaults files. When firmware/build-esp32s3, build-esp32 and build-esp32s3-generic exist, which release.yml builds before its make test, it also checks each build's generated sdkconfig. On GitHub Actions a missing build directory fails instead of skipping.

Both files include cases that break the real files on purpose and expect a failure.

make test here: 1,401 passed, 1 failed. The failure is test_peer_net.py::test_two_meet_by_a_rooms_code. It also fails on main on this machine, where it overruns its 5 s wait by a few milliseconds, and it passed in the v0.3.0 release run. This PR doesn't touch anything it uses.

The bench

The bench is a bare ESP32-S3 board running the generic S3 config, with a test-only patch (not in this PR) that puts the link on UART0 at 115,200 baud through the board's USB-serial bridge, not on UART1 at 85,227. Log lines are held off that UART while the link is busy. There is no NES, StickS3 or Plus2 on the bench. A classic ESP32 devkit was added for the Plus2's chip (see "Classic ESP32").

These runs came before the TLS hardening; its own runs are in "TLS hardening". The S3 images, each built with the bench patch from the source below (no warnings). The 6.1.1 images were built from a tree that is f0d09ff's without 5a61964's one setting (Mbed TLS's memory).

Image Source App sha256, reply time App sha256, heap and Wi-Fi
5.5.5 30f2abc, #90's head (this branch no longer builds with 5.5) c540f2fa14c0… 5f7b0015968c…
6.1.1 f0d09ff without 5a61964, and an extra defaults file that sets both options to n 84563cead708… b2b125854eba…
6.1.1 + the two options f0d09ff without 5a61964 a6974e156984… 00f21545d90e…
6.1.1 + the two options + DEFAULT_MEM_ALLOC (this branch's setting) f0d09ff without 5a61964, plus an extra defaults file setting CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC=y, the setting 5a61964 adds not run 7e3f96a045a1… (Wi-Fi and TLS only)
6.1.1 + the two options + EXTERNAL_MEM_ALLOC (not chosen) f0d09ff without 5a61964, plus an extra defaults file setting CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y not run f282ffdf6532… (Wi-Fi and TLS only)

The reply times and the functional suite are from one set of images, and the heap figures from a second set, built from the same sources. Each reply-time run was done twice, and the heap runs once per image. The bench patch differs between the two sets in its log handling and heap sampling. The second holds log lines in PSRAM, not internal RAM, so that the heap figures don't include its 16 KB of log buffers. It sends held lines from the link task, 512 bytes at a time, once the line has been quiet for 30 ms, and it samples the largest free block every 100 ms. Each table compares images from one set only. The Wi-Fi and TLS runs used the second set, and two more images, one for each Mbed TLS memory setting.

Reply time

The figure is the firmware's own reply time (turnaround, from DIAG STATS): 400 requests per cell, all answered; median / p99 / max, in µs. Where the two runs differ, the cell gives both.

Request 5.5.5 6.1.1 6.1.1 + the two options
8-byte ECHO, idle 87 / 94–96 / 96–105 92–93 / 132–136 / 146–164 87 / 97–98 / 98–103
100-byte ECHO, idle 93 / 116–117 / 123–138 105 / 158–169 / 197–202 94 / 127–130 / 132–137
8-byte ECHO, Wi-Fi scanning 87 / 153 / 189–194 93–94 / 205–208 / 312–336 88 / 164–172 / 229–259

Without the options, 6.1.1 is slower in every row: 5 to 12 µs at the median and 36 to 55 µs at p99. With them, the medians are back to 5.5.5's, within 1 µs. The tails stay higher than 5.5.5's: p99 is 10 to 19 µs higher for the 100-byte ECHO and with Wi-Fi scanning, and the max with Wi-Fi scanning is 229–259 against 189–194.

What this can't show, as noted on #48: arrived is stamped after xQueueReceive returns, so the UART interrupt and the wake into link_task are outside the figure. It shows the slowdown, and the fix, in the code after the wake. That makes it a lower bound on the reply time, not a wire measurement, on the S3 and on the classic ESP32 below. The measurement on the wire, with Wi-Fi busy, is still open in #17.

No hello was resent in the runs that log resends (the functional suite, and the Bluetooth runs on the first set). The six reply-time runs came before resend logging was added. None of their hellos failed, but a resend there wouldn't have shown. The heap runs on the second set resent none either. TAPE SAVE is resent 3 times per save on both versions, as PROTOCOL.md expects, since there is no answer while flash is written.

Internal heap

Each heap image was flashed whole, then run through boot and the link, a KBD scan (Bluetooth on), and a 180 s soak (the jukebox streaming and a Wi-Fi scan every 30 s, Bluetooth off). The soak was intact on all three, 10 of 10 rounds. These images keep Mbed TLS in internal RAM, and no TLS connection is open in these runs.

Internal heap, bytes 5.5.5 6.1.1 6.1.1 + the two options
Free at idle 100,771 105,871 94,351
Least, boot and the link 100,035 105,055 93,535
Least, Bluetooth on 57,583 62,875 51,359
Least, soak 96,599 101,227 89,907
Least largest free block, Bluetooth on and soak 31,744 31,744 31,744

With the two options, the S3 has 6.2 to 6.5 KB less free internal heap than on 5.5.5 at idle, after boot and with Bluetooth on: 51,359 bytes against 57,583 with Bluetooth on. In the soak the gap is 6.7 KB (89,907 against 96,599). Its minima come from long windows, since the bench held its log lines while the link was busy, so they can only be placed within the streaming part of the run. Once Bluetooth is off and the heap has settled, the gap is 6.5 KB, 93,875 bytes against 100,367. Without them, 6.1.1 has 4.6 to 5.3 KB more than 5.5.5. So the options cost about 11.5 KB of heap (11,520 bytes at idle), the same as the DIRAM figure from the builds. Turning Bluetooth off gives its memory back on all three, to within 0.5 KB of idle.

The largest free block is 31,744 bytes on all three. That is very likely the free size of one 32 KB region, so this row would only show fragmentation that leaves less than about 31 KB.

The figures include about 4 KB that the bench itself still uses on all three images (its heap task and a small buffer), and the minima include the link's traffic.

Wi-Fi and TLS

On a real network, five S3 images: 5.5.5, 6.1.1 without the options, 6.1.1 with them, and 6.1.1 with them and each of two Mbed TLS memory settings, DEFAULT_MEM_ALLOC (this branch's) and EXTERNAL_MEM_ALLOC (tested and not chosen). Every image passed all of these that it ran:

  • joining, or rejoining, the network
  • two NESpedia articles
  • an HTTP request, answered 200
  • 30 s of the radio (run on the three 6.1.1 images with the options; not on 5.5.5 or on 6.1.1 without the options)
  • a NESpedia search and then an HTTPS GET while a KBD scan was running (Bluetooth on, no keyboard present)

The last test leaves the least internal heap:

Image Least free internal heap, bytes, per run Least largest free block
5.5.5 7,307 / 7,259 7,680
6.1.1 15,331 14,336
6.1.1 + the two options 1,999 / 3,759 / 3,215 7,680
6.1.1 + the two options + DEFAULT_MEM_ALLOC (this branch's setting) 21,191 / 21,491 21,504
6.1.1 + the two options + EXTERNAL_MEM_ALLOC (not chosen) 33,235 / 34,911 31,744

With the options and Mbed TLS's memory all internal, each run logged 7 or 8 W wifi:m f null lines: the Wi-Fi driver failing to allocate. With either of the other two settings there were none. With DEFAULT_MEM_ALLOC the least free is about 3 times 5.5.5's (21.2 to 21.5 KB against 7.3 KB). One caveat: in both EXTERNAL_MEM_ALLOC runs, the first DEFAULT_MEM_ALLOC run, and two of the three runs with Mbed TLS's memory all internal, the 5 s KBD scan ended before the HTTPS GET, so only the NESpedia search ran entirely within it. In the second DEFAULT_MEM_ALLOC run the scan was still running when the search finished.

6.1.1 is slower over the network than 5.5.5 on every 6.1.1 image, with the options or without: NESpedia's articles and searches take 3.8 to 5.4 s against 2.9 to 3.6 s, and an HTTPS GET 3.06 to 3.4 s against 2.35 to 2.7 s. The new Mbed TLS is the likely cause, but that isn't proven.

Classic ESP32

An ESP32-D0WD-V3 devkit with 4 MB of flash and no PSRAM, with a 4 MB partition table for the bench only and the same test patch. Three images: 5.5.5 (#90), and this branch on 6.0.3, without the options and with them. They were built with the classic bench patch from 30f2abc (5.5.5, 815539c4eb43…), 71f6032 (6.0.3, 7092e1d631fc…) and f7772b4 (6.0.3 with the options, a301a0b0faae…). 5a61964 changes only the S3's settings, and f0d09ff's esp_hid change isn't in these images. Nor are the TLS hardening commits; their classic run is in "TLS hardening". A real Plus2 has 2 MB of PSRAM, so of the heap figures only the differences between images carry over to it.

Reply time, µs, median / p99, two runs each, 400 requests per cell (399 answered in one of the 100-byte runs with the options):

Request 5.5.5 6.0.3 6.0.3 + the two options
8-byte ECHO, idle 94 / 101–102 115–116 / 124–126 98–99 / 106–107
100-byte ECHO, idle 108 / 116–118 156 / 165–166 127–139 / 136–146
8-byte ECHO, Wi-Fi scanning 94 / 101 115 / 125–136 98–99 / 105–107

The options bring the 8-byte replies to within about 5 µs of 5.5.5's at the median. The 100-byte replies stay 19 to 31 µs slower at the median (127–139 against 108). The cause isn't found; this is a known limit of this PR.

Free internal heap at idle: 105,256 bytes on 5.5.5, 119,760 on 6.0.3 and 108,804 with the options. The firmware's "internal" figure includes the ESP32's leftover IRAM, which takes only 32-bit allocations, not Wi-Fi's or Mbed TLS's. The options take 11,276 bytes of it: the heap's IRAM region at boot is 22,988 bytes without them and 11,712 with them (12,960 on 5.5.5). Without that region the idle heap is 92,296 on 5.5.5, 96,772 without the options and 97,092 with them. So the heap Wi-Fi and Mbed TLS use is the same with the options and without, within a few hundred bytes (the region lengths leave out the heap's own bookkeeping), and 4.5 to 4.8 KB above 5.5.5's. In the release builds the Plus2's DRAM is 79,887 bytes with the options and without them.

All three images passed: 200 ECHOs with none lost; RAW runs at periods 21, 14 and 7, byte-exact; a tape saved and loaded on a freshly formatted FAT; DRIVE and KBD answering 0, which means this board can't be a drive or take a keyboard. The first boot after an erase, which formats the files partition, takes 6.2 s on 6.0.3 against 3.6 s on 5.5.5.

Wi-Fi: joining and an HTTPS GET, answered 200, passed on all three, in 2.8 s on 5.5.5 and 3.9 to 4.1 s on 6.0.3. On all three images, 5.5.5 included, NESpedia reports that the site did not answer and the radio that the nesp32 is out of memory: this board has no PSRAM. Both are untested on the classic chip.

Resends on this board line up with 64-byte bursts of 0xFF from its CP2102 USB-serial bridge, on 5.5.5 too. They come from the bridge, not from ESP-IDF.

The raw bench output isn't attached, because it lists the neighbours' Wi-Fi networks.

Which tests ran on which image

  • S3, all three of 5.5.5, 6.1.1 and 6.1.1 + the two options: reply time and internal heap.
  • S3, 6.1.1 + the two options only, with Mbed TLS in internal RAM: the functional suite, all passed:
    • Boot, and the link: 200 ECHOs, none lost.
    • RAW runs at periods 21, 14 and 7, byte-exact.
    • The jukebox: the list, a 60 KB stream byte-exact, a rip converted on 5.5.5 plays, PCM byte-exact.
    • Files across an upgrade from 5.5.5 and back down: a tape saved on 5.5.5 loads, one saved on 6.1.1 loads after going back to 5.5.5, the FAT partition parses clean (ESP-IDF's fatfsparse.py) and the file hashes match.
    • NET's Wi-Fi scan, and a KBD scan (no keyboard present).
    • The drive lent and returned, with no USB host attached.
    • A 5-minute soak: 16 of 16 rounds intact, slowest reply 345 µs.
  • S3, five images (the three above, and the options image with each Mbed TLS memory setting): Wi-Fi and TLS.
  • Classic ESP32, all three images: reply time, idle heap, the functional tests listed in that section, and the Wi-Fi join and HTTPS GET.
  • Classic ESP32, 6.0.3 with the options and each Mbed TLS memory setting: booting with no PSRAM. With DEFAULT_MEM_ALLOC it boots, rejoins and gets 200 from an HTTPS GET; with EXTERNAL_MEM_ALLOC it resets in a loop.
  • S3 and classic devkit, with the TLS hardening: the 18 HTTPS addresses; on the S3 also the Wi-Fi and TLS tests; on the classic devkit, boot without PSRAM, the join and an HTTPS GET.
  • Not run: the USB drive with a host; pairing a keyboard; NESpedia and the radio on the classic chip; anything on a StickS3, a Plus2 or with a NES; a measurement on the wire. Move the firmware to ESP-IDF 6 before Mbed TLS 3.6 ends (March 2027) #17's hardware list is still open.

🤖 Generated with Claude Code

JC-000 and others added 7 commits November 16, 2026 11:51
…driver

link.c includes driver/uart.h, which lives in the esp_driver_uart
component. ESP-IDF 5.5 gets it to main through driver; ESP-IDF 6.0 does
not, and there the build stops at that include. main now asks for the
component by name. It is in 5.5 as well, so this goes in before the
move to ESP-IDF 6 (Armitage64#17) and changes nothing on 5.5.5.

Built on ESP-IDF 5.5.5 and 6.0.3, for the StickS3, the StickC Plus2 and
the generic ESP32-S3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The move to ESP-IDF 6 that Armitage64#17 lays out. The releases are built with
6.1.1 for the StickS3 and the generic ESP32-S3, and with 6.0.3 for the
StickC Plus2 (release.yml), instead of 5.5.5. M5GFX does not build for
the classic ESP32 on 6.1.1: 6.1.1 renamed the DAC functions that its
Panel_CVBS calls (m5stack/M5GFX#425). 6.0.3 has the same Mbed TLS as
6.1.1 (4.1.1). The READMEs and firmware/CMakeLists.txt say 6.x where
they said 5.x, and the changelog has a line for it.

CONFIG_NEWLIB_NANO_FORMAT comes out of sdkconfig.defaults. ESP-IDF 6
builds with Picolibc, and the option it was renamed to
(CONFIG_LIBC_NEWLIB_NANO_FORMAT) depends on Newlib, so 6.0.3 and 6.1.1
pass over it. On 6.0.3 the sdkconfigs and the image sizes are the same
with it and without it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ESP-IDF 6.0 places FreeRTOS's functions and the ring buffer's in flash
by default (CONFIG_FREERTOS_IN_IRAM and CONFIG_RINGBUF_IN_IRAM are off),
keeping in RAM only those that interrupts and the scheduler call. The
link task's path through a request is not among them: the wait on the
UART's event queue, and the driver's ring buffers that the request is
read from and the reply written to. Both options are now on, which puts
those functions back where ESP-IDF 5.5 had them.

On 5.5 FreeRTOS was in RAM through a hidden option that defaults to y,
and the ring buffer because RINGBUF_PLACE_FUNCTIONS_INTO_FLASH defaults
to n; 5.5 has no RINGBUF_IN_IRAM. The comment in sdkconfig.defaults says
so. This replaces a6dc84b from Armitage64#48, whose comment had it that ESP-IDF 5
lacked both options; that commit was reverted there (a1ffeaf).

In the release builds they cost 11,520 bytes of DIRAM on the StickS3,
on 6.1.1 (202,170 to 213,690 of 341,760), and 11,276 bytes of IRAM on
the StickC Plus2, on 6.0.3 (108,083 to 119,359 of 131,072), and the
images come out 788 and 1,184 bytes smaller. The generic ESP32-S3's
DIRAM figures are the StickS3's. All three release builds pass with no
warnings. One of the items deferred from Armitage64#48 in Armitage64#17.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On the ESP32-S3 IRAM and DRAM share one block of internal RAM, so the
11.5 KB that the FreeRTOS and ring buffer options put in IRAM comes out
of the heap. On a generic ESP32-S3 built with 6.1.1, the worst case
measured (a NESpedia search and an HTTPS fetch while a Bluetooth
keyboard is looked for) left as little as 2.0 to 3.8 KB of internal heap
free, with the Wi-Fi driver failing to allocate ("m f null") several
times a run. 5.5.5 left about 7.3 KB in the same test.

Mbed TLS now allocates by malloc's rules (CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC)
instead of from internal RAM only, ESP-IDF's default, which the firmware
had on 5.5.5 as on 6. PSRAM is in malloc (SPIRAM_USE_MALLOC), and
SPIRAM_MALLOC_ALWAYSINTERNAL is 16384, both ESP-IDF's defaults: so the
16 KB record buffer each connection reads into goes to PSRAM, and the
4 KB one it writes from and the rest stay internal. Either falls back to
the other kind of RAM when it has to. In the same test the least
internal heap free was then 21,191 and 21,491 bytes, with no "m f null".

CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC, which puts all of Mbed TLS's memory in
PSRAM, gave 33 to 35 KB, but it has no fallback: Mbed TLS's crypto is
set up at startup, and a board whose PSRAM does not answer aborts there
and restarts over and over. With this setting a classic ESP32 with no
PSRAM, built with 6.0.3 and the options, starts and gets an HTTPS page
from internal RAM.

The setting is in sdkconfig.defaults.esp32s3, for the StickS3 and the
generic ESP32-S3. The StickC Plus2 is left as it is: on the ESP32 IRAM
is apart from the heap that Wi-Fi and Mbed TLS allocate from, so the
options do not take from it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
components/esp_hid takes the place of ESP-IDF's own esp_hid, so it
should be the version the StickS3 is now built with. It was 5.5.5's,
with master's nimble_hidh.c (56f1ae2, the fix that turns a keyboard's
reports on) and nesp32's three changes to it. 6.1.1 has that fix, and
its nimble_hidh.c is the one here less nesp32's changes, which stay.
ble_hidd.c, bt_hidh.c and esp_hid_common.c are now 6.1.1's as they are;
6.1.1's esp_hid_common.c checks a report map's sizes and counts for
overflow. test_apps is left out. Only esp_hid_common.c, esp_hidd.c,
esp_hidh.c and the two NimBLE files are compiled, and on the StickC
Plus2, which has no Bluetooth, only the first three.

main/idf_component.yml now asks for ESP-IDF 6.0 or later: the firmware
is built and tested with ESP-IDF 6 only. The esp_hid README and
firmware/README.md say what the copy is and where it came from, and
firmware/README.md has the new image sizes: 1,682,762 bytes for a
StickS3 on 6.1.1 (414,390 of the 2 MB slot free) and 1,274,142 for a
StickC Plus2 on 6.0.3. All three release builds pass with no warnings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The firmware's TLS is the services' fetches through esp_http_client
(main/fetch.c, main/update.c): a TLS 1.2 client, 1.3 being off by
ESP-IDF's default. Nothing in main, components or the managed components
uses esp-tls as a server, esp_https_server, or Mbed TLS's server side,
so CONFIG_MBEDTLS_TLS_CLIENT_ONLY leaves that side out.

Renegotiation goes too. esp-tls turns it on for every connection
whenever CONFIG_MBEDTLS_SSL_RENEGOTIATION is set, so a server's
HelloRequest would start a second handshake. Without it Mbed TLS answers
a HelloRequest with a no_renegotiation warning and the connection
carries on (ssl_tls12_handle_hs_message_post_handshake in 4.1.1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
secp256k1 and the three Brainpool curves (BP256R1, BP384R1, BP512R1)
are left out of Mbed TLS. X25519, P-256, P-384 and P-521 stay.

The roots the firmware trusts are ESP-IDF's full bundle, cacrt_all.pem
(cacrt_local.pem is left out, as cross-signed verification is on). In
6.1.1 it has 142 roots: 100 RSA (34 of 2048 bits, 66 of 4096) and 42 EC
(4 P-256, 37 P-384, 1 P-521). In 6.0.3, which the StickC Plus2 is built
with, it has 144: 101 RSA (35 and 66) and 43 EC (4 P-256, 39 P-384).
None has a secp256k1 or Brainpool key.

The servers are the services' nine (nesp32.retrobits.tv,
npr-ice.streamguys1.com, opendata.adsb.fi, query.wikidata.org,
public.api.bsky.app, api.zippopotam.us, api.open-meteo.com,
nesp32-rendezvous.retrobits.workers.dev, en.wikipedia.org) and the
NPR program's other stations: nine more, and the streamtheworld.com
server that KUSC's address sends the fetch on to. The BBC's is plain
HTTP. Over TLS 1.2, all 19 chains verify; 7 leaf keys are P-256 and 12
RSA 2048, and the 41 intermediates are P-256 or P-384 EC or RSA of 2048
to 4096 bits. All 19 choose X25519 for the key exchange, and P-256 when
X25519 is not offered. None uses secp256k1 or a Brainpool curve.

A program can ask for any address, so a server elsewhere that needs one
of these curves would now fail its handshake.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JC-000
JC-000 marked this pull request as ready for review November 18, 2026 01:52
JC-000 and others added 5 commits November 17, 2026 19:53
main's README now lists what building needs (Armitage64#94). Its firmware line
said ESP-IDF 5.1 or later, with 5.5.5 and 6.0.3 as the versions built
with; this branch needs 6.0 or later (main/idf_component.yml), and the
releases use 6.1.1 for the ESP32-S3 boards and 6.0.3 for the Plus2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
firmware/README.md and deploy.sh's header gained "ESP-IDF 5.1 or later"
on main (Armitage64#94). This branch needs 6.0 or later, and a StickC Plus2 needs
one older than 6.1.1 until m5stack/M5GFX#425 is fixed: deploy.sh takes
the latest ~/.espressif/v*/esp-idf when IDF_PATH is not set, and that
may be 6.1.1.

deploy.sh's usage prints its header, lines 2 to 17, which stopped short
of the end once Armitage64#94 lengthened it; it prints lines 2 to 20 now, the
whole header.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
usb.c includes esp_partition.h (for the StickS3's USB drive), but main
did not ask for esp_partition: it had the header only because
wear_levelling, which main requires, requires esp_partition publicly.
That is how main lost driver/uart.h on ESP-IDF 6.0, when driver stopped
requiring esp_driver_uart (Armitage64#90). main now names the component itself.

The release builds are unchanged: StickS3 1,673,534 bytes and generic
ESP32-S3 1,673,206 on 6.1.1, StickC Plus2 1,264,558 on 6.0.3, all
without warnings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tests/test_firmware_requires.py reads firmware/main's sources and its
CMakeLists.txt, and fails when a header main includes comes from an
ESP-IDF component main does not require by name, or from a managed
component main/idf_component.yml does not list. Headers of the
components ESP-IDF makes every component require are allowed, and so
are the C and C++ library's. The map from header to component and the
list of library headers hold only the headers main includes, each
checked against the 6.0.3 and 6.1.1 trees (sys/socket.h is lwip's
there, not the library's). An include in none of the lists fails,
whether it is written with "" or <>, so a new one gets looked up
rather than passed over. Components commented out of main's
CMakeLists.txt, with # or #[[ ]], are not counted as required. A
component appended for the S3 only counts for every target, so the test
cannot tell when one is moved into that list.

It is the check that would have caught Armitage64#90, which it shows by taking
esp_driver_uart out of main's REQUIRES. Run on e112a26 it found
esp_partition missing too (the commit before). No ESP-IDF is needed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tests/test_firmware_sdkconfig.py works out each release build's settings
from sdkconfig.defaults* as ESP-IDF does (the files of SDKCONFIG_DEFAULTS
in order, each followed by its .<target> file) and checks the ones the
move to ESP-IDF 6 chose:

- FREERTOS_IN_IRAM and RINGBUF_IN_IRAM on every build;
- on the ESP32-S3s, MBEDTLS_DEFAULT_MEM_ALLOC and no other of its
  choice, with SPIRAM_USE_MALLOC (no other PSRAM access method) and
  SPIRAM_MALLOC_ALWAYSINTERNAL left at ESP-IDF's 16384, which that
  setting relies on;
- on the StickC Plus2, Mbed TLS's memory left internal;
- TLS as a client only, neither of the choice's server modes, without
  renegotiation, with secp256k1 and the three Brainpool curves off and
  X25519, P-256, P-384 and P-521 on;
- TLS 1.3 and MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH off, as ESP-IDF leaves
  them: Armitage64#92's reading of Mbed TLS 4.1.2's advisories relies on both.

Where a setting is one of a Kconfig choice, the choice's other members
are checked off too, since in a defaults file a later member set to y
wins over an earlier one.

It also checks firmware/build-<name>/sdkconfig, the configuration a
build was actually made with, where there is one: Kconfig passes over an
option it does not know, as 5.5 does RINGBUF_IN_IRAM. release.yml builds
into those directories before it runs make test, so a release checks its
own builds. On GitHub Actions a build directory that is not there fails,
so that a renamed one cannot turn the check off; elsewhere it is skipped.
A set of changes to the defaults (the S3s on EXTERNAL_MEM_ALLOC, FreeRTOS
in flash, Brainpool back, a TLS server mode after the client one, TLS
1.3, and more) must each be caught.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main brought Armitage64#98 (Jukebox's fastest rates: raw.c, its tests and docs;
CLAUDE.md), Armitage64#99 (more of CLAUDE.md, docs/DEVELOPMENT.md), and hardware
and web site files. Armitage64#98 and this branch each added a line under
Firmware in CHANGELOG.md; both are kept, Armitage64#98's first. Nothing else
overlaps: raw.c uses no ESP-IDF API.

make test: 1403 passed, 1 failed (test_peer_net's 5 s timing, which
fails the same way on main); make test-apps APPS=throughput: 193 passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JC-000 added a commit to JC-000/nesp32 that referenced this pull request Nov 21, 2026
idf6-move took main's Armitage64#98 (Jukebox's fastest rates) and Armitage64#99
(CLAUDE.md). It merges here with no conflict: CHANGELOG.md keeps this
branch's line after Armitage64#92's, and Armitage64#98's PROTOCOL.md note is in a section
this branch does not change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JC-000 and others added 3 commits November 21, 2026 21:41
docs/RELEASING.md asks for the pull request's number; Armitage64#17 is the issue
Armitage64#92 is part of.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CLAUDE.md sends readers to the skills for how the firmware is built. The
skill gave an older size for the StickS3's image and said nothing of the
StickC Plus2's needing an ESP-IDF older than 6.1.1, or of what deploy.sh
does when the newest one installed is 6.1.1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CLAUDE.md keeps the firmware's to-do items in docs/TODO.md. The Plus2's
move from 6.0.3, waiting on m5stack/M5GFX#425, was only in the notes
next to the 6.0.3 build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JC-000 added a commit to JC-000/nesp32 that referenced this pull request Nov 22, 2026
idf6-move now cites Armitage64#92 in its CHANGELOG line, updates the firmware
skill for ESP-IDF 6, and lists the StickC Plus2's move to 6.1.1 in
docs/TODO.md. The CHANGELOG line it changed is the one just above this
branch's, so git saw a conflict; idf6-move's line is taken, and this
branch's follows it as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant