pcsx2 icon indicating copy to clipboard operation
pcsx2 copied to clipboard

[BUG]: PCSX2 "Failed to open" BIOS files with uppercase extensions

Open skierpage opened this issue 2 years ago • 16 comments

Describe the Bug

I followed the PCSX2 Getting Started instructions to dump my PS2 BIOS files which created the files `SCPH-70012_BIOS_V12_USA_200.{BIN,EROM,NVM,ROM1,ROM2}. I ran the PCSX2 flatpak and pointed it at the BIOS files and chose my machine BIOS, then opened my game ISO (SSX on Tour)

But ~/.var/app/net.pcsx2.PCSX2/config/PCSX2/logs/emuLog.txt contains

        BIOS rom1 module not found, skipping...
        BIOS rom2 module not found, skipping...
        BIOS erom module not found, skipping...
...
Failed to open NVM file '/path/to/PCSX2_bios_files/SCPH-70012_BIOS_V12_USA_200.nvm' for writing

Note the program is trying to open files with lowercase extensions (.nvm), but the dumped files have uppercase extensions (.NVM). I ran strace on the flatpak and confirmed it is attempting e.g.

newfstatat(AT_FDCWD, "/home/spage/Documents/Games/PCSX2_bios_files/SCPH-70012_BIOS_V12_USA_200.rom1", 0x7f2d06cba490, 0) = -1 ENOENT (No such file or directory)

However, SSX on Tour starts up and runs! I don't see how PCSX2 can work when it indicates it can't read these files :confused:

Reproduction Steps

  • Dump your PS2 BIOS per Getting Started
  • Run the PCSX2 flatpak
  • Look at the emuLog.txt file.

Expected Behavior

Maybe the instructions should tell the user to rename the dumped BIOS files to have lowercase extensions.

PCSX2 Revision

PCSX2 Nightly - v1.7.2648 Compiled on Apr 24 2022

Operating System

Linux (64bit) - Specify Distro Below

If Linux - Specify Distro

Fedora (running Flatpak)

skierpage avatar Apr 25 '22 10:04 skierpage

PCSX2 only needs to see the main BIN/ROM0 file, the others are generally unimportant unless you're in China, but yeah it should be detecting them.

refractionpcsx2 avatar Apr 25 '22 10:04 refractionpcsx2

It would work on Windows as the paths are case insensitive. The "simple" solution would to rename the files and make the extensions lowercase. As far as I can tell, even going back a few versions, PCSX2 has searched for lowercase extension ROM files.

stenzek avatar Apr 25 '22 11:04 stenzek

It would work on Windows as the paths are case insensitive. The "simple" solution would to rename the files and make the extensions lowercase.

Should https://pcsx2.net/guides/basic-setup/#dumping-the-bios mention this? (BTW, I have a pull request improving the guide.) An alternative is to change PCSX2 code to use uppercase extensions in

//   This function does not fail if rom1, rom2, or erom files are missing, since none are
//   explicitly required for most emulation tasks.
...
        LoadExtraRom("rom1", eeMem->ROM1);
        LoadExtraRom("rom2", eeMem->ROM2);
        LoadExtraRom("erom", eeMem->EROM);
...
        std::string mecfile(FileSystem::ReplaceExtension(BiosPath, "mec"));
        std::string nvmfile(FileSystem::ReplaceExtension(BiosPath, "nvm"));

As far as I can tell, even going back a few versions, PCSX2 has searched for lowercase extension ROM files. ... PCSX2 only needs to see the main BIN/ROM0 file

I think the main .BIN file loads because FindBiosImage() looks at every file in EmuFolders::Bios regardless of extension to find one that looks like it holds the main BIOS.

BTW, when SSX on Tour appeared in a window with sound, I jumped up and down :joy:. Thanks for your work!

skierpage avatar Apr 25 '22 19:04 skierpage

An alternative is to change PCSX2 code to use uppercase extensions in

That would break everyone's existing setups on Linux/Mac which are using the lowercase extensions (which was the case, going back at very least a few stable releases).

IMO, the least risky solution is to add a rename step in the guide.

stenzek avatar Apr 30 '22 03:04 stenzek

Feels weird, considering PS2 uses UDF for discs, and they're all upper-case named. Might should've been upper from the start for a sense of continuity? I dunno, chiming in.

OdinVex avatar Jun 12 '22 13:06 OdinVex

considering PS2 uses UDF for discs,

Most if not all use ISO9660. I'm not sure if the firmware/BIOS is even able to speak UDF, I've never checked.

stenzek avatar Jun 12 '22 13:06 stenzek

considering PS2 uses UDF for discs,

Most if not all use ISO9660. I'm not sure if the firmware/BIOS is even able to speak UDF, I've never checked.

? For the PS2 DVDs even? Could have sworn it was ISO+UDF/UDF.

OdinVex avatar Jun 12 '22 16:06 OdinVex

https://github.com/Florin9doi/pcsx2/commit/68bc9402c9edeb4a220cc8021dfe4e75385da87a

Florin9doi avatar Aug 30 '22 09:08 Florin9doi

Florin9doi@68bc940

why are you opening the NVM as read only? it can be modified at any time by the BIOS (if the user changes any options). Unless I've misunderstood what's going on here.

refractionpcsx2 avatar Aug 30 '22 09:08 refractionpcsx2

For the same reason it is opened read-only now : https://github.com/PCSX2/pcsx2/blob/aae53fb9da136f372a5fb0526950538374fdfde0/pcsx2/CDVD/CDVD.cpp#L193

Florin9doi avatar Aug 30 '22 09:08 Florin9doi

fair enough, the diff was just confusing, looked like you'd changed it.

refractionpcsx2 avatar Aug 30 '22 09:08 refractionpcsx2

I wonder if a general "open case insensitive" routine would be better. i.e. if the open fails, read the directory, and look for any matches without case sensitivity. Because otherwise e.g. .Mec / .Nvm still wouldn't work on unix, but would be fine on Windows.

stenzek avatar Aug 30 '22 09:08 stenzek

The bios dumpers usually write all uppercase or all lowercase file extensions. Other combinations are less likely to be encountered. Another issue is to decide which file to use when multiple files are present : .nvm, .Nvm or .NVM. Ideally is to have the user decide, but would be too much headache for nothing.

Florin9doi avatar Aug 30 '22 10:08 Florin9doi

If you somehow had multiple variants of extension case, I think you probably have greater problems :)

stenzek avatar Aug 30 '22 10:08 stenzek

I haven't the slightest idea why I can't reproduce this, but link suggested I try: I've capitalized the file extensions, and the line Failed to open NVM file '/path/to/blahblahblah.nvm' for writing or anything similar doesn't appear anywhere in the Zsh log or in the emulog window. Instead, the .NVM file remains, and when the game is booted (trying SSX On Tour as well), a .nvm file is simply created as well.

TheTechnician27 avatar Mar 17 '24 22:03 TheTechnician27

For the sake of resolving this to 'almost all scenarios' I'd suggest checking for all upper and using that, then lower and using that (or whatever order preferred). I'd say almost all cases would be one or the other. In a filepicker I'd add both as possible sources, just to ease any issue.

OdinVex avatar Mar 17 '24 23:03 OdinVex