Skip to content

Alternate sector information is not processed, resulting in corruption upon save #17

@DeadlySystem

Description

@DeadlySystem

Memory cards contain 20 reserved sectors ("Alternate Sectors") in the FAT block that can be used to replace broken sectors. The respective documentation can be found here under "Broken Sector List".

It seems MemcardRex does not process this information and instead assumes that all sectors are sane. This can lead to severe problems when working with corrupted cards. An example flow I've been able to verify is exporting a single save containing a corrupted sector. MemcardRex in this case exports the save with the corrupted sector, the alternate sector is ignored. When this save is later re-imported, it remains corrupt - even though the original memory card image works fine (because it contains the alternate sector). Also, when simply saving the full image again, alternate sectors seem to be cleared - resulting in MemcardRex corrupting the original save.

My suggested treatment would be to replace the broken sectors with their alternate sectors when a memory card is loaded, and clear the alternate sectors at this point. This would effectively fix the card image and prevent inconsistencies from occurring when the card is edited. However, this solution also has a few drawbacks that I can think of:

  • If the card image is written back to the physical memory card from which it was taken, the previously-broken sectors of this card are likely still broken, and therefore the saves will break unless MemcardRex detects write errors and creates new alternate sectors. It might be that the memory card adapter or the memory card itself perform these checks though - I'm not familiar with the involved protocols.
  • It is not clear from the specs if alternate sectors can also replace sectors within the FAT block - possibly even other alternate sectors, or possibly even themselves. From a pure format definition perspective, this is possible. In an extreme case, MemcardRex would need to read sectors in some to-be-determined order to ensure that data is read consistently, handle recursive replacements, and avoid loops. I personally don't believe that the PlayStation BIOS (or the memory card controller?) is smart enough to handle this - it might ignore such alternate sectors, or just crash. I suppose the easiest option here would be to prevent loading of images whose alternate sectors reference the FAT block.
  • Compatibility with FreePSXBoot might be affected. Suggested treatment would be to disable automatic substitution with the option introduced in 0952399 (Note that this specific change is unrelated to alternate sectors, it only seems to fix checksums, which is a different concern) and show a warning to users when attempting to load such an image, possibly disabling editing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions