PlayStation 2 Linux kernel
This Linux kernel branch implements the o32 ABI for the Sony PlayStation 2.
# uname -mrs
Linux 5.4.46+ mips
# cat /proc/cpuinfo
system type : Sony PlayStation 2
machine : SCPH-37000 L
processor : 0
cpu model : R5900 V3.1
BogoMIPS : 291.58
wait instruction : no
microsecond timers : yes
tlb_entries : 48
extra interrupt vector : yes
hardware watchpoint : no
isa : mips1 mips3
ASEs implemented : toshiba-mmi
shadow register sets : 1
kscratch registers : 0
package : 0
core : 0
VCED exceptions : not available
VCEI exceptions : not available
Building
A mipsr5900el-unknown-linux-gnu target GCC cross-compiler is recommended, with for example the command make ARCH=mips CROSS_COMPILE=mipsr5900el-unknown-linux-gnu- vmlinux. A provisional configuration is available in arch/mips/configs/ps2_defconfig.
The wiki includes a guide on building and installing PlayStation 2 Linux.
Input/output processor (IOP) modules
The input/output processor (IOP) is a MIPS R3000A, or in later PlayStation 2 models a PowerPC 405GP emulating a MIPS R3000A. This processor provides a number of kernel services, for example handling of USB OHCI interrupts. These are implemented as IOP modules that the kernel loads as firmware.
This kernel requires the IOP modules provided with the iopmod repository, to be installed as kernel firmware.
See also #11.
Installing
This kernel can be started directly from a USB flash drive, using for example uLaunchELF for the PlayStation 2. A special kernel loader is unnecessary.
Limitations
This PlayStation 2 Linux kernel is work in progress, and only a minimum of devices for a useful system have been ported to the latest kernel version. A much older version 2.6.35.14 kernel from 2010 supports more devices etc.
See also #3, #5, #14, #15, #16, #18, #19, #21, #22, #23, #24 and #25.
Graphics
The Graphics Synthesizer device driver supports 1920x1080p (noninterlace), with either an HDMI adapter or component video, as well as common video resolutions such as 720x576p, 720x480p, 640x512i, 640x480i, etc. Console text is accelerated with hardware texturing.
This kernel implements an early printk. The conventional putc prints to a serial port, that requires soldering on the PlayStation 2. This putc instead prints to a video frame buffer using the Graphics Synthesizer, which at the moment is fixed at the video resolution 1920x1080p for an HDMI adapter or component video. The following three lines are the first ones visible on the screen when the kernel boots:
zimage at: 00803BE0 00BDDE8C
Uncompressing Linux at load address 80010000
Now, booting the kernel...
An experimental Direct Rendering Manager (DRM) driver for the Graphics Synthesizer is implemented, as this is requirement for #1.
USB devices
USB devices such as keyboards, flash drives, wifi, etc. are supported. However, due to memory limitations in the PlayStation 2 I/O Processor (IOP), some USB device drivers may need to be adjusted to work properly.
Dependencies when compiling PlayStation 2 Linux programs
GCC 9.1 or later is recommended. Older GCC versions can be used if commit d728eb9085d8 (MIPS: Default to --with-llsc for the R5900 Linux target as well) is applied.
Glibc 2.29 or later is recommended. Older Glibc versions can be used if commit 8e3c00db16fc (MIPS: Use `.set mips2' to emulate LL/SC for the R5900 too) is applied.
GAS 2.32 or later is optional. It has the -mfix-r5900 option to compile generic MIPS II and MIPS III code with the appropriate workaround for the R5900 short-loop hardware bug.
See also #8.
PlayStation 2 Linux distributions
A modern Gentoo Linux can be compiled for the R5900 and the PlayStation 2. The Gentoo sys-devel/crossdev package page and the cross build environment guide explain the details involving configuring for example a Gentoo profile and a corresponding overlay. Once those simple steps have been taken the command # crossdev -s4 -t mipsr5900el-unknown-linux-gnu can be used to obtain an R5900 cross toolchain as well as the basis of an R5900 Gentoo root filesystem in /usr/mipsr5900el-unknown-linux-gnu. As the guide explains, the R5900 base system can be built from scratch using the command # mipsr5900el-unknown-linux-gnu-emerge -uva --keep-going @system. The root filesystem can then be used with R5900 QEMU user mode emulation for further compilations and testing, or directly in Linux on PlayStation 2 hardware.
PlayStation 2 Linux emulation
R5900 QEMU can be used to emulate programs compiled for PlayStation 2 Linux.
General README
Read the general README for further information on the Linux kernel.