PS2Linux2.6 Software Development Kit

 

A serious decision and alternative to PS2SDK with new points of PS2 programming view

 

advantages

- always up to date toolchain;
- SWAP-partition support;
- any advantage of kernel2.6 and linux as system;
- more ways and programs for debugging

 

disadvantages

- a loaded kernel uses too much RAM memory enough;
- has no access to SONY's special HDD partitions (yet)



The PS2Linux2.6 SDK set: a cross-compiler based on uClibc and a special library sps2dev. Read the spoiler how to build this cross-compiler.

 

Building cross-compiler

cd ~ (in this ex. home directory is used as directory for buildings)
mkdir /usr/local/ps3
mkdir /usr/local/ps3/mipsr5900el-unknown-linux-uclibc
cd linux-2.6.35.4-mipsel-ps2 (kernel source directory)
make headers_install INSTALL_HDR_PATH="/usr/local/ps3/mipsr5900el-unknown-linux-uclibc" (include folder appears here)

tar -jxvf binutils-2.24.tar.bz2
cd binutils-2.24
mkdir build; cd build
../configure --prefix=/usr/local/ps3 --target=mipsr5900el-unknown-linux-uclibc --enable-shared --enable-plugins --disable-werror
grep /proc/cpuinfo -e "processor" | wc -l (got number of cores to use while doing make. For ex., it is 2)
make -j 2
make install
cd ../../

tar -jxvf gcc-4.9.0.tar.bz2
cd gcc-4.9.0
mkdir build; cd build
../configure --prefix=/usr/local/ps3 --target=mipsr5900el-unknown-linux-uclibc --enable-languages=c --disable-nls --disable-shared --disable-libssp --disable-libmudflap --disable-threads --disable-libgomp --disable-libquadmath --disable-target-libiberty --disable-target-zlib --without-ppl --without-cloog --with-headers=no --disable-libada --disable-libatomic --with-llsc=no --with-float=hard --disable-multilib
make -j 2
make install
cd /usr/local/ps3/lib/gcc/mipsr5900el-unknown-linux-uclibc/4.9.0
ln -s libgcc.a libgcc_eh.a
cd ~

export PATH=/usr/local/ps3/bin:$PATH
tar -jxvf uClibc-0.9.33.2.tar.bz2
cd uClibc-0.9.33.2
patch -p1 < uClibc-0.9.33.2-26.patch
cp uClibc-0.9.33.2-ps2linux2.6-config.txt ./.config
make oldconfig
make -j 2
if you'll get __gcc_personality_v0 error - add -lgcc_eh after $LIBGCC to Makefile where link.so
make install
rm -f /usr/local/ps3/lib/gcc/mipsr5900el-unknown-linux-uclibc/4.9.0/libgcc_eh.a

cd ~/gcc-4.9.0/build
make distclean; rm -rf *
../configure --prefix=/usr/local/ps3 --target=mipsr5900el-unknown-linux-uclibc --enable-languages=c,c++ --includedir=/usr/local/ps3/mipsr5900el-unknown-linux-uclibc/include --disable-libada --with-llsc=no --with-float=hard --disable-multilib
make -j 2
make install

Your cross-compiler is ready!


Next part is building sps2mod-0.5.0 (tar.gz) - testprograms

 

Building sps2mod-0.5.0

You have to have a kernel source compiled with kernel and it's modules compiled first. Read the readme.txt and obtain for yourself your own kernel-configure! Or use mine one attached.

Now, note that sps2mod-0.5.0 folder is in the same directory near linux-2.6.35.4-mipsel-ps2 folder.

Compilation of sps2mod.ko module is easy enough and do not required any additional edits. Just use "sh build26.sh"
Compiled module sps2mod.ko must exist in your further project\system and should be activated like "insmod /path/to/sps2mod.ko"
After the moudle is activated, you'll should create a device node for it in your project (not in PCLinux) once. Use:
awk "\\$2==\$device\" {print \\$1}" /proc/devices
- suppose, the 251 value printed. Then the command for creation:
mknod /dev/sps2 c 251 0


Many sps2dev samples are using ee-dvp-as for compiling, which provides with official toolchain from PS2Linux Kit DVD2. You have to download this one or find binutils-2.9EE source and binutils-ps2linux-1.0.0.patch. Or just pass this part and you'll never use vector units for your project.

 

Building old cross-compiler

cd /usr/local
tar -jxvf /path/to/headers.tar.bz2
cd ~

So, you have binutils-2.9EE unpacked from source. Go:
cd binutils-2.9EE
patch -p1 < binutils-ps2linux-1.0.0.patch
Edit file ld/ldlex.l . Line 576:
Change yy_current_buffer to YY_CURRENT_BUFFER
mkdir build; cd build
../configure --prefix=/usr/local/ee --target=mipsEEel-linux --enable-shared
make -j 2
make install
cd ~

Download official gcc-3.0.3. Go:
export PATH=/usr/local/ee/bin:$PATH
tar -zxvf gcc-3.0.3.tar.gz
cd gcc-3.0.3
patch -p1 < gcc-3.0.3-r5900.patch
patch -p1 < gcc-3.0.3-modern.patch
mkdir build; cd build
rm -rf ../libstdc++-v3
../configure --prefix=/usr/local/ee --target=mipsEEel-linux --enable-shared --enable-languages=c,c++
make -j 2
make install

A cross-compiler for old linux is ready. We just need ee-dvp-as from it.


Now you are ready to compile sps2dev-0.5.0 (tar.gz) - All Files and Readme's.

 

sps2dev-0.5.0

It is required to have ps2cross.mk file with all according cross-compiler variables set near sps2dev-0.5.0 folder.
Some samples can not be compiled (because you have to have XFree86-3.3.6 cross-compiled), so go on your own.



Use sps2dev tutorial:
Dr HS Fortuna Playstation 2 Linux Games Programming
It might you will need a system to test your PS2Linux2.6 programs:
PS2Linux2.6 USB Test Release (7z)

It is not required to use a linux system for your creation - think this way: cross-compile the program it's static type and launch it from USB using initrd.

 

Advice to developers

Processor r5900 understoods up to MIPS-III opcodes. However, there is prefetch technology available. Think on how to use it in your project and be careful with "pref" opcode.