Skip to content

Build the U2+L WiFi module firmware (raw_c3) with ESP-IDF 6.1.1 (build only, not hardware-tested) - #1029

Draft
JC-000 wants to merge 51 commits into
GideonZ:masterfrom
JC-000:pr/idf6-raw_c3
Draft

JC-000 wants to merge 51 commits into
GideonZ:masterfrom
JC-000:pr/idf6-raw_c3

Conversation

@JC-000

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

Copy link
Copy Markdown
Contributor

Built for the U2+L, but not hardware-tested. I have no U2+L. The module image builds, and that is all that has been checked. Neither WiFi, the UART link to the Ultimate nor the update path has been exercised on a real U2+L. Chris offered to test it; any result, good or bad, is the first real test. "If you can test it" below lists what to check.

Part of #952. Draft. Base: master 3db34d2.

This is the third 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. Build the U64 WiFi module firmware (raw_u64) with ESP-IDF 6.1.1 #996: raw_u64 (U64 / U64 Elite).
  3. This PR: raw_c3 (U2+L).

Until the other two merge, the "Commits" and "Files changed" tabs here also show their commits. #1027, a bug fix for all three ESP32 modules, is already on master. This PR's own commits are the last ones: Build the U2+L WiFi bridge (raw_c3) with ESP-IDF 6.0.3 (build-only, untested), Build all three ESP32 modules in the ESP-IDF 6 image in CI, four performance commits that only change where code is placed (see item 3), and three that move the module on to 6.1.1 (see item 4).

Why

Espressif stops supporting ESP-IDF 5.3 on 2027-01-25, after which the module's network stack and crypto get no security fixes. #1028 and #996 move the other two ESP32 modules. This PR moves the last one, so the tree has one ESP-IDF version and make esp32 builds all three modules in one environment.

Change

