Files
mckero 542515d5ad Finish the portability sweep: one firmware resolver, no author paths
The probe scripts, run.sh, trace_run.sh, webui.py and two emulator tests each named the same hardcoded firmware from a source tree that is not in this repository. They now resolve QEMU and the firmware the way tools/uvk5_testenv.py does -- environment, then PATH, then whatever the checkout has -- and skip with a reason when there is nothing.

webui.py's --qemu and --elf lost their author defaults too: a bare qemu-system-arm through PATH, and no firmware until one is uploaded, which the page already reports.
2026-10-01 15:15:31 +08:00

59 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Watch the firmware's own keypad scan while a key is held.
#
# Breaks inside KEYBOARD_Poll right after read_rows(), and prints the column
# index being scanned together with the row bits actually sampled. This
# distinguishes "the scan never runs" from "the scan runs but the rows never
# go low".
set -uo pipefail
# shellcheck source=tools/uvk5_elf.sh
. "$(dirname "$0")/uvk5_elf.sh"
ELF=$(uvk5_find_elf) || { echo "SKIP no firmware found; set ELF or put one in assets/firmware" >&2; exit 0; }
KEY="${1:-MENU}"
HITS="${2:-12}"
python3 - "$KEY" <<'PY'
import json, socket, sys
key = sys.argv[1]
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
s.connect("/tmp/uvk5-qmp.sock")
buf = b""
def rd():
global buf
while b"\n" not in buf:
buf += s.recv(4096)
line, buf = buf.split(b"\n", 1)
return json.loads(line)
rd()
for p in ({"execute": "qmp_capabilities"},
{"execute": "qom-set", "arguments": {"path": "/machine/keypad",
"property": "press", "value": key}}):
s.sendall(json.dumps(p).encode() + b"\n")
while True:
m = rd()
if "return" in m or "error" in m:
break
print(f"holding {key}")
PY
SCRIPT=$(mktemp --suffix=.gdb)
trap 'rm -f "$SCRIPT"' EXIT
{
echo "set confirm off"
echo "set pagination off"
echo "target remote :1234"
echo "break keyboard.c:231"
echo "commands"
echo "silent"
echo "printf \"col j=%u reg2=%#06x odr=%#06x\\n\", j, reg2, *(unsigned int *)0x50000414"
echo "continue"
echo "end"
for _ in $(seq "$HITS"); do echo "continue"; done
echo "detach"
echo "quit"
} >"$SCRIPT"
timeout 120 gdb-multiarch -batch -x "$SCRIPT" "$ELF" 2>&1 | grep -E "col j=|Breakpoint|No symbol|Function"