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 kindTarget interfaceRegression caught
link_downMDIO BSR bit 2 / W5500 PHYCFGRStuck netif_is_link_up() or unclosed dead TCP sockets
packet_lossEthernet MAC RX ringTX retry exhaustion or pbuf pool exhaustion
crc_errorCorrupted FCS frameMAC 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.yaml

Suite & 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: 0

CI 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.yaml

Troubleshooting checklist

SymptomFix
STM32H7 ETH DMA descriptors return garbagePlace ETH RX/TX descriptors in D2 SRAM (0x30040000) with non-cacheable MPU attributes.
W5500 socket stays in SOCK_ESTABLISHED after disconnectEnable TCP keepalive (Sn_KPALVTR) and check PHYCFGR link bit periodically.

Frequently asked questions

QuestionAnswer
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.

Related boards & component twins

More in Fault Injection & Debugging