Skip to content

Building a PlayStation 2 Linux kernel

frno7 edited this page May 17, 2022 · 27 revisions

Make sure that you have

Go to the Linux kernel source directory with cd linux. In the following, initramfs is assumed to be installed in ../initramfs relative to the linux directory.

To simplify the make commands used to compile the kernel, define the following environment variables, with Bash syntax:

export ARCH=mips
export CROSS_COMPILE=mipsr5900el-unknown-linux-gnu-
export INSTALL_MOD_PATH=../initramfs
export INSTALL_MOD_STRIP=1

The alternative is to supply these variables as arguments to make, rather than defining them as environment variables.

Verify that the CONFIG_INITRAMFS_SOURCE kernel configuration matches INSTALL_MOD_PATH, with grep CONFIG_INITRAMFS_SOURCE .config printing CONFIG_INITRAMFS_SOURCE="../initramfs".

Assuming arch/mips/configs/ps2_defconfig is used as a kernel configuration, do the following commands to build the kernel and obtain its vmlinuz file:

make ps2_defconfig
make olddefconfig
make vmlinux
make modules
make modules_install
rm ../initramfs/lib/modules/*/{build,modules.*,source}
make vmlinuz

The -j option, for example -j $(getconf _NPROCESSORS_ONLN), can be used to have make build the kernel faster by using all available processors.

The make modules_install command installed kernel modules in the ../initramfs/lib/modules directory. The dependency files that were installed with the kernel modules can be removed to reduce the size of the initramfs, because Busybox will either ignore them or replace them with its own files, typically with its depmod command in ../initramfs/sbin/init. Therefore, the dependencies and other unnecessary files are removed with rm.

The Linux kernel vmlinuz file made with make vmlinuz should be about 4 MB, or less, depending on its configuration, and the size of the initramfs linked within the file.

Next, proceed by installing and booting PlayStation 2 Linux.

Troubleshooting Issues

Kernel hangs at boot

If your kernel hangs while booting then checking you have installed modules correctly to the initramfs by making sure initramfs/lib/modules/5.4.169+/kernel is populated. If it's not then you need to check your INSTALL_MOD_PATH variable and then rerun make modules_install && make vmlinuz

Text too small

By default the font size is set at 8x8 which can be a problem to read with poor capture card, to remedy this run make menuconfig and change the font size to 8x16 in the library routines section.