#!/bin/sh # B10B-5 board side: arm ONE TEST OVP FAULT injection ("ovp") or "none" and log fast: 1 s x 12, then 5 s x 10 (≈ 62 s). Reads only, except the single hook write. # usage: b10b4-act.sh TAG "susp 1"|"vdd 0"|"ibat 0"|none -> /tmp/b4-TAG.log T=$1; CMD=$2; L=/tmp/b5-$T.log; R=/sys/kernel/debug/regmap/0-00/registers; D=/sys/bus/iio/devices/iio:device0; H=/sys/kernel/debug/pm8916_lbc/b10b5_fault grep -q " /sys/kernel/debug " /proc/mounts || mount -t debugfs debugfs /sys/kernel/debug rd() { dd if=$R bs=9 skip=$(($1)) count=1 2>/dev/null | cut -d' ' -f2; } s() { echo "S $1 up=$(cut -d' ' -f1 /proc/uptime) vbat=$(cat $D/in_voltage6_input) vph=$(cat $D/in_voltage7_input) usbin=$(cat $D/in_voltage0_input) pmt=$(cat $D/in_temp8_input) chgst=$(rd 0x1009) crt=$(rd 0x1010) urt=$(rd 0x1310) path=$(rd 0x1308) susp=$(rd 0x1347) vdd=$(rd 0x1040) ibat=$(rd 0x1044) ctrl=$(rd 0x1049) failed=$(rd 0x104a) st=$(head -1 /sys/kernel/debug/pm8916_lbc/state | cut -d' ' -f2)" >> $L; } trap '' HUP echo "BEGIN $T cmd='$CMD' $(date -u +%T)" >> $L s pre; s pre if [ "$CMD" != none ]; then echo "$CMD" > $H; echo "WRITE rc=$? '$CMD' up=$(cut -d' ' -f1 /proc/uptime)" >> $L; sleep 1; dmesg | grep -E "FAULT safe clamp|B10B-5 TEST|-> FAULT" | tail -3 >> $L; fi i=0; while [ $i -lt 12 ]; do s "+${i}s"; sleep 1; i=$((i+1)); done i=0; while [ $i -lt 22 ]; do sleep 5; s "+$((12+5*i+5))s"; i=$((i+1)); done echo "END $T $(date -u +%T)" >> $L