DevkitAdvance Linux Setup Guide

NOTE:

This page is somewhat old now and although the links and information are still correct I would recommend for people to use DevkitARM instead, since it is less buggy, right up to date (gcc 3.4), much smaller and gets regular updates. DevkitARM is available from www.devkit.tk (build scripts to build the devkit from source are in the DIY section of the website.)
Guide to Installing the Linux Devkit Advance from source

Introduction
I have taken it upon myself to try and provide installation details for those of us actually using the devkit in Linux. Including how to build the devkit from source, and getting started.

Packages you need;
binutils http://ididntdoit.et.tudelft.nl/~jason/agb-binutils-2.11.2.tar.bz2
gcc http://ididntdoit.et.tudelft.nl/~jason/agb-gcc-3.0.2.tar.bz2
newlib ftp://sources.redhat.com/pub/newlib/newlib-1.10.0.tar.gz

Installation;
Download the three source packages mentioned above into a new directory. Next, download this install.sh script that I made and put it into the directory with the source packages.

Run install.sh by typing “./install.sh” or “sh install.sh”. It should extract the sources and build them into a new directory, it cleans up the sources afterwards so you are left with only tarballs and a ready to use devkit in a directory called devkitadvance.

Now all you have to do is add the devkit binaries to your path. You can move the devkitadvance directory wherever you like, mine resides in /gbadev/devkitadvance. To add the binaries to my path I type the following; “export PATH=$PATH:/gbadev/devkitadvance/bin” I have added that command to my ~/.profile to save typing it all the time.

Checking the Installation;
Typing “arm-thumb-elf-gcc -v” should give you an indication that its installed. You will need to compile a test program to make sure its working properly though.

Save the following c code into a file called main.c on your harddisk somewhere and compile it with this command; “arm-thumb-elf-gcc -o test.elf main.c”

int main () {

return (0);
}

That should compile with no errors and produce test.elf. The command; “arm-thumb-elf-objcopy -v -O binary test.elf test.bin” will copy the binary out of test.elf into the file test.bin. You can run this binary straight away in an emulator or on your GBA by using a flash cart.

Getting started;
To get anything to actually run I had to get a new crt0.o and lnkscript. These are available in a package by Jeff Frohwein from http://www.devrs.com/gba/files/crtls.zip.

Firstly you need to delete all traces of any “crt0.o” files in your devkitadvance tree. You can find out where they are by going into your devkitadvance directory and typing; “find . -name crt0.o”

Next, unzip the crtls.zip from above into a new directory and assemble the crt0.S file with the following command; “arm-thumb-elf-as -o crt0.o crt0.S”

You should move the files “crt0.o” and “lnkscript” to your project directory, for example copy them into the directory with the test program you compiled earlier from this page. With this crt0.o and lnkscript the main in your programs should be AgbMain, so change the main.c you made earlier. You should now compile it with this command; “arm-thumb-elf-gcc -T lnkscript -o test.elf main.c” after this you can get the binary out using the same command as before; “arm-thumb-elf-objcopy -v -O binary test.elf test.bin”

I have created a simple gba project skeleton that anyone is free to use. It contains the lnkscript and crt0.o from above and a Makefile that shows how to compile the program and extract the binary for use. You can download my simple gba project skeleton if you want to make life easy for yourself. (You do still need to delete all the “crt0.o” files in you devkitadvance tree.)

More GBA