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 > WMB compatible executable

#50340 - mokoloko - Mon Aug 08, 2005 9:15 am

Hello:

I'm new to the DS coding but I have done some simple things for the GBA.

I have downloaded the devkitpro, and the ndslib and now I'm following the Doublec's tutorials.

I have compiled the first sample (Demo1) and I have flashed (demo1.nds.gba) it to a cart and it works on the real hardware (I have flashed my DS with the patched firmware.

Then I have tried the WMB application and I sended the program (demo1.nds) to the DS and it worked! I was surprised because I though that I must do some changes in the code to be able to run from the WiFi.

In the GBA you must change the start address and the address of the data segments to be on the RAM area, so I supossed that something similar happens on the DS, but this sample works without work.

Then I have tried more complex samples and demos from other people and they didn't worked.

I suposse that the Demo1 works because it doesn't access data outside from the executable, and if the DS copies the executable to the RAM it works, but if a program needs to read more data you need to prepare the data to the correct address.

So my question is how could I make a program that runs from the WiFi? I prefer to use the wifi to test my programs beacuse now they will be only a few KBs in size, and this way you don't need to flash one time and another all the times that you make a simple change to the code.

Probably with something like a define or changing some lines in the linker script you could have three diferent versions of your program.

I'm looking for something that let you make:

1.- A WiFi version. It's limited by the RAM, but it's very fast to test.
2.- A Flash version. It's the best way to reales a final work.
3.- A mixed version. You could flash the data (graphics, music, etc) to the flash and then send by WiFi the executable code. The program will read the data from the flash cart, but the code from ram. This is an ideal solution fro developing because the data won't change very often from built to built, but the code will change constantly, so you have a fast way to test your program with less limitations that the WiFi version.

I think that this can be done simply changing some information in the code, but I don't know what. As I have said today it's my first day coding on the DS and I haven't found any info about this.

Is out there any document that tells something about this? Anybody knows to do that?

I know that SCUMMVM uses something like that, because the author has released a WiFi version and a Flash version...

Thanks a lot. I hope that somebody could help me...

#50347 - Sausage Boy - Mon Aug 08, 2005 3:23 pm

It's is actually very easy to make different versions of your program.
The reason some programs only run from cart, is because they use
the cartridge to load their data. The ones that do work have their data
included in the binary.

You need a way to either load from the binary, or from cartridge. The good
thing is, this is very easy to make. From reading doublec's tutorials, you've
probably heard of gbfs. This is a quite flexible filesystem, which only needs
a pointer to the beginning of it to work.

My suggestion is that you make an #ifdef, like, if CARTRIDGE is designed,
use doublec's code for setting the pointer. If it's not defined, you'll want to
use code that gets the pointer in some other way.
There is a good thread here: http://forum.gbadev.org/viewtopic.php?t=6449

Note that the cartridge version is useless, since the wmb one will run on
cartridge too. You only want the cartridge version if your data is larger
than 4MB minus the amount of ram your program uses. This is since it
will be loaded into ram. This solution is also good if you want to be able
to run your program fast with wmb and not all the data, and then add all
the files to the filesystem and compile it for cartridge.
_________________
"no offense, but this is the gayest game ever"

#50353 - mokoloko - Mon Aug 08, 2005 4:07 pm

Thanks for the information. If I have undestood the things right it's very simple to make what I want.

I only have a question: Is it possible to run the code directly from the cart or it must be copied from the cart to ram always? It could be nice to run the code from ROM and use the RAM only for the things that need it...

Thanks again.

#50363 - Sausage Boy - Mon Aug 08, 2005 8:00 pm

If you do it the doublec (most common) way, the data, won't be loaded to ram.
This must be used if your data is bigger than 4mb.
_________________
"no offense, but this is the gayest game ever"

#50429 - pepsiman - Tue Aug 09, 2005 4:20 pm

mokoloko wrote:
Is it possible to run the code directly from the cart or it must be copied from the cart to ram always?


It is possible, the .ds.gba version of DSlinux does it.

You need to write your own asm startup code for the ARM7, which gives the ARM9 access to the GBA slot, copies the ARM7 binary to RAM, jumps to the ARM7 binary and tells the ARM9 where to start from.

See http://cvs.sourceforge.net/viewcvs.py/dslinux/dslinux/linux-2.6.x/arch/armnommu/mach-nds/head.S?rev=1.11&view=auto for how DSLinux does it.

#50641 - mokoloko - Thu Aug 11, 2005 8:49 am

It sounds very interesting, but also a bit complex...

Perhaps in the future if my program needs it, I will investigate it, but for now I will use the RAM. ;-)

#50711 - decayer - Fri Aug 12, 2005 12:44 am

mokoloko wrote:


Then I have tried the WMB application and I sended the program (demo1.nds) to the DS and it worked! I was surprised because I though that I must do some changes in the code to be able to run from the WiFi.



While my Cart Flash does not arrive, I tried to make the same, but I got something strange: [Images not permitted - Click here to view it]

It's normal?

#50954 - pepsiman - Sun Aug 14, 2005 9:11 pm

decayer wrote:
It's normal?


Yes, the garbage logo is actually a NDS loader to allow the .nds file to load itself into RAM when it is written to a GBA flash card.