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 > no$gba debug function

#113685 - MrK - Fri Dec 29, 2006 7:06 pm

Hi!

I'm using no$gba to debug. I have the following function to trigger a software breakpoint, which creates code to generate a mov r11,r11 and then return back to appBkp.
appBkp is always an ARM function

Code:


char NOGBAcode[4096];

void appBkp (void)
{
char *ptr=NOGBAcode;

   // breakpoint mov r11,r11
   *(int *)ptr=0xe1a0b00b; ptr+=4;      // mov r11,r11
   *(int *)ptr=0xe12fff1e; ptr+=4;      // bx lr

   ((void (*)(void))NOGBAcode)();           // call code
}


the thing is that it works on no$gba emulator (breaks into debugger), works on other emulators (but it's ignored), however in real hardware hangs the console. Any ideas? Maybe a cache problem?

TIA!

p.s. yes, I know I can do that function in assembler, however I'd like to get it done in C (appLog is giving me some other functions, and I don't feel like doing the %s %x %d replacement in assembler for a test app)

#113686 - Mighty Max - Fri Dec 29, 2006 7:20 pm

Yes, whenever you alter code to execute in a region that is cached, flush the caches.

The following code will flush code and data cashes: (Tho you only need to flush the line needed, the code flushes the complete caches)
Code:

flush_caches:
   eor r0,r0,r0
   MCR p15,0,r0,c7,c5,0
   MCR p15,0,r0,c7,c6,0
   BX lr


Assuming you didnt allready execute a breakpoint with other code there, you can take the DC_* functions of ndslib instead.

:edit: PS: use the array as volatile
_________________
GBAMP Multiboot