Alex

alex-free.github.io

EDCRE: EDC/ECC Regenerator For BIN+CUE CD Disc Images

EDCRE provides an advanced solution to detect and or update EDC/ECC data to match any edits done to a data track of a CD image.

EDCRE

Table of Contents

Downloads

Version 1.0.6 (11/9/2023)

Changes:

About previous versions.

What Is EDC/ECC Data?

EDC is a special checksum that verifies the integrity of the user data portion of a sector in a data track. If during a sector read the EDC does not match the data read by the CD drive, ECC data then provides a way to correct the data to what was expected in most cases. If a significant amount of the sector is unreadable or modified this may not be correctable with ECC data, but in many common cases (i.e. slightly scratched discs) it does work quite well and provides much more reliability and resilience for data CD reading.

When you edit a data track in a CD image, the original EDC and ECC will remain untouched causing it to mismatch the new contents of the user data in any modified sectors, causing any changes to not take effect or invalidate the disc image when it is burned to a disc and used on real hardware. Usually this isn’t a problem however since almost all CD burning software writes updated EDC/ECC to burned discs, and most emulators ignore the EDC/ECC data in sectors by design. IMGBurn always writes updated EDC/ECC data, and there isn’t a way to disable that behavior. CDRDAO always writes updated EDC/ECC data when using the default generic-mmc driver. It is possible however specify the generic-mmc-raw be used instead which does not modify EDC/ECC data and leaves it as is. CloneCD always writes updated EDC/ECC data unless you use the RAW writing mode. Writing updated EDC data to disc is usually what you want, that way the correct matching EDC/ECC data correlates to any modification to the user data of sectors found in a disc image.

But what if you want to edit user data of sectors in a data track of a CD disc image and then write it raw? That is exactly what I want to do, as it defeats the EDC-based anti-piracy protection measure found in almost all of the Dance Dance Revolution PSX games.

PSX EDC Anti-Piracy Protection

The idea of EDC/ECC based additional anti-piracy protection is a brilliantly flawed one. See, Sony’s tools to generate disc images back in the day were buggy. One such bug appears to be that the reserved sectors 12-15, which are zero filled in the user data portion of the sector, also have an EDC checksum of zero. The correct checksum for a zero-filled user data sector should be 3F 13 B0 BE, but it isn’t. It’s 00 00 00 00 like the rest of the sector besides the sync data. This actually doesn’t matter in practice, so the bug went unoticed and the technically invalid sector 12-15s shipped on real licensed PSX CD-ROMs. This apparently got fixed eventually in some newer version of the cdgen Sony tool that created disc images.

Someone working on the Dance Dance Revolution PSX games noticed this strange behavior and figured out that it could be exploited as an additional anti-piracy protection measure. If the real licensed PSX CD-ROM discs were shipped with an EDC checksum of zero in sector 12-15, then when someone went to rip the real licensed PSX CD-ROM disc and then burn it back to a CD-R, the EDC checksum in sector 12-15 would no longer be 00 00 00 00, it would be the expected 3F 13 B0 BE. Game code can read the EDC checksum on the disc at sector 12, and a routine could then lock up the game if the EDC data is non-zero to deter piracy.

PSX EDC Protection Workaround With EDCRE

EDCRE has a simple solution to allow edited/patched PSX disc images that have EDC Protection to work on real PSX hardware. By using the -s 16 argument, you can not touch the checked sector (12) and instead only regenerate EDC/ECC data for all data sectors starting at the system volume descriptor sector (16/LBA 166).

if you burn the disc image RAW using CloneCD or CDRDAO. At the same time any edits/patches made to a PSX disc image will have matching EDC/ECC data (since any such edits would be on the game data itself which starts at the 16th sector) allowing patches to the data track work correctly on real hardware.

Usage

EDCRE is a command line program. On Windows and most Linux distributions, you can simply drag and drop the “track 01.bin” file of the PSX game you want to update EDC/ECC data for.

If you want to see more verbose info, and or if you want to update EDC/ECC data for all sectors (what you probably want if the data track bin file is not an EDC Protected PSX game but rather something else), you need to execute edcre with command line options:

Usage: edcre <optional arguments> <track 01 bin file>

Optional Arguments:

-v Verbose, display each sector LBA number containing invalid EDC data, if any.

-t Test the disc image for sectors that contain invalid EDC/ECC. Does not modify the track bin file in any way.

-s Start EDC/ECC regeneration at sector number following the -s argument instead of at sector 0. In example, -s 16 starts regeneration at sector 16 (LBA 166) which would be the system volume for a PSX disc image (and what is recommended most of the time). TOCPerfect Patcher users want -s 15 here however.


Windows

Linux

Burning EDCRE Patched Disc Images

CDRTools

I recommend using the latest CDRTools for burning EDC protected PSX games on Linux. There are pre-built portable releases of a new enough CDRTools for Linux available. Windows versions are available somewhere. The required command syntax for burning EDCRE patched games is this:

cdrtools -raw16 --speed=x cuefile=yourgame.cue

Breakdown what each of these arguments to CDRDAO do:

-raw16 specifies to burn the cd image without regenerating EDC/ECC data internally.

--speed=x specifies the burn speed. Replace x with a number.

cuefile=yourgame.cue specifies that your using a cue file named yourgame.cue. Replace yourgame.cue with the game’s cue file your burning.

CDRDAO 1.2.5

The latest CDRDAO v1.2.5 also supports burning EDC Protected PSX games with CD audio tracks correctly using the generic-mmc-raw driver. There are pre-built portable releases of a new enough CDRDAO for Linux available. The required command syntax for burning EDCRE patched games is this:

cdrdao write --speed x --driver generic-mmc-raw --swap -n --eject yourgame.cue

Breakdown what each of these arguments to CDRDAO do:

License

EDCRE is modified CDRDAO source code, which is licensed under the GPLv2 license. Please see the file license.txt in each release for full info.

Credits