Sony Playstation 3

From Gentoo-en
Jump to: navigation, search

Sony Playstation 3 is a home theater personal computer (HTPC) class device which acts as a multimedia frontend in living room. It's an open platform computer in which Gentoo Linux can be installed using documentation found on this page.

This article intends to be an up-to-date installation/configuration Gentoo guide for the PS3. The documentation found for this purpose is very old and deprecated and should not be used nowadays.


Old articles

There are several web pages explaining how to install Gentoo on the Sony PS3. However, those are mostly deprecated.
http://overlays.gentoo.org/proj/cell/wiki/InstallGentooOnPS3
http://ps3wiki.qj.net/index.php/Gentoo_Howto
http://overlays.gentoo.org/proj/cell

Getting started

Your installation of Gentoo should follow three main steps:

  • Prepare PS3 for the installation of other OS and partition hdd using the tools provided by Sony.
  • Install Gentoo as you would do it on any other hardware.
  • Install PS3-related packages.

Preparing the PS3

First of all, you must prepare the PS3 for the installation of another OS. The most recent bootloader for the PS3 is Petitboot, which can be found here: http://ozlabs.org/~jk/projects/petitboot/. To format your PS3 and install Petitboot, follow the instructions on this website. You can also use more recent development petitboot builds here: http://www.kernel.org/pub/linux/kernel/people/geoff/cell/ps3-petitboot/.

Getting the installation media

To perform the installation, you need a LiveCD to boot up. Gentoo PPC CDs booting on the PS3 are quite old and do not support some technologies such as ext4. You can use any other distro's PPC/PS3 LiveCD. You can also use an old but working Gentoo/PS3 LiveCD, which can be found on any gentoo mirror under experimental/ppc64/installcd-ps3-minimal[...].

Getting a stage3 and a Portage snapshot

Get the latest ppc64 Gentoo stage3 from in releases/ppc/current/ on any Gentoo mirror. See the Gentoo PowerPC installation documentation for more information and a list of mirrors. You can choose to use a 32-bit userland or a 64-bit userland. Choose the stage3 that fits your needs.

The way of getting the portage snapshot is the same than this manual. Get the stage3 and the snapshot, and put those two files on a USB stick.


Disk partitionning

Format your hard disk the same way you would for any other Gentoo installation. As the PS3 has only 512 Mib of RAM, you should create a pretty big swap partition (up to 1 Gib), just in case. A boot partition isn't necessary.


Make.conf

File: /etc/make.conf
CHOST="powerpc64-unknown-linux-gnu"
# CHOST="powerpc-unknown-linux-gnu" # for 32-bit userland

CFLAGS="-O2 -pipe -mcpu=970 -mabi=altivec"
# CFLAGS="-O2 -pipe -mcpu=cell -mabi=altivec" # for GCC >= 4.4.0
CXXFLAGS="${CFLAGS}"

MAKEOPTS="-j2"

# For unstable packages, uncomment:
# ACCEPT_KEYWORDS="~ppc64" # 64-bit
# ACCEPT_KEYWORDS="~ppc"   # 32-bit 

USE="altivec gsl cblas ps3 subversion wifi -qt -qt3 -qt4 -kde -kde4 -gnome"

VIDEO_CARDS="fbdev"
INPUT_DEVICES="evdev mouse keyboard joystick"

Note here that this configuration is accepting ~ppc64 keywords so this system may be unstable, but the packages will be more bleeding-edge.

WARNING: If you use an old LiveCD, do NOT perform any upgrade now. Wait until you have a recent kernel and booted it. Upgrading glibc will break python (and emerge is programmed in python). See bug 271367

Kernel

