48 lines
3.8 KiB
Bash
Executable file
48 lines
3.8 KiB
Bash
Executable file
#!/bin/bash
|
|
# B9L-PERSIST — the ONLY write: aboot := lk1st autoboot + B9L ST7735S panel/splash (lk2nd 23.1 + b9l patch, AURORA_SPI_PANEL=1 AURORA_SPLASH=1).
|
|
# Run on 480s ONLY after an explicit GO for the write. Derived from b5a/A4-write.sh + b9/b9c/cache/B9C-write.sh (gates/verify). Only aboot is written;
|
|
# boot (emmc1 e9579f33), cache (B9C b9ce13c9) and everything else are checked before and after. The live aboot (must be 3b8cd266) is read back first = backup.
|
|
# Entry: HW EDL (battery on, D+ -> GND, plug USB, release). Never `edl reset`. Stops at the first failed gate.
|
|
cd ~/doc/modem/jz08-aurora || exit 1
|
|
L=firehose/007050e100000000_394a2e47cf830150_fhprg_peek.bin
|
|
O=logs/b9/b9l/W ; A3=logs/b5a/A3 ; P=logs/b5a/A4pre ; mkdir -p $O
|
|
NEW=b9/b9l/persist/aboot-lk1st-b9l.pad1M ; NEW_SHA=15208dbb4feafccd72d2b06db5714cd746c216701f0ef8822c58bb47105d37c4
|
|
OLD=b5a/aboot-lk1st-aurora-autoboot.pad1M ; OLD_SHA=3b8cd2667837fc7083cb28991d849f9b408a07fa743bfd05eafee7b053760f85 # current aboot (B5a)
|
|
BOOT_SHA=e9579f33c7304cd47f487f2b61cd9226dc04fd3a63775d62b4b95fc15bd3ebff
|
|
CACHE_SHA=b9ce13c9f48e36a5054c0ae3c39dc3f184b1fc2eea1d57d4b8bd8e9ae800a37b
|
|
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) = 1048576 ] || die candidate
|
|
[ "$(sha $OLD)" = $OLD_SHA ] && [ $(stat -c %s $OLD) = 1048576 ] || die rollback-image
|
|
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 "^aboot:" $O/00-printgpt.log | grep -q "Offset 0x0000000008100000, Length 0x0000000000100000" || die aboot-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 cache $O/pre-cache.bin >/dev/null 2>&1; [ "$(sha $O/pre-cache.bin)" = $CACHE_SHA ] || die cache-not-b9c
|
|
E r aboot $O/pre-aboot.bin >/dev/null 2>&1; [ "$(sha $O/pre-aboot.bin)" = $OLD_SHA ] || die aboot-not-3b8cd266
|
|
echo "== W aboot := lk1st-b9l (LBA 264192, 2048 sectors)"
|
|
E w aboot $NEW > $O/10-aboot-write.log 2>&1; echo "rc=$?"; grep -a "Wrote" $O/10-aboot-write.log
|
|
E r aboot $O/11-aboot-readback.bin > $O/11-aboot-readback.log 2>&1 || die readback-rc
|
|
sha256sum $NEW $O/11-aboot-readback.bin
|
|
cmp $NEW $O/11-aboot-readback.bin || die "ABOOT READBACK MISMATCH — do NOT reboot; run b9/b9l/persist/B9L-rollback.sh"
|
|
echo ABOOT_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 cache $O/post-cache.bin >/dev/null 2>&1; [ "$(sha $O/post-cache.bin)" = $CACHE_SHA ] || die cache
|
|
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 "B9L_ABOOT_WRITE_VERIFIED — power off fully (USB, then battery) before the first boot"
|