PCSX2 / pcsx2

PCSX2 - The Playstation 2 Emulator
https://pcsx2.net
GNU General Public License v3.0
11.83k stars 1.63k forks source link

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

Open skierpage opened 2 years ago

skierpage commented 2 years ago

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

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)

refractionpcsx2 commented 2 years ago

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.

stenzek commented 2 years ago

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.

skierpage commented 2 years ago

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!

stenzek commented 2 years ago

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.

OdinVex commented 2 years ago

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.

stenzek commented 2 years ago

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.

OdinVex commented 2 years ago

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.

Florin9doi commented 2 years ago

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

refractionpcsx2 commented 2 years ago

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.

Florin9doi commented 2 years ago

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

refractionpcsx2 commented 2 years ago

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

stenzek commented 2 years ago

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.

Florin9doi commented 2 years ago

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.

stenzek commented 2 years ago

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

TheTechnician27 commented 8 months ago

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.

OdinVex commented 8 months ago

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.