PCSX2 / pcsx2

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

[BUG]: PSBBN Does not boot #11746

Open toffee-makes-things opened 2 months ago

toffee-makes-things commented 2 months ago

Describe the Bug

Current Issue

PSBBN Wont Boot Under PCSX2, Currently Due To Issues In DEV9

Original Bug The Issue Started On

When Attempting To Boot Into A PSBBN (decrypted KELF) Install, it reads from the HDD then attempts to boot kernel, however the IOP sends "ATA failed, -502" and the system restarts to OSD as a result (or at least im pretty sure that is whats going on)

Feel free to check the logs i have provided below

Reproduction Steps

  1. Get PSBBN
  2. Decrypt the PSBBN OSDBOOT.elf
  3. Launch using ulaunch or equivalent
  4. Wait for it to restart to OSD

Expected Behavior

No response

PCSX2 Revision

PCSX2 v2.1.109

Operating System

Mac OS Sonoma

If Linux - Specify Distro

No response

CPU

Apple M1 Pro

GPU

Apple M1 Pro

GS Settings

No response

Emulation Settings

No response

GS Window Screenshots

No response

Logs & Dumps

log.txt

toffee-makes-things commented 2 months ago

Oh i should probably say, 2997.1353 is where

ATA: error: ata timedout while non data command & ATA: error: ATA failed, -502

happen

TheLastRar commented 2 months ago

Can you test this build and see if you get any more addition logs? https://github.com/TheLastRar/pcsx2/actions/runs/10547168292

toffee-makes-things commented 2 months ago

log.txt

This is the complete log of the entire process using your build @TheLastRar

(for reference, the process being: launching WLaunchElf, going to the proper partition and directory, excecuting the decrypted KELF, the OSDBOOT running, then being sent back to BIOS)

toffee-makes-things commented 2 months ago

The point where OSDBOOT is launched is at [74.8622]

The point where the ATA error occurs is at [121.8278]

TheLastRar commented 2 months ago

Okay, that narrows it down to what command is causing issue, but I'm not yet sure why. I fixed a bug I had spotted (although it might not be the cause) and added a few more log entries Can you test this build and post back the log? https://github.com/TheLastRar/pcsx2/actions/runs/10553246754

Edit: I'll probably just need the timestamp of ATA error for this one

toffee-makes-things commented 2 months ago

@TheLastRar This one actually failed faster than the previous attempts

log.txt

I now error with a -503

[   71.2147] DEV9: *ATA_R_ALT_STATUS 16bit read at address 1000005c, value 40, Active  True 
[   71.2155] DEV9: *ATA_R_ALT_STATUS 16bit read at address 1000005c, value 40, Active  True 
[   71.2161] DEV9: *ATA_R_CONTROL 16bit write at address 1000005c, value 0
[   71.2165] DEV9: *ATA_R_SELECT 16bit write at address 1000004c, value 0
[   71.2169] DEV9: *ATA_R_CMD 16bit write at address 1000004e, value b0
[   71.2174] DEV9: Starting Command b0, is LBA enabled false
[   71.2178] DEV9: ATA: regSector is (null)
[   71.2182] DEV9: ATA: SMART_ATTR_SAVE Not Implemented
[   71.2186] DEV9: *ATA_R_STATUS (Fallthough to ATA_R_ALT_STATUS)
[   71.2271] DEV9: *ATA_R_ALT_STATUS 16bit read at address 1000004e, value 41, Active  True 
[   71.2277] ATA: error: cmd err 0x41, 0x04
[   71.2282] ATA: error: ATA failed, -503
TheLastRar commented 2 months ago

Alright Let me know if https://github.com/TheLastRar/pcsx2/actions/runs/10559511252 works

toffee-makes-things commented 2 months ago

@TheLastRar This does fix the ATA issue as seen before. however PSBBN's OSDBOOT.elf will still send me back to the standard BIOS as apposed to well, PSBBN and im not really sure why? No issues with how EE is being emulated (no TLB miss) and generally very minimal fuss, so i dont know why PSBBN refuses to load. I attached the log so that you can see that your fix did infact work & incase that there are any other errors related to DEV9 that im not quite seeing

