1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
"""Wait for the ROM_SW window, then clear the $AMDVBFL marker at 0x7000.
ROM_SW is only ungated while the PSP has not booted. On a real main-power cycle
there is a window before the PSP gates it. This polls continuously and writes
sector 7 the instant the engine answers.
Plan:
1. start this script
2. toggle the PSU off/on
3. it catches the window and writes sector 7 from spiflash.bin (marker = zeros)
Sector 7 of spiflash.bin is byte-identical to current flash EXCEPT the 8-byte
$AMDVBFL marker, so this changes exactly those 8 bytes.
Abort with Ctrl-C. Writes nothing unless the engine is actually reachable.
"""
import subprocess, sys, time
IMAGE = "psp_out/spiflash.bin"
SECTOR = 7
TIMEOUT = float(sys.argv[1]) if len(sys.argv) > 1 else 600.0
def try_flash():
p = subprocess.run([sys.executable, "extra/amdflash/romless.py", "flash", IMAGE,
"--start-sector", str(SECTOR), "--sector-count", "1", "--yes"],
capture_output=True, text=True, timeout=120)
out = (p.stdout or "") + (p.stderr or "")
return ("OK sector" in out), out.strip().splitlines()[-1] if out.strip() else ""
print("polling for the ROM_SW window (PSP not booted)...")
print(" -> toggle the PSU off/on now")
t0 = time.time()
n = 0
while time.time() - t0 < TIMEOUT:
n += 1
ok, last = try_flash()
if ok:
print("\n*** CAUGHT THE WINDOW at t=%.1fs (attempt %d) ***" % (time.time()-t0, n))
print(" %s" % last)
rb = subprocess.run([sys.executable, "extra/amdflash/romless.py", "read", "0x7000", "0x10"],
capture_output=True, text=True, timeout=60)
print(" 0x7000 now reads: %s" % (rb.stdout or rb.stderr).strip().splitlines()[-1])
print("\n marker cleared -> now power-cycle again and check MEMSIZE")
sys.exit(0)
if n % 20 == 0:
print(" t=%.0fs attempt %d: still gated (%s)" % (time.time()-t0, n, last[:60]))
time.sleep(0.05)
print("timed out without catching the window")
|