Skip to content

Build the U64 WiFi module firmware (raw_u64) with ESP-IDF 6.1.1 - #996

Draft
JC-000 wants to merge 36 commits into
GideonZ:masterfrom
JC-000:pr/2-idf6-r4
Draft

JC-000 wants to merge 36 commits into
GideonZ:masterfrom
JC-000:pr/2-idf6-r4

Conversation

@JC-000

@JC-000 JC-000 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Closes #994. Part of #952.

Draft. This is the second of three ESP-IDF 6 PRs, each built on the one before. If they are accepted they should merge in this order:

  1. Build the Elite II / C64 Ultimate control module (u64ctrl) with ESP-IDF 6.1.1 #1028: u64ctrl (Elite II / C64 Ultimate). It also adds the digest-pinned ESP-IDF 6 CI image.
  2. This PR: raw_u64 (U64 / U64 Elite).
  3. Build the U2+L WiFi module firmware (raw_c3) with ESP-IDF 6.1.1 (build only, not hardware-tested) #1029: raw_c3 (U2+L). Draft, build only, untested.

#1027 (SSID and password terminators) is already on master. Until #1028 merges, the "Commits" and "Files changed" tabs here also show #1028's commits. Base: master 3db34d2. This PR's own commits are the last ones, in three groups:

  • The move to ESP-IDF 6.0.3. Build the U64 WiFi bridge (raw_u64) with ESP-IDF 6.0.3, Lock the mbedTLS key store in the U64 WiFi bridge (MBEDTLS_THREADING_C) and Keep dropping WiFi packets quietly when the bridge has no UART buffer.
  • Performance. Six commits that win back the WiFi latency the move cost. See "Performance" below.
  • The move on to 6.1.1. Build raw_u64 with ESP-IDF 6.1.1, Say 6.1.1 in raw_u64's version history and Leave the Wi-Fi OWE soft-AP support out of raw_u64. The first moves the pin and regenerates sdkconfig; no value the module sets changes, including the IRAM placement options. The second changes a comment. The third sets CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_SOFTAP to n: 6.1.1 added that option with default y, 6.0.3 had none, and the module is station only, so soft-AP code stays out (about 1.5 KB of flash).

Why move

The raw_u64 module firmware (U64, U64 Elite) builds on ESP-IDF 5.3.1. The reasons to move, firmest first:

The pin is ESP-IDF 6.1.1: espressif/idf:v6.1.1, by digest (sha256:2b4f966c37eaedc19542b0637a5f850b2eff9478d8e858192aa0073d92c2dc91). The closed Wi-Fi libraries are newer than in 6.0.3; the PHY library is identical.

Change

  • raw_u64 builds with ESP-IDF 6.1.1 (the first commit of the move used 6.0.3). The code changes 6.0 forced are in my_uart.c: uart_periph.h moved from soc/ to hal/, and uart_isr_handle_t is gone (the function takes intr_handle_t).
  • CMakeLists.txt: CMake 3.16 minimum, and configure stops on an ESP-IDF older than 6.
  • sdkconfig was regenerated with idf.py reconfigure from the 5.3.1 file. Values present in both versions carry over unless 6.0 forces them, and new options take 6.0's defaults. Some of those change behaviour: picolibc replaces newlib, FreeRTOS and ring-buffer functions run from flash instead of IRAM (the performance commits below put them back), WPA3-compatible mode is compiled in, and esp_netif_receive() now returns errors to the WiFi driver.
  • MBEDTLS_THREADING_C is on (the 6.0 default). With mbedTLS 4, PSA key slots need it once more than one task uses PSA, and the WiFi supplicant already does.
  • wifi_modem.c, hacked_recv: when no UART buffer is free, it now calls pbuf_free(p) and returns ERR_OK. It used to return ERR_BUF. On 5.3.1 the driver was told ESP_OK either way; on 6.0 it would see ESP_FAIL. The packet is dropped in both cases.
  • The module version goes up by one minor (rpc_dispatch.h), and its version history names 6.1.1. The U64 updater reflashes the module whenever the installed version differs from the package's (update_u64.cc), so this is what installs it. Add NET_CMD_GET_RANDOM: hardware random bytes for C64 programs #953 also takes the next minor, for a different image. Whichever of the two lands second renumbers.
  • Not in this PR: the SSID and password terminator fix. A 32-character SSID or 64-character password had no terminator, and the NVS lookup failed for such an SSID and stored it again on every connect. The bug is on master, in all three modules, and has nothing to do with ESP-IDF 6, so it is its own PR, Terminate 32-character SSIDs and 64-character passwords in the ESP32 WiFi modules #1027. This PR needed it, because -O2 makes the compiler flag the bug and the build stops. Terminate 32-character SSIDs and 64-character passwords in the ESP32 WiFi modules #1027 is on master now, so this PR no longer carries it.
  • CI builds raw_u64 next to u64ctrl in the pinned espressif/idf:v6.1.1 image that Build the Elite II / C64 Ultimate control module (u64ctrl) with ESP-IDF 6.1.1 #1028 adds. raw_c3 stays in my_docker_image (ESP-IDF 5.3.1) until Build the U2+L WiFi module firmware (raw_c3) with ESP-IDF 6.1.1 (build only, not hardware-tested) #1029. README.txt, software/wifi/raw_u64/README.md and software/u64ctrl/README.md say which ESP-IDF each module needs.

