Linux 2.6 on PS2

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

eth0, I know what you mean, but the problem is that at this stage we need experienced toolchain and kernel hackers. Such people with time to spare on something like this are in very short supply so it's really the lack of knowledgable people rather than the lack of docs that's the problem. Of course, docs can be used to teach people but I'm not about to write a book on toolchain hacking. The PS2-specific stuff is just the icing on the cake, you need to understand the toolchain before you can seriously start messing with it. Having said all that, I only learnt what I know from an online crash course in MIPS assembly and staring at the GCC source for days on end. Besides writing a guide on how to build the toolchain, the best I can probably do is document my patch so far to explain why I have made the changes I have.
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

Gah! Clearly I'm not with it at the moment. I was getting ldc1/sdc1 confused with lld/scd. The latter two are also missing from the EE but as I originally thought, GCC doesn't seem to use them. The former two are missing because the EE only has 32-bit floating point registers. But the error involves movdi_64bit, which I thought was just for integers, not floats. I'm still quite confused!
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

I've just had a look at mips.c in GCC SVN. It just so happens that the code that deals with this was significantly changed just 7 days ago. I think this new code will help me to fix the problem. The trouble is I don't want to start using GCC SVN but I don't exactly want to wait for the next release either, especially since the last one was 3 days ago and didn't include these changes. Hmm.
pontus
Posts: 2
Joined: Sun Sep 30, 2007 2:59 am

Post by pontus »

I found that changing to O32 ABI gets rid of the sdc1 et al. I believe the N32 ABI is defined for 64-bit floating point registers, so the quickest way to a working Linux 2.6 could well be O32.
Mega Man
Posts: 260
Joined: Sat Jun 18, 2005 3:14 am
Contact:

Post by Mega Man »

For your information my kernelloader supports now USB with linux. So you can now use your USB keyboard with initrd. Support for mc and pad will follow soon.

http://mitglied.lycos.de/ps2dev/linux.html

Is there some progress with linux 2.6 and the gcc?
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

That's fantastic news, man. It'll help a lot.

I got distracted when I decided to take up the task of cleaning up the Unreal/UT ebuilds on Gentoo. I've very nearly finished that now so I should be getting back to things soon after getting back home. I'm currently away sorting out wedding plans. Such a hectic life I lead. :P
Mega Man
Posts: 260
Joined: Sat Jun 18, 2005 3:14 am
Contact:

Post by Mega Man »

Best wishes for your wedding.

I added support for memory cards and enabled USB also when ps2link is used for debugging (intrelay.irx).

http://mitglied.lycos.de/ps2dev/linux.html
Mega Man
Posts: 260
Joined: Sat Jun 18, 2005 3:14 am
Contact:

Post by Mega Man »

I added support for ps2 pads in kernelloader.
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

The wedding isn't till May but thanks. :)

It sounds like you've covered just about everything in that loader. Is there anything else left to do?

Not a whole lot to report here. Before the break, I tried a snapshot of GCC but couldn't figure out the previous problem. Since returning, I've grabbed a newer snapshot. The MIPS area seems to be very active and many of the changes are relevant but I'm still facing the same problem at the moment. I have some ideas now, though. I just noticed that they changed the names of the multiply/divide registers and now they kind of clash with the names we were using for the PS2's own registers so I'm going to have to go through the whole patch and change register names all over the place. Doh!
Mega Man
Posts: 260
Joined: Sat Jun 18, 2005 3:14 am
Contact:

Post by Mega Man »

I think I only need to change TGE to get everything working. The loader seems to be stable.
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

I'm now working with a GCC snapshot dated 20071130. I've got the -linux target to build again. I think the reason it failed is because I wasn't redefining LONG_DOUBLE_TYPE_SIZE as 64 anymore. The default is 128 and setting it to 128 causes the TF/TC mode stuff to be included in libgcc. I'm not 100% sure but I think that stuff requires TF floating point emulation to be built but we can't use that because I think it requires TI support in hardware. The R5900 does have that but I won't add support for it until the end. Phew!

