Fault Injection & Debugging
SPI NOR Flash and EEPROM torn-write testing in CI
Catch 64-byte EEPROM page wraps, missing WREN latches and unrecovered LittleFS mounts before bricking customer units.
Two storage bugs dominate field RMAs: writing across an EEPROM 64-byte page boundary (wrapping silently to byte 0 of the same page) and losing power mid-sector erase on SPI NOR flash.
CircuitTwin models W25Q128JV sector-erase/page-program rules (bits only clear 1 to 0 until erased) and AT24C256C/24LC256 page boundaries, letting CI test torn writes deterministically.
Non-volatile memory bugs caught
| Memory | Hardware rule modelled | Firmware bug caught |
|---|---|---|
W25Q128JV / W25Q64JV | 0->1 requires 4 KB sector erase; WREN resets after write | Overwriting config bytes without erasing sector first |
AT24C256C / 24LC256 | 64-byte page buffer wrap + 5 ms write busy NACK | Multi-byte write spanning 0x003E..0x0044 corrupts 0x0000 |
FM24CL64B | Zero write delay F-RAM | Verify fast crash-log persistence without busy polling |
Local CLI workflow
Shell - run Flash and EEPROM fault tests
ct test run --json --junit results/storage.xml tests/flash-eeprom.suite.yamlSuite & fault configuration
tests/flash-eeprom.suite.yaml
version: 1
board: nrf52840-dk
firmware: build/littlefs_app.elf
tests:
- name: w25q128-mount-write-and-disconnect
timeout_ms: 3000
faults:
- at_ms: 400
part: w25q128jv
kind: bus_disconnect
duration_ms: 30
expect:
console_contains: "LFS_RECOVERY_OK"
exit_code: 0CI pipeline integration
.github/workflows/storage-ci.yml
name: Flash & EEPROM Storage CI
on: [push, pull_request]
jobs:
storage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: circuittwin/action@v1
with:
suite: tests/flash-eeprom.suite.yamlTroubleshooting checklist
| Symptom | Fix |
|---|---|
| W25Q128JV page program writes nothing | Send WREN (0x06) immediately before every Page Program (0x02) or Sector Erase (0x20) command. |
| EEPROM bytes 0..3 get overwritten during struct save | Split writes at 64-byte page boundaries and poll for ACK between pages. |
Frequently asked questions
| Question | Answer |
|---|---|
| Does CircuitTwin enforce NOR Flash bit-clearing rules (1 to 0 only)? | Yes. Programming a W25Q NOR Flash page only clears bits from 1 to 0; returning a bit to 1 requires a 4 KB sector or 64 KB block erase. |