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 > How is GBA Flash Cartridge mapped into DS memory space?

#67775 - swzte - Fri Jan 20, 2006 8:13 am

As we know,in GBA Flash Cartridge,the Flash is 16 bits wide and 24bit addresses are squeezed through the Gampak bus.First, I want to know whether Address bit0 of the 24bit addresses is connectted to Flash Address bit0? Or Address bit1 of the 24bit addresses is connectted to Flash Address bit0?.Second, how does I get the Flash ID?Is it right this way?
*(volatile unsigned short *) (0x08000000+0x555*2)=0xaa;
*(volatile unsigned short *) (0x08000000+0x2aa*2)=0x55;
*(volatile unsigned short *) (0x08000000+0x555*2)=0x90;
FlashId=*(volatile unsigned short *) (0x08000000+0x1*2);


Or this way?
*(volatile unsigned short *) (0x08000000+0x555)=0xaa;
*(volatile unsigned short *) (0x08000000+0x2aa)=0x55;
*(volatile unsigned short *) (0x08000000+0x555)=0x90;
FlashId=*(volatile unsigned short *) (0x08000000+0x1);

#67888 - Joat - Sat Jan 21, 2006 3:27 am

It depends on the flash cartridge, whether it's using 16 bit chips or 2x 8 bit chips for instance.

However, most cartridges (all of them except homebrew ones, and probably the xport) completly disable the /WE line to the flash chips unless you first unlock them. This protocol is also different for nearly every brand of flash cartridge I'm afraid.

I've collected all the information I have found here:
http://www.bottledlight.com/ds/index.php/Hardware/FlashCartridges

Good luck, and if you find any other information for your particular kind of cart, or see any errors on my page, please let me know.

Another quick note: it's usually 5555 and 2aaa, not 555 and 2aa, but once you ID your brand, you will prolly find the chip type and can grab the exact datasheet.
_________________
Joat
http://www.bottledlight.com

#68447 - nmain - Tue Jan 24, 2006 5:19 pm

swzte wrote:
As we know,in GBA Flash Cartridge,the Flash is 16 bits wide and 24bit addresses are squeezed through the Gampak bus.First, I want to know whether Address bit0 of the 24bit addresses is connectted to Flash Address bit0? Or Address bit1 of the 24bit addresses is connectted to Flash Address bit0?.Second, how does I get the Flash ID?Is it right this way?
*(volatile unsigned short *) (0x08000000+0x555*2)=0xaa;
*(volatile unsigned short *) (0x08000000+0x2aa*2)=0x55;
*(volatile unsigned short *) (0x08000000+0x555*2)=0x90;
FlashId=*(volatile unsigned short *) (0x08000000+0x1*2);


Or this way?
*(volatile unsigned short *) (0x08000000+0x555)=0xaa;
*(volatile unsigned short *) (0x08000000+0x2aa)=0x55;
*(volatile unsigned short *) (0x08000000+0x555)=0x90;
FlashId=*(volatile unsigned short *) (0x08000000+0x1);



The first code fragment you give writes shorts to the memory addresses 8000aaa, 800554, 8000aaa, 8000002. The second code fragment writes shorst to the memory addresses 8000555, 80002aa, 8000555, 8000001; and will fault on some platforms because the writes are not aligned. I don't know anthing about DS development, so I can't answer the question of which one is right for you, but I suspect it's a first. Remember, while it is true that incrementing a pointer p increases the address of p by sizeof (*p), in your example you add before you cast into a pointer; so regular integer math is used. i.e.:

&(((vu16 *) 0x08000000) + 0x555)
evaluates to 0x080002aa
&(vu16 *) (0x08000000 + 0x555)
evaluates to 0x08000555