Building a Bootable Disc
This guide briefly explains the necessary steps to produce a homebrew iso9660 bootable disc suitable for the GameCube using a Linux PC. You can also build bootable discs using other operating systems, but this guide will currently focus on Linux only.
A homebrew iso9660 bootable disc can be directly booted in the same way a game is booted by both modchip and softmod IPL replacements, and by drivechips through the original IPL.
The iso9660 specification requires discs to have a reserved area of 16 sectors (the so called System Area) at the begining of the disc. The use of this area is not part of the iso9660 specification, thus it can be used for whatever particular purposes are needed. Usually this area is zeroed.
A GameCube disc contains a boot program, called the apploader, at a fixed position in the disc that gets called by the IPL to load the main executable program of the disc.
Coincidentally, the location of the apploader in a GameCube disc falls within the System Area. That means that we can place our own apploader into an iso9660 disc and keep the disc iso9660 compliant.
An iso9660 disc is not bootable by default. There are some standard extensions to provide booting services to an iso9660 disc, though. One of these extensions is the "El Torito Specification".
The custom apploader presented here is compatible with the "El Torito Specification" booting extensions and is able to boot DOL executables, meaning that we can use the already existing developer and iso9660 authoring tools to build our own homebrew bootable discs!
- A working Linux PC with the mkisofs, growisofs and netpbm tools installed.
- The ppc toolchain installed
- A DVD writer capable of burning DVD-R or DVD+R media.
- DVD-R or DVD+R media compatible with your GameCube.
- The cubeboot-tools package
- A valid DOL program that satisfies the following requisites (for cubeboot-tools 0.3):
- text and data sections must be within the address range 0x80000000 .. 0x80400000 (maybe a bit more)
- text and data sections must load to 32 byte aligned memory positions
- text and data sections must reside on 32 byte aligned file positions
- the DOL program must not rely on PSO being already loaded
For example, the GameCube Linux kernel binary in DOL format, once udolrel'ed, meets all the DOL-related requirements.
For simplicity, we will call bootldr.dol the DOL program that will get executed during disc boot.
Preparing the cubeboot-tools package
You need to build the cubeboot-tools unless you just want to use the Generic Boot Image file (gbi.hdr) as is.
1. Uncompress the cubeboot-tools tarball to a directory where you have write access.
$ cd /home/isobel $ tar xjvf /temp/cubeboot-tools-0.3.tar.bz2
2. Build the Generic Boot Image file (gbi.hdr) and the rest of tools.
$ cd cubeboot-tools-0.3 $ make
This procedure will generate various files and tools. The most important one is the gbi.hdr file (32768 bytes).
The ppm2bnr tool converts a 96x32 ppm image file to a Nintendo GameCube banner file. The banner file generated by this tool can be fed into mkgbi to construct a Generic Boot Image compatible with the Nintendo GameCube original IPL.
You can create a ppm file with several graphic tools, for example the Gimp.
The banner file contains some texts that get displayed by the original IPL at various stages. You can set these text messages through the use of various command line options to ppm2bnr.
Here are some examples of typical program invocation:
- Print program usage
$ ./ppm2bnr/ppm2bnr -h Usage: ppm2bnr [OPTION] [FILE] [-o OUTFILE] -n, --name=TEXT set name (32 chars max) -c, --company=TEXT set company (32 chars max) -N, --full_name=TEXT set full name (64 chars max) -C, --full_company=TEXT set full company (64 chars max) -d, --description=TEXT set description (128 chars max) -o, --outfile=PATH output file (default stdout)
- Convert my_banner.ppm into banner.bnr (the full command goes into one line)
$ ./ppm2bnr/ppm2bnr my_banner.ppm -n "Sample disc" -c "by isobel" \ -N "This is a sample disc" -C "www.gc-linux.org" -o banner.bnr
The mkgbi tool generates a Generic Boot Image file (gbi.hdr) to be used later to build a bootable homebrew iso9660 disc.
mkgbi needs a banner file and a file containing the apploader code to inject into the System Area. You can find ready-to-use versions of these files within the cubeboot-tools directory (icons/opening.bnr and ppc/apploader/apploader.bin, respectively).
Here follow some examples of typical program invocation:
- Print program usage:
$ ./mkgbi/mkgbi -h Usage: mkgbi [OPTION] -o [OUTFILE] -a, --apploader=FILE use apploader from file (default `apploader.bin') -b, --banner=FILE use banner from file (default `openning.bnr') -o, --outfile=PATH output file (default stdout)
- Generate a Generic Boot Image file (my_gbi.hdr) from the default apploader and banner
$ ./mkgbi/mkgbi -a ppc/apploader/apploader.bin -b icons/opening.bnr -o my_gbi.hdr
BEWARE! DO NOT USE THIS TOOL UNLESS YOU KNOW WHAT YOU ARE DOING! This tool is still Rudimentary Software (TM) and lacks lots of checks which can result in non-working DOLs. You all have been warned...
The udolrel tool converts an existing DOL into a new DOL which loads at lower memory positions, suitable for being booted from the original IPL. In addition, the resulting DOL generated by udolrel can optionally perform several interesting actions, like stopping the dvd drive motor or disabling the xenogc drivechip.
Currently, udolrel will only work if the memory area used by the original DOL do not overlap with the memory area used by the resulting DOL. And will silently fail otherwise!!!
You can safely use udolrel with DOLs loading high enough like the gc-linux kernel zImage.dol, or IPL replacements like GCoS.
(A smart reader will have noticed by now that you can actually run the existing GCoS releases on the xenogc through a udolrel generated DOL...)
udolrel needs to be passed a file containing the stub that will take care of relocating the DOL in memory. This relocation stub is available at ppc/sdre/sdre.bin within the cubeboot-tools directory, once cubeboot-tools are built.
These are some examples of program usage.
- Print program help
$ ./udolrel/udolrel -h Usage: udolrel [OPTION] [FILE] -o [OUTFILE] -s, --stop-motor stop dvd motor (default don't stop) -x, --disable-xenogc disable xenogc on startup (implies -s) -r, --releng=PATH relocation engine image (default sdre.bin) -o, --outfile=PATH output file (default stdout)
- Convert a gc-linux kernel zImagel.dol into a noxeno.dol, disabling the xenogc drivechip on startup.
$ ./udolrel/udolrel -x -r ppc/sdre/sdre.bin zImage.dol -o noxeno.dol
Making a bootable disc
Basically, making a bootable disc means building an iso9660 image with the "El Torito Specification" boot extensions, with a specific Generic Boot Image (gbi.hdr), and with the DOL file we want to boot as a boot file (bootldr.dol).
This procedure comprises the following steps:
1. We assume that you have the gbi.hdr file in the current directory.
2. Create a directory where you will store the disc contents.
$ mkdir ./my_bootable_disc
3. Copy the files you want to include in the disc to the directory created in step 2.
$ cp /my/files/* ./my_bootable_disc
4. Copy the DOL program you want executed during disc boot to the directory created in step 2.
$ cp /my/programs/bootldr.dol ./my_bootable_disc
5. Build the iso9660 disc image.
$ mkisofs -R -J -G ./gbi.hdr -no-emul-boot -b bootldr.dol -o ./my_bootable_disc.iso ./my_bootable_disc/
The command above will build an iso9660 image with Rock-Ridge and Joliet extensions, with the "El Torito Specification" booting extensions and with bootldr.dol as a boot image file in no emulation mode.
Note that the -b command line option must specify just the name of the DOL program we will boot, not the path where it is stored. This file must be present within the directory created in step 2.
5. Burn the image you have created to DVD-R or DVD+R media.
# growisofs -dvd-compat -Z /dev/dvd=./my_bootable_disc.iso
Note that you may need root privileges in order to burn the iso9660 image to disc.
Booting a bootable disc
In order to boot a homebrew disc built using these instructions, use the appropiate option of your GameCube replacement IPL (GCOS, NinjaShell, Qoob, Viper, ...).
Practical Case: Creating a mfe-distro bootable disc
A mfe-distro based disc can be easily transformed into a bootable disc, thus making it even easier to get the MPlayer front-end running. We just need to build the disc in the way we learned in this article.
- the gbi.hdr file from the cubeboot-tools package
- the mfe-fs.bz2 file from the mfe-distro package
- a mfe-boot.dol (mfe-bo20.dol, already udolrel'ed) that supports GameCube-like discs (do NOT use any version older than mfe-bo18.dol or, althought it will boot, it will refuse to use the disc)
- your media files
Here follows the step by step procedure:
1. Create a working directory.
$ mkdir ./workdir
2. Copy the gbi.hdr file to the working directory.
$ cp /temp/gbi.hdr ./workdir/
3. Create, under the working directory, a directory where you will store the disc contents.
$ cd ./workdir $ mkdir ./disc/
4. Copy the mfe-bo20.dol and the mfe-fs.bz2 files to the disc contents directory.
$ cp /temp/mfe-bo20.dol ./disc/mfe-boot.dol $ cp /temp/mfe-fs.bz2 ./disc/
5. Copy your media files to the disc contents directory.
$ cp /my/media_files/* ./disc/
6. Make sure you have more than ~350MB and less than ~1.5GB of data in the disc contents directory.
This check is to make sure that the disc will be accepted, and that all data will be readable by your cube.
7. Build the disc image.
$ mkisofs -R -J -G ./gbi.hdr -no-emul-boot -b mfe-boot.dol -o ./disc.iso ./disc/
8. Burn the disc image to a DVD-R or DVD+R that your cube can read.
# growisofs -dvd-compat -Z /dev/dvd=./disc.iso
Use of root privileges may be needed during this step.
After all of this you have a disc that can boot by simply choosing the appropiate option of your custom replacement IPL.
A ready-to-use sample mfe-distro-sample-built-with-cubeboot-tools-0.2.iso.bz2 (~80MB, compressed with bzip2) is available for you to test.
bzip2 for windows installer (~706KB)