Repository navigation
Conversation
- Build the wolfIP nxp_mcxe_enet port without the MCUXpresso SDK, in interrupt mode, with ENET IRQs 73-75 routed to the driver handler. - IMAGE_HEADER_SIZE=1024 in mcxe247.config: the 179-entry vector table needs 1 KB alignment for VTOR, otherwise the ENET IRQs vector to the wrong handler. - Place the wolfIP state in SRAM_L and use 9 KB TCP buffers per socket. - Speed test: TCP and UDP server on port 9 with rx, tx and bidirectional modes, and a per-test CPU breakdown from the driver cycle counters. Host side: tools/scripts/wolfip_speed.py. - Drop the SDK paths from the TRACE32 debug script and the docs.
- Ctrl-C on the console stops the throughput server - UDP datagrams carry a session id chosen by the host for each test. The board ignores data of a finished test, so datagrams still queued on the way cannot start a new test, and the host ignores board datagrams of an earlier test. - wolfip_speed.py sends UDP at 100 Mbit/s on the wire by default instead of as fast as the host can, and warns when --rate 0 is used.
-ffreestanding disables the compiler builtins, so every small fixed-size memcpy in wolfIP (one per 16-bit word in the transport checksum, header field accessors) became a call to the byte-wise memcpy in src/string.c. That was most of the stack's CPU time. Building the wolfIP sources hosted lets the compiler inline them. Measured with tools/scripts/wolfip_speed.py at 48 MHz, Mbit/s: TCP rx 4.3 -> 6.9, TCP tx 4.1 -> 6.3, UDP rx 5.5 -> 9.1, UDP tx 5.4 -> 9.0.
wolfIP is CPU bound on the MCXE247. -O2 on the wolfIP objects is 10-18% faster than -Os for 12KB more flash (80 MHz, code cache on): tcp-rx 24.1 -> 27.0, tcp-tx 22.0 -> 25.9, udp-tx 38.2 -> 41.8 Mbit/s. With the faster stack the driver keeps up with a line-rate UDP flood, and wolfIP_poll() took up to 128 frames per call into a socket that holds six datagrams, so udp-rx fell to 7.6 Mbit/s. Limiting the budget to 8 frames lets the speed server drain the socket between batches: udp-rx 36.9 -> 45.1 Mbit/s. WOLFIP_POLL_BUDGET needs the wolfIP change that makes it overridable.
The receiver thread gave up the GIL on every recvfrom() and then waited for the pacer's busy-wait loop to release it, so the host dropped most of what the board sent (55-92% loss). Bidir now drains the socket between sends in one thread and collects the board's last datagrams afterwards. UDP bidir board tx as received by the host: 8.4 -> 21.5 Mbit/s, 0% loss.
With ENABLE_WOLFIP=1 the network command now runs the TCP and UDP throughput server (WOLFIP_SPEED_TEST=1); the TFTP fetch is opt-in with WOLFBOOT_TEST_TFTP=1. Update the config comments and docs/Targets.md.
memcpy (already in SRAM_U as RAM code) and wolfIP's csum_add() were the hottest code. In SRAM_U the core fetches code over the system bus, which the copies' own data accesses also use; SRAM_L is fetched over the code bus in parallel. A .ramcode_l section in ARM-s32k1xx-wolfip.ld takes string.o's .ramcode and wolfip.o's .text.csum_add ahead of the .text rule, loads after .edidx in flash, and is copied at reset (APP_RAMCODE_L in startup_arm.c). .keystore is now placed in flash explicitly; the new layout had made it an orphan in SRAM_L. 332 bytes of SRAM_L. 80 MHz, code cache on: tcp-rx 29.2 -> 33.8, tcp-tx 28.7 -> 33.1, udp-rx 56.0 -> 66.6, udp-tx 49.6 -> 60.4, udp-bidir 23.6+26.5 -> 28.9+32.5 Mbit/s. TFTP test and a flash write from the test-app pass.
s32k1xx_clock_hsrun() enters HSRUN on the FIRC, then runs the core from the SPLL at 112 MHz (bus 56 MHz, flash 28 MHz), as the SDK's BOARD_BootClockHSRUN does. s32k1xx_clock_run() returns to RUN at 80 MHz. The SOSC and SPLL setup is split into helpers that the 80 MHz path now shares. With S32K1XX_HSRUN_SPEED_TEST the test-app's network command runs the speed server in HSRUN and switches back when it stops, so flash writes from the console still work. mcxe247.config sets it. The SMC register offsets were the Kinetis layout. On the S32K1xx and MCXE247 VERID and PARAM come first: PMPROT is at 0x08, PMCTRL at 0x0C and PMSTAT at 0x14. Before, the HSRUN enable went to a read-only register, so S32K1XX_CLOCK_HSRUN could never enter HSRUN either. 112 MHz vs 80 MHz: tcp-rx 33.8 -> 45.7, tcp-tx 33.1 -> 43.7, udp-rx 66.6 -> 95.6 (line rate), udp-tx 60.4 -> 75.8, udp-bidir 28.9+32.5 -> 38.0+42.8 Mbit/s. After the server stops, a flash write (success) works and HSRUN can be entered again.
At -Os GCC compiled the unaligned-source word loop with both pointers recomputed from the byte count on every pass: 15 instructions per 16 bytes. Step word pointers instead and store through an aligned type, since the destination is aligned by then: 11 instructions per 16 bytes. Results match a byte copy for every length up to 300 and all source/destination offsets 0-7 (host test, ASan/UBSan). MCXE247 wolfIP speed test at 112 MHz: udp-tx 75.8 -> 77.5 Mbit/s, wolfIP cycles per frame down 2-4% for tcp-rx, udp-tx and udp-bidir.
Board server: - Refuse a TCP client while a UDP test runs. Its speed_start() cleared the shared state and silently ended the UDP test. - A TCP client that sends no direction byte within 500 ms gets a bidir test. A plain "nc <ip> 9" that only reads never got any data. - End a UDP bidir test when the board's stream ends, as tx already did. It stayed open until the host's 'q', about 1 s later, so the window held an idle tail: an 8 s test was timed as 9 s and the board rx rate read about 11% low (udp-bidir rx 38.9 -> 43.8 Mbit/s at 112 MHz, same loss). wolfip_speed.py: - An error in a TCP worker thread (reset, sendall() timeout) now fails the test instead of reporting partial counts. The socket is closed in a finally block, and the receiver waits with select() so it no longer changes the timeout the sender's sendall() uses. - Send 'q' before every test, TCP too, so a UDP test left running cannot make the board refuse the TCP client.
There was a problem hiding this comment.
🟡 Changes recommended
Unchecked XMODEM header sizes and packet bounds can allow flash writes beyond the update partition’s usable capacity, corrupting reserved trailer sectors, the swap sector, or later flash.
4 open issues
What changed in this PR
Adds bare-metal wolfBoot support for the FRDM-MCXE31B board, including firmware update testing and optional wolfIP networking. It builds on the MCXE247 networking and throughput work from #991.
Changes:
- Adds the MCXE31B HAL, memory layouts, configuration, and console test application.
- Integrates optional EMAC networking with shared throughput tests and memory-copy optimizations.
- Adds target documentation, TRACE32 programming scripts, and a CI build job.
| File | Description |
|---|---|
tools/scripts/wolfip_speed.py |
Adds host-side TCP/UDP throughput and statistics reporting. |
tools/scripts/mcxe31b/e31b_flash_update.cmm |
Programs update images with trailer-capacity checks. |
tools/scripts/mcxe31b/e31b_flash_factory_bin.cmm |
Programs factory images with IVT and size checks. |
tools/scripts/mcxe31b/e31b_debug.cmm |
Adds board connection and symbol-loading support. |
tools/scripts/mcxe247/e247_debug.cmm |
Removes obsolete SDK source-path setup. |
test-app/wolfip_tftp_test.h |
Shares application timebase and cancellation interfaces. |
test-app/wolfip_tftp_test.c |
Adds EMAC support and TCP/UDP throughput testing. |
test-app/startup_arm.c |
Adds interrupt routing, ECC initialization, and code relocation. |
test-app/Makefile |
Integrates MCXE31B and optional wolfIP build settings. |
test-app/ARM-s32k1xx-wolfip.ld |
Places network state and hot code in SRAM_L. |
test-app/ARM-mcxe31b.ld |
Defines the standard application memory layout. |
test-app/ARM-mcxe31b-wolfip.ld |
Separates network code, state, and DMA buffers across memory regions. |
test-app/app_s32k1xx.c |
Adds network cancellation and clock-mode handling. |
test-app/app_mcxe31b.c |
Adds the console, XMODEM updates, LEDs, and network command. |
src/string.c |
Optimizes ARM copies with unaligned source addresses. |
hal/s32k1xx.h |
Adds clock/cache interfaces and corrects SMC offsets. |
hal/s32k1xx.c |
Implements clock transitions and flash-cache maintenance. |
hal/mcxe31b.ld |
Defines bootloader IVT, flash, and DTCM placement. |
hal/mcxe31b.h |
Defines MCXE31B registers and board connections. |
hal/mcxe31b.c |
Implements clocks, caches, UART, and flash operations. |
docs/Targets.md |
Documents board setup, networking, programming, and update testing. |
config/examples/mcxe31b.config |
Adds target defaults and optional network settings. |
config/examples/mcxe247.config |
Updates clock, alignment, and network-test defaults. |
arch.mk |
Selects Cortex-M7 and the MCXE31B flash origin. |
.github/workflows/test-configs.yml |
Adds the MCXE31B configuration build job. |
Review effort: Balanced
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #1001
Scan targets checked: wolfboot-src, wolfboot-bugs
Not reviewed (no scan target covers them): .github/workflows/test-configs.yml, arch.mk, config/examples/mcxe247.config, config/examples/mcxe31b.config, docs/Targets.md, hal/mcxe31b.h, hal/mcxe31b.ld, hal/s32k1xx.h, test-app/ARM-mcxe31b-wolfip.ld, test-app/ARM-mcxe31b.ld, test-app/ARM-s32k1xx-wolfip.ld, test-app/Makefile, test-app/wolfip_tftp_test.h, tools/scripts/mcxe247/e247_debug.cmm, tools/scripts/mcxe31b/e31b_debug.cmm, tools/scripts/mcxe31b/e31b_flash_factory_bin.cmm, tools/scripts/mcxe31b/e31b_flash_update.cmm, tools/scripts/wolfip_speed.py
Coverage: 7 of 7 in-scope changed file(s) opened by the reviewer
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
Review tier: Max
5d14e48 to
9d192c7
Compare


Add NXP MCX E31B target (FRDM-MCXE31B), with optional wolfIP network test
Tested on FRDM-MCXE31B
Note: goes with wolfSSL/wolfip#201