Skip to content

Add external-flash offset support (Mario); deny it for Zelda#381

Open
slash-proc wants to merge 1 commit into
BrianPugh:mainfrom
slash-proc:extflash_offset
Open

Add external-flash offset support (Mario); deny it for Zelda#381
slash-proc wants to merge 1 commit into
BrianPugh:mainfrom
slash-proc:extflash_offset

Conversation

@slash-proc

Copy link
Copy Markdown
Contributor

A new ext_offset flag relocates the patched Mario firmware's external data from the 0x90000000 base to 0x90000000 + ext_offset, so the OFW can coexist with other data (e.g. a second OFW) on a large SPI flash.

  • _patch.py: ext_offset flag on mario (int_parser converter; offset bounds are validated downstream by gnw.flash).
  • firmware.py / patch.py: the relocation lookup shifts external-flash destinations by a per-firmware _offset (set on self.external in call); both move/copy paths use FLASH_BASE + _offset.
  • mario.py: repoint the memory-mapped read base, grow the OCTOSPI device size to span the offset, and offset the NVRAM save address. That last part is required for correctness: without it the save targets the un-offset 0xfe000+ext_offset (e.g. 0xd9000), which lands in the other console's external region and corrupts it.

Zelda cannot support this. It has no relocatable base register and reaches its external data through absolute pointers, so its data is fixed at 0x90000000. The zelda command accepts ext_offset for parity but rejects any nonzero value with a clear ValueError.

A new `ext_offset` flag relocates the patched Mario firmware's external data
from the 0x90000000 base to 0x90000000 + ext_offset, so the OFW can coexist
with other data (e.g. a second OFW) on a large SPI flash.

* _patch.py: `ext_offset` flag on `mario` (int_parser converter; offset bounds
  are validated downstream by gnw.flash).
* firmware.py / patch.py: the relocation lookup shifts external-flash
  destinations by a per-firmware `_offset` (set on self.external in __call__);
  both move/copy paths use FLASH_BASE + _offset.
* mario.py: repoint the memory-mapped read base, grow the OCTOSPI device size to
  span the offset, and offset the NVRAM save address. That last part is required
  for correctness: without it the save targets the un-offset 0xfe000+ext_offset
  (e.g. 0xd9000), which lands in the other console's external region and corrupts
  it.

Zelda cannot support this. It has no relocatable base register and reaches its
external data through absolute pointers, so its data is fixed at 0x90000000. The
`zelda` command accepts `ext_offset` for parity but rejects any nonzero value
with a clear ValueError.
@slash-proc

Copy link
Copy Markdown
Contributor Author

hmm... I tried to get my branch up-to-date with upstream/main and I didn't realize it would affect this PR. I'm not sure what to do since the pre-commit.ci - pr check failed (not sure what it's saying failed). just let me know if there's something I need to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant