How to boot a .nds
From DSWiki
[edit] New
There is now a new library that does this automatically, bootlib.
Get it here: Project Page
[edit] OLD:
This method seems to work with the GBAMP only! If you know how to do this for other cards, or how to launch a .nds file from memory, please add it here!
Put this in for your arm7:
if (*((vu32*)0x027FFE24) == (u32)0x027FFE04) { // Check for ARM9 reset
REG_IME = IME_DISABLE; // Disable interrupts
REG_IF = REG_IF; // Acknowledge interrupt
*((vu32*)0x027FFE34) = (u32)0x08000000; // Bootloader start address
swiSoftReset(); // Jump to boot loader
}
Put this in for arm9, customize file names for variables or fixed filenames.
void bootGBAMPnds(void) {
REG_EXMEMCNT &= ~(0x8080);
FILE *handle = fopen("filename.nds", "rb");
if(handle < 0) {
iprintf("\nLoader has failed!\n");
}
struct stat st;
u32 cluster;
stat("/filename.nds", &st);
cluster = st.st_ino;
fclose(handle);
REG_EXMEMCNT |= (0x8080);
REG_IME = IME_DISABLE; // Disable interrupts
REG_EXMEMCNT |= (0x8080); // ARM7 has access to GBA cart
*((vu32*)0x027FFFFC) = cluster; // Start cluster of NDS to load
*((vu32*)0x027FFE04) = (u32)0xE59FF018; // ldr pc, 0x027FFE24
*((vu32*)0x027FFE24) = (u32)0x027FFE04; // Set ARM9 Loop address
swiSoftReset(); // Reset
}

