Files
makronix/mobile/tools/lib.sh
T
lotherkandClaude Opus 5.5 b9c0affdb8 mobile: hotdogb stable state: msm built in, display warnings fixed, self-flashing, serial console
Kernel (7.0.0-sm8150-g1299aab93171):
- msm DRM built in again: up at 0.6-0.8 s instead of 4.2 s, safe since
  0003 and 0004.
- 0005: CLK_OPS_PARENT_ENABLE on the pixel RCGs (as sdm845): "rcg didn't
  update its configuration" is gone.
- 0006: dsi_err_worker reported every error as status=4, a FIFO error
  that was none (lane FIFOs empty) and hid the ACK error (bit 0); it now
  reads status=40 ack_err=..., the panel's report on the first read after
  the takeover.
- ftrace (dynamic, function_graph), Landlock.

Without a button: the DTB gets the PON's mode-bootloader/mode-recovery
(fdtput on the pinned binary until the DTS moves in; new pin), Void gets
reboot-mode(1) and a runit stage-3 hook that restarts with the mode
(base/reboot2.c, built static by mkrootimg.sh).  flash.sh and
flash-root.sh reboot a running phone into fastboot themselves and wait for
ABL without ever cutting a command off or resetting the device -- two
usbresets after the userdata flash crashed it into 05c6:900e.  Writing the
fallback slot no longer makes it active.

Access: dnsmasq (DHCP only) on usb0, so the host keeps 172.16.42.2 after
the initramfs; an ACM function next to NCM with the kernel console and a
login on ttyGS0; phone_addr falls back to IPv6 link-local;
tools/reboot-loop.sh for boot races.  zram swap (half the RAM, zstd).

Measured: 20 of 20 warm reboots reachable; the self-flash
(build/logs/selfflash3-2026-11-08.log).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 09:52:05 +00:00

109 lines
3.6 KiB
Bash

#!/bin/sh
#
# Shared by the tools: load a device's configuration.
#
# . "$(dirname "$0")/lib.sh"
# load_device devices/hotdogb
#
# The device's SOC (set in its device.conf) names soc/<SOC>/soc.conf, which is
# read first; the device.conf is read second and overrides it. Afterwards:
#
# DEVDIR the device directory
# DTB, CMDLINE, KERNEL_CONFIG ... made absolute
# everything else as set in the two files
#
# Adding a phone is adding devices/<codename>/ (docs/PORTING.md); no tool
# changes.
ROOT=$(cd "$(dirname "$0")/.." && pwd)
load_device() {
DEVDIR=$(cd "$1" && pwd) || { echo "no such device dir: $1" >&2; exit 2; }
[ -f "$DEVDIR/device.conf" ] || { echo "$DEVDIR: no device.conf" >&2; exit 2; }
SOC=$(sed -n 's/^SOC=//p' "$DEVDIR/device.conf" | head -n 1)
[ -n "$SOC" ] || { echo "$DEVDIR/device.conf: SOC not set" >&2; exit 2; }
[ -f "$ROOT/soc/$SOC/soc.conf" ] || { echo "no soc/$SOC/soc.conf" >&2; exit 2; }
. "$ROOT/soc/$SOC/soc.conf"
. "$DEVDIR/device.conf"
for _v in DTB CMDLINE KERNEL_CONFIG; do
eval "_p=\${$_v:-}"
[ -z "$_p" ] || eval "$_v=\$DEVDIR/\$_p"
done
}
die() {
echo "$0: $*" >&2
exit 1
}
# The running phone over the USB network. phone_addr prints the address
# where ssh answers: PHONE_IP (172.16.42.1) if it does, else the IPv6
# link-local neighbour on the host's cdc_ncm interface -- the host loses its
# IPv4 when it misses the phone's DHCP (docs/BOOT.md) -- or nothing.
# phone_ssh ADDR CMD runs CMD as root (PHONE_PASS, default makronix).
phone_ssh() {
sshpass -p "${PHONE_PASS:-makronix}" ssh -o ConnectTimeout=3 \
-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
-o LogLevel=error "root@$1" "$2"
}
phone_addr() {
command -v sshpass >/dev/null || die "needs sshpass"
if phone_ssh "${PHONE_IP:-172.16.42.1}" true 2>/dev/null; then
echo "${PHONE_IP:-172.16.42.1}"
return 0
fi
for _d in /sys/class/net/*; do
[ "$(basename "$(readlink -f "$_d/device/driver" 2>/dev/null)")" = cdc_ncm ] ||
continue
_i=${_d##*/}
_own=$(ip -6 -o addr show dev "$_i" scope link 2>/dev/null |
awk '{sub("/.*", "", $4); print $4}')
for _a in $(ping -6 -c 2 -W 2 "ff02::1%$_i" 2>/dev/null |
awk '/bytes from/ {sub("%.*", "", $4); print $4}' | sort -u); do
[ "$_a" = "$_own" ] && continue
if phone_ssh "$_a%$_i" true 2>/dev/null; then
echo "$_a%$_i"
return 0
fi
done
done
return 1
}
# fastboot_ready: a phone in fastboot that answers, or die. When none is
# there but the phone runs Linux, reboot it into fastboot (reboot-mode
# bootloader, which needs the PON's mode-bootloader in the DT); otherwise
# wait, the phone may be between two USB identities. Gives up after 120 s
# without a fastboot device. Never resets the device (fastboot_answers).
fastboot_answers() {
[ -n "$(fastboot devices)" ] || return 1
# Wait long and never cut a command off: after a large flash (userdata)
# ABL stays busy for more than 15 s and does not answer; a host that
# gives up and resets the device then (usbreset) crashes it into the
# Qualcomm crash-dump mode, 05c6:900e (measured 2026-11-08: two resets
# 30 s apart, then error -71 and the phone dark).
timeout 120 fastboot getvar product >/dev/null 2>&1
}
fastboot_ready() {
_t=0 _asked=
while [ "$_t" -lt 120 ]; do
if [ -n "$(fastboot devices)" ]; then
fastboot_answers && return 0
die "the phone is in fastboot but does not answer"
fi
if [ -z "$_asked" ] && _a=$(phone_addr); then
echo "$0: rebooting the phone at $_a into fastboot" >&2
phone_ssh "$_a" "reboot-mode bootloader" >/dev/null 2>&1 || true
_asked=1
fi
sleep 2
_t=$((_t + 2))
done
die "no phone in fastboot within 120 s"
}