Fault Injection & Debugging
Ethernet link-down and packet-loss testing in CI
Test cable unplug, PHY auto-negotiation flaps and burst packet loss on compiled networking firmware without a switch.
Embedded lwIP and socket stacks frequently leak pbufs or stall RX DMA rings when an Ethernet cable unplugs mid-transfer. Bench testing requires physically pulling RJ45 cables.
CircuitTwin injects link_down and packet_loss faults on RMII PHYs (LAN8720A) and SPI controllers (W5500) so CI proves DHCP renew and socket reconnect succeed every time.
Ethernet fault scenarios
| Fault kind | Target interface | Regression caught |
|---|---|---|
link_down | MDIO BSR bit 2 / W5500 PHYCFGR | Stuck netif_is_link_up() or unclosed dead TCP sockets |
packet_loss | Ethernet MAC RX ring | TX retry exhaustion or pbuf pool exhaustion |
crc_error | Corrupted FCS frame | MAC accepts bad frame when checksum offload is misconfigured |
Local CLI workflow
Shell - run Ethernet link-down recovery suite
ct test run --json --junit results/eth-link.xml tests/eth-linkfault.suite.yamlSuite & fault configuration
tests/eth-linkfault.suite.yaml
version: 1
board: nucleo-f767zi
firmware: build/lwip_app.elf
tests:
- name: rmii-link-drop-and-reconnect
timeout_ms: 4000
faults:
- at_ms: 500
part: lan8720a
kind: link_down
duration_ms: 800
expect:
console_contains: "ETH_RECONNECTED"
exit_code: 0CI pipeline integration
.github/workflows/eth-fault-ci.yml
name: Ethernet Link Fault CI
on: [push, pull_request]
jobs:
eth:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: circuittwin/action@v1
with:
suite: tests/eth-linkfault.suite.yamlTroubleshooting checklist
| Symptom | Fix |
|---|---|
| STM32H7 ETH DMA descriptors return garbage | Place ETH RX/TX descriptors in D2 SRAM (0x30040000) with non-cacheable MPU attributes. |
| W5500 socket stays in SOCK_ESTABLISHED after disconnect | Enable TCP keepalive (Sn_KPALVTR) and check PHYCFGR link bit periodically. |
Frequently asked questions
| Question | Answer |
|---|---|
| Can CircuitTwin test Ethernet link-down faults on both RMII MACs and W5500 SPI chips? | Yes. Inject link_down faults against MDIO PHYs like LAN8720A or SPI controllers like W5500 inside suite.yaml. |