Self-update writes the new build to SD, then boots known-good /boot.dol
Previous version launched the image it had just received, which is the one
thing that cannot be made safe: a broken build hangs the console and the
checks can only catch a truncated or non-DOL image, never a plausible but
broken one.
The flow is now receive -> write to SD -> boot /boot.dol:
- netboot_sd_write() mounts the card (auto-detecting SD2SP2, then SD Gecko
slot B, then slot A), writes the image to the path the host asked for,
and READS IT BACK AND COMPARES. A half-written .dol that still parses is
exactly the failure this design exists to avoid, and the card is the one
component here with no other integrity check.
- netboot_boot_file() then loads /boot.dol -- a known-good Swiss -- and
launches that instead.
So the only image this ever jumps into is one that was already known good. A
broken test build costs nothing: Swiss comes up and can load anything,
including the previous build. If the SD write or verify fails, nothing is
launched at all and the menu is still there.
The destination path travels in the DONE frame rather than being baked in, so
the host decides where the build lands (send-dol.py --dest, default
/gc_bba_test.dol).
libfat is unmounted before the jump: leaving the card mounted hands the next
image a filesystem libfat still thinks it owns, on an EXI channel it is about
to reinitialise.
Note the SD Gecko in memory-card slot A shares EXI channel 0 with the BBA
(channel 0, device 2). libogc arbitrates, but SD2SP2 is on its own channel
and avoids the question -- hence the detection order.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+13
-4
@@ -51,6 +51,9 @@ def main():
|
||||
help="per-block ACK timeout in seconds (default 0.5)")
|
||||
ap.add_argument("--retries", type=int, default=20,
|
||||
help="per-block retransmits before giving up (default 20)")
|
||||
ap.add_argument("--dest", default="/gc_bba_test.dol",
|
||||
help="where to write it on the SD card "
|
||||
"(default /gc_bba_test.dol)")
|
||||
args = ap.parse_args()
|
||||
|
||||
img = open(args.dol, "rb").read()
|
||||
@@ -96,15 +99,21 @@ def main():
|
||||
pct = 100 * (seq + 1) // len(blocks)
|
||||
print(f"\r {pct:3d}% block {seq + 1}/{len(blocks)}", end="", flush=True)
|
||||
|
||||
# DONE is not ACKed: the GC launches the new image immediately, so there is
|
||||
# nothing left running to answer. Send it a few times in case one is lost.
|
||||
# DONE carries the destination path and is not ACKed: the GC goes
|
||||
# straight on to writing the card and booting Swiss, so there is nothing
|
||||
# left running to answer. Send it a few times in case one is lost.
|
||||
dest = args.dest.encode()
|
||||
if len(dest) >= 64:
|
||||
sys.exit("--dest too long (max 63 bytes)")
|
||||
for _ in range(5):
|
||||
s.send(frame(dst, src, OP_DONE, 0, len(blocks)))
|
||||
s.send(frame(dst, src, OP_DONE, 0, len(blocks), dest))
|
||||
time.sleep(0.02)
|
||||
|
||||
dt = time.time() - t0
|
||||
print(f"\nsent {len(img)} bytes in {dt:.1f}s "
|
||||
f"({len(img) * 8 / dt / 1e6:.2f} Mbit/s); GC should relaunch now")
|
||||
f"({len(img) * 8 / dt / 1e6:.2f} Mbit/s)")
|
||||
print(f"GC writes it to {args.dest} on the SD card, verifies it, "
|
||||
f"then boots /boot.dol")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user