One of my new colleagues recently told me that he knew about PS2rd and that he had used it in the past to do some reverse engineering. In case you haven’t heard of it (really?), PS2rd stands for Playstation 2 remote debugger and used to be my pet project back when I was into homebrew and game hacking. Its killer feature is the ability to dump the PS2’s RAM to PC while playing a game. Best thing: it’s all open source and completely legal.
Without a doubt, it’s always motivating to see people actually using your software. And even though active development of PS2rd has been on hold for over 1.5 years, the mere fact that my colleague mentioned the project spurred my interest in it again. Incidentally, I’ve been a happy Mac user since last Christmas and trying to get my Linux stuff running on OS X anyway. So I set out to find a way to compile and use PS2rd under Mac OS X as well.
For a DevOps guy like me, the most appealing solution to that problem is Vagrant. FYI, Vagrant is awesome – it allows you to easily set up lightweight development environments based on virtual machines (or boxes in Vagrant speak). The cool thing about those boxes is that they can be used by others on any platform that Vagrant runs, including Windows, Linux, and Mac OS X. What follows is a step-by-step guide on how to create such a box for your everyday PS2 development.
The Vagrant Box
First of all, install the Vagrant base image for Ubuntu 10.04 (Lucid Lynx). In the past I’ve used Ubuntu exclusively for PS2 homebrew, so that’s where we’re starting from:
Then create a VM based on the Ubuntu box and boot it up:
Next, SSH into the VM and install Git before cloning the PS2 toolchain scripts from GitHub:
The toolchain scripts will automatically download, compile, and install everything we need for PS2 development, including cross compilers for PS2’s EE and IOP processors and a homebrew PS2 SDK. Start the setup, which will take several minutes to finish, this way:
When done, new compilers etc. can be found under
/usr/local/ps2dev. We need to modify the
$PATH variable in order to run them from the command line. Edit the login script
~/.profile to add the following:
After manually sourcing the login script again (done automatically next time you log in), we can run the EE cross compiler, for instance:
At that point, we’re basically done with the PS2 build environment. We could package up the VM in the form of a Vagrant box file and distribute it. However, there’re a few useful tricks that will drastically reduce the size of the final box:
Finally, exit the VM and package it up into a box file called
ps2dev.box. After the packaging is complete, install the box locally for later use:
If you don’t want to do all those steps yourself, you can also install the ready-to-use box I’ve uploaded to GitHub:
With our brand-new Vagrant box, compiling PS2rd under OS X is a piece of cake. Simply clone the code repository of PS2rd and set up a VM in the project folder:
Inside the VM, the contents of the project folder is shared at
/vagrant. Go to that folder and invoke
make to build PS2rd:
In order to run cross-compiled binaries like
ee/loader/ps2rd.elf on your PS2, I recommend installing ps2client directly on OS X, so you can use it outside of the VM too:
That’s it. Happy hacking.
Just a small update to add two tidbits that didn’t make it in the original post.
First, here’s a Vagrantfile
that, once added to your PS2 project, will make the Vagrant setup even simpler.
That file basically tells
vagrant up to use the ps2dev box we built before.
If that box isn’t already available on your system, Vagrant will automatically
download and install it for you.
With the Vagrantfile and an SSH shortcut, it only takes four commands to clone and compile PS2rd:
Second, I built another Vagrant box,
this time based on the brand-new Ubuntu 12.04 release (Precise Pangolin). The
only difference I noticed while creating the box was that I had to install
in addition to
git-core. Get the new box from GitHub: