DS development was pretty hard with my last flashkit.. by hard I mean next to impossible. Avoid the UltraFlashPass 512Mbit set for homebrew. I bought an R4DS recently, it's the tits.
The R4 can boot homebrew code out of the box and has support for the DLDI and FAT filesystem access libraries, should come in quite handy. ^^ I've been working on a few DS apps, the most complex of which is an SSH client. Development was hindered by the previous flashkit however, I'll revive it once I have time. At the moment I'm porting my GBA rom dumper to the DS and enabling it to dump directly to the MicroSD or whatever is in your Slot 1 device. I would then like to copy at small roms (64Mbit max I think) to the RAM pack shipped with the Opera browser and jump into GBA mode, I'm not sure if this is going to be possible.
Some of this will be written as a guide to doing certain things, like setting up the DevkitPro environment or interacting some library. The rest will be written as a record of things I've found.. skim the shit you don't find useful. :P
The DS contains most of the GBA ARM7 hardware and then a whole layer of ARM9 stuff on top. The DevkitPro flavour for the DS is DevkitARM just like the GBA. There are libraries to support the DS' 802.11b capabilities among other things. Let's start with building a DevkitARM environment for DS development.
First off, DevkitPro heavily based on the GNU toolchain and is one of those things that is easier to get working if you happen to be in a GNU environment (Most linux based systems) or one that can support GNU in a non-retarded fashion i.e. any of the BSDs. Windows users should stick to the pre-builds in my honest opinion,…
There are pre-builds of DevkitARM for GNU/Linux hosts, but it's much nicer to build your own. Debian users should start installing the build-essential package and in the meantime head over to the DevkitPro sourceforge page (which seems pretty well hidden on their homepage for some reason) and checkout the latest version of the buildscripts.
Once you have the buildscripts archive downloaded you should extract it to your path of choice. I'm going to be working in /home/daniel/.dev/nds with my final install being in /home/daniel/.dev/nds/devkitpro, you should replace uses of these paths with yours. To get the build process going do the following in the directory you extracted the buildscripts archive.
daniel@kotoko:~/.dev/nds$ ./build-devkit.sh
Magically the following will appear on your terminal..
This script will build and install your devkit. Please select the one you require 1: build devkitARM (gba gp32 ds) 2: build devkitPPC (gamecube) 3: build devkitPSP (PSP)
Obvisously, you want to select option one.
The installation requires binutils-2.17, gcc4.1.1 and newlib-1.14.0. Please select an option: 1: I have already downloaded the source packages 2: Download the packages for me (requires wget)
Unless you have the files laying around somewhere, maybe from a previous devkitpro build, you should select option two. The source files it will download are pretty big, I suggest you stash them for use again later. For example you could build a PSP toolchain out of them too.
Please enter the directory where you would like 'devkitARM' to be installed: for mingw/msys you must use <drive>:/<install path> or you will have include path problems this is the top level directory for devkitpro, i.e. e:/devkitPro
As I mentioned earlier my final build is going to me in /home/daniel/.dev/nds/devkitpro. If you want to make it accessible to everyone that uses your system you may want to store it in /usr/local or similar instead.
Now the build process begins… and doesn't finish for a while. I'll explain the post-build setup (environment variables etc) and how to build the support libraries and examples tomorrow. ciao!
Once the build process has finished you'll be asked if you want to keep the source files, I suggest you do, as I said before you can use them to build other DevkitPro targets.
The next thing to do is to export DEVKITPRO and DEVKITARM environment variables so that projects built around DevkitARM build. The system-wide way to do this is in /etc/profile for your user you could do this in your ~/.profile or the rc for your shell. How you do it is up to you. I added this to my /etc/profile
DEVKITPRO=/home/daniel/.dev/nds/devkitpro/ DEVKITARM=/home/daniel/.dev/nds/devkitpro/devkitARM/ export DEVKITPRO DEVKITARM
Time to test your shiny new toolchain by building something with it. Get over to the DevkitPro Sourceforge page again and browse to the files, examples, and then grab the latest nds-examples-yyyymmdd.tar.bz2 examples archive. At the time of writing this is nds-examples-20070127.tar.bz2. Extract the archive, you want to do this into an empty target directory… type make in the root of the examples tree and it'll build everything for you. Some examples might not build because of missing libraries, ones not included in the vanilla DevkitARM, I'm going to write about building and install those later. Browse around some the built examples and copy either the resulting .nds file to your Slot 1 device or the .ds.gba file if you have a Slot 2 device and see if it works on your DS. ^^
You can see the Hello World example running. Really need to work out how to get thumbnails from Gallery2 into dokuwiki. :/ Anyhoo, more later.. busy busy busy. :(
Update; Here's a thumbnail from gallery2 that links to the larger image.. The dokuwiki syntax doesn't really allow for it unless you insert raw HTML. :/
<a href="http://photos.cardboardbox.org.uk/main.php?g2_itemId=928"><img src="http://photos.cardboardbox.org.uk/main.php?g2_view=core.DownloadItem&g2_itemId=929&g2_serialNumber=2"></a>
Comparing the NDSTech Wiki page about the memory layout of the NDS and nocash's GBATEK's memory map for the GBA you can see the GBA cart space is mapped between 0x08000000 and 0x09FFFFFF on both. just got to work out how the NDS handles DMA, surely the GBA modes still exist, hopefully accessible in NDS mode…
The writable memory in the expansion pak starts at 0x09000000, the normal GBA rom header starts at 0x8000000 and the actual code right after that. Apparently it's not possible to switch to GBA mode and start execution from a different entry point. A multiboot to do the jump from GBA mode isn't possible either because the EWRAM is cleared when the GBA BIOS starts. See my post on gbadev.