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

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

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

## Troubleshooting 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. |

## Related boards & component twins

[Board: nucleo-l476rg](https://circuittwin.ai/boards/nucleo-l476rg) [Board: nrf52840-dk](https://circuittwin.ai/boards/nrf52840-dk) [Board: b-u585i-iot02a](https://circuittwin.ai/boards/b-u585i-iot02a) [Twin: BQ27441-G1](https://circuittwin.ai/twins/bq27441-g1) [Twin: MAX17048](https://circuittwin.ai/twins/max17048) [Twin: TLF35584](https://circuittwin.ai/twins/tlf35584) [Twin: BME280](https://circuittwin.ai/twins/bme280) [Stimuli & power-rail inputs](https://circuittwin.ai/docs/inputs)

## More in Fault Injection & Debugging

[I2C NACK and stuck-bus fault injection in CI](https://circuittwin.ai/guides/i2c-nack-fault-injection) [SPI bus fault testing and chip-select verification](https://circuittwin.ai/guides/spi-bus-fault-testing) [Debugging UART baud mismatches and framing errors](https://circuittwin.ai/guides/uart-baud-mismatch-debugging) [Cortex-M HardFault triage in CI and reverse GDB](https://circuittwin.ai/guides/cortex-m-hardfault-ci-triage)

> ## Run this workflow on your own ELF
>
> Start free on CircuitTwin to run local board twins, fault matrices and CI checks with zero per-run credits.
>
> [Start now](https://app.circuittwin.ai/try) [Read the quickstart](https://circuittwin.ai/docs/quickstart) [Connect a coding agent](https://circuittwin.ai/docs/agents)
