Complete Guide to the 0.15 TFlops hello world

MAR 2010

Late march 2010, Sony dropped the bomb on a PS3 feature called OtherOS. This feature allows you to run Linux on a PS3 machine. And this, in turn, allows hobbyists to experiment with a 0.15 TFlops supercomputer without shelling out $20000 for a CELL development machine. On April 1 2010, this feature will be disabled. The CELL in a PS3, after all these years, is still a marvel of computing power, worthy of unlocking. I enjoyed developing for it when it came out. I think it's time for an update on my old ps3 development writeup.

STEP 0: Purchase Hardware

Buy an old model PS/3, not the Slim version, because that one cannot run Linux.

STEP 1: Do not upgrade

If your PS/3 wants to upgrade the firmware (because you try to play a new blu-ray disk, access the PSN, or play a game), refuse. Upgrading your PS/3 firmware will remove the OtherOS feature and wipe your existing linux data, if you have it.

STEP 2: Burn a disc

There are quite a few ps3 distros out there. You will want xubuntu for ppc+ps3. Xubuntu is an excellent choice: the underlying Ubuntu/Debian are industrial strength distributions. And Xubuntu is the distro without all the bloat. A mean lean Ubuntu, so to speak. And less is more, we want to do CELL development, not watch eyecandy on a 1920x1080p fully equiped desktop. Get your CD image from here. Get the one labeled PlayStation 3 alternate install CD.

STEP 3: Format HD

In Cross Media Bar (XMB), select Settings -> System Settings -> Format Utility. I did not bother to backup my ps3 data, because I'm through playing games. It's time for serious stuff, CELL development, so screw the games.

STEP 4: Kickoff install

Kick off the install from XMB, by selecting Settings -> System Settings -> Install OtherOS. Followed by a reboot via Settings -> System Settings -> Default System -> OtherOS.

STEP 5: Input devices

Hook up a keyboard and a mouse to your PS/3.

STEP 6: Install Xubuntu

Start by hitting ENTER, or if you are hooked up to 1080p HDTV, why not do 'install video=ps3fb:mode:37' instead, so you get to enjoy all that screen real estate on your HDTV. Do a manual partitioning, and set the root fs to type ext3, because kboot does not understand ext4. Also set up a swap partition. You need to partition the entire sda disk. The hypervisor will contain your partitioning to the OtherOS part only. In case you did end up with ext4: you may have better luck with petitboot. However, for me this did not work, so I went with ext3. These folks had better luck.

STEP 7: Clean up crap

Less is more, and command-line interfaces rule. You may as well get rid of all the gnome, xfce, games, and x11 stuff. A good way to force this is to remove a low level x11 lib with 'apt-get purge libx11-6' command. You need to sudo into a root shell first, of course. After that, you can get the rest of the packages up to date with 'apt-get dist-upgrade'.

STEP 8: SSH server

The most convenient way for developent is probably via resmote shells onto the ps3. So the first essential package that we need, and is not available by default is an ssh server. So install this with 'apt-get install openssh-server'. Once this is done, we can do the rest of the sessions on another machine. If your ps3 gets its IP address from a dhcp server, you need to look up its IP. Alternatively, you can give your PS3 a static IP address by editing /etc/network/interfaces. See 'man 5 interfaces' on how to edit it.

STEP 9: Tool Chain

Install the SPU compiler with 'apt-get install gcc-4.4-spu'. Mount spufs by editing /etc/fstab and adding the line:

    none   /spu   spufs   defaults   0   0
  
Followed by 'mount /spu' command.

STEP a: Test Compiler

	$ echo "int main() { puts(\"hello world\"); }" > hello.c
	$ spu-gcc-4.4 hello.c
	$ /usr/bin/elfspe ./a.out
	hello world