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 > Can't get code to run from GBA cart

#81471 - HyperHacker - Sat Apr 29, 2006 10:45 am

After about 4 hours of doing exactly the same thing that hbfirmware (which works) does to run DS code from the GBA slot, I've managed to get two white screens. I've tried everything I can think of about 6 times. Argh.

ARM9:
Code:
void Reboot()
{
   int i;
   sysSetBusOwners(false, false, false); //All to ARM7
   IPC->arm9desc = 0;
   IPC->arm7data = PL_BLINKFAST;
   IPC->arm7desc = A7_POWERLED;
   while(IPC->arm9desc != A9_ACK) swiDelay(1);
   IPC->arm9desc = 0;

   REG_IME=0;
   REG_IE=0;
   DISP_SR=0;
   DISPLAY_CR=0;
   SUB_DISPLAY_CR=0;
   i=0;
   swiFastCopy(&i, (u32*)0x40000B0, 0x01000000 | (0x30>>2));

   //clear VRAM
   POWER_CR=1;
   VRAM_CR=0x80808080;
   VRAM_E_CR=0x80;
   VRAM_F_CR=0x80;
   VRAM_G_CR=0x80;
   VRAM_H_CR=0x80;
   VRAM_I_CR=0x80;
   i=0;
   swiFastCopy(&i, (u32*)0x6800000, 0x01000000 | (0xA4000>>2));
   VRAM_CR=0;
   VRAM_E_CR=0;
   VRAM_F_CR=0;
   VRAM_G_CR=0;
   VRAM_H_CR=0;
   VRAM_I_CR=0;

   POWER_CR=POWER_SWAP_LCDS | POWER_ALL_2D;
   i=0;
   swiFastCopy(&i, (u32*)0x5000000, 0x01000000 | (0x800>>2));
   i=0;
   swiFastCopy(&i, (u32*)0x7000000, 0x01000000 | (0x800>>2));

   IPC->arm9desc = 0;
   IPC->arm7desc = A7_REBOOT;
   *(u32*)0x27ffe24=0x027ffe28;
   *(u32*)0x27ffe28=0xe51ff00c;
   ((call0)0x27FFE28)();
}


ARM7
Code:
switch(T.arm7desc) //T is a copy of IPC
{
   case 0:
   break;


   case A7_REBOOT: //Reboot to GBA cart
   REG_IME=REG_IE=0;

   SerialWaitBusy();
   REG_SPICNT = SPI_ENABLE | SPI_DEVICE_POWER | SPI_BAUD_1MHz | SPI_CONTINUOUS;
   REG_SPIDATA = 0;
   SerialWaitBusy();
   REG_SPICNT = SPI_ENABLE | SPI_DEVICE_POWER | SPI_BAUD_1MHz;
   REG_SPIDATA = PM_BACKLIGHT_TOP | PM_BACKLIGHT_BOTTOM | PM_SOUND_PWR;

   POWER_CR=POWER_SOUND;
   //swiChangeSoundBias(1,0x400); //Non-existant function >_>

   //reset DMA
   i=0;
   swiFastCopy(&i, (u32*)0x40000B0, 0x01000000 | (0x30>>2));
   swiDelay(100000);
   ((call0)0x080000c0)();
   break;