uzbek-plus/b11/run/b11-btn-watch.sh

14 lines
908 B
Bash

#!/bin/sh
# B11 read-only button watcher: polls TLMM GPIO37/107 (debugfs) and PM8916 PON RT 0x0810 every ~0.1 s, logs changes. NO writes.
T=${1:-b1}; DUR=${2:-90}; LOG=/tmp/b11-btn-$T.log; D=/sys/kernel/debug
exec >$LOG 2>&1
up() { cut -d' ' -f1 /proc/uptime; }
st() { g=$(grep -E "^ gpio(37|107) " $D/gpio | awk '{print $1"="$4}' | tr '\n' ' ')
p=$(dd if=$D/regmap/0-00/registers bs=9 skip=$((0x810)) count=1 2>/dev/null | cut -d' ' -f2)
echo "$g pon_rt=$p"; }
E0=$(cat /proc/interrupts | grep -i pwrkey | awk '{print $2}')
echo "B11BTN $T $(up) START dur=$DUR"; last=""
end=$(( $(cut -d. -f1 /proc/uptime) + DUR ))
while [ $(cut -d. -f1 /proc/uptime) -lt $end ]; do s=$(st); [ "$s" != "$last" ] && echo "B11BTN $T $(up) $s"; last=$s; usleep 100000; done
echo "B11BTN $T $(up) pwrkey-irq before=$E0 after=$(cat /proc/interrupts | grep -i pwrkey | awk '{print $2}')"
echo "B11BTN $T $(up) END"