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 > Re-initializing the DS Hardware

#163640 - cornaljoe - Tue Oct 07, 2008 2:29 pm

When using this code to boot into GBA mode from DS mode, some carts don't reboot properly. They hang at the GBA logo with no Nintendo logo. I believe the problem is the way these carts partially boot the DS firmware. Is there a way to completely reboot the DS with the firmware intact to insure GBA mode doesn't freeze?

ARM9
Code:
inline void clearmem(u32 dest, u32 size)
{   int i=0;
   swiFastCopy(&i, (u32*)dest, 0x01000000 | (size>>2));
}

void main()
{  sysSetBusOwners(BUS_OWNER_ARM7,BUS_OWNER_ARM7);
   swiDelay(0x200000);
   REG_IME=0;
   REG_IE=0;
   REG_DISPSTAT=0;
   DISPLAY_CR=0;
   SUB_DISPLAY_CR=0;
   
   clearmem(0x40000B0, 0x30);
   
   REG_POWERCNT=1;
   VRAM_CR=0x80808080;
   VRAM_E_CR=0x80;
   VRAM_F_CR=0x80;
   VRAM_G_CR=0x80;
   VRAM_H_CR=0x80;
   VRAM_I_CR=0x80;
   clearmem(0x6800000,0xA4000);
   VRAM_CR=0;
   VRAM_E_CR=0;
   VRAM_F_CR=0;
   VRAM_G_CR=0;
   VRAM_H_CR=0;
   VRAM_I_CR=0;
   
   REG_POWERCNT=POWER_SWAP_LCDS | POWER_ALL_2D;
   clearmem(0x5000000, 0x800);
   clearmem(0x7000000, 0x800);
   
   if(((PERSONAL_DATA *)0x023FFC80)->_user_data.gbaScreen)
   {   REG_POWERCNT &= ~POWER_SWAP_LCDS;
   }else
   {   REG_POWERCNT |= POWER_SWAP_LCDS;
   }
   
   REG_IPC_FIFO_TX = 0x88888888;
}


ARM7
Code:
void main()
{   uint8 current, backlight;
   
   if(((PERSONAL_DATA *)0x023FFC80)->_user_data.gbaScreen)
   {   backlight = ~PM_BACKLIGHT_TOP;
   }else
   {   backlight = ~PM_BACKLIGHT_BOTTOM;
   }
   
   // Reset the clock if needed
   rtcReset();

   //enable sound
   powerON(POWER_SOUND);
   SOUND_CR = SOUND_ENABLE | SOUND_VOL(0x7F);

   REG_SPICNT = SPI_ENABLE | SPI_DEVICE_POWER | SPI_BAUD_1MHz | SPI_CONTINUOUS;
   REG_SPIDATA = 0x80;

   SerialWaitBusy();
   REG_SPICNT = SPI_ENABLE | SPI_DEVICE_POWER | SPI_BAUD_1MHz ;
   REG_SPIDATA = 0;

   SerialWaitBusy();
   current = REG_SPIDATA & 0xff;

   current = current & backlight;

   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 = current;

   SerialWaitBusy();
   swiSwitchToGBAMode();
}

#163712 - hacker013 - Thu Oct 09, 2008 5:18 pm

that can't
_________________
Website / Blog

Let the nds be with you.