I am working on a boot loader for a STM32F103 (Cortex M3) and I cannot get the jump code to work properly. I am fairly new to ARM and I have exhausted my knowledge in trying to fix this. This is what I have:
#define USER_FLASH_START ( 0x8000000 + ( 16 * 1024 ) ) /* Flash start address 16K */ #define USER_FLASH_END ( 0x8000000 + ( 0x10000 ) ) #define USER_FLASH_SIZE ( USER_FLASH_END - USER_FLASH_START )
void GoToUserApp(void) {
u32 appJumpAddress;
void (*GoToApp)(void);
appJumpAddress = *((volatile u32*)(USER_FLASH_START + 4));
GoToApp = (void (*)(void))appJumpAddress;
SCB->VTOR = USER_FLASH_START;
__set_MSP(*((volatile u32*) USER_FLASH_START)); //stack pointer (to RAM) for USER app
GoToApp();
}
The above code just keeps causing the controller to reset. If I debug, I am getting these values:
- USER_FLASH_START: 0x8004000 - appJumpAddress: 0x8000101 - GoToApp: 0x8000101 - __set_MSP: 0x8000156
These values do not make sense to me so I am hoping someone here can help me out. Thanks.