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 Flash Equipment > GBA Cartridge Header and GBA System Control

#160835 - guybye - Wed Jul 23, 2008 8:47 am

I've read at http://nocash.emubase.de/gbatek.htm#gbasystemcontrol that there should be a GBA Cartridge Header. So as far as I understand the header is actually a part of the data that is in the cart. So, if I am downloading a bin file to a flash cart who takes care of this header?

At the GBA System Control section it is said that the wait state parameters are set. BY WHOM?
How do I access these registers?
Is there an automatic subroutine that read this data from the cart (by the NDS)?
If I am using a slow home made flash-cart how do I configure the NDS for the right wait-state??

Hope someone knows the answers....

So, thanks ahead
Guy

#160836 - eKid - Wed Jul 23, 2008 9:19 am

The GBA header is prefixed to all GBA game binaries, it contains data necessary to boot the game (entry points, checksums, etc). I don't think you need a header if you're just using the cart for data.

The wait states for the gba slot can be changed on the DS with the EXMEMCNT register (same address as GBA's WAITCNT)
http://nocash.emubase.de/gbatek.htm#dsmemorycontrolcartridgesandmainram

#160844 - guybye - Wed Jul 23, 2008 12:22 pm

OK, But if I am using my home made flash cart with has its own latency- someone need to tell NDS that information? who is gonna do that?

btw how do i write to the EXMEMCNT what is the C functoin that does it?
I am a hardware man --> so some C refernce can do no harm.

Thanks,
Guy

#160846 - eKid - Wed Jul 23, 2008 2:10 pm

guybuy wrote:
OK, But if I am using my home made flash cart with has its own latency- someone need to tell NDS that information? who is gonna do that?

Aren't you, the cartbuilder, supposed to know those things? :P
You could maybe test some data reads from the cart on the DS with decreasing waitstates and see when the data goes wrong. :)

To set the cart waitstates in C (using libnds):

Code:

#include <nds.h>

// wSRAM = SRAM access time (0-3 = 10, 8, 6, 18 cycles)
// wN = ROM 1st access time (nonsequential) (0-3 = 10, 8, 6, 18 cycles)
// wS = ROM 2nd access time (sequential) (0-1 = 6, 4 cycles)
// PHI = PHI-pin out (0-3 = Low, 4.19MHz, 8.38MHz, 16.76MHz)
// [no idea what PHI-pin out is]

void SetGBATiming( int wSRAM, int wN, int wS, int PHI )
{
    // mask other bits into a variable
    u32 memcnt = REG_EXMEMCNT & 0xFF80;
   
    // add new waitstate settings
    memcnt |= wSRAM | (wN << 2) | (wS << 4) | (PHI << 5);

    // set wait control
    REG_EXMEMCNT = memcnt;
}

#160897 - tepples - Thu Jul 24, 2008 4:34 am

guybye wrote:
OK, But if I am using my home made flash cart with has its own latency- someone need to tell NDS that information? who is gonna do that?

Your card will boot up in 4,2 wait state. Commercial games change it to 3,1 soon after they start.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#160902 - eKid - Thu Jul 24, 2008 5:02 am

tepples wrote:
Your card will boot up in 4,2 wait state. Commercial games change it to 3,1 soon after they start.

Note that the DS seems to have different waitstate settings than a GBA.

edit: err, maybe not, gbatek specifies WAITCNT measurements in waitstates and EXMEMCNT in actual access time.

#160907 - guybye - Thu Jul 24, 2008 12:53 pm

I am tring to develop a flash card based on a data flash (32GB). It is a quite slow flash so i want to use N,S = 8,2. So the command to change from 4,2 to 8,2 is stored in the flash.... the GBA/NDS will not be able to read this data since it access the cart with higher speed (4,2). What can I do?
10x

Guy

#160910 - eKid - Thu Jul 24, 2008 1:05 pm

Sounds like a problem... Not really sure if there is a solution besides using custom code before starting the cart's program..

Do you want 8,2 16mhz cycles or 33mhz cycles?

#160970 - tepples - Fri Jul 25, 2008 12:51 pm

guybye wrote:
I am tring to develop a flash card based on a data flash (32GB). It is a quite slow flash so i want to use N,S = 8,2. So the command to change from 4,2 to 8,2 is stored in the flash.... the GBA/NDS will not be able to read this data since it access the cart with higher speed (4,2). What can I do?

"Data flash" is often NAND, especially in those sizes. Some commercial GBA flash cards, such as EFA II, use a hybrid NAND/NOR setup: the card's menu and the running game are stored in a fast 256 Mbit NOR flash, and the user can copy a game from the NAND to the NOR from within the card's menu. The EZFlash V works the same way: the user copies a GBA game from NAND in SLOT-1 to fast NOR flash on the 3-in-1 expansion in SLOT-2 using a program that runs on the DS.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.