So I built the -elf target again and starsim still runs. I was about to post this but then thought I'd better try madplay too. Somewhat good news. It gets one line further than it did before but it still doesn't work and unfortunately, the machine freezes up so I can't diagnose the problem. Hmmm.

Code: Select all

pksh version 2.1
 Connecting to 192.168.1.204
pksh> iopexec isjpcm.irx
log: IOP cmd: 1 args
log: iSjPCM v2.2 - by Sjeep, Lukasz Bruun & Evilo 
log: iSjPCM: RPC Initialize
log: loadmodule: id 33, ret 0
pksh> eeexec madplay.elf bass.mp3
log: unmounting
log: unmounted
log: Get Reboot Request From EE
log: ps2ip_ShutDown: Shutting down ps2ip-module
log: tty mounted
log: host: mounted
log: IOP cmd thread started
log: Naplink thread started
log: loadbuffer: id 31, ret 0
log: loadmodule: fname rom0:CLEARSPU args 0 arg 
log: clearspu: completed
log: loadmodule: id 32, ret 1
log: read/write allocate memory 4000
log: EE: Cmd thread
log: loadelf: fname host:madplay.elf secname all
log: loadelf version 3.30
log: Input ELF format filename = host:madplay.elf
log: 0 00100000 00038000 ....
log: 1 00138020 00025fd8 ...
log: Loaded, host:madplay.elf
log: start address 0x100158
log: gp address 00000000
log: MPEG Audio Decoder 0.15.2 (beta) - Copyright (C) 2000-2004 Robert Leslie et al.
d3roga
Posts: 1
Joined: Tue Dec 04, 2007 7:43 pm

Post by d3roga »

I've been quite impressed with your work on getting linux 2.6 to run on PS2. So I thought that I'd try to do some work on it on my own too.

If I've understood correctly the latest binutils patch is for version 2.16 (http://gps2.aura-online.co.uk/ was down so couldn't check the latest updates). I've been digging around binutils a bit and decided on trying to bring the patch up-to-date for version 2.18.
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

Hey. Thanks for getting involved.

The server crashed last night but it's up again now. Sorry about that. The latest binutils patch is for 2.16.1. The work was initially done by the Gentoo user garlicbread but he didn't actually try building or running anything with it. It needed further fixing up, which I did, and I also separated out the R5900, IRX and DVP patches. I haven't tested the DVP stuff at all but that isn't important right now. garlicbread said he also tried to patch up to 2.17 but had some problems. Maybe they weren't serious though.

I'm happy with binutils as it is because 2.16.1 is still relatively recent and works adequately with the latest stuff. Still, you're welcome to take it further if you want! I haven't made any changes to binutils since the last commit so what's in the repository now is the latest.
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

Great news! madplay doesn't crash anymore! It doesn't play any sound either but this is still a step forward.

Code: Select all

pksh version 2.1
 Connecting to 192.168.1.204
