Fault Injection & Debugging
Brownout reset and power-rail cycling tests in CI
Verify firmware waits for regulator power-good pins and re-initializes peripherals cleanly after a power-rail drop.
Battery-powered PCBs switch peripheral 3.3 V rails off via load switches or PMIC enable pins to save microamps. If firmware talks to an I2C sensor before its rail ramps up, the bus latches or returns garbage.
CircuitTwin models regulator ramp delays, power-good outputs and MCU-switched device supplies (crates/ct-behavior/src/kinds/parts.rs), letting CI inject rail drops and assert clean recovery.
Power-rail behaviors tested
| Behavior | Model element | Bug caught |
|---|---|---|
Rail ramp delay | start_delay_ns + ramp_ns + power_good_pin | Firmware accesses sensor before rail stabilizes |
Switched sensor rail | Supply attachment on MCU GPIO | Forgetting to re-init sensor registers after power cycle |
Supervisor reset hold | Undervoltage delay + reset timeout | Boot race against external flash wake time |
Local CLI workflow
Shell - run power-cycle fault suite
ct test run --json --junit results/power-rail.xml tests/power-cycle.suite.yamlSuite & fault configuration
tests/power-cycle.suite.yaml
version: 1
board: nucleo-l476rg
firmware: build/lowpower_app.elf
tests:
- name: sensor-rail-power-cycle-reinit
timeout_ms: 3000
expect:
console_contains: "SENSOR_REINIT_AFTER_PWR_OK"
exit_code: 0CI pipeline integration
.github/workflows/power-rail-ci.yml
name: Power-Rail Sequencing CI
on: [push, pull_request]
jobs:
power:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: circuittwin/action@v1
with:
suite: tests/power-cycle.suite.yamlTroubleshooting checklist
| Symptom | Fix |
|---|---|
| Sensor returns reset defaults after sleep wake | Re-run full sensor configuration registers after re-enabling the switched supply pin. |
| I2C pins back-power unpowered sensor | Set SDA/SCL to analog or low-output before cutting the sensor supply rail. |
Frequently asked questions
| Question | Answer |
|---|---|
| Does CircuitTwin model regulator startup sequencing and power-good pins? | Yes. The pin-logic engine models multi-rail regulators with enable pins, ramp delays, chained after_rail dependencies and open-drain power-good outputs. |