gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > NDS Loader

#76369 - Fling - Tue Mar 21, 2006 2:39 am

Just looking for some confirmation/help/suggestions on writing a NDS loader. I know there are a few out there, but a lot work with CF cards which isn't what I need (primarily because I have a F2A 64M heh... but that's not the point of this post).

Basically, I'm trying to write a loader + server program that will receive a NDS rom image from my computer over my network, load that into memory, and then have the DS execute it. The loader program will be stored on my flashcard, but the rom images received via network will just be executed as soon as they're received (not written to the card or anything). I have the network stuff done... successfully receives any rom image I send over the network, loads it into memory, etc... the problem I'm having is getting the DS to execute the rom image once it's been received.

I've done some searching on this forum and found quite a bit of info. In particular, I've been looking at the bootloader code from here. I'm 99% certain I've figured out exactly what each part of the code is doing and how it relates to the basic process of loading a NDS posted by natrium42 here.

Anyway, that particular bootloader code I linked to that I've been looking at (boot.c in the BootLoader source directory)... first, it seems that it's just the ARM7 code? The code seems to direct the ARM9 from the ARM7 if I'm not mistaken, which I guess makes it a bit easier to synchronize the two processors? Also, at the end of the beginning comments, there's this little bit:

Quote:
Helpful information:
This code runs from the first Shared IWRAM bank:

0x037F8000 to 0x037FC000

So, everything in boot.c executes in that address space? How do I load the code in there to begin with? (Or am I missing something really obvious? heh).

Any and all help would be greatly appreciated!

#76387 - josath - Tue Mar 21, 2006 7:04 am

First off, here's another nds loader which may help you, and this one is designed to boot from a gbfs filesystem on gba flashcarts:
http://cvs.sourceforge.net/viewcvs.py/ndslib/ndslib/examples/loader/boot/main.cpp?rev=1.1&view=markup
(You can look in MultiNDS to see how the bootloader is called.)

as for the 'how do I copy to memory', I think he just simply copies it into ram. as in byte by byte. But I'm not completely sure about it.

#76486 - Fling - Wed Mar 22, 2006 2:20 am

I think the only thing really holding me back at this point is getting the loader code into the proper place.. I noticed that ndstool has a few options to set the ARM7/ARM9 binary locations and execution start points, however, when I tried using those options, it didn't seem to work... only time it would ever work is if I left the RAM locations and execution points at the default settings (0x02000000 and 0x03800000).

So... I'm wondering, is there anyway to get one (or even both for that matter) of the binaries to execute at different addresses then the defaults? If so, how would I go about doing this? I just feel like I'm missing something really silly here, heh.

#76556 - josath - Wed Mar 22, 2006 6:38 pm

Two possible options:
1. leave the nds ram/execute locations at default, when your app starts, copy your code to the right place manually
2. change the locations in the .nds, however you will need to change some settings in your linking process. the code compiles, expecting it will be loaded at a certain place. I don't know much more about this, sorry, but thats the general idea

#76604 - tepples - Thu Mar 23, 2006 12:54 am

josath wrote:
leave the nds ram/execute locations at default, when your app starts, copy your code to the right place manually

And for this to work, you may have to compile the function in question with the switch -fPIC so that GCC generates position-independent code.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.