1. Build the U2+L WiFi bridge (raw_c3) with ESP-IDF 6 (first built with 6.0.3, now 6.1.1; see item 4). These are the same fixes #996 makes for raw_u64:

  • 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.
  • wifi_modem.c, hacked_recv: when no UART buffer is free, it frees the packet and returns ERR_OK. It used to return ERR_BUF, and on ESP-IDF 6 esp_netif_receive() would pass that on to the WiFi driver as an error. The packet is dropped either way.
  • sdkconfig was regenerated with idf.py reconfigure from the 5.3.1 file. Of the 1,328 options in the old file, 1,182 are in the new one too, and 7 of those changed value. Those are ESP_WIFI_EXTRA_IRAM_OPT (set by the placement commit in item 3) and ESP_NETIF_RECEIVE_REPORT_ERRORS (forced on by ESP-IDF 6), MBEDTLS_THREADING_C (on, as in Build the U64 WiFi module firmware (raw_u64) with ESP-IDF 6.1.1 #996: PSA key slots need it once the WiFi supplicant and other tasks both use PSA), MBEDTLS_X509_TRUSTED_CERT_CALLBACK (selected by ESP-IDF 6's certificate bundle check), the DHCP option length (68 to 69), and the esptool before/after spelling (two options). 146 options are gone, and 366 new ones take ESP-IDF 6's defaults. Among those: picolibc replaces newlib, mbedTLS 4 replaces 3, FreeRTOS and ring-buffer functions run from flash rather than IRAM (the third commit puts them back), and WPA3-compatible mode is compiled in. The C3-specific values (minimum chip revision, flash size, brownout level, USB-Serial-JTAG secondary console) are unchanged. A build at the head leaves sdkconfig unchanged. Please review the values, not just the build.
  • rpc_dispatch.h: the module version goes up by one minor, only so that the image identifies itself. The U2+L updater does not compare the module version. update_u2pl/update.cc prints the detected module's name and offers "Want to update the WiFi Module?" whenever the ESP32 answers, and it reflashes when the user says yes. (The U64 and U64E-II updaters do compare it.) I also corrected the comment in rpc_dispatch.h, which said otherwise.

2. Build all three ESP32 modules in the ESP-IDF 6 image in CI. CI builds raw_u64, raw_c3 and u64ctrl with one make esp32 in the pinned espressif/idf:v6.1.1 image from #1028, and my_docker_image no longer builds any ESP32 module. So the ESP32 cache key no longer names my_docker_image's image id, and the step that read it is gone. The old raw_c3 command ran in my_docker_image with --net=custom_network --mac-address=.... The ESP-IDF image builds u64ctrl and raw_u64 without those options in #1028 and #996. README.txt and the three module READMEs now say that all three modules need ESP-IDF 6, and raw_c3 gets a Building section like the other two.

After this PR, no module needs ESP-IDF 5.3.1 any more. make, make esp32, make u64, make u64ii, make u2pl and make clean need an ESP-IDF 6 IDF_PATH. CI still packs the images with the _no_esp targets.

What is left on 5.3.1. docker/Dockerfile still installs ESP-IDF 5.3.1, and ghcr.io/gideonz/riscv (used by build.sh) also has 5.3.1, so neither can build the modules. I did not change them. Those images are yours, and the other CI steps run in my_docker_image. Once the three PRs are in, moving the Dockerfile to 6.1.1 would let CI drop $IDF6_IMAGE and make build.sh work again. I can send that as a separate PR if you want it.

Not carried over from #1028. #1028 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_c3 routes UART1 the same way, with CTS flow control, and has the brownout interrupt on, so the same ESP-IDF 6 changes reach it. I did not port those fixes. On the U64 Elite, raw_u64 ran without them (see #996), but nothing has run on a U2+L.

3. Keep the packet path in IRAM (four commits, placement only). ESP-IDF 6 moved the FreeRTOS queue and task functions and the ring buffer to flash by default (CONFIG_FREERTOS_IN_IRAM and CONFIG_RINGBUF_IN_IRAM are off). On the U64 Elite's ESP32, putting them back, and then the rest of the packet path, brought WiFi latency back to the 5.3.1 range on a quiet channel (see #996). These four commits make the same placement changes here, and nothing else:

  • Keep FreeRTOS and the ring buffer in IRAM in the U2+L WiFi bridge: sets the two options.
  • Run the U2+L WiFi bridge UART and dispatch code from IRAM: a linker fragment (main/linker.lf) places the UART interrupt handler, the UART buffer code, hacked_recv() and dispatch() in IRAM.
  • Keep more of the WiFi driver in IRAM in the U2+L WiFi bridge (ESP_WIFI_EXTRA_IRAM_OPT): one sdkconfig line.
  • Run the netif, pbuf and heap path of the U2+L WiFi bridge from IRAM: the per-frame netif, pbuf, heap and sys_arch functions. In the linked ELF, none of them calls into flash on the packet path.

There is no core pinning (the C3 has one core), no change to the FIFO thresholds and no -O2. I kept to placement because I cannot run or measure this module. On 6.0.3 it cost 9,678 bytes of DRAM and took 8,094 bytes out of flash code (DRAM used 165,794 of 321,296, 155,502 free). At the 6.1.1 head DRAM used is 168,044 of 321,296 (153,252 free) and flash code is 667,872 bytes (both read from the linker map).

4. Move on to ESP-IDF 6.1.1 (three commits).

  • Build raw_c3 with ESP-IDF 6.1.1: the build instructions name the espressif/idf:v6.1.1 image (pinned by digest in Build the Elite II / C64 Ultimate control module (u64ctrl) with ESP-IDF 6.1.1 #1028, sha256:2b4f966c37eaedc19542b0637a5f850b2eff9478d8e858192aa0073d92c2dc91) and sdkconfig is regenerated by 6.1.1. Every existing value is unchanged, including the IRAM placement options. The Mbed TLS is the same 4.1.1 commit as in 6.0.3.
  • Say 6.1.1 in raw_c3's version history: a comment.
  • Leave the Wi-Fi OWE soft-AP support out of raw_c3: 6.1.1 added CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_SOFTAP with default y. 6.0.3 had no such option and the module only runs as a station, so it is n, which keeps the 6.0.3 behaviour and saves flash.

Size and flash

This PR's own changes are mostly sdkconfig; the other files are small.

bridge.bin is 922,816 bytes (0xE14C0); it was 892,736 on 6.0.3. The factory partition is 1,048,576 bytes (ESP-IDF's single-app table), so 125,760 bytes (12%) are free; 155,840 (about 15%) were on 6.0.3. The bootloader is 20,624 bytes; it starts at 0x0 on the C3 and has 37% of its space before the partition table at 0x8000 free.

What was tested

Build only, in espressif/idf:v6.1.1 (amd64 under emulation, macOS on Apple silicon). The per-commit builds below were made on 6.0.3, before the move; at the 6.1.1 head raw_c3 builds:

  • Each of the first two commits builds raw_c3, raw_u64 and u64ctrl. Of the performance commits, the UART and dispatch commit and the last one were built on their own; I did not rebuild the other two one by one. The only compiler warning is the unused variable _err in rpc_dispatch.c, which is old code.
  • idf.py build leaves sdkconfig unchanged, for all three modules (6.0.3; at the 6.1.1 head, raw_c3 and the modules of the PRs below).
  • make esp32, run the way CI runs it (non-root, in the pinned image, from the top of the tree), builds the three modules.
  • 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 on both of them. I did not run make host_tests on the performance commits (no code under test changed).

The workflow change has not run on the self-hosted runner, and make u2pl was not run end to end here (it needs the Lattice and RISC-V toolchains as well).

6.1.1 head, CI image: make host_tests_idf6 RC=0 (102 checks, 0 failed), tests/lib/u64ctrl_ca_test.py OK, lint OK, and the raw_c3 module build RC=0. 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). The 6.1.1 build prints 5 CMake warnings and some Kconfig deprecation notes from ESP-IDF itself.

Hardware

None on this PR's module. The hardware runs covered the Ultimate 64 Elite and the C64 Ultimate, whose modules are raw_u64 and u64ctrl: Round B on 6.0.3 (one work-in-progress build, git hash fdb59b059) and the repeat on 6.1.1 (git hash 1a0778724), each with the stack below and above this PR. Their results are in #996 and #1028 and say nothing about raw_c3. The U2+L, the U64 (non-Elite) and the Elite II were not tested.

Not tested

Everything on a U2+L: flashing, WiFi association, DHCP, traffic through the UART link, the update path, the receive hook with no free UART buffer, power-off and brownout.

If you can test it

  1. Get an update file. The simplest is update_*.u2l from this PR's CI run (User Artifacts), once CI has run. Otherwise build the module with the container command in software/wifi/raw_c3/README.md and then make u2pl_no_esp.
  2. Before flashing, note the module name the updater prints under "WiFi module detected".
  3. Run the update and answer yes to "Want to update the WiFi Module?". Check that it reports "Flashing ESP32 Success!".
  4. Power-cycle the U2+L. Optionally, run the updater again just to read the "WiFi module detected" line, which should name the module this PR builds, then answer no to its questions, including "Reset Configuration? (Recommended)", unless you want your settings cleared.
  5. Check that the module joins your WiFi network and that the U2+L answers ping and a REST request (GET /v1/info) over WiFi, as it does with the 5.3.1 module. If you can, compare the throughput too, since some sdkconfig defaults changed.
  6. To go back, run any current release's U2+L update and answer yes to the WiFi question. That reflashes the ESP-IDF 5.3.1 module.

Please post what you see, either way.

Written with Claude Opus 5.5 in Claude Code.

@chrisgleissner

Copy link
Copy Markdown
Collaborator

@JC-000 I do not see any discussion on the Github issue since @GideonZ asked to slow down and discuss before we open PRs.

Could we please hold off on raising PRs that target Gideons repo for draft work as each change to such a PR will incur build cost for Gideon, and may be wasted if the approach cannot be merged.

I like proof of concepts, but they are best done against your own fork, with a discussion about the final approach.

Maybe I am lacking context and maybe such discussions have happened directly with @GideonZ. Could you please give more context about this, and why this PR was raised?

Thanks

@JC-000

JC-000 commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

@chrisgleissner I know I moved a fair amount of things at once and I did read the mail on speed. If this looks like mission creep that is not really what happened. My goal is to get the stack required for TLS into a testable state and then I plan to go quiet except for fixing issues in my PRs if they are wanted. Adding #1016 and running the tests and research on the 40ms delay was very easy to do inline while other work was in process on IDF 6 and on the NIOS vs ESP32 benchmarks for TLS offload that I ran for @barryw. I found a lot of little issues like #1018 that I had to resolve. With the current IDF 5 approaching EOL in a few months IDF 6 looked like it had to happen sooner rather than later. I made sure to rebase on top of master before doing my IDF 6 testing with #1012 merged. The NIOS vs ESP32 TLS offload benchmarks were also decisive in favor of ESP32. Many of the issues I found were not directly related to an IDF 6 migration, but were blockers for it or kept appearing as anomalies in testing. I tried to make this as digestible for you as possible by making the issues like the #1026 race condition and the #1027 missing terminator discrete to facilitate review work, but the race condition was causing testing issues, and the missing terminator was a build blocker for IDF 6 on some platforms. They were unavoidable and not mentioning them would be irresponsible of me. This way they are visible and can be fixed independently of the IDF 6 PRs. FWIW I even PR'd a fix in mbedTLS 4.1.1 so that it better handles TLS 1.3/1.2 handshakes.

Because there are three different platforms and everyone wants feature parity for something like an RNG or TLS, I had to build IDF 6 for U64E, C64U, and U2. As you can see from this one, I did them as separate PRs that stack. This was to avoid one huge PR where if an issue is found that is platform specific, it blocks them all.

Outside of that, my #953 still has to be rebased onto the IDF 6 PRs, and I need to complete another test round for the wifi switch logic fix on C64U/U64E so that the hardware RNG is enabled when the radio is off. This is not my issue in a direct sense since I did not set out to work on the wifi logic behind the menus, but without fixing that the rng won't work in a way that anyone can understand. If a user goes from wifi enabled to wifi disabled the rng will break but only one platform and not another, which is the kind of ick I shouldn't allow out my front door as a PR.

So again I do hear you and I'm not trying to barrage the repo. The road to TLS has just needed more grading before it could be paved. I will get #953 caught up with IDF6 and the wifi on/off RNG logic fully tested on my end, and then aside from anything that needs to be changed in an issue or PR I have open, I plan to be quiet. Only if I see general alignment on the TLS offload in #997 will I launch the work for DTLS.

@chrisgleissner

Copy link
Copy Markdown
Collaborator

Thanks @JC-000 . As long as we keep the PRs focused, agree first on major PRs before writing code (as per our CONTRIBUTING.md guide), and otherwise try to get PRs merged before moving on to the next topic, I am fine with it.

As context, there is only Gideon and myself with the ability to merge PRs. I cannot sensibly merge stuff where Gideon raised concerns about the need for a discussion. So unless you get his agreement on the approach taken, all of the TLS PRs won't be able to get merged.

It is much easier for me to merge bug fixes, or very targeted, small feature enhancements. But anything involved will definitely need Gideon's approval, and he is very busy. I am saying that to both manage expectations, but also keep things manageable on the PR reviewer side.

Also, it would really help if you could get a UII+L since ideally, all firmware contributors, especially those who lift the heavy stones to speak figuratively, need to test their code themselves, and present the test results in an easy to read manner in the PR summary. Few people enjoy testing the code of others, especially engineers, and I think testing one's own creation is just a matter of due diligency and good engineering practices.

I appreciate you may not currently have a UII+L, but it would help if you could get one and add it to your set of devices to test on. Maybe reach out to @GideonZ and mention why this is needed, and see what he says about this and also your TLS-related PRs.

Best wishes

@JC-000

JC-000 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Understood, thanks. That matches how I'm handling the WiFi work: #1031 lists the bugs I found while testing, and asks before I open any PRs; those fixes are small and standalone.

For the TLS PRs, I'll keep them mergeable and testable against master, but I won't change their command numbers or features without a reason, so they stay a stable baseline: a TLS command set with a working back end that can be reviewed and tried as it is. I haven't seen any objection to the command set or the features so far, but I'd welcome critical review of both, and ideas for a better way to do this. They won't go further until Gideon has agreed the approach. Once they're rebased and each description has its red/green and soak results, I'm happy to mark any of the drafts ready for review if that makes it easier for you; otherwise they stay drafts until Gideon has weighed in.

I'm looking into getting a UII+L so I can test the raw_c3 changes myself.

Written with Claude Opus 5.5 in Claude Code.

@chrisgleissner chrisgleissner added 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. labels Oct 29, 2026
JC-000 and others added 22 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>
…flash

The WiFi task runs on core 0. esp_intr_alloc() binds an interrupt to the core it is called on, so my_uart_init() now runs from a short task pinned to core 1, which keeps the UART ISR off the core the WiFi driver is using. The ISR, the UART buffer code, hacked_recv(), dispatch() and cmd_send_eth_packet() move to IRAM with a linker fragment (noflash). The ISR flags stay 0, so the interrupt is masked while the flash cache is off (NVS writes) and nothing in the handler has to be safe to run then; the overflow branch calls the flash function uart_hal_rxfifo_rst(), but RXFIFO_OVF is not in the enable mask, so it does not run. The dispatch task is pinned to core 1 at priority 19 so it runs where the ISR feeds it. Also check the init semaphore and the task create.

The whole of my_uart.c is noflash, so my_uart_connect_pins() and the brownout callback now sit in IRAM too (the callback already was IRAM_ATTR), and the callback is registered from the core 1 task. Neither depends on the core: the brownout interrupt is a separate system interrupt, and the pin routing is called as before from task context. This is harmless.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The RX full threshold drops from 120 to 64 and the TX empty threshold from 10 to 64 (the hardware flow control threshold of 122 is unchanged). At 5 Mbaud the interrupt latency budget before RTS asserts goes from 2 bytes (4 us) to 58 bytes (116 us), and the TX FIFO has 128 us instead of 20 us to be refilled. The margin after RTS asserts stays 6 bytes.

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

The option is off by default for the ESP32-S3 and places more of the WiFi driver send and receive code in IRAM.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Place esp_netif_transmit/receive/free_rx_buffer, wlanif_input, esp_pbuf_allocate/free, wifi_transmit/free, esp_wifi_internal_free_rx_buffer, pbuf_free, pbuf_alloced_custom, pbuf_init_alloced_pbuf, mem_malloc, mem_free, sys_arch_protect/unprotect and sys_mutex_lock/unlock in IRAM (noflash), so the per-packet path between the WiFi driver and the UART bridge no longer calls flash-resident code. What is left in flash is off that path: the one-time sys_mutex_new, the esp_event_post calls guarded by the runtime tx_rx_events_enabled flag, and the command handlers that dispatch() calls for non-packet commands.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
raw_u64 moves to ESP-IDF 6.0.3 (mbedTLS 4) and reports V1.7, so the
updater installs it. raw_c3 stays on ESP-IDF 5.3.1 in my_docker_image,
unchanged.

- my_uart.c: uart_periph.h moved from soc/ to hal/, and
  uart_isr_handle_t (a typedef of intr_handle_t) is gone.
- CMakeLists.txt: CMake 3.16, since the CMake 4 that ESP-IDF 6 ships
  warns that 3.5 is deprecated; configure stops on an ESP-IDF older
  than 6.
- sdkconfig: regenerated by idf.py reconfigure from the 5.3.1 file.
  Values present in both versions are carried unless ESP-IDF 6 forces
  them. Options that are new in ESP-IDF 6 take its defaults, and some
  of those change behaviour: picolibc replaces newlib, FreeRTOS and
  ring-buffer functions other than the ISR ones run from flash instead
  of IRAM, WPA3-compatible mode is compiled in (SAE H2E stays compiled
  in, as in 5.3.1), and esp_netif_receive() now always returns errors
  to the WiFi driver. The toolchain goes from GCC 13.2 to 15.2. A
  second reconfigure and a build leave sdkconfig unchanged.
- rpc_dispatch.h: V1.7, the next minor after master's 1.6. The open
  GET_RANDOM change (GideonZ#953) also wants a minor; whichever of the two
  lands second adapts its number and history line.
- CI builds raw_u64 next to u64ctrl in the espressif/idf:v6.0.3
  image, pinned by digest, and raw_c3 in my_docker_image as before.
- README.txt, raw_u64/README.md and u64ctrl/README.md say which
  ESP-IDF each module needs and how to build it.

Co-Authored-By: Claude Opus 5.5 (1M context) <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". It makes PSA safe with more
than one PSA user: the WiFi supplicant (ESP_WIFI_MBEDTLS_CRYPTO, on
in this project) imports and destroys PSA keys now, and a TLS engine
would be another. The pthread implementation comes with it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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 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 (about 10.6 KB more IRAM; 31,197 B of 131,072
stay free).

Measured on a U64E over WiFi, one leg per image (the same suite and
commands in each): with these two options the writemem latency (p50, p90,
p99 = 35.8, 82.5, 155.8 ms) is back in the range of the IDF 5.3.1 image
(34.0-35.7, 75.6-85.0, 135.7-158.5 ms); without them it was 40.8, 102.2,
202.7 ms. The REST probe only moves part of the way back (p50 91.3 ms
against 75.6-76.7 on 5.3.1 and 96.7 without), and the FTP get is not
restored.

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

Same IDF 6 fixes as raw_u64: uart_periph.h moved to hal/, uart_isr_handle_t
is gone, CMake 3.16 and an IDF >= 6 check, the receive hook frees the pbuf
and returns ERR_OK when no UART buffer is free, and MBEDTLS_THREADING_C on.
sdkconfig is regenerated by idf.py reconfigure. The version is bumped to
1.7 only to label the image: the U2+L updater does not compare it. Built
only: no U2+L hardware, never flashed or run.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The WiFi task runs on core 0. esp_intr_alloc() binds an interrupt to the core it is called on, so my_uart_init() now runs from a short task pinned to core 1, which keeps the UART ISR off the core (and cache) the WiFi driver is using. The ISR, the UART buffer code, hacked_recv() and dispatch() move to IRAM with a linker fragment (noflash). The ISR is allocated with flags 0 and is not an IRAM-safe interrupt: it must not run while the flash cache is off, and the buffer code it calls is in IRAM anyway. The dispatch task is pinned to core 1 at priority 19 so it runs where the ISR feeds it. Also checks the init semaphore and the task create.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
With raw_c3 on ESP-IDF 6, none of the ESP32 modules needs ESP-IDF 5.3.1
any more, so CI builds all of them with one `make esp32` in the pinned
espressif/idf:v6.0.3 image instead of one module in my_docker_image and
two beside it. The ESP32 cache key no longer names my_docker_image's
image id, since that image does not build them now.

README.txt and the three module READMEs lose the notes that said the
modules need different ESP-IDF versions and that `make` could not
complete with one IDF_PATH. They now say all three need ESP-IDF 6 and
that docker/Dockerfile still installs 5.3.1. raw_c3 gets a Building
section like the other two.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Trigger the RX FIFO interrupt at 64 bytes instead of 120 and the TX empty interrupt at 64 instead of 10, so the receive ISR has more FIFO left to absorb a delayed service. The RTS flow threshold (122) is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <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 (10,606 B more DRAM, 165,180 B of 321,296 stay free; flash code drops by 10,748 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; raw_c3 is only built, not run on hardware.
The change is the same two sdkconfig lines.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Put more of the WiFi driver hot path into IRAM, so frames are not delayed by flash cache misses.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Move the UART ISR, the UART buffer code, hacked_recv(), dispatch() and cmd_send_eth_packet() to IRAM with a linker fragment (noflash). Placement only: the chip has one core, so no task is pinned and no priority changes. The ISR flags stay 0, so the interrupt is masked while the flash cache is off (NVS writes) and nothing in the handler has to be safe to run then; the overflow branch calls the flash function uart_hal_rxfifo_rst(), but RXFIFO_OVF is not in the enable mask, so it does not run.

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 3 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>
…(base update for GideonZ#1029)

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 #996 into this branch (8501e58). #996 now contains #1028 and 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 the other two. make host_tests and make host_tests_idf6 pass, and raw_c3 still builds in the pinned ESP-IDF 6.0.3 image. It is still untested on a real U2+L.

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
…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 16 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>
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>
…branch

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>
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>
The 1.13 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 U2+L WiFi module firmware (raw_c3) with ESP-IDF 6.0.3 (build only, not hardware-tested) Build the U2+L WiFi module firmware (raw_c3) with ESP-IDF 6.1.1 (build only, not hardware-tested) Nov 17, 2026
@chrisgleissner chrisgleissner added the build Build and CI infrastructure label Nov 20, 2026
JC-000 and others added 3 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>
Brings in master 40188c7 through the merged pr/2-idf6-r4 branch (the PR
below this one in the stack, merge/996-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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants