Repository navigation
mcxe31b emac - #201
mcxe31b emac#201twcook86 wants to merge 14 commits into
Conversation
|
There was a problem hiding this comment.
🟡 Changes recommended
Oversized packet-socket frames can permanently block TX queues, and descriptor-ring tails at the DTCM boundary can be programmed with untranslated DMA addresses.
2 open issues
What changed in this PR
Adds an SDK-independent EMAC port for NXP MCX E31B, with documented E327/E32B Cortex-M7_0 support, for wolfIP’s wolfBoot test-app integration. The branch builds on the MCXE247 ENET work in #196.
Changes:
- Adds EMAC initialization, DMA descriptor rings, polling or receive interrupts, and optional statistics.
- Documents board wiring, clock setup, DTCM placement, and configuration options.
- Includes the stacked ENET driver changes, configurable polling budget, and shared checksum optimizations.
| File | Description |
|---|---|
src/wolfip.c |
Makes the polling budget configurable and consolidates checksum calculations. |
src/port/nxp_mcxe_enet/README.md |
Documents standalone ENET operation and memory requirements. |
src/port/nxp_mcxe_enet/nxp_mcxe_enet.h |
Adds interrupt, eDMA, statistics, and configuration APIs. |
src/port/nxp_mcxe_enet/nxp_mcxe_enet.c |
Replaces SDK calls with direct ENET, PHY, and eDMA control. |
src/port/nxp_mcxe_enet/nxp_mcxe_enet_regs.h |
Defines registers for the standalone ENET driver. |
src/port/nxp_mcxe_enet/config.h |
Allows socket-buffer size overrides. |
src/port/nxp_mcxe_emac/README.md |
Documents supported hardware, integration, and tuning. |
src/port/nxp_mcxe_emac/nxp_mcxe_emac.h |
Defines the EMAC public API and build options. |
src/port/nxp_mcxe_emac/nxp_mcxe_emac.c |
Implements EMAC initialization, DMA transfers, interrupts, and statistics. |
src/port/nxp_mcxe_emac/nxp_mcxe_emac_regs.h |
Defines EMAC and platform-control registers. |
src/port/nxp_mcxe_emac/config.h |
Supplies networking defaults for the new port. |
Review effort: Balanced
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #201
Scan targets checked: wolfip-src, wolfip-bugs
Not reviewed (no scan target covers them): src/port/nxp_mcxe_emac/README.md, src/port/nxp_mcxe_enet/README.md
Coverage: 6 of 9 in-scope changed file(s) opened by the reviewer; not opened: src/port/nxp_mcxe_emac/config.h, src/port/nxp_mcxe_enet/config.h, src/port/nxp_mcxe_enet/nxp_mcxe_enet.h
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Max
3b16b9e to
19f2ebf
Compare
19f2ebf to
25adfec
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #201
Scan targets checked: wolfip-src, wolfip-bugs
Not reviewed (no scan target covers them): src/port/nxp_mcxe_emac/README.md, src/port/nxp_mcxe_enet/README.md, src/test/unit/unit.c, src/test/unit/unit_tests_proto.c
Coverage: 2 of 8 in-scope changed file(s) opened by the reviewer; not opened: src/port/nxp_mcxe_emac/config.h, src/port/nxp_mcxe_emac/nxp_mcxe_emac.c, src/port/nxp_mcxe_enet/config.h, src/port/nxp_mcxe_enet/nxp_mcxe_enet.h, src/port/nxp_mcxe_enet/nxp_mcxe_enet_board.h, src/port/nxp_mcxe_enet/nxp_mcxe_enet_regs.h
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: Lite
There was a problem hiding this comment.
🟡 Changes recommended
A full TX ring can cause a 5 ms busy-wait per send inside wolfIP_poll(), delaying receive processing, timers, and other interfaces instead of immediately returning -WOLFIP_EAGAIN as required.
1 open issue
2 resolved since last review
Review effort: Balanced
9e7ffb0 to
b77cdd4
Compare
- nxp_mcxe_emac_stop() disables the interrupts, the MAC and its DMA, so a caller can stop it before a clock change; init uses it to stop a running MAC first. - Remove tx_wait_cycles from the stats: send() never waited, and the nxp_mcxe_enet_stats layout it mirrored no longer has it.
- Reset and restart the MAC and DMA after a fatal bus error, including one raised while the restart runs; the restart is kept out of line so poll() and send() stay small. After a failed re-init or restart, poll() and send() drop traffic until init succeeds. - After an MDIO timeout, later transfers fail at once until re-init. - Read the core and CSR clocks live for timeouts, the MDIO divider and the stats; us_to_cycles() scales milliseconds and the remainder separately so long delays do not overflow. - Keep the PHY address once the LAN8741 is identified. - Document the init return codes and blocking time, that only a LAN8741 is supported, link changes, bus error restarts, and the 1518-byte (VLAN-tagged) frame limit. - CI: Cortex-M7 compile of the driver and wolfIP core (polled, IRQ with stats, IRQ without OSF), checking the interrupt handler symbol and that both include the port's config.h. Tested on the FRDM-MCXE31B: speed test unchanged.
-I. came first, so wolfip.c included the top-level config.h instead of src/port/nxp_mcxe_enet/config.h. Put the port directory first, as the wolfBoot test-app does, and check that wolfip.c and the driver both include the port's config.h.
- grep -q exits at the first match, which can end nm with SIGPIPE and, with pipefail, fail the check for a handler that is there. Use grep -c, which reads all of its input. - nxp_mcxe_enet: drop the stale TX timeout reference in send().
- Set DEMCR.TRCENA before the DWT unlock: the DWT ignores writes, the unlock too, until it is set, and the cycle counter then never starts. - init() stops the interface before its argument and cache checks, so a call that fails with -1 or -5 also leaves it stopped, as documented. - Stop the build when the descriptor counts are not 2 to 1024 or the DMA burst length is not 1, 2, 4, 8, 16 or 32. Tested on the FRDM-MCXE31B: speed test unchanged.
Replace the driver's copy of the clause-22 register map and of the PHY reset and auto-negotiation start with nxp_phy.h and nxp_phy_init(), through MDIO accessors as in nxp_mcxe_enet. The LAN8741 ID check and the special control/status register stay in the driver. Its reset and auto-negotiation waits are bounded to about 1 s each, so init() without link now blocks for up to about 7 s. Tested on the FRDM-MCXE31B: link up, DHCP, speed test unchanged, and a second init.
eth_poll() copied each frame from the buffer address in the receive descriptor. Copy from the driver's rx_buf[] for that descriptor instead, and check the length against the buffer size; the descriptor snapshot no longer reads the buffer field.
A completely full transmit ring moves the tail pointer onto the oldest pending descriptor, which the DMA reads as an empty ring, and transmit stalls. eth_send now refuses a frame when the next descriptor is still owned. README: the timestamp clock stays at /2 at both link speeds.
b77cdd4 to
bd44a49
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #201
Scan targets checked: wolfip-src, wolfip-bugs
Not reviewed (no scan target covers them): .github/workflows/mcxe247.yml, .github/workflows/mcxe31b.yml, src/port/nxp_mcxe_emac/README.md
Coverage: 2 of 3 in-scope changed file(s) opened by the reviewer; not opened: src/port/nxp_mcxe_emac/nxp_mcxe_emac.h
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Lite
Fenrir's latest completed scan found no issues; clearing the prior automated change request.
- emac_reset(): say why MAC_Configuration is written between setting SWR and waiting for it, as the NXP SDK does in RMII mode - The rx_errors stat also counts frames too long for the wolfIP buffer


nxp_mcxe_emac: standalone EMAC driver for NXP MCX E31B (also E327/E32B)
Note: Goes with wolfBoot PR #1001
Tested on the FRDM-MCXE31B with the wolfBoot test-app:
TCP 88-90 Mbit/s receive and 86 Mbit/s send
UDP 95.7 Mbit/s each way