b25: S12v2-full + B66-ELF + S16 baked

This commit is contained in:
SashegDev
2026-09-13 12:01:19 +00:00
parent 15eeba929d
commit c875e8712f
4 changed files with 197 additions and 17 deletions
+89
View File
@@ -955,6 +955,95 @@ def main():
save(d, 'img0_b24.elf')
# b25 = b24 + helper-pop S16 chain (0x8007B66 pop{r4,pc} -> bx ip):
# the pop reads scratch ([sp+4] = counters 0..4, frames marched by
# null-cycles) instead of pushed lr. bx ip uses ip preset by S12
# (ARM stub at 0x8006964) to S16 (0x08006CC0, scaffold): restore r7
# (peripheral base) and jump to poll-loop resumption 0x8007779.
# 2B patch, no eating (bx ip = 0x47c0 fits the pop slot).
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')
# Clock S11 (see b24).
o = off(0x800E988)
assert d[o:o + 2].hex() == '10bd', hx(d, 0x800E988, 2)
d[o:o + 2] = bytes.fromhex('7047')
# Helper-pop S16 chain: pop{r4,pc} (2B 10bd) -> bx ip (2B 4760;
# ip preset by S12 to S16). 0x47c0 would be bx lr (wrong reg!).
o = off(0x8007B66)
assert d[o:o + 2].hex() == '10bd', hx(d, 0x8007B66, 2)
d[o:o + 2] = bytes.fromhex('6047')
save(d, 'img0_b25.elf')