Code: Build the kernel (64-bit userland)
# cd /usr/src/linux
# make ps3_defconfig
# make menuconfig 
Add here what you need... For example, the default config file may not have the USB keyboard and mouse support, 
and ext2 and ext3 filesystems are compiled as modules (so you won't be able to boot a ext3 partition). You may also 
need to add the VGA text console support. If you plan to run a GUI, it is suggested to change the preemption model 
from Server to Desktop.
# make && make modules_install
# cp vmlinux /boot/vmlinux-kernelversion

For a 32-bit userland, you need the package kgcc64 which provides a 64-bit cross-compiler.

Code: Build the kernel (32-bit userland)
# cd /usr/src/linux
# make ps3_defconfig
# make menuconfig 
Add here what you need... For example, the default config file may not have the USB keyboard and mouse support, 
and ext2 and ext3 filesystems are compiled as modules (so you won't be able to boot a ext3 partition). You may also 
need to add the VGA text console support. If you plan to run a GUI, it is suggested to change the preemption model 
from Server to Desktop.
# CROSS_COMPILE="powerpc64-unknown-linux-gnu-" make && make modules_install
# cp vmlinux /boot/vmlinux-kernelversion

If you want an optimized kernel (and you have gcc >= 4.4.0), you may add the following in front of the make command:

Code: Build an optimized kernel (gcc 4.4.0 or higher)
 
# KFLAGS="-march=cell"

kboot.conf

Note: Note that the harddisk device is /dev/ps3dax. (Where x is an integer value.)
Note: To set the videomode, use ps3-video-mode. For example, to set the resolution to 1080p use ps3-video-mode -v 5 -c -f

Petitboot needs a config file if you want it to boot your Gentoo installation. It doesn't seem to find the /boot/petitboot.conf file, so let's name it /etc/kboot.conf to avoid problems. Here is an example:

File: /etc/kboot.conf
default=gentoo
timeout=10

# 480i = ps3fb:mode:1
# 576i = ps3fb:mode:6
# 720p = ps3fb:mode:3
# 1080i = ps3fb:mode:4
# 1080p = ps3fb:mode:5

gentoo='ps3da1:/boot/vmlinux-2.6.30-gentoo-r4 root=/dev/ps3da1 video=ps3fb:mode:3 rhgb'

fstab and using the gpu's RAM as swap

The PS3 comes with only 256 Mb of RAM, but you can add the 256 Mb of the gpu's RAM as a high-speed SWAP. The device is named /dev/ps3vram

File: /etc/fstab
# /etc/fstab: static file system information.
# <fs>                  <mountpoint>    <type>          <opts>          <dump/pass>
/dev/ps3da1             /               ext3            noatime         0 1
/dev/ps3vram            none            swap            sw              0 0
/dev/ps3da2             none            swap            sw              0 0
/dev/sr0                /mnt/cdrom      auto            noauto,ro       0 0
none                    /spu            spufs           defaults        0 0

shm                     /dev/shm        tmpfs           nodev,nosuid,noexec     0 0

Adjust this file to reflect your system. (partitions, filesystems, etc).

After your first boot, create the swap filesystem on /dev/ps3vram using mkswap /dev/ps3vram. You can manage you different swaps and give priority to the vram using swapon.

When using the PS3 using the Game OS, it will destroy the swap filesystem on dev/ps3vram. You may add this file to ask udev to re-create the swap filesystem at each boot:

File: /etc/udev/rules.d/10-ps3vram-swap.rules
KERNEL=="ps3vram", ACTION=="add", RUN+="/sbin/mkswap /dev/ps3vram", RUN+="/sbin/swapon -p 10 /dev/ps3vram"


Cross-compiling

As the PS3 cpu isn't very fast for compiling, you should use distcc to cross-compile on another machine. Note that you need the same GCC version on all the machines used to cross-compile. More information about distcc and cross-compilation is found here : http://www.gentoo.org/doc/en/distcc.xml


PPU and SPU toolchain and utilities

You already have the PPU toolchain, as this is what you built your system with. Using crossdev to get the ppu toolchain is deprecated.

In order to get a working toolchain for the SPUs, you may use crossdev. The result will be the same (but the Gentoo-way) of getting the IBM Cell SDK's SPU toolchain, but have different names for the GCC binaries.

Code: SPU toolchain
# emerge crossdev
# crossdev -t spu -s1 --without-headers # see bug [http://bugs.gentoo.org/show_bug.cgi?id=259144 259144]
# crossdev -t spu

You should also want the libraries and utilities for the SPUs:

Code: SPU utilities
# emerge libspe2
# emerge spu-tools


After installation

Let's assume, the Playstation is running its native OS. To boot another OS, go to Settings/System Settings/Standardsystem and select "other system". The Playstation will reboot, and the installed other OS will boot, here Gentoo.

To switch back to the PS3 native OS, execute
ps3-boot-game-os
under gentoo or at the kboot prompt.

PS3 Overlay

There is an unofficial overlay which provides a video driver for the PS3 using the SPUs. The article Overlay article explains how to add it.


Troubleshooting

The system does not boot

If your system doesn't boot and you see : "Warning: unable to open an initial console", boot the LiveCD, mount your partition, chroot, go in /dev (do not mount liveCD's /dev) and create the console node with:

Code: Creating the console node
mknod -m 660 console c 5 1