b23: S10 + table poke + S9 baked

This commit is contained in:
SashegDev
2026-09-13 10:37:18 +00:00
parent 9c45d06ed2
commit 95b98054b3
4 changed files with 122 additions and 6 deletions
+74
View File
@@ -800,6 +800,80 @@ def main():
save(d, 'img0_b22.elf')
# b23 = b22 + S10 (rollback sideways-exit fix):
# 0x8016720 pop{r4,pc} has no matching push; it exits sideways to
# helper-mid (0x8005BBA) instead of sbl_main (0x802f6a3), closing a
# ping-pong cycle (S9->rollback->query->helper->assert->labyrinth).
# Route to S10 (0x08006C88, scaffold): movw/movt ip + bx ip to
# 0x802f6a3. Eats the following NOP (movs r0,r0).
d = bytearray(base)
for va, (a, b) in BLX2BL.items():
set4(d, va, b)
for va, exp, new in [
(0x802F664, 'e4f77efc', 'c046c046'),
(0x802F672, 'e6f7bbfa', 'c046c046'),
(0x802F678, 'e9f7fef9', 'c046c046'),
(0x801B71E, '9847fee7', 'c046c046'),
(0x8008396, 'fef780f9', 'c046c046'),
(0x8016184, 'fdf790fc', 'c046c046'),
(0x801B76C, '280b0508', '00000708'),
(0x8017AFC, 'bde8fc87', 'eef74fb8'),
(0x802F690, '9847fee7', 'c046c046'),
(0x801671C, '9847fee7', 'c046c046'),
(0x8013BAC, 'f8bd0a4a', 'f3f730b8'),
(0x801B6BE, 'bde8f081', 'ebf7c3ba'),
(0x8016720, '10bd0000', 'f0f7b2ba'),
]:
assert hx(d, va) == exp, (hex(va), hx(d, va))
set4(d, va, new)
# Full bl idiom at 0x8006682 (bl + pop, 6B) -> NOPs (see b18).
o = off(0x8006682)
assert d[o:o + 6].hex() == '00f001f807bd', hx(d, 0x8006682, 6)
d[o:o + 6] = bytes.fromhex('c046c046c046')
o = off(0x8013AA8)
assert d[o:o + 4].hex() == '07f026be', hx(d, 0x8013AA8)
d[o:o + 4] = bytes.fromhex('c046c046')
o = off(0x8013BA6)
assert d[o:o + 2].hex() == 'b888', (hex(0x8013BA6), hx(d, 0x8013BA6, 2))
d[o:o + 2] = bytes.fromhex('ff20')
# Logger S8 (see b21).
o = off(0x8034810)
assert d[o:o + 4].hex() == 'bde8fc87', hx(d, 0x8034810)
d[o:o + 2] = bytes.fromhex('7047')
save(d, 'img0_b23.elf')
+7 -1
View File
@@ -325,6 +325,12 @@ def main():
"059b0bb1bde8f081002040f20004c0f2220440f20005c0f2"
"220540f2000ac0f6060a41f2000bc0f6060b4ff60073c0f6"
"5f039d464ff29d6cc0f6020c6047"))
# S10 stublet (10B @0x08006C88, b23): rollback-exit router.
# movw/movt ip + bx ip to sbl_main 0x802f6a3.
mu.mem_write(0x08006C88, bytes.fromhex("4ff2a36cc0f6020c6047"))
# PBL version-table fabrication (b23): [0x080528D0] = STUBV so the
# rollback query's blx calls maze (returns 0 = versions OK).
W32(0x080528D0, STUBV)
# stack zone fill (STUBV odd)
mu.mem_write(0x085F0000, struct.pack("<I", STUBV) * (0x10000 // 4))
# pop-site slots (sp values from traces)
@@ -361,7 +367,7 @@ def main():
# --- end parity ---
# stub range is readonly on HW/QEMU: ignore SBL heap-clobber writes,
# keep maze/stublets intact (restore-on-write with reentrancy guard)
STUB_LO, STUB_HI = 0x080068C0, 0x08006C90 # +S7/S9 + banner tail
STUB_LO, STUB_HI = 0x080068C0, 0x08006CA0 # +S7/S9/S10 + banner
stub_snap = bytes(mu.mem_read(STUB_LO, STUB_HI - STUB_LO))
_inww = [False]
_swn = [0]