pksh> iopexec isjpcm.irx 
log: IOP cmd: 1 args
log: iSjPCM v2.2 - by Sjeep, Lukasz Bruun & Evilo 
log: iSjPCM: RPC Initialize
log: loadmodule: id 33, ret 0
pksh> eeexec madplay.elf bass.mp3 
log: unmounting
log: unmounted
log: Get Reboot Request From EE
log: ps2ip_ShutDown: Shutting down ps2ip-module
log: tty mounted
log: host: mounted
log: IOP cmd thread started
log: Naplink thread started
log: loadbuffer: id 31, ret 0
log: loadmodule: fname rom0:CLEARSPU args 0 arg 
log: clearspu: completed
log: loadmodule: id 32, ret 1
log: read/write allocate memory 4000
log: EE: Cmd thread
log: loadelf: fname host:madplay.elf secname all
log: loadelf version 3.30
log: Input ELF format filename = host:madplay.elf
log: 0 00100000 00037ff0 ....
log: 1 00138010 00025fe8 ...
log: Loaded, host:madplay.elf
log: start address 0x100158
log: gp address 00000000
log: MPEG Audio Decoder 0.15.2 (beta) - Copyright (C) 2000-2004 Robert Leslie et al.
log: loadbuffer: addrres 51b00 args 0 arg 
log: iSjPCM v2.2 - by Sjeep, Lukasz Bruun & Evilo 
log: iSjPCM: RPC Initialize
log: loadbuffer: id 33, ret 0
log: iSjPCM: Memory Allocated. 1455872 bytes left.
log: iSjPCM: Sound buffers cleared
log: iSjPCM: SPU2 initialised!
log: iSjPCM: Setting up playing thread
log: iSjPCM: Entering playing thread.
log: open name host:bass.mp3 flag 1 data 44978
log: open fd = 2
log: 0 frames decoded (0:00:00.0), -inf dB peak amplitude, 0 clipped samples
I had an idea that turned out to be a rather good one. GCC uses a macro called TARGET_NEWABI to set a lot of other macros. It's definition is usually (mips_abi == ABI_N32 || mips_abi == ABI_64). As far as I understand it, EABI should also included here but it's not because it's been deprecated by GCC. Redefining this with EABI included did the trick. :)

I've also been trying some other stuff in the ps2dev repository. SDL, SDL_image, SDL_gfx and their dependencies all build without a hitch but none of the tests successfully run just yet. Some of them crash with a register dump so I do have some leads to follow.
GhostWolf
Posts: 1
Joined: Wed Dec 12, 2007 6:28 am

Post by GhostWolf »

I have been looking for Linux on the PS2 so I'm looking forward to the end user release of this.
Good Work people! and good luck!
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

You could be waiting some time but thanks.

Work is heavy at the moment but I'm still finding a little time to work on this. I'm out of ideas for now so I've started adding support for the 128-bit MMI instructions. This seems to be easier than I originally thought. Once that's done, this GCC will be actually have all the features of 3.2.2 and more! Then it'll just be a case of actually getting it to work properly. Piece of cake. ;)
Mega Man
Posts: 260
Joined: Sat Jun 18, 2005 3:14 am
Contact:

Post by Mega Man »

I have a new kernelloader release 1.0.
Now I have also a binary release it can load kernel and initrd from USB memory stick or ps2 memory card.

http://mitglied.lycos.de/ps2dev/kernell ... loader.elf

Added
Here are files that can be used for testing:
http://mitglied.lycos.de/ps2dev/vmlinux
http://mitglied.lycos.de/ps2dev/initrd.gz
Last edited by Mega Man on Tue Dec 25, 2007 1:38 am, edited 1 time in total.
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

That's a great Christmas present. :D
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

I fancied a change of scenery so I decided to have a go at getting Linux 2.6 to recognise the APA partition format. I thought it would be easy. Sadly not. The partition stuff has changed a little bit since 2.4.17. This alone wouldn't be so bad but there's another problem. APA partitions are not (always) contiguous. They are split into 512MB segments across the disk. It looked as though support for non-contiguous partitions had been removed but when I tried to find out why that was, I realised that they weren't supported in vanilla 2.4.17 either. It seems this feature is exclusive to MontaVista's kernel. I'm not sure whether bringing this feature up to date will be possible. It will probably make getting any patch committed to the official kernel quite tricky. Bugger.
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

I've spent much of today staring at kernel source and I now have a fairly solid idea of how Linux handles partitions. Fascinating! I have a rough idea of how I'd go about adding support for non-contiguous partitions but I'm not confident enough to actually give it a shot right now. There are a few bits in the MontaVista code (something to do with hashes?) that I don't understand the relevance of. Maybe they don't really do anything but then why would they be there? I also have to be careful because screwing this up could nuke my PC's hard drives! I'd certainly test it in an emulator first. Maybe another time. Back to GCC!
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

To handle non-contiguous partitions, use the device-mapper. You could even set it all up from userspace using "dmsetup create", see man dmsetup and Documentation/device-mapper/linear.txt for examples.
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

