SDK docs menu

Guides

Fault injection

A power-path part with protection, such as a load switch, current limiter, eFuse or a regulator with a fault or power-good pin, can be faulted on purpose. The rest of the board follows: the rail drops, voltage dividers on it read 0, and a current-sense amplifier reads what flows. Your test then checks that the firmware notices and recovers.

Find a part's faults

Faults are ordinary controls, shown under the part's Fault injection heading on the website. Their names come from the part's panel, so list them first:

print(board.U7)
# U7 — Load switch, simulated
#   do   U7.shutdown
#   do   U7.short-at-the-current-limit
#   do   U7.short-hiccup
#   do   U7.clear-fault
#   read U7.vout, U7.load-current, U7.fault, U7.fault-injected

A part without a fault-injected reading takes no faults. See Parts for naming parts by reference designator.

Test the firmware's response

Here U7 feeds a sensor rail that the firmware watches:

def test_sensor_rail_short_is_reported(hardlabs_board):
    board = hardlabs_board
    board.wait_for("app ready")

    board.do("U7.short-at-the-current-limit")      # a short on the rail U7 feeds
    assert board.read("U7.fault-injected")
    board.wait_for("sensor rail fault", within=1)  # your firmware's own message

    board.do("U7.clear-fault")                     # the rail comes back
    assert not board.read("U7.fault-injected")
    board.wait_for("sensor rail ok", within=2)

Board.do injects and clears the fault, Board.read confirms it, and the waits count simulated time.

What each fault does

A part offers the modes its datasheet describes:

  • Shutdown. The part turns its output off as its own protection would, and asserts its fault or power-good pin. The rail falls to 0 V and the parts on it lose their supply.
  • Short at the current limit. The part keeps conducting at its current limit into a short on the rail. The rail sits near 0 V, and a sense resistor on the rail carries the limit, so a current-sense amplifier reads it.
  • Hiccup. The part cycles: current limit, off, on again. Where the datasheet gives no cycle times, the part's settings hold them and its model scope marks them as assumed.
  • Clear. The part goes back to normal and the loads draw again.