GC-Linux with rootFS on SD

From GC-Forever Wiki
Jump to navigation Jump to search


First of all I want to thank the people who made all this possible:

The guys from GC-Linux: http://www.gc-linux.org

Simon "Scorpei" van de Berg for his great tutorial how to build an SD-card adapter for the cube: http://ngc.scorpei.com/GUIDE-SD_adapter.html

The linuxwiki: http://linuxwiki.de

The creators of MFE: http://www.gc-linux.org/wiki/Mfe-distro

The aim

The aim of this Project is to create a custom Linux Kernel, which runs on a modified GameCube and has the root file system on an SD-card which is plugged into the memory-card slot via an SDGecko. After the system boots form the SD-card, it should start a custom program which allows the user to start programs using the GameCube-pad.


Normally the GC-Linux kernel will try to load the root file system from a NFS attached storage over the BBA.

However this isn't very practical because you need a broadband adapter for your GameCube, and you will always have to run an NFS-Share on your PC or a dedicated Server. What I want is a stand-alone Linux on my GameCube! So why not create one by myself?


  • Create & boot a Kernel with his root file system on an SD-Card [Done!]
  • Create an auto executing script (init/linuxrc?) [Done!]
  • Write an GameCube-pad controlled program [ToDo…]
  • Enjoy your Linux-Cube!

What you will need

  • Nintendo Gamecube
  • Method to load homebrew
  • An SD-Card (max. 2GB atm)
  • SDGecko (See [5] or Buy)

For Compiling it

cp .config  linux-2.6.32/.config
cp gamecube.dts linux-2.6.32/arch/powerpc/boot/dts/gamecube.dts

What should happen?

After the GameCube boots, you will start the kernel.dol from the 1st partition of your SD-Card (fat formatted). The kernel will boot and mount the 2nd partition as his root (ext2/3 Formatted). Then will the Kernel look for his init-script and execute it. In our Case we use the /bin/init script to configure the rest of the hardware (swap, mounting, etc.) and then start our script/program.

The boot parameter

The boot parameters were the first thing I edited. It’s defined in the “arch/powerpc/boot/dts/gamecube.dts”-file. I edited it as follows:

