Add fault injection for chips and rails

This commit is contained in:
Baptiste MOINE committed 2026-10-31 17:30:05 +01:00
1 parent 927e2ecb20
commit 4177e98dfb
11 files changed
+431 -16

No files matched your search

+63
View File
@@ -21,6 +21,7 @@ expect() {
echo "ccplex test (emulator exit $status):"
expect 'cannot run: CPU rail off' 'an unpowered release is refused, with the reason'
expect 'ram repair: done' 'a powered RAM repair completes'
expect 'unpowered: CPU0 stayed dark' 'and the core really did not execute'
expect 'CPU0 released: AArch64 EL3, MMU off, entry 0xA0000000' 'a powered release boots CPU0 at the SB vector'
expect 'clock stopped: CPU0 held still' 'a core released with its clock stopped does not run'
@@ -56,4 +57,66 @@ else
fail=1
fi
# ---- fault injection ------------------------------------------------------
#
# The same payload against broken hardware. Pinned to Erista, which is what
# the payload's bring-up drives (MAX77621 + MAX77620 GPIO5), so the result
# does not depend on whatever rcm_emu.ini happens to say.
expect_not() {
if grep -q -- "$1" "$FLOG"; then
echo " FAIL $2 (present: $1)"
fail=1
else
echo " ok $2"
fi
}
fexpect() {
if grep -q -- "$1" "$FLOG"; then
echo " ok $2"
else
echo " FAIL $2 (missing: $1)"
fail=1
fi
}
run_fault() {
FLOG=tests/ccplex/out_fault_$1.log
SDL_VIDEODRIVER=dummy RCM_EMU_NO_AUDIO=1 timeout 120 "$EMU" "$PAYLOAD" \
--oem erista --fault "$1" > "$FLOG" 2>&1
fstatus=$?
echo "ccplex test, --fault $1 (emulator exit $fstatus):"
if [ "$fstatus" -ne 0 ]; then
echo " FAIL the emulator exited with status $fstatus (124 = timed out)"
fail=1
fi
}
# A rail whose buck answers and takes its enable, but delivers nothing. Over
# I2C the console looks healthy; only what the rail feeds notices.
run_fault vdd_cpu
fexpect '\[fault\] vdd_cpu (rail)' 'the fault is announced before the run'
fexpect 'RAM repair requested with no CPU rail (fault: vdd_cpu)' 'the RAM repair is held, and says why'
fexpect 'ram repair: never completed' 'so STS never sets (bdk would spin here forever)'
fexpect 'cannot run: CPU rail has no output (fault: vdd_cpu' 'the release is refused, naming the fault'
expect_not 'CPU0 released: AArch64' 'and the core never executes'
fexpect 'powered: magic=00000000' 'the payload sees no mailbox write'
expect_not 'I2C5 0x1B NAK' 'the buck itself still answers on I2C'
fexpect 'MAX77620 PWR_OFF received' 'the payload still runs to its power-off'
# A dead buck: NAKs, takes no writes, and the rail goes with it - even though
# its register file was seeded with VOUT_EN set.
run_fault max77621_cpu
fexpect 'I2C5 0x1B NAK: max77621_cpu is dead' 'the dead chip NAKs its address'
fexpect 'ram repair: never completed' 'its rail is dead with it'
fexpect 'cannot run: CPU rail has no output (fault: max77621_cpu dead)' 'the release is refused, naming the chip'
expect_not 'CPU0 released: AArch64' 'and the core never executes'
fexpect 'MAX77620 PWR_OFF received' 'the main PMIC, not faulted, still powers off'
# A fault on the other generation's chip must change nothing here: Erista
# has no MAX77812 to break.
run_fault max77812
fexpect 'ram repair: done' 'an Erista ignores a dead MAX77812'
fexpect 'CPU0 released: AArch64 EL3, MMU off, entry 0xA0000000' 'and CPU0 boots as normal'
expect_not 'NAK: max77812 is dead' 'a chip this board does not have is not reported dead'
[ $fail -eq 0 ] && echo "ccplex test: PASS" || { echo "ccplex test: FAIL - see $LOG"; exit 1; }