Aha! That's exactly what I need. Thanks. I had looked around but all I could find was LVM, which isn't quite the same thing. I would like it to be possible to boot from an APA partition but I guess an initrd/initramfs could do the trick there.
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

I'll continue the APA stuff here...

http://forums.ps2dev.org/viewtopic.php?p=62801
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

Minor news. After toing and froing with the maintainer of gnuconfig since August, with him changing his mind three times, I managed to convince him to add mips64r5900 to config.sub. I'm not sure when this update will hit Portage. I have asked for a bump but it was last updated very recently.
mazxim
Posts: 23
Joined: Thu Jan 24, 2008 12:29 am
Contact:

Post by mazxim »

Chewi, you are a MYTH man! Thanks so much for your hard work, don't give up this project, I simply hope that you still having fun with all this matter! ;)

For who don't know how much efforts this guy have put on the project, here there's a link:

http://gps2.aura-online.co.uk/trac/gentoo-ps2/ <--- GENTOO ON PS2 !!!

..good speed!
jaymacdonald
Posts: 22
Joined: Sat Feb 24, 2007 7:20 am

Post by jaymacdonald »

Hi, could you add USB->USB support, like NapLink (http://naplink.napalm-x.com/)? Thanks.
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

Some of you guys are crazy. I appreciate the thanks but I'm not that great. Really. =P A little research into these things goes a long way. I really wish some of you would have a shot at this yourselves but you don't seem to believe me when I say it's not THAT scary.

jay, I'm not familiar with NapLink and I don't think it's relevant to what I'm doing, I'm afraid.

I've only had a little time lately. I usually only have time to renew the patches against the latest GCC snapshot and by the time I get around to looking at it again, a new snapshot has already come out. I hope 4.3 gets released soon.

I've just built myself a new machine. Quad core. :D That should make building GCC much faster. I also plan to switch back to JFS. Deleting and unpacking GCC on XFS takes aaaages.
jaymacdonald
Posts: 22
Joined: Sat Feb 24, 2007 7:20 am

Post by jaymacdonald »

Chewi wrote:Some of you guys are crazy. I appreciate the thanks but I'm not that great. Really. =P A little research into these things goes a long way. I really wish some of you would have a shot at this yourselves but you don't seem to believe me when I say it's not THAT scary.

jay, I'm not familiar with NapLink and I don't think it's relevant to what I'm doing, I'm afraid.

I've only had a little time lately. I usually only have time to renew the patches against the latest GCC snapshot and by the time I get around to looking at it again, a new snapshot has already come out. I hope 4.3 gets released soon.

I've just built myself a new machine. Quad core. :D That should make building GCC much faster. I also plan to switch back to JFS. Deleting and unpacking GCC on XFS takes aaaages.
Great work. Sorry, I was refering to the bootloader that Mega Man was creating. (for loading bootimage from naplink).
Also, I am in possession of the Sony RTE, but no hard drive or ethernet. Can I use a disc and the RTE to load Gentoo On my PS2?
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

You mean a read-only system on a DVD? Maybe. If I remember rightly, loading ROMs from a disc for SNES-Station requires you to do the swap trick so the same rule probably applies here. Unless your console is modded, of course. That's also assuming that recent Gentoo stuff is working, which it isn't, but you could do the same for Black Rhino or whatever.
jaymacdonald
Posts: 22
Joined: Sat Feb 24, 2007 7:20 am

Post by jaymacdonald »

Chewi wrote:You mean a read-only system on a DVD? Maybe. If I remember rightly, loading ROMs from a disc for SNES-Station requires you to do the swap trick so the same rule probably applies here. Unless your console is modded, of course. That's also assuming that recent Gentoo stuff is working, which it isn't, but you could do the same for Black Rhino or whatever.
My system has the independence exploit, so I can run homebrew and the rest. (Swap-Magic too).
The bootloader is a step at recreating the RTE, or am I wrong?
Post Reply