Repository navigation
HDD Manager: repair the zero disk ID on A2 drives from older builds - #457
Conversation
An APA Jail A2 drive formatted by an older build has a zero MBR disk ID at 0x1B8. Windows treats that as no ID and may write its own, which breaks the APA checksum, so the PS2 sees a damaged header. Newer formats already write a non-zero ID. Options > Repair A2 disk ID... asks for confirmation, verifies the APA header (both header sectors: magic, checksum, A2 marker, the three MBR entries), and only if the ID is zero writes a non-zero ID and the recomputed APA checksum into sector 0, then reads it back. Nothing else is written. A drive that is not A2, already has an ID, or whose header does not verify is left alone. The APA Jail scheme and the sector 0 layout are Berion's. Host tests only; not tested on PCSX2 or a real PS2.
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Requested by NathanNeurotic Ripto · project thread
What
HDD Manager > Options > Repair A2 disk ID... for APA Jail A2 drives formatted by an older build.
Sector 0 is both the APA header and the PC MBR, and the APA checksum covers the MBR's 4-byte disk ID at 0x1B8. Older A2 formats left that ID at 0. Windows treats 0 as "no ID" and may write its own, which breaks the APA checksum, so the PS2 sees a damaged header. #453 made new A2 formats write a non-zero ID; this repairs drives already formatted.
How
hddFormatDiskIdFix(src/hdd_format.c) reads both header sectors and verifies the APA magic, the checksum, theAPAJ-A2marker and the three MBR entries. If any of that fails it refuses and does not guess.1if the clock is 0, as the formatter does) and recomputes the APA checksum. Nothing else in the sector changes.hddFormatDiskId) writes sector 0 only, flushes and reads it back, through the same raw session, volume release and IOP reset the existing relabel repair uses. Partitions, data and GPT are not touched.The APA Jail scheme and the sector 0 layout are Berion's.
Verification
tests/test_hdd_format.pycovers the checksum logic: fresh ID untouched, zero ID fixed with only the ID and checksum changed, bad checksum, bad magic, damaged second sector, Windows-style ID with a bad checksum, wrong marker, type D, plain exFAT and a failed read are refused;test_hdd_format_ui.pychecks the dry-run, release and sector-0-only ordering). The related HDD host tests pass.dash_hdd.c,hdd_format_ps2.c) was not compiled locally, so CI is its first build. Not tested on PCSX2 or a real PS2.Refs #453
Generated by Claude Code
Summary by CodeRabbit