frno7 / linux

Linux 2.2, 2.6, 3.x, 4.x and 5.x kernels for the PlayStation 2.
Other
92 stars 6 forks source link

The kernel is crashing on PSX DESR after printing that info #78

Open AKuHAK opened 2 years ago

AKuHAK commented 2 years ago

The kernel is crashing on PSX DESR after printing that info. After that, it just freezes. My_Great_Game_-_My_Great_Capture_2022-05-08_13-48-50

Originally posted by @AKuHAK in https://github.com/frno7/linux/discussions/73#discussioncomment-2710057

AKuHAK commented 2 years ago

I checked rom0:INTRMANI and it is the same as in retail models so it is something else that breaks the chain

immolo commented 2 years ago

I don't have the irx errors on my machine but it does hang at the same place for me until I press return then it drops me to shell.

frno7 commented 2 years ago

I don't have the irx errors on my machine but it does hang at the same place for me until I press return then it drops me to shell.

@immolo, the kernel typically continues to initialise various subsystems in the background, after the shell prompt appears, and it happily prints its log messages about these on top of the shell prompt. The astute observer will notice the following line on @AKuHAK’s screen:

/ # usb 1-1: new full-speed USB device number 2 using ohci-ps2

The shell prompt is displayed to the left with / #, and an unrelated kernel log message usb 1-1: new full-speed USB device number 2 using ohci-ps2 has been printed by the kernel afterwards. The kernel and the shell are simply sharing the same console, and their outputs are therefore interleaved, but they are otherwise unrelated.

Pressing enter makes the prompt ‘reappear’, but it’s not necessary because the shell was waiting for input all along. A quick way to clear a garbled screen is to press ctrl + L.

frno7 commented 2 years ago

@AKuHAK, what would dmesg | grep rom say, if you put it in your /sbin/init? It should print something like this:

rom0: Found 98 files in 3900816 bytes
rom1: Found 29 files in 407408 bytes
rom0: Version 0170 Europe CEX 2003-02-27

These lines have been scrolled off your screen, but dmesg and grep can retrieve them. :-)

frno7 commented 2 years ago

I checked rom0:INTRMANI and it is the same as in retail models so it is something else that breaks the chain

In addition to dmesg | grep rom mentioned, one can do more advanced things, such as

# modprobe rom-sysfs
# cat /sys/rom/rom0/file/*/name | grep INTRMAN
INTRMANP
INTRMANI

to confirm that this ROM file exists and is recognised. Moreover, a script romcat to print ROM files on standard output

#!/bin/sh
cd $1 && dd if=/dev/mem bs=$(cat size) iflag=skip_bytes \
        skip=$(( $(cat data) )) count=1 status=none

can be combined with another script romlib to print all exported libraries in all ROM files, like this:

#!/bin/sh
for d in /sys/rom/rom?/file/*
do
    echo "$d $(cat $d/name)"
    romcat $d >/tmp/file.rom &&
        iopmod-info --identify /tmp/file.rom &&
        iopmod-info /tmp/file.rom | grep "export library"
done

On a SCPH-50004 it’ll print something like this:

/sys/rom/rom0/file/0 RESET
/sys/rom/rom0/file/1 ROMDIR
/sys/rom/rom0/file/10 EXCEPMAN
export library  0x0101  excepman
/sys/rom/rom0/file/11 INTRMANP
export library  0x0102  intrman
/sys/rom/rom0/file/12 INTRMANI
export library  0x0102  intrman
/sys/rom/rom0/file/13 SSBUSC
export library  0x0101  ssbusc
/sys/rom/rom0/file/14 TIMEMANP
export library  0x0101  timrman
/sys/rom/rom0/file/15 TIMEMANI
export library  0x0101  timrman
/sys/rom/rom0/file/16 DMACMAN
export library  0x0102  dmacman
/sys/rom/rom0/file/17 SYSCLIB
export library  0x0101  sysclib
export library  0x0102  stdio
/sys/rom/rom0/file/18 HEAPLIB
export library  0x0101  heaplib
/sys/rom/rom0/file/19 THREADMAN
export library  0x0101  thbase
export library  0x0101  thevent
export library  0x0101  thsemap
export library  0x0101  thmsgbx
export library  0x0101  thfpool
export library  0x0101  thvpool
export library  0x0102  thrdman
/sys/rom/rom0/file/2 EXTINFO
...

So romlib | grep -C1 intrman will print something like

/sys/rom/rom0/file/11 INTRMANP
export library  0x0102  intrman
/sys/rom/rom0/file/12 INTRMANI
export library  0x0102  intrman

to confirm ROM files and library exports. For this I built the iopmod-info for the R5900 with

ACCEPT_KEYWORDS="**" USE="-modules tools static" mipsr5900el-unknown-linux-musl-emerge -v sys-firmware/iopmod

Then I copied the scripts and the tool to the SCPH-50004 hardware

scp romcat romlib /usr/mipsr5900el-unknown-linux-musl/usr/bin/iopmod-info ps2:/usr/bin/

which is running Dropbear, but they can be put on a USB storage device as well, of course. The files and scripts used here are described in the wiki article on the PlayStation 2 read only memory (ROM).

AKuHAK commented 2 years ago

@frno7 you can check rom0 content offline for all ps2 variations: search on archive.org for Redump - Sony - PlayStation 2 - BIOS Images 2021 I used the ROMIMG tool on the windows to extract all content for bootrom .\ROMIMG.exe /x .\ps2-0180j-20031028.bin then i copy extracted content into rom/ folder on Linux, created script ./romlib.sh with content:

#!/bin/sh
for d in rom/*
do
    echo "$d"
        ./iopmod-info --identify $d &&
        ./iopmod-info $d | grep "export library"
done

0180j - is the bootrom of PSX DESR v1

intrman is completely the same as in retail models, it is failing BEFORE intrman load (I think), but I don't know where exactly: ./romlib.sh | grep -C1 intrman:

rom/INTRMANI
export library  0x0102  intrman
rom/INTRMANP
export library  0x0102  intrman
rom/IOMAN

also full output of ./romlib.sh

rom/-
rom/ADDDRV
rom/CDVDFSV
export library  0x0101  cdvdfsv
rom/CDVDMAN
export library  0x0101  cdvdman
rom/CLEARSPU
rom/DMACMAN
export library  0x0102  dmacman
rom/EECONF
export library  0x0103  eeconfig
rom/EELOAD
rom/EELOADCNF
rom/EENULL
rom/EESYNC
export library  0x0101  eesync
rom/EXCEPMAN
export library  0x0101  excepman
rom/FILEIO
rom/HEAPLIB
export library  0x0101  heaplib
rom/IGREETING
rom/INTRMANI
export library  0x0102  intrman
rom/INTRMANP
export library  0x0102  intrman
rom/IOMAN
export library  0x0102  ioman
rom/IOPBOOT
rom/IOPBTCON2
rom/IOPBTCONF
rom/KERNEL
rom/KROM
rom/KROMG
rom/LIBFI
rom/LOADCORE
export library  0x0101  loadcore
rom/LOADFILE
rom/LOGO
rom/MCMAN
export library  0x0101  mcman
rom/MCSERV
export library  0x0101  mcserv
rom/MODLOAD
export library  0x0101  modload
rom/OSDCNF
rom/OSDSND
rom/OSDSYS
rom/OSDVER
rom/PADMAN
export library  0x0102  padman
rom/PATAD
export library  0x0103  atad
rom/PCDVDFSV
export library  0x0101  cdvdfsv
rom/PCDVDMAN
export library  0x0101  cdvdman
rom/PDEV9
export library  0x0107  dev9
rom/PEESYNC
export library  0x0101  eesync
rom/PFILEIO
rom/PFLASH
export library  0x0101  fls
rom/PFLSLOAD
rom/PHDD
rom/PHDDLOAD
rom/PIOMAN
export library  0x0104  ioman
rom/PLIBSD
export library  0x0105  libsd
rom/PLOADCORE
export library  0x0103  loadcore
rom/PLOADFILE
rom/PMCMAN
export library  0x0207  mcman
rom/PMCSERV
export library  0x0201  mcserv
rom/PMODHSYN
export library  0x0104  modhsyn
rom/PMODLOAD
export library  0x0106  modload
rom/PMODMIDI
export library  0x0105  modmidi
rom/PMODSESQ
export library  0x0101  modsesq
rom/PMTAPMAN
export library  0x0204  mtapman
rom/PPADMAN
export library  0x0203  padman
rom/PRMMAN2
export library  0x0101  rmman2
rom/PROMDRV
export library  0x0201  romdrv
rom/PS1DRV
rom/PS1ID
rom/PS1VER
rom/PS2LOGO
rom/PSDRDRV
export library  0x0101  sdrdrv
rom/PSIFCMD
export library  0x0101  sifcmd
rom/PSIFMAN
export library  0x0101  sifman
rom/PSIO2MAN
export library  0x0204  sio2man
rom/PSTDIO
export library  0x0103  stdio
rom/PSXVER
rom/PSYSCLIB
export library  0x0104  sysclib
export library  0x0103  stdio
rom/PSYSMEM
export library  0x0101  sysmem
rom/PTHREADMAN
export library  0x0102  thbase
export library  0x0101  thevent
export library  0x0101  thsemap
export library  0x0101  thmsgbx
export library  0x0101  thfpool
export library  0x0101  thvpool
export library  0x0102  thrdman
rom/PTIMEMANI
export library  0x0103  timrman
rom/PXATAPI
export library  0x0101  xatapi
rom/PXFROMMAN
export library  0x0203  xfromman
rom/RDRAM
rom/REBOOT
rom/RESET
rom/RMRESET
rom/ROMDRV
export library  0x0201  romdrv
rom/ROMGSCRT
rom/ROMVER
rom/SBIN
rom/SECRMAN
export library  0x0103  secrman
rom/SIFCMD
export library  0x0101  sifcmd
rom/SIFINIT
rom/SIFMAN
export library  0x0101  sifman
rom/SIO2MAN
export library  0x0101  sio2man
rom/SNDIMAGE
rom/SSBUSC
export library  0x0101  ssbusc
rom/STDIO
export library  0x0102  stdio
rom/SYSCLIB
export library  0x0101  sysclib
export library  0x0102  stdio
rom/SYSMEM
export library  0x0101  sysmem
rom/TBIN
rom/TDEV9
export library  0x0109  dev9
rom/TDVRDRV
export library  0x0101  pvrdrv
rom/TDVRMISC
rom/TESTMODE
rom/TESTSPU
rom/TEXIMAGE
rom/THREADMAN
export library  0x0101  thbase
export library  0x0101  thevent
export library  0x0101  thsemap
export library  0x0101  thmsgbx
export library  0x0101  thfpool
export library  0x0101  thvpool
export library  0x0102  thrdman
rom/TIMEMANI
export library  0x0101  timrman
rom/TIMEMANP
export library  0x0101  timrman
rom/TIOPIMG
rom/TLIBSD
export library  0x0104  libsd
rom/TPADMAN
export library  0x0203  padman
rom/TSIO2MAN
export library  0x0204  sio2man
rom/TXATAPI
export library  0x0101  xatapi
rom/UDNL
rom/VBLANK
export library  0x0101  vblank
rom/VERSTR
rom/XCDVDFSV
export library  0x0101  cdvdfsv
rom/XCDVDMAN
export library  0x0101  cdvdman
rom/XLOADFILE
frno7 commented 2 years ago

@AKuHAK, how much, or little, of the ROM does the kernel recognise on the actual hardware? The suggested scripts should be able to say some things about that.

immolo commented 2 years ago

I don't have the irx errors on my machine but it does hang at the same place for me until I press return then it drops me to shell.

@immolo, the kernel typically continues to initialise various subsystems in the background, after the shell prompt appears, and it happily prints its log messages about these on top of the shell prompt. The astute observer will notice the following line on @AKuHAK’s screen:

/ # usb 1-1: new full-speed USB device number 2 using ohci-ps2

The shell prompt is displayed to the left with / #, and an unrelated kernel log message usb 1-1: new full-speed USB device number 2 using ohci-ps2 has been printed by the kernel afterwards. The kernel and the shell are simply sharing the same console, and their outputs are therefore interleaved, but they are otherwise unrelated.

Pressing enter makes the prompt ‘reappear’, but it’s not necessary because the shell was waiting for input all along. A quick way to clear a garbled screen is to press ctrl + L.

@frno7 You are correct and this highlights I badly need a new capture card as I couldn't even see that line on my screen :)

uyjulian commented 2 years ago

A possible reason why the usb 1-1: new full-speed USB device number 2 using ohci-ps2 message is appearing is the Memory Stick reader that is integrated into the system.

frno7 commented 2 years ago

A possible reason why the usb 1-1: new full-speed USB device number 2 using ohci-ps2 message is appearing is the Memory Stick reader that is integrated into the system.

I’ve got the same line, and a bunch of others with my development kit:

usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
ohci-ps2 ohci-ps2: PlayStation 2 USB OHCI host controller
ohci-ps2 ohci-ps2: new USB bus registered, assigned bus number 1
hub 1-0:1.0: USB hub found
usbcore: registered new interface driver usb-storage
usbcore: registered new interface driver ums-usbat
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver

Here it comes:

usb 1-1: new full-speed USB device number 2 using ohci-ps2

And then follows even more:

usbcore: registered new interface driver rt2800usb
hub 1-1:1.0: USB hub found
usb 1-2: new full-speed USB device number 3 using ohci-ps2
usb 1-1.2: new full-speed USB device number 4 using ohci-ps2
usb-storage 1-1.2:1.0: USB Mass Storage device detected
scsi host0: usb-storage 1-1.2:1.0
usb 1-2: reset full-speed USB device number 3 using ohci-ps2
usb 1-1.3: new full-speed USB device number 5 using ohci-ps2

There’s a USB wifi device (RT chipset 3070 with the rt2800usb driver) attached, in addition to a keyboard with a hub, etc.

frno7 commented 2 years ago

@frno7 You are correct and this highlights I badly need a new capture card as I couldn't even see that line on my screen :)

@immolo, I’m currently using the Open Source Scan Converter (OSSC) attached to a PlayStation 2 component cable. There are cheap HDMI adapters for the PlayStation 2. Some are better/worse than others regarding flickering, colours, contrast, and so on, as I’ve noticed. The ones I tested handled up to 1920×1080p, but I recall some of the VESA modes fail:

https://github.com/frno7/linux/blob/59a11ab94a4020408c7dfbf92bd55778e17b43f1/drivers/video/fbdev/ps2fb.c#L234-L255

immolo commented 2 years ago

Someone has recommended me an adapter that will work with my hdmi capture card so I'll try that first but if not I'll look into the OSSC.

Anything has to be better than what I'm dealing with though at the moment:

20220509_194350

frno7 commented 2 years ago

@immolo, you might provisionally consider a bigger font, maybe 8x16 or even 16x32 rather than 8x8, if video quality is poor. :-) There’s a selection of them in the kernel (and it’s relatively simple to tailor a new font to taste):

  │ │    [*] Select compiled-in fonts                                     │ │
  │ │    [ ]   VGA 8x8 font                                               │ │
  │ │    [ ]   VGA 8x16 font                                              │ │
  │ │    [ ]   Mac console 6x11 font (not supported by all drivers)       │ │
  │ │    [ ]   console 7x14 font (not supported by all drivers)           │ │
  │ │    [ ]   Pearl (old m68k) console 8x8 font                          │ │
  │ │    [*]   Acorn console 8x8 font                                     │ │
  │ │    [ ]   Mini 4x6 font                                              │ │
  │ │    [ ]   Medium-size 6x10 font                                      │ │
  │ │    [ ]   console 10x18 font (not supported by all drivers)          │ │
  │ │    [ ] Sparc console 8x16 font                                      │ │
  │ │    [ ] Sparc console 12x22 font (not supported by all drivers)      │ │
  │ │    [ ] Terminus 16x32 font (not supported by all drivers)           │ │
immolo commented 2 years ago

@immolo, you might provisionally consider a bigger font, maybe 8x16 or even 16x32 rather than 8x8, if video quality is poor. :-) There’s a selection of them in the kernel (and it’s relatively simple to tailor a new font to taste):

@frno7 That's a great idea however for whatever reason my cross compiler ends up building a 74MB kernel no matter what I do so I need to fix that issue first, strangely though anything else I can build and run on the PS2.

frno7 commented 2 years ago

@frno7 That's a great idea however for whatever reason my cross compiler ends up building a 74MB kernel no matter what I do so I need to fix that issue first, strangely though anything else I can build and run on the PS2.

Are you looking the vmlinux file now? Mine is 86 MB, but vmlinuz comes down to about 4 MB, compressed with debug omitted, etc.

immolo commented 2 years ago

Are you looking the vmlinux file now? Mine is 86 MB, but vmlinuz comes down to about 4 MB, compressed with debug omitted, etc.

I owe you a beer as you just made me understand the mistake I'm making with building kernels.

AKuHAK commented 2 years ago

@AKuHAK, what would dmesg | grep rom say, if you put it in your /sbin/init?

I tried to add this command into init - it seems there is no effect. Since I don't have a Linux machine at the moment - I added this line into GitHub workflow.

          INSTALL_MOD_STRIP: 1
        run: |
          sed '29 i dmesg | grep rom' $INSTALL_MOD_PATH/sbin/init

however, it seems that this has no effect - I cannot see any additional messages on the screen.

My_Great_Game_-_My_Great_Capture_2022-05-19_23-04-46 tried with the latest kernel, the cursor keeps blinking but USB devices do not respond. Strange that the machine's name is unknown.

frno7 commented 2 years ago

I tried to add this command into init - it seems there is no effect. Since I don't have a Linux machine at the moment - I added this line into GitHub workflow.

          INSTALL_MOD_STRIP: 1
        run: |
          sed '29 i dmesg | grep rom' $INSTALL_MOD_PATH/sbin/init

however, it seems that this has no effect - I cannot see any additional messages on the screen.

The effect from sed is printed on the standard output. It needs the -i option to edit the file in-place, so

          sed -i '29 i dmesg | grep rom; sleep 10' $INSTALL_MOD_PATH/sbin/init

would modify the /sbin/init file as intended. One could add ; sleep 10 after grep rom for an extra pause. :-)

Strange that the machine's name is unknown.

The name is determined, in part, by the ROM version, so if the ROM isn’t working there will be troubles obtaining the name too:

https://github.com/frno7/linux/blob/59a11ab94a4020408c7dfbf92bd55778e17b43f1/arch/mips/ps2/identify.c#L58-L77

Finally, I’d suggest adding #define DEBUG at line 7, here:

https://github.com/frno7/linux/blob/59a11ab94a4020408c7dfbf92bd55778e17b43f1/arch/mips/ps2/rom.c#L5-L9

That’ll active some extra pr_debug to help determine the cause of the ROM failure.