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

33 lines
1.2 KiB
Bash

#!/usr/bin/env bash
# Where the firmware is, for the ad-hoc probe scripts.
#
# Every one of them used to name the same hardcoded path -- one developer's CW build --
# so none of them ran on a machine that did not have that file. The order here matches
# tools/uvk5_testenv.py, so the scripts and the tests agree about what is available.
#
# ELF, UVK5_FIRMWARE, UVK5_MULTIBOOT_IMAGE the environment wins
# assets/firmware/*, work/* then whatever the checkout has
#
# Returns non-zero when there is nothing, so a caller can skip with a reason rather
# than run against a path that does not exist.
uvk5_find_elf() {
local var value
for var in ELF UVK5_FIRMWARE UVK5_MULTIBOOT_IMAGE; do
eval "value=\${$var:-}"
if [ -n "$value" ] && [ -e "$value" ]; then
printf '%s' "$value"
return 0
fi
done
local root cand
root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
for cand in "$root"/assets/firmware/*.elf "$root"/assets/firmware/*.bin \
"$root"/work/*.elf "$root"/work/*.bin; do
if [ -e "$cand" ]; then
printf '%s' "$cand"
return 0
fi
done
return 1
}