Consequence for local builds until #1029 lands: make u64 and make u64ii need an ESP-IDF 6 IDF_PATH, make u2pl still needs 5.3.1, and make (all), make esp32 and make clean cannot complete with one IDF_PATH. README.txt documents building the modules in the container and then make u64_no_esp and make u64ii_no_esp. #1029 removes the restriction.

Not carried over from #1028: it restores two ESP-IDF 5.3.1 UART behaviours in u64ctrl. One is the pull-ups on RX and CTS, which 6.0's uart_set_pin() no longer sets. The other is CTS flow control being stopped before a brownout reset, because 6.0's brownout handler now waits for the UARTs to drain. raw_u64 routes UART1 the same way, with CTS flow control, and has the brownout interrupt on, so the same 6.0 changes reach it. On the U64 Elite run below the module booted, joined WiFi and passed the suites without either fix. The power-off and brownout paths were not tested. If you want the same code in both modules, it is a small follow-up.

Performance

The measurements in this section are from 6.0.3 builds. The 6.1.1 results are under "Hardware".

On the U64 Elite, the first ESP-IDF 6.0.3 build of this module was slower over WiFi than the 5.3.1 module. Same suites on the same bench, the first 6.0.3 build against master measured before and after it (12 hours apart):

  • PUT /v1/machine:writemem median 40.8 ms against 34.0 and 35.7; 99th percentile 203 ms against 136 and 159.
  • GET /v1/version median 97 ms against 76 and 77.
  • uci-net-target over WiFi 1,749 s against 1,367 and 1,431.
  • FTP put 209-221 kB/s against 233-256. FTP get overlapped.
  • The minimum latencies and the Ethernet standard profile (2,228 to 2,238 s in all three runs) did not move.

The cause I found: ESP-IDF 6.0 puts most FreeRTOS functions and the ring buffer in flash by default. The 6.0 migration guide says this "may have a slight performance impact" and names CONFIG_FREERTOS_IN_IRAM and CONFIG_RINGBUF_IN_IRAM to restore the old placement (esp-idf commit 26c19928a9 made the change). Espressif sets the option again in its own iperf examples. Every frame passes these queue functions in both directions, on the core the WiFi driver uses. The closed WiFi and PHY libraries also changed between 5.3.1 and 6.0.3, and I cannot test those separately.

The six performance commits, with the IRAM each costs (desk estimates, except the first):

  • Keep FreeRTOS and the ring buffer in IRAM: sets the two options. +10.6 KB.
  • Run the U64 WiFi bridge UART ISR and dispatch on core 1, out of flash: the UART interrupt runs on the core the WiFi driver does not use, and the UART code is in IRAM. The dispatch task is pinned there. About 2 KB.
  • Raise the U64 WiFi bridge UART FIFO thresholds: receive 120 to 64, transmit 10 to 64. The time between the receive interrupt and the sender being stopped goes from 3 to 87 microseconds. No IRAM. I chose these from the interrupt timing, not from a sweep.
  • Enable CONFIG_ESP_WIFI_EXTRA_IRAM_OPT: the WiFi transmit path out of flash. About 6.4 KB.
  • Keep the U64 WiFi bridge per-frame netif and lwip path in IRAM: the functions the bridge calls per frame, and sys_arch as a whole object, because at -O2 pbuf_free() and mem_malloc() call sys_arch_protect(), which calls a split-off helper of sys_mutex_lock() in flash. About 0.7 KB, plus about 1.1 KB for sys_arch. LWIP_IRAM_OPTIMIZATION would place the same functions and about 40 unused ones for 11.4 KB. I checked the linked ELF with objdump: none of these functions calls into flash on the packet path. What stays in flash is command handling, the LED toggle in the dispatch loop (gpio_set_level), and error branches.
  • Build the U64 WiFi bridge with -O2: also removes the unused _err. Roughly no net IRAM, because the IRAM-resident source code gets smaller.

At this head (6.1.1) the module uses 106,819 of 131,072 bytes of IRAM (24,253 free), and 570,968 bytes of flash code. At the last 6.0.3 head it used 106,371 (24,701 free) and 555,272 bytes of flash code. The 5.3.1 module used 95,090, and the first 6.0.3 build 89,275.

