Home New Tutorials Programs
1-R4DS Setup 2-Software Space Invaders
Old Tutorials DSEmu
1-Setup 4-Sound 7-FIFO
2-Framebuffer 5-SRAM 8-Interrupts
3-Keys 6-Filesystems 9-Microphone
10-Extended Rotation Background

Homebrew Nintendo DS Development Tutorial Part 2

The previous tutorial covered the hardware side of the equation. That was the R4DS card which enabled running of homebrew software on a non-modified Nintendo DS. To make your own programs you need some software.

Software

The main tools for software development are the compiler, the libraries, and an emulator to test programs without having to copy them to the device. A good text editor is also important.

The compiler comes as part of the devkitPro set of tools. This is a port of the GNU C compiler for the ARM chip that is used in the Nintendo DS. Included with devkitPro are libraries for using some of the features of the DS. In my older tutorials I often wrote about how to access the low lever routines of the DS. Thankfully devkitPro and its libraries have matured a lot since then and has nicer ways of doing things.

The emulator I've been using lately is DeSmuME. It runs on Windows, Linux and Mac OS X and includes some nice debugging features.

devkitPro comes with an editor for Windows and that should work fine. I use GNU Emacs since I spend quite a bit of time on different operating systems and Emacs runs across all of them.

Installing on Windows

Installing the devkitPro system on Windows is easy. Download and run the devkitPro Windows Installer. This will download and install the compiler, libraries and an editor. All relevant changes are made to your PATH so you can run the programs straight away. It also includes some example programs which we'll use to quickly test the install.

A useful example program that is not installed via the installer is the test program for DSWifi. Download the source from wifi_lib_test.zip and extract it to a directory under 'c:/devkitpro/examples'.

The emulator can be downloaded from the DeSmuME download page. The latest version for Windows is currently 0.7.2 and it's what I used for testing. The download is a .zip file containing the executable. Copy the contents of this .zip file to a directory of your choice. Running the DeSmuME.exe program will start it.

Installing on Linux and Mac OS X

On Linux you'll have to download and install things manually. Create a directory where you want to install the software. I used one called 'devkitPro', located off my home directory.

Download the latest version of devkitARM from the sourceforge repository. Extract this in the 'devkitPro' directory you created. This should create a subdirectory called 'devkitARM' containing the compiler for ARM:

mkdir ~/devkitPro
cd ~/devkitPro
tar jxvf ~/devkitARM_r21-linux.bz2

The library containing the Nintendo DS routines is called libnds. Download the latest version of this and extract this to a 'libnds' subdirectory:

cd ~/devkitPro
mkdir libnds
cd libnds
tar jxvf ~/libnds-20071023.tar.bz2

Download and extract the following libraries in the same way into the 'libnds' subdirectory:

cd ~/devkitPro/libnds
tar jxvf ~/libfat-nds-20070127.tar.bz2
tar jxvf ~/dswifi-0.3.4.tar.bz2

Download and extract the nds examples which contains sample programs to build and try:

cd ~/devkitPro
mkdir examples
cd examples
tar jxvf ~/nds-examples-20071023.bz2

Another useful example is the test program for DSWifi. Download the source from wifi_lib_test.zip and install it in a directory under 'examples':

cd ~/devkitPro/examples
unzip ~/wifi_lib_test.zip

To be able to run the compiler tools from the shell you'll need to set some environment variables. Either set these manually each time you want to do some development, or have them set from within your shells initialization file (probably .bash_rc or .profile):

export DEVKITPRO=~/devkitPro
export DEVKITARM=$DEVKITPRO/devkitARM
export PATH=$PATH:$DEVKITARM/bin

The emulator can be downloaded from the DeSmuME download page. I downloaded the source and built from that but there are also binary builds available.

Testing

A simple test is to build one of the example programs. I used hello_world from the 'examples/nds/Graphics/2D/' directory. From a Windows command prompt, or a Linux/Mac OS X shell, change to this directory and run the command 'make'.

Windows:

cd c:\devkitPro\examples\nds\Graphics\2D\hello_world
make

Linux/Mac OS X

cd ~/devkitPro/examples/nds/Graphics/2D/hello_world
make

This will result in a hello_world.nds file being produced. Copy this to the R4DS card as described in tutorial 1 and you should be able to run it. This same file can be loaded in the DeSmuME emulator to test it on your PC before running it on the device. You can build any of the examples using this approach.

The next tutorial will be diving into creating your own programs.