Thanks, Carlos. Could you tell me what difference makes your code:
LDR SP, [R0] ;Load new stack pointer address
LDR PC, [R0, #4] ;Load new program counter address
instead of mine? I see it functionally identical.
asm volatile("ldr sp, [r0]");
asm volatile("ldr r0, [r0, #4]");
asm volatile("mov pc, r0");
Yes, I first debug then ask. It crashes right after the PC register is loaded. I checked the r0 register has the right value beforehand (the ResetISR address). But in this case I don't think debugging helps as I have the application flashed and what I debug is the bootloader, so the debugger doesn't know anything about the application after the "mov pc". I wonder if there is a way of debugging two independent applications.
Facts so far are:
- The bootloader executes fine until it jumps to the ResetISR [seen with debugger]
- The bootloader does jump to the ResetISR [reason below]
- If at the beginning of the ResetISR function I call main, then it works, but I'm skipping the RAM initialisation
Because of the above, I think my problem is with the RAM initialisation, but I can't see why copying from flash to RAM causes a hang.