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 I completely reboot my DS?

#62914 - agentq - Tue Dec 06, 2005 10:06 pm

Hi,

I've been trying to reboot the DS to the same state it was at power on. I've had some success with swiSoftReset(). By syncing the ARM7 and ARM9 to call this bios function, it reboots, but it seems static initialised variables don't get reset, and this means that memory allocated with malloc() is also still allocated.

I'd like to find a way to do this which works on a flash cart and GBAMP/M3/SC

Edit: I've tried the following code to rerun the static initialisers after a reboot, but it doesn't work. Doesn't crash though.

Code:

   static bool reset = false;

   if (reset) {
      asm("ldr r3, =_init\n  bl _call_via_r3\n");
   }

   reset = true;

#62943 - josath - Wed Dec 07, 2005 1:37 am

To completely reset your DS to initial state (in order to load the wmb demos for example), check out the source to Darkain's loader, used in his MultiNDS frontend.

The sourcecode can be found in the ndslib CVS. There are a couple steps, it involves manually clearing the RAM/VRAM, and resetting many of the registers back to default settings.

#62968 - chishm - Wed Dec 07, 2005 10:11 am

Yeah, as you found out, swiSoftReset() (swi 0x00) actually only resets the CPU then jumps to the address located at 0x027FFE24 (ARM9) or 0x027FFE34 (ARM7). This means it doesn't reset memory or external registers.
_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com

#62970 - Vich - Wed Dec 07, 2005 10:49 am

http://www.cs.rit.edu/~tjh8300/CowBite/CowBiteSpec.htm

This is about the GBA, you might find interesting info about it and it might(not sure if it will) also apply on the ARM7 processor of the NDS. Check chapter 9 of that website document.

Google more on the GBA hardware reset(or hwreset?), you might find better info ('cause I did earlier this week, but can't find the link immediately).

#62972 - wintermute - Wed Dec 07, 2005 11:09 am

agentq wrote:
Hi,
it seems static initialised variables don't get reset


correct.

The *only* way to reset initialised data is to reload the binary.

#62973 - Vich - Wed Dec 07, 2005 11:36 am

wintermute wrote:
agentq wrote:
Hi,
it seems static initialised variables don't get reset


correct.

The *only* way to reset initialised data is to reload the binary.


Are you sure? If you can hardreset the ARM7 on a GBA through BIOS calls(SWI instructions), why can't you do it on the same ARM7 on the NDS?

The webpage that I posted clearly stated the same 0x00 for soft reset ?nd 0x01 for RAM reset.

edit:
Quote:

0x26: HardReset (Undocumented)

Also interesting :)


Last edited by Vich on Wed Dec 07, 2005 11:43 am; edited 1 time in total

#62974 - agentq - Wed Dec 07, 2005 11:42 am

Yeah, I've seen the CowBite spec, as I originally wrote a large chunk of it. ;-)

There seems to be some boot code in \nslib\examples\loader\boot\main.cpp. Is this what josath was referring to?

If I have to reload the binary to reset my static data, does this mean I can't reboot my in memory copy?


Last edited by agentq on Wed Dec 07, 2005 11:43 am; edited 1 time in total

#62975 - wintermute - Wed Dec 07, 2005 11:43 am

Vich wrote:
wintermute wrote:
agentq wrote:
Hi,
it seems static initialised variables don't get reset


correct.

The *only* way to reset initialised data is to reload the binary.


Are you sure? If you can hardreset the ARM7 on a GBA through BIOS calls(SWI instructions), why can't you do it on the same ARM7 on the NDS?

The webpage that I posted clearly stated the same 0x00 for soft reset ?nd 0x01 for RAM reset.


Because the GBA carries initialised data in ROM from where it's copied to RAM. The DS runs everything from RAM so data stays where it is and gets overwritten. GBA multiboot code works the same way.

#63007 - agentq - Wed Dec 07, 2005 8:23 pm

Thanks wintermute, I think that means I won't be able to write a generic 'reboot' call, unless anyone can think of another way?

It seems odd that there's not a SWI call to reboot the machine properly as on tha GBA. I tried SWI 0x26 but it didn't do the job. :-(

#63018 - Vich - Wed Dec 07, 2005 10:04 pm

agentq wrote:
Thanks wintermute, I think that means I won't be able to write a generic 'reboot' call, unless anyone can think of another way?

It seems odd that there's not a SWI call to reboot the machine properly as on tha GBA. I tried SWI 0x26 but it didn't do the job. :-(

Maybe swi 0x26 only works under certain conditions? Like halting the device first, clearing other memory first, etc? (in any order)