What the measurements show. The first three bullets are builds of the same changes (the last of them also had a debug identify string), not this head, one run per image, on different days. The last bullet is this head:

  • With only the FreeRTOS and ring-buffer change, on a quiet channel, writemem and uci-net-target were back inside the range of the two master runs (writemem median 35.8 ms; 1,464 s). The GET /v1/version median (91 ms against 76 and 77) and FTP get (353-394 kB/s against 391-428) were not.

  • With all the changes, on a quiet channel, the module matches master: writemem median 31.8 against 31.2 ms, 99th percentile 121 against 102 ms, uci-net-target 1,127 against 1,156 s, GET /v1/version median equal.

  • With a traffic generator loading the channel (6 Mbit/s on each of two test boards), it does not match master. writemem median is 79.8 ms against 65.1 and uci-net-target took 2,664 s against 2,489 (+7%). The GET /v1/version median was better (145 ms against 160), and so was FTP get (281-293 kB/s against 245-270). I could not confirm that the load was the same on both runs, so I do not draw more than these numbers from the pair.

  • With this head, on a quiet channel (one run, no controlled load, no airtime reading, same AP as the master run but a different day), against master's quiet-channel run:

    master, 5.3.1 this head
    ping (100) avg / p50 / p90 / max 14.6 / 10.4 / 31.2 / 89.9 ms 12.7 / 6.6 / 30.6 / 71.7 ms
    GET /v1/version p50 / mean / p90 / p99 63.4 / 79.6 / 119.6 / 216.8 ms 56.8 / 64.7 / 98.2 / 237.7 ms
    FTP get, kB/s (3 runs) 469, 442, 495 446, 491, 431
    FTP put, kB/s (2 runs) 267, 281 326, 295
    writemem p50 / p90 / p99 31.2 / 52.7 / 101.9 ms 22.8 / 51.8 / 134.2 ms

    The image for this run was the TLS PR's head (this PR plus the TLS commits, TLS client sockets for the U64, through its ESP32 #997) with a module version that exists only on my bench so that the updater installs it. It had no Spike for #807: NET_CMD_WRITE_SOCKET_CHUNK ($16), a payload larger than one command as one datagram #835, so the uci-net-target chunked-write checks fail by construction; I compare only writemem from its first attempt (4,508 requests, against 7,468 for master's whole run). Master's two earlier runs on other days spread by 1.1 ms in the REST median, 1.7 ms in the writemem median and up to 23 ms in the writemem 99th percentile. This head's medians are lower than master's quiet run; its writemem 99th percentile (134 ms) is above that run's 102 ms but inside the range of the two earlier master runs (136 and 159 ms), and its REST 99th percentile (238 ms) is 21 ms above. One run, so this is "not worse", not a speed claim.

I have not repeated the loaded pair with the final commits. I do not claim that this module is as fast as the 5.3.1 one under load.

Size and flash

This PR's own changes are in software/wifi/raw_u64, where sdkconfig is almost all of the changed lines, plus the CI workflow and two README files.

