Linux 2.6 on PS2

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

Moderators: cheriff, Herben

alexp
Posts: 39
Joined: Tue Apr 17, 2007 12:06 am

Post by alexp »

Keep us informed if you make any interesting development
gtbX
Posts: 5
Joined: Wed Jul 25, 2007 9:23 am

Post by gtbX »

Hi, I've been following this thread for a while, and I want to start experimenting.

One question though, how do you set up gcc? I downloaded the gcc source, and applied your patch. I ran "./configure --target=mipsel --prefix=/path/in/my/home/dir && make", but it fails some ways in. Not that I expected it to be that easy (this is on linux btw). Any pointers on where to start/how to setup gcc-4?

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

Post by Chewi »

I'm just finishing up another small project before digging into this so I haven't tried it yet. I plan to use Gentoo's crossdev to do some of the hard work for me. According to the README, the target machine is supposed to be mips64el. I imagine this might change later if we manage to work some R5900-specific stuff back into the toolchain. Anyway, the CHOST should therefore be mips64el-linux-gnu or perhaps mips64el-scei-linux-gnu if you happen to do a lot of other MIPS work. scei was the manufacturer name chosen by the GNU guys. Before you build gcc though, you also need to build binutils in the same way.
alexp
Posts: 39
Joined: Tue Apr 17, 2007 12:06 am

Post by alexp »

the build command for gcc should be something like that

Code: Select all

configure   --prefix=/opt/mips64/ --target=mips64el-linux --disab
le-shared --disable-nls --disable-threads --enable-languages=c
I was using this patched version because gcc insisted on generating 64 bit instructions not present on R5900. If you manage to run a kernel build with more official compilers let me know
AdamWu
Posts: 2
Joined: Thu Jul 26, 2007 6:18 am

Post by AdamWu »

Nice work guys!

It is kind of hard to find many playstation2 related kernel discussions. I first found chewi's post on the official PS2 linux forum, then tracked to his wiki, then his post on Gentoo, and finally here.

I am dying to see the new kernel running because the official PS2 kernel is ancient and does not take advantage of many exciting new features and performance optimizations (like better caching algorithms and interrupt handling). I have worked with 2.6 kernel and I am moderately familiar with it; but I lack knowledge on mips architecture and I am struggling to get a cross compiler working... Will try my best to catch up with your work and see what I can do to help.

One thing I'd like to remind you is that, I remember reading from somewhere that r5900 cpu does not have TAS (test-and-set) instruction that the normal mips cpu has. So implementing a correct spin-lock can be tricky. Here is a research paper on this topic: http://lc.linux.or.jp/lc2001/papers/tas-ps2-paper.pdf (From my limited Japanese vocabulary, I think they gave a viable solution in the paper)

I know it mainly concerns user-level program, however, I remember seeing some spin-lock usage when I was digging in 2.6 kernel network stack. Hopefully this hint helps somewhat. :D
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

Alex, could I just ask what your reasoning was behind using the R4600 as a starting point? The Linux/MIPS wiki states that the R5900 is most like the R5000. There is very little detail there but was there any particular reason why you didn't choose the R5000 instead?
alexp
Posts: 39
Joined: Tue Apr 17, 2007 12:06 am

Post by alexp »

i'm really sorry i can't remember, r5900 is a strange beast, maybe i choose r4600 for compatibility purpose. For sure it's an empirical choice, so feel free to experiment with architecture settings
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

I've been busy. ;) I grabbed Alex's patches and had a look. I was actually more interested in the gcc patch than the kernel patch at this stage because the kernel patch is useless without a working compiler. I was very surprised at just how short the gcc patch was but not in a good way. I had a think about whether a patch this short could really meet the bare minimum required to make the R5900 work properly at all. The only conclusion I could draw was that it couldn't possibly.

To be fair, I don't really understand what the patch actually does. Perhaps Alex could explain it in a bit more detail? All he did was remove some d, < and > characters. The big comment in mips.c about PRINT_OPERAND says this...

Code: Select all

'd'  output integer constant in decimal
'<'	Turn on .set nomacro
'>'	Turn on .set macro
I can't really see how just removing those characters could effectively disable an instruction but then I still find the machine description file very cryptic so I could be missing something.

One of the best ways to know whether gcc is outputting valid code for the R5900 is to use a version of binutils patched for the R5900. The latest available patch is for 2.16.1, which is still quite recent and more than adequate. I cleaned up the opcodes, something I'd been meaning to do for a while. I stripped out the DVP code because that isn't needed right now. I also stripped out the IRX code because that probably won't be needed at all. I tested it against some files and it gave the same results as the old 2.14 version that most people here use so I deemed that a success.