chosen  {
         bootargs = "root=/dev/gcnsda2 rw video=gcn-vifb:tv=auto";

The “root=” parameter tells the kernel that his root is on “/dev/gcnsda2” that means the SD-Card (sd) that is plugged into the GameCube’s (gcn) MemoryCard-Slot1 (a) on Partition 2 (2) [Because the fist is used so SD-Load to execute the kernel.dol] “rootwait” tells him to wait for his root file system until it’s ready. The video parameter tells him which video device to use, and how. In our case he uses the GameCube framebuffer (gcn-vifb), on a tv. With the “auto” parameter, he will look for himself which mode to use. (NTFS, PAL50/60Hz…)

Creating a Root file system

After I could see that my kernel wants to use my SD-Card, I needed a root file system. Basically you don’t need really much, it’s just the normal root-tree (/dev /bin /etc /mnt /usr…) But because I’m a pretty lazy person, I just used a mix of the ramdisk and the file system of the MFE-Distribution and it worked pretty well. I just used my own /linuxrc and /bin/init-scripts. Also you need to add the SD-Card-Devicenodes to the /dev directory. Please do not use the description from the gc-linux wiki [1]. There they were called “/dev/sdcarda” and “/dev/sdcardb” but they are called “/dev/gcnsda” and “/dev/gcnsdb”.

So we will add some nodes (as root):

mknod dev/gcnsda   b 61 0
mknod dev/gcnsda1  b 61 1
mknod dev/gcnsda2  b 61 2
mknod dev/gcnsda3  b 61 3
mknod dev/gcnsdb   b 61 8
mknod dev/gcnsdb1  b 61 9
mknod dev/gcnsdb2  b 61 10
mknod dev/gcnsdb3  b 61 11

We will also need one for Audio-RAM

mknod dev/aram     b 37 0

I also added an 3rd SD-card partition, if we maybe want to use them later.

Last we add an mount path for the 1st SD-Card partition at /mnt/sdcarda, so we can mount it for later use.

# mkdir mnt/sdcarda

After that we need to create an fstab (/etc/fstab) to mount the cube’s Audio RAM as swap.
Also we will add proc, root and our first SD-Card (vfat) Partition [Optional].


/dev/aram       swap            swap    pri=32767                    0       0
/dev/gcnsda2    /               ext3    defaults,errors=remount-ro   0       0
/dev/gcnsda1    /mnt/gcnsda1    vfat    defaults                     0       0
proc            /proc           proc    defaults                     0       0

The Init-Script

So, the kernel boots, the filesystem looks great, what to do next? We need to give our Kernel a init-script. As we didn’t gave the kernel the “init=/…” parameter, he will try to start the default script “/bin/init”.

A very important thing is that init is not allowed to die! So it has to run all the time.

But what has our system now to do? We need:

  • Format Audio-RAM as swap (mkswap)
  • Mount fstab
  • Activate swap
  • Start our programs we need (mplayer, GUI, whatever)
  • Keep init alive!

So let’s do that!


mkswap /dev/aram
mount –a
swapon –a

#Now comes our script or whatever you want to execute

#And keep init alive
while [ 1 –eq 1 ]; do
     sleep 1

Preparing the SD-Card

First of all, we need to prepare our SD-Card partitions. We need a first partition formatted with fat (vfat) and a second partition for the root file system (ext2/3).
How big they are depends on your SD-Card and for what additional use you want to use it.
We need about 10MB For the kernel.dol plus the SDLOADER.BIN and about 20mb for the basic root file system. Since I want to extend the rootfs and maybe want to use other homebrew and kernel.dol’s I formatted it as follows (1GB SD):

  • 300MB vfat
  • 700MB ext2/3

I choose ext3 because I was first using ext2, but I had problems with destroyed libraries. So I switched to ext3 because it’s journaling.
If you are ready to go, copy the file system onto the ext2/3 partition, and the GcImage.dol on the vfat partition.

Preparing SD-Card with fdisk

Partitioning with fdisk is pretty easy, i will do an example of how to do it using a 1GB SD-Card. Of course can you choose your partition sizes as you want. Notice that the device path WILL be another on your system!

# fdisk /dev/mmcblk0           #Change to your device-path
> o                            #Create empty DOS Patition Table
> n                            #Create new Partition
> p                            #Primary
> [Enter]                      #At first sector
> +300M                        #with 300MB size, change to whatever you want for your "Homebrew"-Partition

That was our first partition that is going to be out vfat-homebrew partition, now comes the rootfs partition

> n                            #Create new Partition
> p                            #Primary
> [Enter]                      #At first useable sector (behind our vfat-partition)
> [Enter]                      #With maximum of size (Here: 700MB)
> w                            #Write everything to device
> q                            #Quit fdisk

Now we have our Partitions. But they need a filesystem. In this example we use mkfs for this task:

# mkfs.vfat /dev/mmcblk0p1     #Watch your path!
# mkfs.ext3 /dev/mmcblk0p2     #Same here! 

Now you are ready to go. Copy GcImage.dol to the 1st Partition and the rootfs to the second.

So what’s next?

The next part is to include the software we need. This isn’t very problematic because we can use every binary which is compiled for a PowerPC! So what I did is that I downloaded my binaries and libraries from the Debian package-Service [3]. And used the libSDL and the mplayer binary from the mfe-distribution, since they were included in the filesystem. I just added the libraries for divx and mp3.

If you have an Broadband-Adapter in your Cube, you could even install apt-get and just download the packages directly on your cube!
Another possibility for creating a big but good root file system would be the way from the GC-Linux wiki [4].

Need Help? Got Ideas? Want to Help?

Join the GC-Forever Community! :) [0]


[0] http://nold.freeunix.net/devnull/index.php?show=./Stuff/Consoles/Gamecube/GameCube%20Linux
[0] http://gc-forever.com
[1] http://www.gc-linux.org/wiki/Memory_and_Filesystems#Creating_the_SD.2FMMC_card_device_nodes
[2] http://www.gc-linux.org/wiki/Memory_and_Filesystems#Create_the_device_node_for_the_audio_RAM_driver
[3] http://packages.debian.org
[4] http://www.gc-linux.org/wiki/Creating_a_Root_Filesystem
[5] http://ngc.scorpei.com/GUIDE-SD_adapter.html