log.txt

toffee-makes-things commented 2 months ago

I did see some messages like

[   46.8271] DEV9: SPD_R_INTR_MASK8, WTFH ?
[   46.8264] DEV9: Unknown 8bit write at address 10000074 value 61

&

[   41.5624] DEV9: SMAP: WARN : (fc!=cnt || cnt==0) but packet send request was made oO..

But i dont know if these would exactly prevent it from booting. (I mean to be fair its PSBBN i'd expect it to act weird under an emulator regardless)

TheLastRar commented 2 months ago

From the logs I see that the smap driver has issues I see repeated reads (DEV9 read16 10000028) with a smap: intr status(0x00c7) error following this line DEV9: SMAP: WARN : (fc!=cnt || cnt==0) but packet send request was made oO.. What's happening there is funky regardless

Can you try the following 3 builds to see if anything changes regarding DEV9 read16 10000028 logs and smap: intr status(0x00c7) error messages https://github.com/TheLastRar/pcsx2/actions/runs/10567901936 https://github.com/TheLastRar/pcsx2/actions/runs/10567932862 https://github.com/TheLastRar/pcsx2/actions/runs/10568084291

toffee-makes-things commented 2 months ago

@TheLastRar Will try those, log them, and report back

toffee-makes-things commented 2 months ago

@TheLastRar okay so none of these builds actually succeeded in launching BBN, still getting the same result of being sent back to BIOS

I also see the same smap errors

I have attached the logs marked with the SHA hash of the build below

1b21ed8.txt 7a970d1.txt 4586998.txt

toffee-makes-things commented 2 months ago

I do know PSBBN specifically wants Sony branded network/hdd adapters so maybe this is a result of some weird proprietary thing, but im not sure im not an expert on how PS2 handles networking and ATA lmao, btw im sorry if i have any of the terminology wrong, while i have a rough idea on how the PS2 works and i have tech skills in general, im not a seasoned veteran on the playstation 2

TheLastRar commented 2 months ago

I'll have another look into this later on

TheLastRar commented 1 month ago

Now is later on

Can you run this build https://github.com/TheLastRar/pcsx2/actions/runs/11114262227 and provide a log?

toffee-makes-things commented 1 month ago

@TheLastRar Will do and will report back when I have the chance to run it

toffee-makes-things commented 1 month ago

@TheLastRar Sorry for the delay, here are the logs that were output when running the PSBBN osdboot.elf, it did not boot successfully however the Dev9 logs look a bit different so cant tell if that's a good sign or not

log.txt

TheLastRar commented 4 weeks ago

Thanks,

It looks like PSBBN is expecting interrupts form trying to send a test frame, but isn't incrementing the frame counter before doing so Will need to determine what the correct behaviour is here

TheLastRar commented 3 weeks ago

Can you test this build and report back? https://github.com/TheLastRar/pcsx2/actions/runs/11195056739

toffee-makes-things commented 3 weeks ago

@TheLastRar sent me back to the BIOS but more happened in the logs log.txt

TheLastRar commented 3 weeks ago

@TheLastRar sent me back to the BIOS but more happened in the logs log.txt

Try this build? https://github.com/TheLastRar/pcsx2/actions/runs/11202610307 One of the interrupt status bits was incontinent in my testing, so I could have done the wrong thing.

toffee-makes-things commented 3 weeks ago

@TheLastRar sent me back to the BIOS but more happened in the logs log.txt

Try this build? https://github.com/TheLastRar/pcsx2/actions/runs/11202610307 One of the interrupt status bits was incontinent in my testing, so I could have done the wrong thing.

sent back to BIOS log.txt @TheLastRar

TheLastRar commented 3 weeks ago

Hmm, must also be checking the RXEND bit as well

Can you test https://github.com/TheLastRar/pcsx2/actions/runs/11213350049?

toffee-makes-things commented 3 weeks ago

@TheLastRar I just hit a new point, give me one minute to see what happens next and i'll send the logs

toffee-makes-things commented 3 weeks ago

As far as i can tell it was successful in preforming the test, and it actually tried to read something off of the HDD to boot into what i'd presume is the Linux kernel PSBBN uses, good news no TLB misses so no processor emulation issues yet, bad news it was trying to preform an operation that DEV9 didn't like and it hanged on the Playstation 2 logo, i left it on this for about 10 minutes and it hasn't really done anything

log.txt

Image

toffee-makes-things commented 3 weeks ago

@TheLastRar

TheLastRar commented 3 weeks ago

This thing really likes its 8bit IO

Can you give https://github.com/TheLastRar/pcsx2/actions/runs/11226128513 a shot

toffee-makes-things commented 3 weeks ago

@TheLastRar The behavior got kinda weird this time, notably

[  187.1560] DEV9: IF_CTRL Unknown Bit 4 Set
[  187.1564] DEV9: IF_CTRL Unknown Bit 5 Set
[  187.1569] DEV9: UNDERFLOW BY IOP
[  187.1573] DEV9: Starting Command c8, is LBA enabled false
[  187.1578] DEV9: ATA: DEVICE BUSY, DROPPING WRITE

&

[   86.5500] DEV9: Starting Command 10, is LBA enabled false
[   86.5506] DEV9: ATA: Unknown cmd 10

log.txt

TheLastRar commented 3 weeks ago

It looks like we don't like something in the ReadDMA command. I have, however, implemented the 2 missing commands reported in your log.

Can you test this build? https://github.com/TheLastRar/pcsx2/actions/runs/11236367394 It also includes addition logging around the area I suspect is at fault.

toffee-makes-things commented 3 weeks ago

@TheLastRar i cannot test as the MacOS build did not succeed

toffee-makes-things commented 3 weeks ago

@TheLastRar the reason why seems to be this

 ../../pcsx2/DEV9/ATA/Commands/ATA_CmdDMA.cpp:142:66: error: expected ')'
                Console.Error("DEV9: ATA: Started transfer from invalid LBA %" PRId64, HDD_GetLBA());
                                                                               ^
../../pcsx2/DEV9/ATA/Commands/ATA_CmdDMA.cpp:142:16: note: to match this '('
                Console.Error("DEV9: ATA: Started transfer from invalid LBA %" PRId64, HDD_GetLBA());
                             ^
../../pcsx2/DEV9/ATA/Commands/ATA_CmdDMA.cpp:164:66: error: expected ')'
                Console.Error("DEV9: ATA: Started transfer from invalid LBA %" PRId64, HDD_GetLBA());
                                                                               ^
../../pcsx2/DEV9/ATA/Commands/ATA_CmdDMA.cpp:164:16: note: to match this '('
                Console.Error("DEV9: ATA: Started transfer from invalid LBA %" PRId64, HDD_GetLBA());

apparently some people who have had similar issues needed to put this at the start of the file

#define __STDC_FORMAT_MACROS
#include <inttypes.h>

or a some weird compiler flags to get it working

see: https://github.com/microsoft/rDSN/issues/197 & https://github.com/pytorch/pytorch/issues/5217

but this is where some of my C++ knowledge fades so i don't know what the easy solution for this is :P

TheLastRar commented 3 weeks ago

Woops, You where close, the needed header was #include <cinttypes> This one built https://github.com/TheLastRar/pcsx2/actions/runs/11245869630

toffee-makes-things commented 3 weeks ago

@TheLastRar seems to have fixed some of it (less errors), still gets stuck in a sort of "loop" though

log.txt

TheLastRar commented 2 weeks ago

That was a tricky issue to solve

Can you try this build? https://github.com/TheLastRar/pcsx2/actions/runs/11307863874

toffee-makes-things commented 2 weeks ago

@TheLastRar will report back soon

toffee-makes-things commented 2 weeks ago

@TheLastRar log.txt PCSX2 froze for a bit, encountered multiple TLB misses