Repository navigation
feat(freertos-s32z2): bring up lwIP over NETC Ethernet in poll mode - #23
Merged
Merged
Conversation
3 tasks
youtalk
force-pushed
the
feat/freertos-s32z2-boot
branch
from
June 1, 2026 18:44
b017bf8 to
9e0777f
Compare
youtalk
force-pushed
the
feat/freertos-s32z2-net
branch
from
June 1, 2026 18:44
cced82a to
2ef0c7f
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds the FreeRTOS S32Z2 networking backend by bringing up lwIP over the NXP NETC Ethernet controller in poll mode, wiring the platform dispatch to the new backend, and introducing a patched NETC↔lwIP port to avoid core-lock deadlocks and RX ring stalls.
Changes:
- Add S32Z2-specific lwIP configuration headers and a NETC/lwIP bring-up implementation.
- Add an EthIf/OsIf shim to bridge AUTOSAR-style driver callbacks into the lwIP port and provide missing OS hooks.
- Introduce a vendor-patched
eth_port.cintended to fix poll-mode RX/TX lifecycle issues and make linkoutput non-blocking.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 24 comments.
Show a summary per file
| File | Description |
|---|---|
| actuation_module/include/platform/platform_network.h | Routes PLATFORM_FREERTOS_S32Z2 to the new S32Z2 FreeRTOS networking backend. |
| actuation_module/include/platform/freertos/s32z2/lwipopts.h | Adds lwIP configuration tuned for S32Z2 + CycloneDDS usage. |
| actuation_module/include/platform/freertos/s32z2/lwipcfg.h | Provides a minimal stub required by NXP lwIP glue headers. |
| actuation_module/include/platform/freertos/s32z2/lwip_init.h | Declares the S32Z2 lwIP bring-up entry point. |
| actuation_module/include/platform/freertos/s32z2/freertos_network.h | Implements configure_network() for the S32Z2 FreeRTOS target. |
| actuation_module/freertos_s32z2/vendor_patched/eth_port.c | Adds a patched NETC↔lwIP integration layer (poll-mode focus). |
| actuation_module/freertos_s32z2/lwip_bringup.c | Initializes NETC + lwIP and configures the network interface. |
| actuation_module/freertos_s32z2/ethif_shim.c | Bridges EthIf callbacks to the lwIP port and supplies missing OS hooks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
youtalk
force-pushed
the
feat/freertos-s32z2-boot
branch
from
June 1, 2026 20:43
9e0777f to
03ff0a6
Compare
youtalk
force-pushed
the
feat/freertos-s32z2-net
branch
from
June 1, 2026 20:43
2ef0c7f to
e4508ea
Compare
youtalk
marked this pull request as ready for review
June 1, 2026 20:58
Add the lwIP + NETC networking path for the S32Z2 port: - lwip_bringup.c initialises the NETC switch and Ethernet controller, brings up the interface with a deterministic static IP that matches the DDS bind, and enables the ETH0 RX RGMII clock (MC_CGM_1 MUX_7, sourced from the PHY-driven external RXC) which the default clock config left disabled, so the MAC RX state machine had no clock and received nothing while TX worked. - vendor_patched/eth_port.c runs NETC RX/TX completion in poll mode (STD_OFF); the upstream poll path was never exercised and is fixed here: seed the RX ring in STD_OFF, recycle freed RX pbufs via pbuf->if_idx/rx_buf (the ring otherwise stalled after ETH_RXBD_NUM frames), balance the pbuf_coalesce ref count on TX (a double-free that spun lwIP's assert), and make the netif linkoutput non-blocking (bounded retry + sys_mbox_trypost_fromisr, never sleeping under LOCK_TCPIP_CORE) — a blocking linkoutput deadlocked tcpip_thread and froze both RX and TX once the TX ring filled. - ethif_shim.c bridges the AUTOSAR EthIf RxIndication/TxConfirmation callbacks to eth_port.c and supplies OsIf_TimeDelay for the poll thread. - lwipopts.h sizes the netconn / UDP-PCB / mailbox pools for CycloneDDS's five sockets per participant and the tcpip mailbox. - platform_network.h dispatches the PLATFORM_FREERTOS_S32Z2 branch to the new freertos_network.h (lwIP-backed configure_network()). Stacked on the boot PR. Signed-off-by: Yutaka Kondo <yutaka.kondo@youtalk.jp>
- Rename the freertos_network.h include guard to PLATFORM__FREERTOS__S32Z2__* so it no longer collides with the POSIX simulator's freertos_network.h, and match the closing #endif comment. - Correct the network bring-up comments: the path configures a static IP and blocks only on tcpip_init; it does not request DHCP or wait for a lease (freertos_network.h, lwip_init.h, lwipopts.h). Disable LWIP_DHCP accordingly (unused with static IP). - lwip_bringup.c: delete the one-shot tcpip_done semaphore after init completes (was leaked), and check ip4addr_aton() return values so an invalid LWIP_STATIC_* override fails loudly instead of silently configuring 0.0.0.0. Signed-off-by: Yutaka Kondo <yutaka.kondo@youtalk.jp>
Address PR review (eth_port.c:12): the vendored NXP lwIP NETC glue carried the NXP Confidential and Proprietary header and must not live in this public repo. Replace it with vendor_patched/eth_port.c.patch (our poll-mode datapath fixes: RX-ring seeding, pbuf recycling, balanced pbuf_coalesce ref, non-blocking linkoutput); the build copies the pristine NXP eth_port.c from $LWIP_PATH and applies this patch at configure time. Signed-off-by: Yutaka Kondo <yutaka.kondo@youtalk.jp>
youtalk
force-pushed
the
feat/freertos-s32z2-net
branch
from
June 1, 2026 21:03
e4508ea to
f9467e4
Compare
youtalk
force-pushed
the
feat/freertos-s32z2-boot
branch
from
June 1, 2026 21:03
03ff0a6 to
3078bb2
Compare
oguzkaganozt
reviewed
Jun 5, 2026
oguzkaganozt
reviewed
Jun 5, 2026
oguzkaganozt
reviewed
Jun 5, 2026
main() ignored configure_network()'s return value, so the firmware could construct the DDS/controller stack and report "Live" even after lwIP/NETC failed to come up. Every platform's configure_network() returns 0 on success and nonzero on failure, so check it and std::exit(1) on failure, matching the file's existing error-handling idiom. Addresses PR #23 review (oguzkaganozt). Signed-off-by: Yutaka Kondo <yutaka.kondo@youtalk.jp>
tcpip_init_done() received &tcpip_done, the address of lwip_bring_up_blocking()'s local handle. On the 5 s timeout path the function returns and its stack frame dies while the tcpip thread may still run the callback and dereference that dead address. Pass the SemaphoreHandle_t value directly (it is a pointer typedef) so the callback never touches our stack. Addresses PR #23 review (oguzkaganozt). Signed-off-by: Yutaka Kondo <yutaka.kondo@youtalk.jp>
…gnostically
eth_port.c.patch carried mixed CRLF/LF endings and trailing whitespace,
which `git diff --check` flagged extensively and made review and apply
fragile. Normalize it to pure LF with no trailing whitespace.
GNU patch refuses to apply across a CRLF/LF mismatch ("different line
endings") and the NXP vendor sources are CRLF, so s32z2_apply_vendor_patch()
now strips CRs from both the copied source and the patch before applying --
robust to either ending (port.c.patch, still CRLF, is unaffected). A
unified-diff context line for tab-indented vendor code intrinsically begins
"<space><tab>", which `git diff --check` reports as space-before-tab; a
scoped .gitattributes exempts the committed patches from whitespace checks.
Verified: both vendor patches apply (rc=0) with byte-identical output and
`git diff --check` is clean.
Addresses PR #23 review (oguzkaganozt).
Signed-off-by: Yutaka Kondo <yutaka.kondo@youtalk.jp>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part 3 of the S32Z2 FreeRTOS stack (on top of #22). Adds the lwIP + NETC
networking path, run in poll mode (no RX IRQ, avoiding the R52 lazy-FPU
ISR wall):
lwip_bringup.c— initialises the NETC switch + Ethernet controller, bringsthe interface up with a deterministic static IP matching the DDS bind, and
enables the ETH0 RX RGMII clock (MC_CGM_1 MUX_7, PHY-driven external RXC)
that the default clock config left disabled — so the MAC RX state machine had
no clock and received nothing while TX worked.
vendor_patched/eth_port.c— fixes the upstream poll (STD_OFF) path: seed theRX ring in STD_OFF; recycle freed RX pbufs via
pbuf->if_idx/rx_buf(the ringotherwise stalled after
ETH_RXBD_NUMframes); balance thepbuf_coalescerefcount on TX (a double-free that spun lwIP's assert); and make the netif
linkoutput non-blocking (bounded retry +
sys_mbox_trypost_fromisr, neversleeping under
LOCK_TCPIP_CORE).ethif_shim.c— bridges the AUTOSAR EthIf RxIndication/TxConfirmationcallbacks and supplies
OsIf_TimeDelayfor the poll thread.lwipopts.h— sizes the netconn / UDP-PCB / mailbox pools for CycloneDDS.platform_network.h— dispatchesPLATFORM_FREERTOS_S32Z2to the newfreertos_network.h.The non-blocking linkoutput is the key fix: a blocking linkoutput under the TCP/IP
core lock deadlocked
tcpip_threadand froze both RX and TX once the TX ringfilled (the long-standing "one discovery burst then DDS-silent" symptom).
Evidence — RX and TX both flow on hardware (gdb datapath probe)
After the fix, RX delivery (
rxind0) and TX confirmations (txconf0) both climb,the TCP/IP core lock is free, and the INPKT pool drains:
(The temporary gdb-only datapath counters used to capture this are stripped from
the committed
eth_port.c.)Stack
#21 → #22 → this PR → DDS round-trip. No CI files touched.