-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some machines lacks rom0:OSDCNF #28
Comments
This comment has been minimized.
This comment has been minimized.
Interesting, thanks! I tried to remove It would be great to have SCPH-10000, SCPH-15000, DTL-H10000, TOOL and Namco working properly with Linux as well, although I am unable to test those particular models myself, unfortunately. |
I can refer only to standard practice for resetting IOP: SifInitRpc(0);
#ifdef _DTL_T10000
while (!SifIopReset("rom0:UDNL", 0))
;
#else
#ifdef __DECI2_DEBUG
while (!SifIopRebootBuffer(&deci2_img, size_deci2_img))
;
#else
//Final IOP reset, to fill the IOP with the default modules.
while (!SifIopReset("", 0))
;
#endif
#endif
dev9Initialized = 0;
while (!SifIopSync())
;
SifInitRpc(0);
SifSetCmdBuffer(OplSifCmdbuffer, OPL_SIF_CMD_BUFF_SIZE); Taken from OPL. You can safely ignore DTL and DECI2 exception but the rest should be correct. So you should init SIF, then you should wait until SifIopReset is completed, then wait until SifIopSync is completed and only then init SIF again (!) and do the rest. |
Please check this thread for proper ps2 initialize. |
Linux kernel SIF initialisation is currently documented as thirteen steps: Lines 740 to 781 in c94ed72
It seems OPL Steps 1 and 2 are repeated in 7 and 8, which I believe corresponds to the double I seems you are right that IOP module loading must be conditional on the machine model, which means that |
You are not using any part of our homebrew ps2sdk for unknown reason. I see your post that there is something strange after you boot kernel from uLaunchELF, this is because each ps2 app (firstly you are building ps2 app) should reset ps2 into proper state, but it seems that you are depending of what uLaunchELF does before and do not clear and set up everything. Also sometimes official Sony recomendations are not the best and it is better to use fixes from homebrew ps2sdk. But anyway if you are not using ps2sdk functions you should clone them and clone them as close as you can: |
@AKuHAK I believe the PS2Linux folks have traditionally not used the homebrew PS2SDK as they have the RTE library. The Linux kernel also replaces the EE kernel. The proper way to reboot the IOP without any IOPRP image, is to pass an empty string. I used to pass a NULL, until I realize that it was only possible with the homebrew SDK's SifIopReset() function. If you use OSDCNF, it will only work with consoles that have OSDCNF. If your software stops working after not using OSDCNF, then you shaped your work to be dependent on the board-specific modules (X-modules, OSDSND etc). OPL's method of rebooting the IOP is more complicated because I also designed it to have a custom reboot procedure to load in DECI2 modules (which are missing from the CEX/DEX ROM) for debugging. You really only need to initialize the SIF, issue the reset command, wait for completion, and then finally bring up the SIF interface.
(1) and (2) are done during initialization of SIFCMD. SifInitRpc() has to be called before the reboot. This will do a few things. It will internally call SifInitCmd(), to initialize SIF communications with the existing IOP kernel. It will also initialize the IOP side with the new SIFCMD receive buffer address. So if you don't do this, it could corrupt EE memory when you reset the IOP.
Although this is true, I think you should not be using board-specific modules. This has been a wrong practice that has been going on for too long.
The WS mode ROM version is 0100 - so it will be treated as a "SCPH-10000". Sony would print an "Unknown" if the model cannot be determined, which is something this code is doing differently. The TOOL used to not have OSDSYS in its ROMs because it used to not boot discs directly. This function was added later on, for people to test their master discs without needing to write some code. Who knows why Sony would want to try to read the model number from OSDSYS from a late SCPH-10000/SCPH-15000/DTL-H10000. At the end of the day, we haven't found one that doesn't isn't labelled as a "SCPH-10000" by OSDSYS. But this was how Sony did it for the v1.01 ROMs. |
That is true, and as @sp193 notes, Linux replaces the EE kernel. Linux is an operating system, after all. One of the goals is to run entirely on the hardware. Another goal is to use fully modern and up-to-date versions of tools such as GCC, which is particularly important to compile modern Linux applications. The older Linux 2.6 kernel relies on the BIOS for certain services, perhaps most notably handling of the SIF, but the latest Linux kernel discards the BIOS and handles the hardware directly instead. Linux has several advanced sub-systems, for example related to DMA, and hopefully these can be put into effective use with the capabilities of the PS2 hardware. The great common goal for both the PS2SDK and Linux for the PS2 is, as I see it, to learn about, explore and have fun with the hardware. Having two, or more, independent implementations is a strength, I think, as projects can learn techniques from the others that do things differently. 😄 This Linux project does not attempt to mimic Sony application interfaces as much as the PS2SDK. However, when handling the IOP in particular, some level of SIF protocol compatibility is necessary since the IOP is operated from ROM routines. Linux is concered with MIPS o32 and n32 ABI compatibility. The FPU, for example, is emulated in software for standard MIPS ELF executables due to FPU hardware anomalies, as described in #3.
Yes, as described in #7, the Linux kernel currently uses uLaunchELF as a boot loader. This works well, except for the CP0.Status anomaly. Perhaps a lower-level loader, as described in #4, could be used as a complement or a replacement in the future.
The Academic Free License version 2 licence used for the PS2SDK is considered to be incompatible with the GPL for Linux. This is unfortunate, and means that we cannot copy code between the projects unless it is dual-licenced with for example MIT or some of the other compatible ones.
This is very interesting. Why is repetition required? I have not observed that IOP reset is unreliable. |
All IOP kernel modules are replaceable through the IOP reboots (by supplying an IOPRP image to UDNL), but you'll be defining your own standard if you deviate from how Sony designed it.
The IOP reboot involves sending a SIFCMD message. Within (sce)SifSendCmd() is a call to SifSetDma(), which can fail if the queue within the kernel is full. Although we all know that it's not supposed to be full at that point. Perhaps, it's just a good practice to ensure that your code will never fail, by handling all return values. Whether to do this or not, is up to you. |
Thanks, this is valuable information! Sony compatible IOP modules are sometimes of limited use, since Linux already has sub-systems for USB, file systems, networking, and various other devices and protocols. It can make sense to write new IOP modules that work effectively with these Linux sub-systems, at suitable interface and protocol levels. The low-level SIF DMA command and RPC protocol can probably remain the same though, as I’m not aware of any particular reason to do that differently. The iopmod project is a starting-point for IOP modules for Linux. An IRQ relay module is currently implemented, as it is needed by the current USB OHCI device driver. Handling of the IOP is a bit loose at present, so things may change. 😄
Yes, it seems reasonable for the Linux kernel, when invoked by a boot loader, to expect that the IOP is idle and not in the middle of some transactions.
All return codes that I’m aware of are checked by the Linux kernel. However, it doesn’t make multiple attempts at resetting the IOP. I will have to think about this. |
But there is still a problem that you have an error when trying to remove OSDCNF, I personally don't think that this is because board-specific modules are loaded. To my mind its because IOP is not resetting with standards that cause problems with some arguments.
I understand your point of view, but to my mind, it is overkill and reinventing the wheel. You still are building a PS2 app (in the first place) and only secondly Linux system. You are trying to make as much as possible from the Linux side which can cause anomalies if you are trying to make all from scratch. |
SIF RPC bind will fail if the IOP RPC server module does not exist - like if you are using libpad without loading the right PADMAN version. |
The IOP library dependencies are More specifically, the
Note: When it says for example Similarly, the
So, some of these dependencies are not initialised by the IOP unless Looking at the contents of
Yes, that sounds reasonable!
What modules would you recommend to resolve the dependencies for |
Among the imports you have listed, I cannot see any that are likely to be only available with the board-specific modules. Previously, you wrote that it was a problem with binding with a SIF RPC. Have you determined that it was either of those two IOP modules that could not be loaded, due to a dependency problem? In other words, (Sif)LoadModule returned the exact error code which indicates that. |
@frno7 maybe you can provide full kernel log? and the difference between 2 versions IOP_RESET_ARGS |
The two IOP modules Line 440 in 1a3ad68
Somehow the Lines 530 to 533 in 1a3ad68
For reference, this is the corresponding code in PS2SDK: Perhaps the modules fail to initialise themselves, somehow. The first part to start to executing in any IOP module is this (in two variants, conditional on
But since loading And we ought to end up here: This is where threads and RPC services are set up for Hmm... Any ideas? |
If your iop_reset_arg() function is meant to issue the reboot command to the IOP, it does not look like it supports a NULL parameter. You should pass an empty string. Are those modules loaded from a buffer in EE memory? If so, then I would also like to ask whether you actually have an implementation like mrbrown's SBV LoadModuleBuffer() patch. Sony does something like that too when rebooting the IOP for the HDD Browser with an embeeded IOPRP image, since the v1.3.4 kernel has no support for SifLoadModuleBuffer(), even though the IOP function is there. Without it, LoadModuleBuffer() from the EE does not work because the switch-case block on the IOP doesn't call the function. This would also explain what you have observed because OSDCNF (and EELOADCNF) does include XLOADFILE instead of LOADFILE, which has a working implementation of this RPC function. |
The empty string is passed (as opposed to previous Lines 581 to 607 in 1a3ad68
Yes, always.
No, I wasn’t aware of that patch. Is it this one? https://github.com/ps2dev/ps2sdk/blob/master/ee/sbv/src/patch_enable_lmb.c
Oh, many thanks! |
Yes, that is the patch. You need to apply something like this, before you attempt to call LoadModuleBuffer() from the EE. It requires the SIF, LOADFILE and IOP heap services. |
commit 3dd550a upstream. The syzbot fuzzer provoked a slab-out-of-bounds error in the USB core: BUG: KASAN: slab-out-of-bounds in memcmp+0xa6/0xb0 lib/string.c:904 Read of size 1 at addr ffff8881d175bed6 by task kworker/0:3/2746 CPU: 0 PID: 2746 Comm: kworker/0:3 Not tainted 5.3.0-rc5+ #28 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: usb_hub_wq hub_event Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0xca/0x13e lib/dump_stack.c:113 print_address_description+0x6a/0x32c mm/kasan/report.c:351 __kasan_report.cold+0x1a/0x33 mm/kasan/report.c:482 kasan_report+0xe/0x12 mm/kasan/common.c:612 memcmp+0xa6/0xb0 lib/string.c:904 memcmp include/linux/string.h:400 [inline] descriptors_changed drivers/usb/core/hub.c:5579 [inline] usb_reset_and_verify_device+0x564/0x1300 drivers/usb/core/hub.c:5729 usb_reset_device+0x4c1/0x920 drivers/usb/core/hub.c:5898 rt2x00usb_probe+0x53/0x7af drivers/net/wireless/ralink/rt2x00/rt2x00usb.c:806 The error occurs when the descriptors_changed() routine (called during a device reset) attempts to compare the old and new BOS and capability descriptors. The length it uses for the comparison is the wTotalLength value stored in BOS descriptor, but this value is not necessarily the same as the length actually allocated for the descriptors. If it is larger the routine will call memcmp() with a length that is too big, thus reading beyond the end of the allocated region and leading to this fault. The kernel reads the BOS descriptor twice: first to get the total length of all the capability descriptors, and second to read it along with all those other descriptors. A malicious (or very faulty) device may send different values for the BOS descriptor fields each time. The memory area will be allocated using the wTotalLength value read the first time, but stored within it will be the value read the second time. To prevent this possibility from causing any errors, this patch modifies the BOS descriptor after it has been read the second time: It sets the wTotalLength field to the actual length of the descriptors that were read in and validated. Then the memcpy() call, or any other code using these descriptors, will be able to rely on wTotalLength being valid. Reported-and-tested-by: syzbot+35f4d916c623118d576e@syzkaller.appspotmail.com Signed-off-by: Alan Stern <stern@rowland.harvard.edu> CC: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/Pine.LNX.4.44L0.1909041154260.1722-100000@iolanthe.rowland.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
@frno7 I see you created wiki pages. Just one note - you created the page with compatible models. |
Thanks, @AKuHAK! I’m happy you noticed that the wiki is being updated only some days and hours ago! I’m getting some help too: Денис Визница supplied a detailed guide to building an R5900 cross compiler from sources, for example. Maybe we can be even more precise about compatibility? Some of the models that are expected to work have not actually been tested (yet) with a recent Linux kernel, as far as I know. Some of the models that you list may eventually be made compatible, while others are likely to remain incompatible (mostly those incompatible with uLaunchELF). Would you like to contribute by editing the wiki yourself? |
@frno7 Oh I cannot say that your ps2 Linux implementation will definitely work on all other models :) I just mentioned all models where your implementation will DEFINETYLY (100%) freeze on start. At least for now., until this issue is resolved. There can be other incompatibilities which I didnt catch. I am still waiting for precompiled binaries. I will try to build the system again when I have more spare time. As about wiki - you can just insert a reference to this issue. I think this will be enough. |
@AKuHAK, please review the updated model compatibility. I’m aiming for a comprehensive, structured, and easy to understand wiki. Issues such as this one are good for discussions, but I think that the wiki ought to have the conclusions. Has anybody heard from @kernle32dll lately? He had interesting ideas in #34 (comment). |
Doesn't 9000x also support everything "normally" since the release of PS2 Fortuna? |
Great, thanks, @mirh & @AKuHAK! I have updated model compatibility. By the way, I linked uLaunchELF to your repo. Is it an authoritative source? |
Yes, uLaunchELF that I host is the official wLaunchELF repository. BTW you can also add Sony Bravia KDL-22PX300 into expected to be compatible list :) |
Done, thanks, @AKuHAK! |
Oh, we should take a closer look at those, and try to fix them. Is it on real hardware?
Actually (the old) INITRD and (the new) INITRAMFS are different things, confer the article on what is initramfs?, and especially the section all this differs from the old initrd in several ways. My apologies, I previously failed to recall that when INITRD bails out it’s perfectly natural because INITRAMFS is the one we’ve installed anyway.
Cool, I’ve never attempted to boot Linux with PCSX2. :-) |
Yes it is on my SCPH-70003 that can be seen in this "picture" |
maybe it is because I compiled busybox with default options... don't know |
when this pr will be merged, such things can be downloaded directly here |
As a simple exercise I propose that you try |
Tested. I saw the same hid_errors. While I do not have them in the compiled kernel of mine. Maybe some module to activate in bootscript - like ohci-ps2, usbhid or hid-generic - should solve them.
I was wrong saying that there is the only resolution for gs-drm. There are lines in dmesg output txt file: Launching @AKuHAK's kernel I saw a high resolutioned screen... Hint me, please, how to change it - need I add something in "modprobe gs ..." ?
If to be seriously busy into that trifle problem, that should be fixed once and for all, so the people will never be confused about it. Maybe to add some INITRAMFS/INITRD presence checks? If/else, "initramfs detected"... |
Hmm... interesting. X86-64 is uncommon in this household, and on the decline. I’ll see what I can find for use with the Docker packages. :-)
I highly recommend setting up a network interface via USB, until issue #19 completes. I personally use wifi, but Ethernet is simpler, if one has such a USB device. I’ve compiled Dropbear for remote SSH login, remote scripting, and so on. It could be a consideration for INITRAMFS inclusion, eventually. For development and testing purposes, TCP/IP access is much faster and convenient than using a USB keyboard/filesystem directly attached to the PlayStation 2 hardware.
I think it’s best to avoid the DRM prototype driver, because it’s inferior to the fbdev driver in all respects. I consider dropping it, now that fbdev is actively maintained again, and the DRM no longer is a requirement for issue #1. Also, the DRM subsystem has a lot of known problems with vintage video equipment.
Agreed. The confusing INITRD print statement comes from linux/arch/mips/kernel/setup.c Line 251 in de37b46
which is part of the MIPS architecture kernel setup, but otherwise unrelated to the PlayStation 2 parts. Anyone could post the MIPS maintainers a patch to clear that up. |
I used init scripts from the wiki. These scripts are populated almost as-is into the Docker container. |
@AKuHAK how long does it take? I’m clocking approximately 13 seconds from the first
to the shell prompt. It’s apparently possible to boot the Linux kernel in less than a second, which would be marvellous. :-) |
It takes more cause my TV loose resolution and I should wait for about 20 seconds until the screen will become alive again |
We could make the ps2fb driver pick up the video seamlessly, without any flickering at all. I had it myself a few years ago, when the driver wasn’t fully developed. However, since GS registers cannot be read, confer #68 (comment), the driver will have to assume that the video resolution matches. Alternatively, perhaps we can come up with some kind of protocol to negotiate what the video resolution is from wLaunchELF. If it doesn’t match the expected, it’ll all be garbled output. Likewise with the currently hardcoded 1920×1080p boot console. We could make it inherit the preexisting video resolution from wLaunchELF, for a completely flicker-free video boot. |
During the work day I was thinking something about it. We have two facts - @AKuHAK launched the system with initrd disabled; initrd and initramfs are different things and do not depends one from another. Then just simple to disable initrd in the kernelconfig ps2_defconfig file, and that message will not bother anyone anymore) Moreover, that will enlight the result vmlinuz.elf kernel a bit.
If you ask me, I would not recommend to achieve that. There are manually reasonably written "sleep" lines in the init scripts. If to use init scripts without "sleep" lines, there might be unordered occasions happens. For example, mount a partition with further file accessing in the exact path - the example occasion is "no such file or directory" output, and that's because the system was not in time to mount the partition before the file access from it. |
How? INITRD and INITRAMFS seem to use the same kernel config knob: Lines 1213 to 1214 in 59a11ab
|
With proper dependencies no sleeping is necessary at all, and we'd have maximum speed. :-)
I don't think the |
Line 49 in de37b46
TBH this particular issue can be closed, cause now IOP is rebooted with a null string. So hardware compatibility list is not actual anymore. There still can be incompatibilities. For example, you are mapping rom1 into memory, but many consoles just doesnt have rom1 at all (like protokernels, desr, TEST consoles). But I dont think that this will prevent kernel from booting on those consoles, so this issue technically can be closed. |
Thanks, @AKuHAK! I believe other technical difficulties remain, such as the OHCI driver directly accessing IOP memory space from the R5900: linux/drivers/usb/host/ohci-ps2.c Line 176 in de37b46
However, I think it’d be best to keep things simple and complete issue #1, before complicating drivers to accommodate rare hardware (and software emulated) models. What’s the best approach to update the list of incompatible models? Remove the link to this issue? |
You can remove the whole section: Incompatible models as currently all models should becompatible |
Closing issue per #28 (comment). Thanks again! |
If you are not already doing it, perhaps you might want to consider probing whether the ROM exists before mapping it, much like Sony does for ADDDRV and friends? ADDDRV will first map the DVD ROM (DEV1, if I remember right) to memory with the SSBUSC service, before checking whether there is a valid ROM image there. This can be seen as a problem of using the outdated idea that rom0, rom1, rom2, erom etc, belong to separate ROMs, when they belong to the same DVD ROM chip. Most retail PS2s just have them because the DVD player is built into them. |
Well, that's the issue offtopic, a background barking while big men talking :D But since that was mentioned...
Yeah, looks like there is no way to influence to that kernel message by changing something in kernelconfig; initramfs can not be "separated" from initrd in the needed way.
I gone that way. The theory: The practice:
a bit lower, from line 266:
Tested, working as expected.
However, I see you have a tendention to avoid anything kernel maintainers unacceptable and a things not related to PS2 devices parts coding) @frno7, should I keep it away from your source codes again?)) Means in not your repository. |
@Arch91, since this is an independent improvement, to the benefit of the MIPS architecture, I suggest posting it to linux-mips at vger.kernel.org with a CC to me (noring at nocrew org), explaining the confusion caused by the previous behaviour. No need to wait for issue #1 completion. Hopefully a MIPS maintainer will review your post, discuss its technical details, and eventually accept your Linux kernel patch contribution. Review the procedures on posting Linux kernel patches, should you decide to proceed. I’ve submitted several independent patches. Check |
is it possible to change the resolution by typing some command into the terminal? |
Yes, there are three main methods to configure video modes:
I just updated the video modes section on the wiki about this topic. Thanks for asking, @AKuHAK. :-) |
linux/drivers/ps2/sif.c
Line 49 in 1a3ad68
Some PS2 machines lack OSDCNF in their ROM0. For better compatibility, it will better to avoid using this parameter for resetting IOP, or at least use this parameter only on machines that have this inside ROM0.
So it will lead to incompatibility with SCPH-10000, SCPH-15000, DTL-H10000, all ps2 TOOLs, Namco systems and ps2 emulators inside ps3 and ps4.
You can read more about restrictions here: https://assemblergames.com/threads/ps2-pops-stuff-popstarter.45347/page-39#post-771470
To my mind, it will be safe to use NULL for IOP resetting but I am not quite sure. It is better to ask @sp193 about this.
The text was updated successfully, but these errors were encountered: