Linux On PSP

Welcome to my website of Linux on PSP. This website is dedicated to a small project I did recently for fun, in which I ported a uClinux of version 2.6 on to PSP. You will find some useful information and interesting stuff here if you are also fascinated by the potential of developing software on PSP as well as other embedded systems.
 
Enjoy! -- Jackson Mo


News


 
Sep 12, 2008 - The download links have been updated again

I have uploaded the prebuilt package of the port as well as the prebuilt toolchain to another file hosting server again. They claim the server provides unlimited storage space and unlimited download bandwidth, and I hope they really mean it this time.


June 21, 2008 - The prebuilt unified toolchain has been uploaded

Finally...I've got the 50M package of the prebuilt toolchain uploaded to a file hosting server. It was originally built in RedHat 9 and was placed under /usr/src/buildroot/build_mipsel/ as the result of buildroot. But I suppose it still works even if it's placed elsewhere (cos that's what gcc 4.2 should be capable of). If it doesn't, just put it back to its original location. Enjoy :)


Feb 3, 2008 - uClinux on PSP 0.22 is released

A screenshot of it:

	***********************************
uClinux on PSP 0.22 Release Notes
Jackson Mo on Feb 3, 2008
***********************************

INSTALL
-------
Extract the package and copy the entire folder of uClinux/ folder to PSP/GAME
and run the loader from XMB.

Though unsatisfactory but it seems true that the old loader that runs on 150
firmware does deliver more stable performance than the new slim-compatible
loader. Thus, if the new loader doesn't work for your PSP and you still have
the 150 add-ons, try the old one by replacing the EBOOT.PBP with the on in
FW150/, and moving the whole uClinux/ folder to PSP/GAME150 as well.


REVISIONS
---------
Major bug-fixing/enhancements in the kernel including:
- Adding new ability to the kernel to detect RAM size automatically at boot
time, making it possible for the system to take advantage of the extra 32M
RAM on slim.

- Fixing the binary executable loader to correct a previous bug that caused
small programs (around 8K) to crash when loading.

- Fixing the framebuffer driver enabling mmap and flush operations to access
the driver (See the source of the new On-Screen Keyboard for example).

- Refactoring the joypad driver by moving all console-related function out of
the driver and relocating them into the console screen driver, making the
overall structure more clear and reasonable.

- Adding new ability to the joypad driver to block access to the driver if
the HOLD lock is on. Also, a new emulate mouse driver is attached to the
joypad driver to simlate a PS/2 mouse device on PSP controlled by both analog
and dpad.

Major enhancements in On-Screen Keyboard including:
- Allowing users to customize OSK to use dpad or analog or both as input measures
by specifying different options in boot command.

- Adding new snapshot-taking function to OSK. Press the LCD button to take a
snapshot of the screen, which will be stored at /usr/screenshots which links
to ms0:/picture by default.

- Adding a shutdown function in OSK to power off the machine without typing
commands. Press HOME+CIRCLE+CROSS to initiate the shutdown.

- Adding a new Mouse mode in OSK besides the existing Keyboard mode. Press SELECT
key to switch between modes.

Introducing the new text console Mouse Daemon for PSP:
- This program severs users/developers as a demonstration of how to utilize
the emulate mouse in psplinux. It also provides a copy & paste function to
facilitate users to operate easier in text console.

Major enhancements in pspboot including:
- Re-enabling uses to build the 150 version by specifying "FW150=1" after make.


FILE LIST
---------
uClinux/
uClinux/EBOOT.PBP
uClinux/FW150
uClinux/FW150/EBOOT.PBP
uClinux/kmodlib.prx
uClinux/pspboot.conf
uClinux/README
uClinux/vmlinux-0.22.bin


Jan 9, 2008 - PSPBoot 0.22 for 2.0+ firmware and slim is released

The new PSPBoot 0.22 is released. This version fixes a few bugs, and adopts a safer way of executing code in kernel mode without the 1.5 firmware, hence it can run on 2.0+ firmware and slim without 1.5 add-ons.


Jan 3, 2008 - A new website was made

This website gets a refreshing look to catch up with the spirit of the new year!


Jan 1, 2008 - An unified toolchain is available

A new toolchain with gcc 4.2.1 and uClibc 0.9.29 capable of building both the kenrel and other apps is now available, making developments on this port much easier.



 
 
Features
 
A) uClinux kernel 2.6.22-uc1. There have been substantial improvements from kernel 2.4 to 2.6 (one of which is the preemptible kernel that performs low latency operations). However, MIPS machines with no mmu (like Allegrex) are not yet official supported by the latest uClinux distribution. Therefore the kernel needs some serious patch up before it can be loaded on PSP.
 
B) A configurable loader. The loader's behavior is controllable through a config file, similar to vivi or uboot. However, it only runs on the 1.5 kernel/firmware thus users may experience problems with firmware 3.71 m33 or higher without applying the 1.5 kernel patch (3.71 m33-2).
 
C) Busybox 1.7 armed with loads of utilities running on linux. Again, the original version needs to be patched up before it can run on PSP.
 
D) A serial driver controlling UART3 (the remote control port on fat PSP) allowing you to open a SIO console on the PSP or to use any terminal program on your PC to act as an emulate keyboard when you are using virtual terminal. Up to 6 virtual terminals are available on PSP. Use +/- buttons to switch between terminals.
 
E) A simple Framebuffer driver enabling virtual terminals to be displayed on PSP's LCD screen.
 
F) A new block device driver giving you accessibility to the Memory Stick (Cool!). By default, disk ms0 will be mounted to /ms0 after system startup, and there could be ms1 or more had you Memory Stick been divided into multiple partitions.
 
G) A joypad driver allowing linux applications to acquire input from PSP buttons.
 
H) An On-Screen Keyboard facilitating fast input in the linux environment, and also serving as an example of how to use the joypad driver.
 
I) A patched mips toolchain capable of building both the uClinux kernel and other applications running on PSP.
 
 
Installation
 
Download the latest pre-compiled package here. Extract the package and copy the entire folder of uClinux/ folder to PSP/GAME and run the loader from XMB.
 
Though unsatisfactory but it seems true that the old loader that runs on 150 firmware does deliver more stable performance than the new slim-compatible loader. Thus, if the new loader doesn't work for your PSP and you still have the 150 add-ons, try the old one by replacing the EBOOT.PBP with the on in FW150/, and moving the whole uClinux/ folder to PSP/GAME150 as well.
 
Build the Toolchain
 
Unlike the previous one, a new MIPS(el) toolchain with the gcc 4.2.1 and uClibc 0.9.29 is now in place capable of building both the kernel and other apps. To construct or customize your own toolchain, recommend you to use buildroot (20071216 or any version close to it) available at http://buildroot.uclibc.org/. More details can be found in the following section:
 
    ****************************************************
     Building the MIPS(el) toolchain for uClinux on PSP
    ****************************************************

This package will help you build your own toolchain incorporating gcc 4.2.1 and
uClibc 0.9.29 capable of building both the uClinux kernel and the other apps
that run on PSP. With the help of buildroot (available at http://buildroot.uclibc.org/)
and following a few simple steps below, you will be able to kick off an highly
automatic process that downloads and builds binutilities, gcc, uClibc and other
tools for you, which are all essential to psp-linux development. You may still
need a little trouble-shooting along the way which is also covered in this README,
but everything other than that is still a fairly pleasant experience. Before this
introduction gets more like an ad, let's get started :)

Please visit http://jacksonm88.googlepages.com/ for the latest update.

Jackson Mo
Jan 3, 2008


INSTALL
*******
1) Unpack the buildroot tarball to $(BUILDROOT). $(BUILDROOT) represents
whatever location you would like to have buildroot installed, and most of the
commands below are run under $(BUILDROOT)/.

2) Add $(BUILDROOT)/build_mipsel/staging_dir/usr/bin/ to your search PATH.

3) Applying patch files:
- Copy gcc-4.2.1.linuxonpsppatch to $(BUILDROOT)/toolchain/gcc/4.2.1/
- Copy uclibc-0.9.29.linuxonpsppatch to $(BUILDROOT)/toolchain/uClibc/
- Copy elf2flt.linuxonpsppatch to $(BUILDROOT)/toolchain/elf2flt/
- Apply buildroot-20071216.linuxonpsppatch

4) Config the toolchain:
- make menuconfig, or copy buildroot-20071216-linuxonpsp.config to $(BUILDROOT)/
- make uclibc-menuconfig
- Copy uclibc-0.9.29-linuxonpsp.config to toolchain_build_mipsel/uClibc-0.9.29

5) make


TROUBLE SHOOTING
****************
NOTE: you may not run into every of the issues below as some of the factors
contributing to these issues may vary between different machines/systems.

1) Possible issue 1:
    make[4]: *** [bfd.info] Error 1
    make[4]: Leaving directory `/usr/src/buildroot-20071216/toolchain_build_mipsel/binutils-2.18-build/bfd/doc'
    ...
    make[4]: Leaving directory `/usr/src/buildroot-20071216/toolchain_build_mipsel/binutils-2.18-build/bfd'
    make[3]: *** [info-recursive] Error 1
    make[3]: Leaving directory `/usr/src/buildroot-20071216/toolchain_build_mipsel/binutils-2.18-build/bfd'
    make[2]: *** [all-bfd] Error 2
    make[2]: Leaving directory `/usr/src/buildroot-20071216/toolchain_build_mipsel/binutils-2.18-build'
    make[1]: *** [all] Error 2
    make[1]: Leaving directory `/usr/src/buildroot-20071216/toolchain_build_mipsel/binutils-2.18-build'
    make: *** [/usr/src/buildroot-20071216/toolchain_build_mipsel/binutils-2.18-build/binutils/objdump] Error 2

Workaround:
    cd /usr/src/buildroot-20071216/toolchain_build_mipsel/binutils-2.18-build/bfd/doc
    makeinfo --split-size=5000000 --split-size=5000000   -I /usr/src/buildroot-20071216/toolchain_build_mipsel/binutils-2.18/bfd/doc -o bfd.info `test -f 'bfd.texinfo' || echo '/usr/src/buildroot-20071216/toolchain_build_mipsel/binutils-2.18/bfd/doc/'`bfd.texinfo
    continue to run make under $(BUILDROOT)/

2) Possible issue 2:
    if [ ! -e /usr/src/buildroot-20071216/build_mipsel/staging_dir/mipsel-linux-uclibc/bin/cc ]; then \
                                    ln -snf gcc /usr/src/buildroot-20071216/build_mipsel/staging_dir/mipsel-linux-uclibc/bin/cc; \
                    fi
    ln: creating symbolic link `/usr/src/buildroot-20071216/build_mipsel/staging_dir/mipsel-linux-uclibc/bin/cc' to `gcc': No such file or directory
    make: *** [/usr/src/buildroot-20071216/toolchain_build_mipsel/gcc-4.2.1-final/.installed] Error 1

Workaround:
    cd $(BUILDROOT)/build_mipsel/staging_dir/
    ln -s usr/mipsel-linux-uclibc/ mipsel-linux-uclibc
    continue to run make under $(BUILDROOT)/

3) Possible issue 3:
    install -c /usr/src/buildroot-20071216/project_build_mipsel/linuxonpsp/root/usr/bin/ldd \
                                    /usr/src/buildroot-20071216/build_mipsel/staging_dir/mipsel-linux-uclibc/target_utils/ldd
    install: cannot stat `/usr/src/buildroot-20071216/project_build_mipsel/linuxonpsp/root/usr/bin/ldd': No such file or directory
    make: *** [/usr/src/buildroot-20071216/project_build_mipsel/linuxonpsp/root/usr/bin/ldd] Error 1

Workaround:
    touch $(BUILDROOT)/project_build_mipsel/linuxonpsp/root/usr/bin/ldd
    continue to run make under $(BUILDROOT)/

4) Possible issue 4:
    [ -f /usr/src/buildroot-20071216/build_mipsel/staging_dir/bin/mipsel-linux-uclibc-ld.real ] || \
                                    mv /usr/src/buildroot-20071216/build_mipsel/staging_dir/bin/mipsel-linux-uclibc-ld /usr/src/buildroot-20071216/build_mipsel/staging_dir/bin/mipsel-linux-uclibc-ld.real
    mv: can't stat source /usr/src/buildroot-20071216/build_mipsel/staging_dir/bin/mipsel-linux-uclibc-ld
    make[1]: *** [install] Error 1
    make[1]: Leaving directory `/usr/src/buildroot-20071216/toolchain_build_mipsel/elf2flt'
    make: *** [/usr/src/buildroot-20071216/toolchain_build_mipsel/elf2flt/elf2flt] Error 2

Workaround:
    cd $(BUILDROOT)/build_mipsel/staging_dir/bin/
    ln -s `find .. -name 'mipsel-linux-uclibc-ld'` mipsel-linux-uclibc-ld
    cd $(BUILDROOT)/toolchain_build_mipsel/elf2flt/
    make install
    continue to run make under $(BUILDROOT)/


NOTE: Some of the changes made in this toolchain are aimed to eliminate the
relocation type of R_MIPS_GPREL32 (see details in the MIPS ABI supplement) from
the generated ELF image by specifying the flag of -fno-jump-tables to stop gcc
from using jump tables during code generation. However, jump tables may not be
the sole reason accountable for the use of R_MIPS_GPREL32. If you are still
getting the problem of "reloc outside program" during app loading, further
changes to the toolchain may still be required.


 
 
Build PSPBoot
 
PSPBoot (latest version 0.22 now supporting 2.0+ firmware and slim PSP) is PBP program just like other PSP homebrews. To compile it, you need to install the PSPSDK which is available at http://ps2dev.org/. Download the source here, unpack it and run the following command under the directory you extract the package to:

make INSTALL_DIR="your_desired_location" install

 
To build the version that runs in 150 firmware, use the following command instead:

make INSTALL_DIR="your_desired_location" FW150=1 install

 
 
Build the Kernel
 
With the new toolchain, build the kernel is easy. Just unpack the tarball of the kernel source of version 2.6.22-uc1 (or versions close to it) and apply this new patch, then run the following commands to start the build:
 

make ARCH=mips menuconfig (or simply copy my config file to overwrite the .config file of the kernel)

make ARCH=mips CROSS_COMPILE=mipsel-linux- vmlinux.bin

 
And then compress the image with gzip and modify the bootload script accordingly.
 
NOTE: Since the new toolchain has changed some code related to argument passing to conform to the standard MIPS ABI, the kernel/executable built by this new toolchain is not binary compatible with the executable/kernel built by the old toolchain.
 
 
Build Busybox
 
Unpack the tarball of busybox which is available at http://busybox.net/, and apply this new patch before running the following command:
 

make CROSS_COMPILE=mipsel-linux- LDFLAGS="-static -Wl,-elf2flt" CFLAGS="-fno-jump-tables" menuconfig (or simply copy my config file to overwrite the .config file of busybox)

make CROSS_COMPILE=mipsel-linux- LDFLAGS="-static -Wl,-elf2flt" CFLAGS="-fno-jump-tables" install

 
After that, all the content will be installed in the $YOUR_BUSYBOX_DIR/_install folder. To embed busybox inside the kernel as an initramfs for system init (which is not the only way of booting the kernel as some may favor constructing the rootfs on other storage, like ms0), you may need to pack the _install folder into a cpio package and specify its location during kernel compilation. If you are not familiar with this, google "initramfs" for more technical details.
 
 
Build Your Own Application
 
With the new toolchain installed, building your own application to run on PSP is almost as easy as building one for your desktop pc, except that there are a few details you need to pay attention to. Here is an example of build a hello world program:
 

mipsel-linux-gcc -static -Wl,-elf2flt -fno-jump-tables hello.c -o hello

Here, -static is needed because no share library is supported in nommu systems. -Wl,-elf2flt tells the linker to convert the ELF image into a FLAT executable at the final phase of linking. And -fno-jump-tables is essential too as it tells gcc not to generate relocation entries of GPREL32 frequently used in jump tables. Others are just regular stuff.
 
 
Download
 
Buildroot patch 0.22 to create the unified toolchain: buildroot_patches-0.22.tar.bz2
 
uClinux on PSP-0.22 pre-built: uclinux_on_psp-0.22.zip
Prebuilt unified toolchain for uClinux on PSP: toolchain-uclinux_on_psp-0.22.tar.bz2

Kernel-0.22 config file: kernel-0.22.config.gz
Kernel-0.22 patch: kernel-0.22.patch.gz
 
Kernel-0.20 pre-built: uClinux.zip
Kernel config file: kernel.config.gz
Kernel-0.21 patch: kernel-0.21.patch.gz
 
Busybox-0.22 config file: busybox-0.22.config.gz
Busybox-0.21 config file: busybox.config.gz
Busybox-0.21 patch: busybox-0.21.patch.gz
 
PSPBoot-0.22 source: pspboot-0.22.tar.bz2
PSPBoot-0.22 pre-built: pspboot-0.22-prebuilt.zip (obsolete)
 
PSP OSK2.2 source: psposk2.2.tar.bz2
PSP OSK2.1 source: psposk2.1.tar.bz2
 
PSP Mouse Daemon 0.1 source: pspmd-0.1.tar.bz2
 
The old mips-toolchain pre-built: toolchain-mips.tar.bz2
The old mips-toolchain patch: toolchain-mips.patch.gz
 
Other Downloads:
(Many thanks to danzel again for the porting)
danzel's port of PSPBoot pre-built: http://localhost.geek.nz/psplinux/ucboot340.tar.bz2
danzel's port of PSPBoot source: http://localhost.geek.nz/psplinux/ucboot340_src.tar.bz2
 
 
 
Links
 
http://uclibc.org/
http://ps2dev.org/
http://www.uclinux.org/
http://www.psp-linux.org/
http://www.hitmen-console.org/
...