Installing a Nintendo DS debugger environment on the Mac
Following this list of steps will add a debugger and emulator to the /opt/local root that MacPorts uses for its installed software. Since it can be useful to upgrade devkitpro independently of these, I've left these packages outside the devkitpro tree. Feel free to change the "./configure" lines to place them inside the tree if you wish :-)
Note that I've only tried this with a 10.4.9 Mac running the latest (2.4.1 as of writing) Xcode toolset. If you try with other combinations, your mileage may, as they say, vary...
Install MacPorts
- Go to macports.org and download
MacPorts-1.4. I used 1.32 on the machine I tested this
with, but that's because it was already installed. I
can't see any reason why you ought not use 1.4...
- Double-click the installer and follow the
instructions to install the software.
At this stage you ought to make sure that
- /opt/local/bin is in your path (I can't remember if
Macports does this for you, or you have to edit ~/.cshrc
or ~/.profile)
- you have the environment variable CFLAGS set to
"-I/opt/local/include"
- you have the environment variable LDFLAGS set to
"-L/opt/local/lib".
Depending on which shell you're running inside Terminal/Xterm, this is done in different ways. Type echo $SHELL to find out, and then:
If you are running 'tcsh' or 'csh', edit ~/.cshrc and add
setenv CFLAGS -I/opt/local/include
setenv LDFLAGS -L/opt/local/lib
set path = (/opt/local/bin $path)
If you are running 'sh' or 'bash', edit ~/.profile and add
export CFLAGS=-I/opt/local/include
export LDFLAGS=-L/opt/local/lib
export PATH=/opt/local/bin:$PATH
Install the support software and emulator/debugger
Masscat has updated his source to work with the 0.6 version of desmume. If you want the latest version, read on. If, for some reason, you want the original instructions for the older version, they're still available...
Open a new terminal window so you pick up the values you've just changed (all the following things are done in this terminal). You'll see text scroll by in response to your commands. Sometimes lots of text... Don't be alarmed :-)
- Type sudo port install wget libsdl
gtk2
- Type wget
http://blog.gornall.net/page1/assets/desmume-gdb-0.6.0.tar.bz2
- Type tar xjvf
desmume-gdb-0.6.0.tar.bz2
- Type cd desmume-gdb-0.6.0
- Type ./configure --prefix=/opt/local
--enable-gdbstubs
- Type make
- Type cp src/cli/desmume-cli
/opt/local/bin/desmume-gdb (or use 'sudo' if
you need to)
- Type cd ..
- Type wget
http://blog.gornall.net/assets/gdb-6.6.tar.bz2
- Type tar xjvf gdb-6.6.tar.bz2
- Type cd gdb-6.6
- Type ./configure --target=arm-none-eabi
--prefix=/opt/local
- Type make
- Type make install
... and you're done.
Using the debugger
The patch to desmume means the emulator will create two TCP sockets for GDB to talk to, the ARM7 is on 20001, the ARM9 on 20000. [Note that this is the other way around from the first version]. Only the ARM9 is active as delivered - you'll have to uncomment the code src/cli/main.c around line 164 to get the ARM7.
So, run desmume (type desmume-gdb /path/to/file.nds), load the NDS file you wish to debug, press 'play', and the emulation will start, but nothing will happen just yet - it's waiting to talk to the debugger.
In a different window (to prevent spew from both programs confusing you), run arm-none-eabi-gdb /path/to/arm9.elf (where arm9.elf is the ELF file that the NDS file was created from - this gives you source-level context while you're debugging) and connect to desmume with:
target remote localhost:20000
Now, you're debugging...
I'd just like to re-iterate that none of this is my work. All I'm documenting is how to get it working on the Mac...