bridge.bin is 838,912 bytes (0xCCD00). The 6.0.3 head was 818,224 bytes. 6.1.1 adds about 20 KB to the same sources (820,494 to 840,414 bytes before the OWE commit, which takes off about 1.5 KB). The factory partition is 1,048,576 bytes (ESP-IDF's single-app table: CONFIG_PARTITION_TABLE_SINGLE_APP=y, partitions_singleapp.csv), so 20% (0x33210 bytes) are free; it was 22% on 6.0.3. The bootloader is 25,904 bytes, 2,768 bytes below the partition table at 0x8000; the 5.3.1 one was 26,752 bytes.

Testing

Build, on this head, in espressif/idf:v6.1.1 (amd64 under emulation, macOS on Apple silicon). The first bullet is from the 6.0.3 commits of the move and was not repeated per commit on 6.1.1:

  • Each of the nine commits builds raw_u64 and u64ctrl (on Build the Elite II / C64 Ultimate control module (u64ctrl) with ESP-IDF 6.1.1 #1028), idf.py build leaves sdkconfig unchanged, and make host_tests (in the riscv build image, ESP-IDF 5.3.1) and make host_tests_idf6 (in the ESP-IDF 6 image, 102 checks) pass. One build, of Enable CONFIG_ESP_WIFI_EXTRA_IRAM_OPT, ended in a compiler segfault in IDF's eap_tls.c under amd64 emulation; a rerun of the same commit was clean.
  • On 6.1.1, at the head: raw_u64 builds, make host_tests_idf6 passes (102 checks, 0 failed), lint passes, and a build leaves sdkconfig unchanged. The 6.1.1 build prints 5 CMake warnings and some Kconfig deprecation notes from ESP-IDF itself.
  • The module has no compiler warnings of its own at this head: the -O2 commit removes the unused variable _err in rpc_dispatch.c, which was the only one. In the linked ELF, every function the commits place in IRAM is at an IRAM address.

Host tests on the 6.1.1 head (CI image, as build.yml runs them): make host_tests_idf6 RC=0 (102 checks, 0 failed), tests/lib/u64ctrl_ca_test.py OK. make host_tests runs in the riscv image (ESP-IDF 5.3.1), which the move to 6.1.1 does not touch; it passed on the 6.0.3 head (2026-10-30). make esp32 exits 2 here, as at #1028: raw_c3 still needs 5.3.1 until #1029.

CI has not run on this head. An earlier head's CI run passed (run 38752583354), but its ESP32 step was different (raw_u64 alone in the ESP-IDF 6 image).

Hardware

ESP-IDF 6.1.1

Bench image. One work-in-progress build (git hash 1a0778724) carries this PR together with the stack above it (#997, #1095, #953), #835 and test-only fixes that belong to no PR here. It was installed on the U64E with the updater; the configuration was reset and nothing was reformatted. The build before it (git hash 2a5eb4590) had the 6.0.3 module and the same bench commits; the 6.0.3 figures below are from it. The closed Wi-Fi library changed between 6.0.3 and 6.1.1, so the suites, the soaks and the boots were repeated. Hardware: Ultimate 64 Elite (U64E), firmware 3.15a, core 1.50.

The move to 6.1.1 is a toolchain change, so there is no red/green pair.

Step Result
Boot Stored WiFi Disabled, plug pulled, power button: boots radio-off, 10/10 GET_RANDOM draws (#953). With WiFi enabled, plug pull and power button: REST back in 19 s.
run-tests --e2e --profile quick All 37 suite runs passed.
run-tests --e2e --profile standard All 73 suite runs passed in 2,646 s (2,812 s on the 6.0.3 build).
uci-net-target, deep profile Exit 0 over Ethernet and over WiFi.
Soak over Ethernet, 3600 s 550 iterations (550 on the 6.0.3 image of the earlier round below), 0 lost. The first run failed on a 0.45 s burst of 33 stream-loss events while another job was using the test host; the rerun was clean.
Soak over WiFi, 3600 s, Ethernet cable out 3608 s, 520 iterations (490 on the 6.0.3 image of the earlier round below), 0 FAIL.
nc soak over WiFi with WiFi Enabled FTP shows as degraded, the same as on 6.0.3 and on master (not caused by this PR).

The TLS results of this image are in #997.

WiFi throughput, ESP-IDF 6.0.3 module against 6.1.1, same device and position, one run each, recorded, not a speed claim:

metric 6.0.3 6.1.1
ping x100, -i 0.2, avg 10.65 ms 10.0 ms
rtt n=200 mean / p50 / p90 / p99 ms 72.6 / 63.4 / 99.9 / 202.3 70.4 / 63.2 / 97.1 / 207.6
bulk get, kB/s (3 runs) 480, 417, 472 449 to 459
bulk put, kB/s (2 runs) 234, 249 280 to 287

Earlier round, ESP-IDF 6.0.3

Bench image. One work-in-progress build (git hash fdb59b059) carried the whole stack for Round B: this PR and every PR below it in the stack, the WiFi PR (#1041), #953 and #997, plus test-only commits that belong to no PR here (the lwIP pbuf pool change that fixes SEND ERROR: 12, #1035, and #835). All six PR heads are ancestors of that commit, so the patches of each PR are the bench's patches; the WiFi PR was rebased onto this stack for the build and git range-diff shows only conflict resolutions and module version numbers against its own branch. The hardware rows below therefore test this PR together with the others, and say so. Module version numbers are placeholders for the maintainer to assign at merge.

Before the flash. Each device was on the previous work-in-progress build (git hash 492c587e9): ESP-IDF 5.3.1 modules, no TLS commands, no GET_RANDOM. After the flash the config was reset and only the settings each run needs were set.

This PR is a toolchain move, so there is no red/green pair for it: the check is that the same steps and suites give the same results on the ESP-IDF 6 module as on the 5.3.1 one. The module is raw_u64, so the machine is the Ultimate 64 Elite (U64E): firmware 3.15a, core 1.50. The U64E ran the module of this PR together with the WiFi PR, #953 and #997; the rows do not separate them.

Step Result
Install Flashed with the updater from USB. The updater detected the previous module version and showed "Flashing ESP32 Success!" (read by a person from the screen). The updater rebooted the device itself. Link Up by itself after the flash.
Boot Stored WiFi Disabled, plug pulled 10 s, power button: boots radio-off, 0 station frames in the 123 s after the REST API answered, 10/10 GET_RANDOM draws. After Enable, a second plug pull and power button: REST back in 15.7 s, no popup, the module's first frame before the REST API answered, Link Up about 0.6 s after it.
Joins by itself After the flash, after the boots above, and after the access-point tests (the bench network rejoined without input). After a forget, the stored list was empty and stayed Link Down for 158 s; the password was then entered by hand.
run-tests --e2e --profile quick All 37 suite runs passed (the pre-flash reference run had 5 failures from the test host that did not repeat; "no regression", not "the same set").
uci-net-target, deep profile Exit 0 over Ethernet (19 min) and over WiFi (46 min). 0 x SEND ERROR: 12; the image carries the lwIP change that fixes it, so this row partly measures that change.
Soak over Ethernet, 3600 s, audio and video streams 0 FAIL, 550 iterations (pre-flash reference 550), ping 3659/3660 (0.0% loss), audio 897,689 packets 0 lost.
Soak over WiFi, 3600 s, cable out 0 FAIL, 490 iterations (reference 500), ping 3660/3660, rtt avg 19.4 ms (reference 19.9), max 361 ms (reference 297). One run each; recorded, not a claim.

WiFi throughput, ESP-IDF 5.3.1 module (before, same day) against this stack (after), one run each, recorded, not a speed claim; the differences are within the noise band of earlier repeated runs for rtt p50 and put:

metric before (IDF 5.3.1) after (IDF 6)
ping x100, -i 0.2 0% loss, avg 21.3 ms (max 297) 0% loss, avg 14.1 ms (max 91)
rtt n=200 mean / p50 / p90 / p99 ms 76.2 / 67.6 / 113.9 / 307.4 66.0 / 67.2 / 92.8 / 185.6
bulk get, kB/s (3 runs) 388, 349, 407 423, 370, 442
bulk put, kB/s (2 runs) 237, 305 269, 294

The earlier measurements on this PR's previous heads (14 and 27 October: the same-session master / first-6.0.3 comparison that led to the "Performance" commits, and the standard-profile runs) were on different days and images and are not repeated here. The conclusions drawn from them are in "Performance".

Not tested

barryw, as the workflows contact.

Written with Claude Opus 5.5 in Claude Code.

@chrisgleissner

chrisgleissner commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

@JC-000 Could you please make sure you have the latest master merged into your branch and then investigate in mroe detail why these e2e tests fail for you: openapi-validator, openapi-contract, observability, ultimax-cartridge, freezer-audio

They do not fail for me despite repeated runs. I spent a lot of time getting them to work well against the U64, C64U, and U2+L.

Error details would be great. You can run all e2e tests with full observability logs and then maybe share those for the failing tests.

There are plans to run the e2e tests on CI, but until that is the case, any e2e error should be considered a regression and/or flakiness and then get fixed via a dedicated PR, or on the back of whichever PR exhibited the regression.

As the failing tests have nothing to do with your change, I would recommend raising either a new issue with full logs, or alternatively, for bonus points, a PR that fixes them is always appreciated. :-)

@JC-000

JC-000 commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Rgr, working it. FWIW, I think it might boil down to not having some Python dependencies in place.

@JC-000

JC-000 commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

@chrisgleissner I re-ran the five suites against current master (fc35f21) on the same U64 Elite (fw 3.15, FPGA 126, core 1.50). None of the five failures comes from the firmware. Each one is a gap in my host setup, and the observability one is partly a test portability issue.

  • openapi-validator, openapi-contract: the Python that ran run-tests didn't have tests/requirements.txt installed ("response validation needs PyYAML", "openapi-spec-validator is needed for this suite"). With a venv, both pass: 16 and 18 checks.
  • observability: 179 of 180 cases pass. Two of them failed because the host was macOS:
    • [110] binds 127.0.0.2, which macOS doesn't configure (Errno 49). It passes after sudo ifconfig lo0 alias 127.0.0.2.
    • [158], the golden document, still fails. Part of it was the temp path: support.py:1220 matches only /tmp/e2e-observability-fixture-, and macOS puts temp files under /var/folders/.... TMPDIR=/tmp fixes that part. The rest is Python 3.13's traceback rendering (~~~~^^^^ marker lines, extra source lines). The canonicalizer handles only the 3.10 format, and support.py:1230-1231 says the CI image runs 3.10. Python 3.10 reaches end of life in October 2026 (PEP 619), so I think the expected output, or the canonicalizer, needs to move to a supported version. Also, the failure message prints only diff[:6] (golden_test.py:140-142), which is the header and context, so the log never shows the line that changed.
  • ultimax-cartridge, freezer-audio: my test host was on WiFi, and the U64 streams out of its wired port, so the multicast streams never reached the tests. From a wired host, freezer-audio passes (6 checks), and the video stream for ultimax-cartridge now arrives. ultimax-cartridge then skipped its frame comparison, because this U64 is set to NTSC and the reference is a PAL frame (the reference is a 384x272 PAL frame and this machine streams 384x240). With System Mode set to PAL, it passes (3 checks).

I can open a small PR for the observability portability: match any .../e2e-observability-fixture-* path, handle the 3.11+ traceback markers, and show the changed lines in the failure message. Tell me if you'd prefer to handle that yourself.

@chrisgleissner

Copy link
Copy Markdown
Collaborator

Fantastic work @JC-000 . Yes, it would be brilliant if you could open a dedicated, targeted PR to just fix these tests that failed for you. Please ensure they also continue to work on Linux. I personally build on Kubuntu 24.04, and you could for example use Docker to spin up such an environment quickly. The network settings may need some tweaking, though, to fully resemble a native Kubuntu 24.04. I can try to build and E2E test your PR on my rig once it's done.

@JC-000

JC-000 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

Are you planning to move to newer Python since 3.10 is EOL?

@JC-000

JC-000 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

@chrisgleissner The targeted fix is up: issue #1001, PR #1002. It only touches tests/lib/observability.

I ran it the way you suggested, in an ubuntu:24.04 container (Python 3.12.3, the Kubuntu 24.04 userland) with tests/requirements.txt in a venv. All device-free suites give the same results on master and on the branch, and observability passes on both, which matches what you saw. The failure only shows on Python 3.13/3.14 (Linux as well) and on macOS.

The other four suites needed host setup on my side, not code changes, as in my earlier reply.

One thing I noticed on current master: registry_test fails because tests/e2e/io/iec/directory_rename_test.py from #1000 is not in run-tests SUITES. I kept that out of #1002.

@chrisgleissner chrisgleissner added enhancement New functionality or an improvement to existing behavior, including formats and developer tooling. uci C64-side Ultimate Command Interface, command targets, and Ultimate DOS commands; REST is network. network Networking and remote services: REST, Socket DMA, FTP, Telnet, and online access. labels Oct 17, 2026
@UltimateC64Ultimate64fan

Copy link
Copy Markdown

Any ESP-IDF 6.0.3 upgrade should cover all three ESP targets (raw_u64, u64ctrl, raw_c3) at once rather than creating instant technical debt with two parallel SDKs.

The mbedTLS 4.1.1 on the ESP32 shouldn't be a driver here given @GideonZ's direction in #936 and #952 that TLS belongs on the main Nios II / RISC-V CPU (lwIP), not on the ESP32.

@GideonZ

GideonZ commented Oct 20, 2026

Copy link
Copy Markdown
Owner

TLS also belongs on the ESP32, but for another reason, see PR #1012.

@JC-000

JC-000 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks. On the two-SDK point: my plan is all three module builds on ESP-IDF 6, and the split is only temporary while each module is moved and tested on its own hardware.

  • raw_u64 (U64/U64E): this PR, tested on a U64E.
  • u64ctrl (Elite II / C64U): ported to 6.0.3 with the same build process. As of today it has run on a C64U: cold start, WiFi, and the full network-target suite. It will be its own PR, rebased onto Recover a U64-II over Wi-Fi from a signed manifest #1012 once that's in.
  • raw_c3 (U2+L): it has the same three IDF 6 breakages this PR fixes, so I don't expect blockers, but I have no U2+L to test on.

The move doesn't depend on TLS alone: ESP-IDF 5.3 leaves Espressif's support on 2027-01-25 for all three modules.

@JC-000

JC-000 commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

I rebased this PR, added performance commits, and force-pushed it.

Written with Claude Opus 5.5 and Claude Sonnet 5.5 in Claude Code; reviewed adversarially by separate Claude Opus 5.5 sessions before posting.

JC-000 and others added 7 commits October 30, 2026 14:29
…DF 6.0.3

u64ctrl moves to ESP-IDF 6.0.3 (mbedTLS 4) and bumps the module version
so the updater installs it. This changes the toolchain of the C64
Ultimate's power controller, not only of its WiFi: the module runs
power, button and keepalive handling. It is one commit because none of
its parts builds alone: the CMake check stops CI's ESP-IDF 5.3.1 build,
and the recovery code does not compile under mbedTLS 4.

- my_uart.c: uart_periph.h moved from soc/ to hal/, and
  uart_isr_handle_t (a typedef of intr_handle_t) is gone. The same two
  changes GideonZ#996 makes for raw_u64.
- CMakeLists.txt: configure stops on an ESP-IDF older than 6.
- sdkconfig: regenerated by idf.py build from the ESP-IDF 5.3.1 file.
  Values present in both versions are carried; of the 1498 options in
  the 5.3.1 file only the esptool before/after spelling, DHCP option
  length (68 to 69), X509 trusted cert callback and
  ESP_NETIF_RECEIVE_REPORT_ERRORS changed value (SOC_ constants aside).
  Options that are new take ESP-IDF 6's defaults, among them picolibc
  instead of newlib and the FreeRTOS and ring-buffer functions running
  from flash rather than IRAM. Brownout level 7 and the 100 Hz tick are
  carried.
- rpc_dispatch.h: the module version is the next minor above master's,
  see the history line. The maintainer assigns the number at merge.
- CI builds u64ctrl in espressif/idf:v6.0.3, pinned by digest in
  $IDF6_IMAGE; raw_u64 and raw_c3 stay in my_docker_image. The ESP32
  cache key names both images. README.txt and software/u64ctrl/README.md
  say how to build it.

The recovery code from the Wi-Fi recovery change is ported to mbedTLS 4
and PSA Crypto, because it did not compile: mbedTLS 4 has no public
mbedtls/sha256.h and no mbedtls_pk_get_type(). The mbedTLS 4 port is of
code written for mbedTLS 3.

- recovery_verify.c: the key type comes from mbedtls_pk_get_key_type()
  (an ECC public key); the manifest hash is psa_hash_compute();
  psa_crypto_init() is always called, so the init does not depend on
  MBEDTLS_USE_PSA_CRYPTO, which is still defined as a legacy symbol that
  is slated for removal. A failure to start is reported as
  RECOVERY_ERR_CRYPTO ("crypto library failed"), not as a bad signature.
  The signature itself is still checked by mbedtls_pk_verify() with a DER
  ECDSA signature, as before.
- recovery_verify.h, recovery_verify.c: the streaming hash of a
  downloaded file moves out of recovery.c into recovery_hash_*(), on
  psa_hash_*(), so the host test can run it. It also holds the compare
  with the manifest's hash, reported as RECOVERY_ERR_HASH_MISMATCH.
- recovery.c: stream_file() uses it. The checks, their order and the log
  line for a differing hash are as before; a failure of the crypto
  library is logged by name.
- Two result codes are added after the existing ones; nothing that was
  returned before changes.
- The host test links TF-PSA-Crypto from ESP-IDF 6, so it moves out of
  make host_tests, which CI runs in ESP-IDF 5.3.1, into host_tests_idf6
  and its own CI step in $IDF6_IMAGE.

Tests, written first and red against the unported code (recovery_verify.c
cannot include mbedtls/sha256.h under ESP-IDF 6), check by the error each
case names:

- a valid manifest is accepted;
- the wrong key, a tampered manifest, and a manifest correctly signed by
  an RSA key (rsa512.manifest) are refused as a bad signature;
- a changed or truncated image or bitstream is refused as a hash
  mismatch, and so is a file whose manifest hash differs in its first,
  middle or last byte, which a compare that stopped early would accept;
- a crypto library that will not start, or a hash that fails in its
  update or finish, is reported as such, never as a bad signature or a
  match. The test forces these through --wrap=psa_crypto_init,
  psa_hash_update and psa_hash_finish, so the product code carries no
  test hook.
The signed vectors are unchanged; the two RSA files are new.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
On mbedTLS 4, PSA's key slots are protected by a mutex only with
MBEDTLS_THREADING_C. It is ESP-IDF 6's default; the regenerated
sdkconfig had carried 5.3.1's "not set". The WiFi supplicant
(ESP_WIFI_MBEDTLS_CRYPTO, on in this project) imports and destroys PSA
keys now, and it runs next to anything else that uses PSA. The pthread
implementation comes with it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…T buffer

When no UART buffer is free, the receive hook returned ERR_BUF and
wlanif_input() freed the packet. On ESP-IDF 5.3.1 the WiFi driver was
then told ESP_OK; on ESP-IDF 6 esp_netif_receive() passes the error
on, so the driver would see ESP_FAIL on this path. Stock ESP-IDF 6
already returns ESP_FAIL whenever lwIP's input mailbox is full, so the
driver handles it; free the packet here and return ERR_OK only to
leave this path exactly as before. The packet is dropped either way.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
UART1 is routed to the FPGA pins in two places: at boot, in
setup_modem(), and whenever the machine is switched on, in
regulator_enable(). Before either, the pins hold their reset state or,
after check_fpga() or a power off, a pull-down (check_fpga() sets it on
RXD only; the power-off path sets it on all four). ESP-IDF 5.3.1's
uart_set_pin() put a pull-up on RXD and CTS before connecting them,
replacing it. ESP-IDF 6's uart_set_pin() never touches pulls, so RXD
would stay pulled down and CTS at its reset state while the FPGA
configures, reading as a break and as clear to send where 5.3.1 read
idle and not clear.

One helper, my_uart_connect_pins(), sets the pull-ups and then routes
the pins, in that order as 5.3.1 did, and both places call it. While
the machine is off RX and CTS stay routed, pulled down; a boot that
stays off has the pull-ups on for about 100 ms until
regulator_enable(0), the same as on 5.3.1.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
ESP-IDF 6's brownout interrupt waits for every enabled UART's
transmitter to drain before it resets the chip; 5.3.1 reset at once.
UART1 honours CTS, and CTS idles high through its pull-up when the FPGA
loses power with the machine, so bytes left in the transmit FIFO would
never leave and the wait would last until the 300 ms interrupt
watchdog, ending in a panic reset instead of a brownout reset.

Register a brownout callback, which runs in IRAM ahead of that wait,
that turns CTS flow control off so the FIFO drains. A failed
registration is logged and does not stop the boot.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The host test only used keys of its own. Load every key in
recovery_trusted_keys as an EC public key, require a spare next to the main
key, require that no two shipped keys are the same, and check that a manifest
is verified by a key placed behind all of them.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ESP-IDF 6 moved the FreeRTOS queue/task and ring buffer functions to
flash by default (CONFIG_FREERTOS_IN_IRAM and CONFIG_RINGBUF_IN_IRAM are
off); ESP-IDF 5.3.1 had them in IRAM. Every frame passes
xQueueGenericSend, xQueueReceive and xRingbufferReceive in both
directions, so each call can wait on a flash cache miss. Set both options
to put them back in IRAM (12,140 B more shared IRAM/DRAM, 157,151 B of 341,760 stay free; flash code drops by 13,024 B).

The effect was measured on the U64E's classic ESP32 module only (raw_u64:
writemem p50/p90/p99 back in the IDF 5.3.1 range, the REST probe and FTP
get not fully). On this module it is not measured yet; the C64U bench run is pending.
The change is the same two sdkconfig lines.

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

@chrisgleissner chrisgleissner left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JC-000 thanks for this. The branch conflicts with master. Please merge or rebase master after #1028.

JC-000 and others added 2 commits November 10, 2026 08:20
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Brings in GideonZ#1028's updated branch, which already holds master.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
JC-000 added a commit to JC-000/1541ultimate that referenced this pull request Nov 10, 2026
Brings in GideonZ#996's updated branch, which already holds master and GideonZ#1028.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
JC-000 added a commit to JC-000/1541ultimate that referenced this pull request Nov 10, 2026
Brings in GideonZ#1029's updated branch, which already holds master and GideonZ#1028/GideonZ#996.
The tree was merged against the old WiFi series tip so that GideonZ#953's own changes
apply on top of the merged GideonZ#1041, not on the earlier copy of it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
JC-000 added a commit to JC-000/1541ultimate that referenced this pull request Nov 10, 2026
Brings in GideonZ#953's updated branch, which already holds master, GideonZ#1028, GideonZ#996 and GideonZ#1029.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
JC-000 and others added 2 commits November 12, 2026 13:10
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

# Conflicts:
#	Makefile
…ideonZ#996)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@JC-000

JC-000 commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

Merged the updated #1028 into this branch (d36a8e6). #1028 now contains current master, and the merge had no conflicts. The module version is still above master's, and the diff is still only this PR's change on top of #1028. make host_tests and make host_tests_idf6 pass, and raw_u64 builds in the pinned ESP-IDF 6.0.3 image.

Written with Claude Sonnet 5.5 in Claude Code.

JC-000 added a commit to JC-000/1541ultimate that referenced this pull request Nov 12, 2026
…(base update for GideonZ#1029)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
JC-000 added a commit to JC-000/1541ultimate that referenced this pull request Nov 12, 2026
…ci-net-get-random (base update for GideonZ#953)

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

# Conflicts:
#	software/io/network/network_target.h
JC-000 added a commit to JC-000/1541ultimate that referenced this pull request Nov 13, 2026
…aster) into pr/3-tls-r1 (base update for GideonZ#997)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
JC-000 and others added 10 commits November 16, 2026 14:25
The build instructions name the 6.1.1 image, and the sdkconfig is regenerated by 6.1.1 with every existing value unchanged, including the IRAM placement options.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
CI and the build instructions move from the 6.0.3 image to espressif/idf:v6.1.1, pinned by digest. The sdkconfig is regenerated by 6.1.1; every value the module sets is unchanged, including the IRAM placement options (FreeRTOS, ring buffer and Wi-Fi in IRAM). Its mbedTLS is the same Mbed TLS 4.1.1 commit as 6.0.3.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The reason codes WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT, _AUTH_FAIL and
_HANDSHAKE_TIMEOUT keep the values 15, 202 and 204 in ESP-IDF 6.1.1.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The 1.31 line of the version history said the module was built with ESP-IDF 6.0.3. It is now built with 6.1.1.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
ESP-IDF 6.1.1 added CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_SOFTAP, which defaults to y. 6.0.3 had no such option, and the module only runs as a station, so it is set to n to keep the 6.0.3 behavior and not link soft-AP code.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The 1.20 line of the version history said the module was built with ESP-IDF 6.0.3. It is now built with 6.1.1.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
ESP-IDF 6.1.1 added CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_SOFTAP, which defaults to y. 6.0.3 had no such option, and the module only runs as a station, so it is set to n to keep the 6.0.3 behavior and not link soft-AP code.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@JC-000 JC-000 changed the title Build the U64 WiFi module firmware (raw_u64) with ESP-IDF 6.0.3 Build the U64 WiFi module firmware (raw_u64) with ESP-IDF 6.1.1 Nov 17, 2026
@chrisgleissner chrisgleissner added the build Build and CI infrastructure label Nov 20, 2026
JC-000 and others added 2 commits November 23, 2026 13:22
Conflicts resolved:
- software/u64ctrl/main/rpc_dispatch.h: master's GideonZ#1097 took V1.30 for the root list
  change; this branch keeps its own V1.31 (ESP-IDF 6.1.1) and carries master's
  1.30 history note below it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Brings in master 40188c7 through the merged pr/idf6-u64ctrl branch (the PR
below this one in the stack, merge/1028-master-1123). No conflicts.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Build and CI infrastructure enhancement New functionality or an improvement to existing behavior, including formats and developer tooling. network Networking and remote services: REST, Socket DMA, FTP, Telnet, and online access. uci C64-side Ultimate Command Interface, command targets, and Ultimate DOS commands; REST is network.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move the raw_u64 WiFi module firmware to ESP-IDF 6.0.3

4 participants