I then did what was necessary to gcc 4.1.2 (Gentoo/MIPS says there's a problem with 4.2.0) to make it accept a CHOST of mips64vr5900el-scei-linux-uclibc, the same CHOST I had used for binutils. As I expected, gas screamed bloody murder because gcc was outputting instructions not present on the R5900. Using the gcc 3.2.2 patch as a guide, I then starting making the absolutely necessary adjustments. This included adding MASK_SINGLE_FLOAT to TARGET_DEFAULT, enabling floating point emulation, forcing LONG_DOUBLE_TYPE_SIZE to 64 and setting Pmode to SImode. After a few attempts, I eventually got it to build. But what to test it with?

I tried building the kernel using Alex's patch. It fell flat on its face. I then tried building uClibc 0.9.29. Even with most of the options enabled, it got all the way to the final linking before failing with a few undefined references. This was actually a better result than I expected.

Code: Select all

  CC libc/sysdeps/linux/common/ssp-local.os
  CC libc/misc/internals/__uClibc_main.os
  CC libc/inet/rpc/rpc_thread.os
  CC libc/stdlib/atexit.os
  AS lib/crt1.o
  AS lib/Scrt1.o
  AS lib/crti.o
  AS lib/crtn.o
  STRIP -x -R .note -R .comment lib/libc.a
  AR cr lib/libc.a
  STRIP -x -R .note -R .comment lib/uclibc_nonshared.a
  AR cr lib/uclibc_nonshared.a
  AR cr libc/libc_so.a
make&#91;3&#93;&#58; `conf' is up to date.
ln -fs sgidefs.h ./include/
  LD libuClibc-0.9.29.so
libc/libc_so.a&#40;difftime.os&#41;&#58; In function `difftime'&#58;
difftime.c&#58;&#40;.text+0x14&#41;&#58; undefined reference to `__floatsidf'
difftime.c&#58;&#40;.text+0x3c&#41;&#58; undefined reference to `__subdf3'
libc/libc_so.a&#40;_fpmaxtostr.os&#41;&#58; In function `_fpmaxtostr'&#58;
_fpmaxtostr.c&#58;&#40;.text+0xc0&#41;&#58; undefined reference to `__nedf2'
_fpmaxtostr.c&#58;&#40;.text+0xe8&#41;&#58; undefined reference to `__eqdf2'
_fpmaxtostr.c&#58;&#40;.text+0x10c&#41;&#58; undefined reference to `__ltdf2'
_fpmaxtostr.c&#58;&#40;.text+0x114&#41;&#58; undefined reference to `__divdf3'
_fpmaxtostr.c&#58;&#40;.text+0x1b8&#41;&#58; undefined reference to `__muldf3'
_fpmaxtostr.c&#58;&#40;.text+0x344&#41;&#58; undefined reference to `__gedf2'
_fpmaxtostr.c&#58;&#40;.text+0x3d8&#41;&#58; undefined reference to `__adddf3'
libc/libc_so.a&#40;__psfs_do_numeric.os&#41;&#58; In function `__psfs_do_numeric'&#58;
__psfs_do_numeric.c&#58;&#40;.text+0x5fc&#41;&#58; undefined reference to `__truncdfsf2'
libc/libc_so.a&#40;strtof.os&#41;&#58; In function `strtof'&#58;
strtof.c&#58;&#40;.text+0x40&#41;&#58; undefined reference to `__extendsfdf2'
/usr/lib/gcc/mips64vr5900el-scei-linux-uclibc/4.1.2/libgcc.a&#40;_fixunsdfsi.o&#41;&#58; In function `__fixunsdfsi'&#58;
&#58; undefined reference to `__fixdfsi'
make&#91;1&#93;&#58; *** &#91;lib/libc.so&#93; Error 1
make&#58; *** &#91;lib/libc.so.0&#93; Error 2
I'm not stumped yet. I have a few ideas. I know there are a few things I haven't covered like preventing gcc from emitting the ll/lld/sc/scd MIPS2 instructions. I can't figure out where these are in the machine definition. I'm not even sure if they're there at all. The Linux kernel has options for building with or without ll/sc and lld/scd but what about stuff other than the kernel? I also haven't added support for the movn/movz MIPS4 instructions yet. There are a bunch of other improvements the old patch makes but I don't think these are essential. They include support for the 128-bit instructions.

The old patch includes some code to fix the R5900 short loop length bug. I have read that it would be easier for gas to address this issue but it was done in gcc in case you were using an assembler other than gas. gas already warns the user if the loop is too short so it should just be a case of adding NOPs. That's probably easy if you know how but I don't know how! I did see a mailing list discussion with someone who was attempting to do it though so maybe I'll get in contact with them.

If you're interested in my gcc work, let me know and I'll put it up but regardless of whether you are or not, I highly recommend that you use an R5900-patched version of binutils. If you don't, you could simply be trying to run code on the PS2 that will never work.
Last edited by Chewi on Mon Jul 30, 2007 1:31 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 »

Heh I fixed the problem affecting uClibc a little sooner than expected! Turns out floating point emulation is enabled by default and I'd overridden the correct settings with some incorrect ones. uClibc now builds without any errors. Whether it works or not is another matter. I do get a lot of "cast from pointer to integer of different size" warnings but I'm hoping that's normal. I guess I'll start looking at the kernel next.
AdamWu
Posts: 2
Joined: Thu Jul 26, 2007 6:18 am

Post by AdamWu »

Chewi wrote:I do get a lot of "cast from pointer to integer of different size" warnings but I'm hoping that's normal. I guess I'll start looking at the kernel next.
Be careful on those warnings. Since you are now building 64bit kernel instead on 32bit, those warning are significant: whenever you cast an 32 bit int to 64 bit pointer it will try to "sign-extend" the address; whenever you cast 64 bit pointer to 32bit int, the number is truncated.

If you happend to have a low address, it will work out OK:
0x0000000000123456 -> 0x00123456 -> 0x0000000000123456

But it is not OK if you have a high address:
0x000000FFFF123456 -> 0xFF123456 -> 0xFFFFFFFFFF123456

Once a strange error of random crash (userlevel program) buged me for hours, and it turned out to be caused by this case.
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

Thanks for that, I'll check to see if any of the type sizes need adjusting.
alexp
Posts: 39
Joined: Tue Apr 17, 2007 12:06 am

Post by alexp »

Chewi wrote:I grabbed Alex's patches and had a look. I was actually more interested in the gcc patch than the kernel patch at this stage because the kernel patch is useless without a working compiler. I was very surprised at just how short the gcc patch was but not in a good way. I had a think about whether a patch this short could really meet the bare minimum required to make the R5900 work properly at all. The only conclusion I could draw was that it couldn't possibly.
You are right, indeed that patch does not really address R5900 problems, it just remove doubleword version of some instruction from "<d>" means something like "use doubleword instruction if asked". But I'm easily wrong about that. I've little to none knowledge about gcc internals. That was a quick hack to make the kernel run, and i'm happy to see that removed. Good work Chewi. I'm now leaving for vacation. So i will probably not be active for a month or so.

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

Post by Chewi »

Ah, sorry for thinking it was supposed to be more than that. The PS2 is the only reason I've ever touched the gcc internals but I think I'm starting to get the hang of it. Hopefully we can help each other out. Not right now though. You have a good break!
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

Time for an update. I've moved up to gcc 4.2.0 after discovering that the problem was only with a patch being applied by Gentoo. It works when I don't apply this patch. I have also added support for the MIPS4 conditional move instructions. That's the good news.

The bad news is I still can't stop those warnings from appearing, though I have dug quite deep into the problem. I initially thought it was because I hadn't redefined POINTER_SIZE as 32 but that didn't fix it. I realised that it wasn't using 64-bit longs by default even though I had added MASK_LONG64 to TARGET_DEFAULT. I fixed that but now I'm also getting the opposite warning of "cast to pointer from integer of different size". I modified the first warning to give me more information.

Code: Select all

warning&#58; cast from pointer &#40;'void *', 32&#41; to integer &#40;'long long int', 64&#41; of different size
The pointer type varies but it's always 32-bit. The integer type is always a 64-bit long long int. It should be a 32-bit int. I have no idea where it's getting long long int from but I'm trying to find out. mips.h includes this.

Code: Select all

#undef SIZE_TYPE
#define SIZE_TYPE &#40;POINTER_SIZE == 64 ? "long unsigned int" &#58; "unsigned int"&#41;

#undef PTRDIFF_TYPE
#define PTRDIFF_TYPE &#40;POINTER_SIZE == 64 ? "long int" &#58; "int"&#41;
As I said, POINTER_SIZE is now 32 so it should be using the right types. But even if it were 64, neither of these say long long int so where is it coming from? Suggestions welcome!
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

gtbX
Posts: 5
Joined: Wed Jul 25, 2007 9:23 am

Post by gtbX »

Hey Chewi, what version/patch of binutils are you using for that?

I tried compiling alexp's kernel with the ps2dev toolchain (gcc-3.2.2), but it dies early on with an error of

Code: Select all

include/asm/sgidefs.h&#58;18&#58;2&#58; #error Use a Linux compiler or give up.
and many of these

Code: Select all

include/asm/io.h&#58;119&#58; warning&#58; cast from pointer to integer of different size
I thought it was worth a shot.
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

I am familiar with that first error, you need to build the toolchain with "linux" somewhere in the CHOST. I doubt that will be enough to make the ps2dev version of gcc work though.

Funny you should mention binutils, I was going to commit my binutils stuff tonight. I've had to delay it though because I want to get the GNU guys to fix the R5900 machine name first. If you look at /usr/share/gnuconfig/config.sub (on Gentoo, at least), you'll see an entry that says mips64vr5900el. This should be mips64r5900el. That v was apparently added in error. As a result, I've had to incorrectly use "vr5900" in all my patches. I'd rather get this fixed now than later. I sent an e-mail with a patch tonight and I await their reply. Once I've heard back, I'll commit binutils and let you know.
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

This is starting to make my head hurt. I hadn't let uClibc finish building for a while and I realised that enabling 64-bit longs by default was causing it to fail. Digging a bit deeper, I realised that uClibc was assuming that if you have 64-bit longs then your word size must also be 64. However, the word size was set to 32, the same as the pointer size, hence the failure. From what little I can gather, the PS2's word size is 32. This makes sense. So why does the ps2sdk gcc 3.2.2 enable 64-bit longs by default? I know the PS2 has 64-bit integer registers but it also has a 32-bit address space. Which should I favour here?
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

It turns out the guy I contacted about the machine name worked under Cygnus on the toolchain for the original PS2 Linux release! He was sure they'd used "vr5900" but after exchanging a few e-mails, I managed to convince him otherwise. "I stand corrected!" That patch will go into GNU CVS in the next couple of weeks. Unless you're a Gentoo user who uses crossdev, you needn't worry about it though.

I've now committed my latest binutils patchset. Gentoo users need to go here. Others can grab the patchset directly here. The relevant patches are #97, #98 and #99 though only #97 is really needed for now. Note that this hasn't actually been tested on the PS2 yet but it hasn't changed a great deal from the last patchset. You should set a CTARGET of mips64r5900el-scei-linux-uclibc.
gtbX
Posts: 5
Joined: Wed Jul 25, 2007 9:23 am

Post by gtbX »

Chewi, how does one use a CTARGET?
I tried using --target=mips64r5900el-scei-linux-uclibc for binutils, but it choked on the -uclibc part, so I changed it to -gnu. Then, gcc complained that it couldn't recognize the chost, so I changed it to mipsel-linux-gnu (going for lowest common denominator). gcc died eventually - after rebuilding binutils - with

Code: Select all

Error&#58; opcode not supported on this processor&#58; mips1 &#40;mips1&#41; `c.lt.s $f0,$f2'
which is baffling to me, as it is apparently a mips1 instruction.

I'm not using portage to install this, as I want to learn how it's put together (and I don't want to fubar my gentoo install :P ). Therefore, everything is being built as a lowly user, and installed with --prefix=~/ps2dev/buildroot
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

You specified it correctly. Did you apply the patches by hand? You've just reminded me that uClibc support requires some small patches that Gentoo will apply if you use the ebuild. The patchset can be found on the Gentoo mirrors and is called binutils-2.16.1-uclibc-patches-1.1.tar.bz2. Simply changing -uclibc to -gnu should have worked though. I wonder if it's trying to use the config.sub from /usr/share/gnuconfig/config.sub. If so, the vr5900 names need fixing. Using mipsel will not work because it's not specific enough.

I do recommend using crossdev because this stuff is complicated enough already. It'll install everything to the right place and it will not fubar your system. :P You can remove the resulting installation using emerge -C cross-mips64r5900el-scei-linux-uclibc/binutils. I had a user install both binutils and my patched gcc 4 using crossdev tonight and it worked out okay.
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

Good news! I visited #gcc where I spoke to another guy who'd worked on the original toolchain, a guy who worked for Sony on the PS3 toolchain and another very helpful guy. I was afraid I'd get ignored or insulted but it wasn't like that at all.

The helpful guy explained that most code expects long sizes and pointer/word sizes to be the same, which is what I had suspected. He suggested either using 64-bit pointers or 32-bit longs.

The PS2 guy explained that enabling 64-bit longs effectively changes the ABI, which isn't something we want to do. Based on that, I decided to disable 64-bit longs despite the fact that they were enabled in 3.2.2.

What I ended up with was actually less code than before, which I think is a good sign. I was still getting the cast warnings though. In an attempt to flush out the culprit, I did something a little unusual. I replaced instances of "long long" with "long" in entire parts of the uClibc tree to see what would happen. I eventually tracked down the problem to libc/sysdeps/linux/mips/bits/syscalls.h. The syscalls were being made with long long arguments. The code looks like this...

Code: Select all

#if _MIPS_SIM == _ABIO32 || _MIPS_SIM == _ABI64
# define ARG_TYPE long
#else
# define ARG_TYPE long long
#endif
Defining ARG_TYPE as long does stop the warnings but I'm not sure if this is the right thing to do. I have found a recent interesting post relating to glibc, which appears to be about the same issue. I'll give the technique a try later.
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

I'm starting to think the warnings should just be ignored. It occurs because 32-bit pointers are inserted into 64-bit argument registers. Do bad things happen if you insert 32-bit longs into 64-bit integer registers? I don't know enough about assembly yet. I tried asking in #uclibc but I was in the channel for most of the day and no one said a thing.
gtbX
Posts: 5
Joined: Wed Jul 25, 2007 9:23 am

Post by gtbX »

I tried using your portage overlay, but it still didn't install. (crossdev -t mips64r5900el-scei-linux-uclibc). I've used crossdev before to install sparc and hppa toolchains, though I've only used them with distcc to install stuff. I'm trying again manually with a --target=mips64r5900el-unknown-linux-gnu, to see if it was the scei that threw gcc off. If I understand what its for, we should probably drop it anyways, since this isn't the official ps2 linux w/RTE.

Ok, I downloaded binutils-2.16.1 and gcc-4.2.1 from gnu.org. I patched binutils with patches 97, 98 and 99 from that patch tarball, and gcc with the gcc patch you provided (was I supposed to apply both? does only gcc-4.2.0 work?)

in binutils dir:
./configure --prefix=~/ps2dev/linux-2.6.21-ps2/buildroot --target=mips64r5900el-unknown-linux-gnu
make
make install
export PATH=$PATH:~/ps2dev/linux-2.6.12-ps2/buildroot

in gcc dir:
./configure --prefix=~/ps2dev/linux-2.6.21-ps2/buildroot --target=mips64r5900el-unknown-linux-gnu --enable-languages=c

and it's compiling for now. Does that look right?

[edit]
it just died complaining something about threads:

Code: Select all

../.././gcc/gthr-posix.h&#58;43&#58;21&#58; error&#58; pthread.h&#58; No such file or directory
../.././gcc/gthr-posix.h&#58;44&#58;20&#58; error&#58; unistd.h&#58; No such file or directory
I'll try disabling them and try again.
[edit2] nope. same spot.
[edit3] ok, cleaned out and tried again. now its complaining about a missing -lc. at least i'm getting closer!
hmm.. how do I build glibc if I don't yet have a compiler?
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

If you tried to build gcc from my overlay, it won't have worked because I have only committed 3.0.4 there. I don't want to commit stuff that is likely not to work, though I'm now thinking about adding it with KEYWORDS="-*" or something. The last part of the log from crossdev would be helpful. "scei" isn't the problem, it worked for me and my friend. I think it looks better than "unknown". :P

Your other issues are the sort of things I've seen from trying to do this manually in the past. It's why I use crossdev! You don't need a libc to build a basic C compiler.
gtbX
Posts: 5
Joined: Wed Jul 25, 2007 9:23 am

Post by gtbX »

I noticed your gcc overlay, but didn't install it since its so old.

I tried crossdev yet again, this time using both:
crossdev -t mips64r5900el-unknown-linux-gnu
crossdev -t mips64r5900el-unknown-linux-uclibc
This got much farther along, but of course, plain gcc-4.2.1 doesn't build since your patch doesn't get applied (unsupported opcode error, both times). I believe "unknown" is the default/generic vendor name for most systems, with the exception of "pc" in i686-pc-linux-gnu. Sparc, hppa, and amd64 all use unknown.

As far as doing it manually, you're right I don't need libc, just the headers from it and the linux kernel. I believe I have them installed, but it seems to be trying to use the i386 kernel headers instead of mips. I'm going to mess with it some more to see if I can get gcc working.
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

Please bear with me, I do intend to make this stuff install more reliably through crossdev soon.

Since uClibc is of no use without a kernel, I've decided to move onto the next stage. That would be the kernel but first I want to see that my gcc patch is working to some extent. This means trying some home brew stuff.

I modified my patches slightly and managed to build binutils and gcc for mips64r5900-scei-elf. crossdev then tried to build the latest version of newlib but this failed. I grabbed the old newlib patch from the ps2toolchain package that's available here. What a mess! Whoever prepared that patch must have been smoking something. Fortunately, it was very easy to pick out the important bits from amongst the mess. I applied these to the latest version of newlib and after a bit of work, I managed to get that to build.

I then tried to build the "ee" part of ps2sdk. There were a lot of cast warnings but this didn't surprise me because it expects 64-bit longs. I had to fix a few code errors due to gcc 4 being stricter than gcc 3. After a while, it asked for a C++ compiler. Uh oh. I hadn't expected that. I told crossdev to build gcc again with C++ for mips64r5900-scei-elf and to my surprise, it worked first time. I carried on building ps2sdk and it eventually asked for some IOP-related stuff that I hadn't built yet. I'll need to build the IOP toolchain before I can continue. I'll probably try that tomorrow.
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

Code: Select all

Error&#58; opcode not supported on this processor&#58; mips1 &#40;mips1&#41; `c.lt.s $f0,$f2'
I found out what causes this error. It was mentioned elsewhere in this forum. You were building for the wrong processor but it also occurs when you try to build the IOP toolchain. Someone did a bad job of updating the binutils patch in the past and this instruction was being removed for MIPS 1-3. I have managed to fix this in such a way that it should still work for the R5900. As for the IOP toolchain in general, I added the necessary modifications to gcc and I've managed to get gcc to build as well as binutils. The IRX stuff doesn't seem to be working though. I get this when the first link is made during the ps2sdk build.

Code: Select all

make&#91;2&#93;&#58; Entering directory `/home/chewi/ps2toolchain/ps2sdk/iop/dev9/dev9'
mipsel-scei-irx-gcc -fno-builtin -fno-builtin -nostdlib -s -o bin/ps2dev9.irx obj/ps2dev9.o obj/exports.o obj/imports.o 
/usr/libexec/gcc/mipsel-scei-irx/ld&#58; failed to resolve the irx name
collect2&#58; ld returned 1 exit status
make&#91;2&#93;&#58; *** &#91;bin/ps2dev9.irx&#93; Error 1
make&#91;2&#93;&#58; Leaving directory `/home/chewi/ps2toolchain/ps2sdk/iop/dev9/dev9'
make&#91;1&#93;&#58; *** &#91;all-dev9&#93; Error 2
make&#91;1&#93;&#58; Leaving directory `/home/chewi/ps2toolchain/ps2sdk/iop/dev9'
make&#58; *** &#91;all-dev9&#93; Error 2
Maybe the IRX code needs some significant modifications for the latest binutils or maybe there are just some minor warnings that need to be fixed up. Hopefully I can figure it out. If not, it is possible to build in ELF format and convert to IRX later but I suspect this may make building ps2sdk awkward.
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

It turned out to be the -funit-at-a-time optimisation. Building with -O0 worked okay. I didn't want to disable optimisation completely though so I made -fno-unit-at-a-time (as well as -fno-merge-constants) a default option. That works great. Now I'm sifting through more code strictness errors.

edit: The IOP part of ps2sdk now builds successfully. :D
User avatar
Chewi
Posts: 104
Joined: Sun Nov 26, 2006 12:49 pm
Location: Perth, Scotland
Contact:

Post by Chewi »

I took IOMANX.IRX, PS2IP.IRX, PS2IPS.IRX and PS2DEV9.IRX and put them on a memory card with uLaunchELF. I'm not sure which IRX's are used for what but I'm guessing the "IP" ones are used for networking. I tried renaming my existing PS2IP.IRX while connected via FTP and it wouldn't let me so I guess that means it was in use. With these new IRX's installed, I was still able to use FTP . I guess that means it works? Can anyone confirm this? The real acid test will be to build uLaunchELF itself. I'll try that soon.
Post Reply