uzbek-plus/b7/b7c/cache/B7C-write.sh
q 8d7721c775 B7: add network time bootstrap and persistent B7C cache
B7A: QMI DMS time vs VNIIFTRI NTP (DMS = UTC - 0.28 s, sigma 1 ms; NITZ = DMS
truncated to 1 s). B7B: a 1970 -> 2026 date -s step is harmless for the modem
stack. B7C: aurora-modem probes DMS/NITZ along the start flow and steps
CLOCK_REALTIME once at the first valid sample (REG registered/attached), never
RTC; background SNTP check (query only) after START OK. 3/3 class-A cold boots
PASS (residual +0.04/+0.36/+0.84 s), cache 14fe453a written (B7C_WRITE_VERIFIED)
and verified by a normal power-on (V1, +0.26 s).

Also publishes the prerequisite R2 (boot-hang / lk eMMC investigation, T4
telnet baseline that B7C builds on) and R3 (autonomous cold boot, NCM loss)
material, and extends tools/publish-sanitize.py to r2/, r3/, b7/.
Binary images, initramfs, busybox and raw logs stay out (see b7/*/SHA256SUMS).
2026-10-02 20:18:25 +03:00

48 lines
3.6 KiB
Bash

#!/bin/bash
# B7C — the ONLY write: cache := ext2 extlinux -> B7C candidate (T4 + time bootstrap: aurora-modem 932c9ff2, build-epoch, busybox ntpd). Run on 480s ONLY after explicit GO.
# Derived from r2/t4/T4-write.sh (T4 write, CACHE_MATCH + T4_WRITE_VERIFIED 2026-10-02); only image, expected hashes and log dir changed.
# Entry: HW EDL (battery on, D+->GND, plug USB, release). Never `edl reset`. Stops at first failed gate.
cd ~/doc/modem/jz08-aurora || exit 1
L=firehose/007050e100000000_394a2e47cf830150_fhprg_peek.bin
O=logs/b7/b7c/W ; A3=logs/b5a/A3 ; P=logs/b5a/A4pre ; mkdir -p $O
NEW=b7/b7c/cache/cache-extlinux-b7c.img ; NEW_SHA=14fe453af6e94d414044c1c6da9eebe5c325fad842ddc5e17d09ba6b421a74cb
OLD_SHA=9d3bc8900ab4b4ec26cfb16d2a0e83a8b3f8f4b74793e842bccfd366263368b7 # current cache = T4 extlinux
BOOT_SHA=e9579f33c7304cd47f487f2b61cd9226dc04fd3a63775d62b4b95fc15bd3ebff
ABOOT_SHA=3b8cd2667837fc7083cb28991d849f9b408a07fa743bfd05eafee7b053760f85
die(){ echo "STOP: $*"; exit 1; }
sha(){ sha256sum "$1" | cut -d" " -f1; }
E(){ edl --loader=$L "$@"; }
echo "== G0 inputs"
[ "$(sha $L)" = 53f193500c03248f0d671ab57bfe9ca8a42967e97f28403294b4b3f854075aca ] || die loader
[ "$(sha $NEW)" = $NEW_SHA ] && [ $(stat -c %s $NEW) = 134217728 ] || die candidate
[ "$(sha r2/t4/cache-extlinux-t4.img)" = $OLD_SHA ] || die rollback-image
[ "$(sha logs/r2/t4/W/11-cache-readback.bin)" = $OLD_SHA ] || die t4-readback-backup
lsusb | grep -q 05c6:9008 || die "no 9008"
echo "== G1 identity + geometry + baseline"
E printgpt > $O/00-printgpt.log 2>&1 || die printgpt
grep -aq "Serial: *0x<SAHARA_SERIAL>" $O/00-printgpt.log || grep -aq "Mode detected: firehose" $O/00-printgpt.log || die serial
grep -a "^cache:" $O/00-printgpt.log | grep -q "Offset 0x000000004118c000, Length 0x0000000008000000" || die cache-geometry
E rs 0 34 $O/pre-gptp.bin >/dev/null 2>&1; cmp $O/pre-gptp.bin $A3/gpt-primary-34.bin || die gpt-changed
E r boot $O/pre-boot.bin >/dev/null 2>&1; [ "$(sha $O/pre-boot.bin)" = $BOOT_SHA ] || die boot-not-emmc1
E r aboot $O/pre-aboot.bin >/dev/null 2>&1; [ "$(sha $O/pre-aboot.bin)" = $ABOOT_SHA ] || die aboot-not-autoboot
E r cache $O/pre-cache.bin >/dev/null 2>&1; [ "$(sha $O/pre-cache.bin)" = $OLD_SHA ] || die cache-not-backup
echo "== W cache := candidate (LBA 2133088, 262144 sectors)"
E w cache $NEW > $O/10-cache-write.log 2>&1; echo "rc=$?"; grep -a "Wrote" $O/10-cache-write.log
E r cache $O/11-cache-readback.bin > $O/11-cache-readback.log 2>&1 || die readback-rc
sha256sum $NEW $O/11-cache-readback.bin
cmp $NEW $O/11-cache-readback.bin || die "CACHE READBACK MISMATCH — do NOT reboot; run b7/b7c/cache/B7C-rollback.sh"
echo CACHE_MATCH
echo "== V everything else unchanged"
E rs 0 34 $O/post-gptp.bin >/dev/null 2>&1; cmp $O/post-gptp.bin $A3/gpt-primary-34.bin || die gptp
E rs 7634911 33 $O/post-gptb.bin >/dev/null 2>&1; cmp $O/post-gptb.bin $A3/gpt-backup-33.bin || die gptb
E rs 305184 1024 $O/post-tzbak.bin >/dev/null 2>&1; cmp $O/post-tzbak.bin $A3/tzbak-305184.bin || die tzbak
E r boot $O/post-boot.bin >/dev/null 2>&1; [ "$(sha $O/post-boot.bin)" = $BOOT_SHA ] || die boot
E r aboot $O/post-aboot.bin >/dev/null 2>&1; [ "$(sha $O/post-aboot.bin)" = $ABOOT_SHA ] || die aboot
for p in sbl1 rpm tz hyp recovery modemst1 modemst2 fsg fsc persist; do
E r $p $O/post-$p.bin >/dev/null 2>&1; cmp $O/post-$p.bin $A3/$p.bin || die "$p changed"; echo "$p == A3"
done
for p in modem system userdata; do
E r $p $O/post-$p.bin >/dev/null 2>&1; cmp $O/post-$p.bin $P/$p.bin || die "$p changed"; echo "$p == A4pre"; rm -f $O/post-$p.bin
done
(cd $O && sha256sum *.bin > SHA256SUMS)
echo "B7C_WRITE_VERIFIED — power off fully (USB, then battery) before first boot"