Hi,
I have a problem where application is loaded with a custom bootloader, and seems to work fine, but until some interrupt occurs. After that it hangs. If I disable interrupts, or just make sure they don't occur (when enabled) - app works fine.
Also if I load the app without the custom bootloader (directly into 0x0 address) - interrupts work fine.
I searched through the forums but couldn't find anything that can help solve that.
Can somebody point me to what the error might be?
Here is some code:
The linker of the application:
#define APP_BASE 0x0000500c #define RAM_BASE 0x20000000 MEMORY { FLASH (RX) : origin = APP_BASE, length = 0x0003aff4 SRAM (RWX) : origin = RAM_BASE, length = 0x00008000 } SECTIONS { .intvecs: > APP_BASE .text : > FLASH .const : > FLASH .cinit : > FLASH .pinit : > FLASH .init_array : > FLASH .vtable : > RAM_BASE .data : > SRAM .bss : > SRAM .sysmem : > SRAM .stack : > SRAM } __STACK_TOP = __stack + 512;
The linker of the bootloader:
#define APP_BASE 0x00000000 #define RAM_BASE 0x20000000 MEMORY { FLASH (RX) : origin = APP_BASE, length = 0x00005000 SRAM (RWX) : origin = RAM_BASE, length = 0x00008000 } SECTIONS { .intvecs: > APP_BASE .text : > FLASH .const : > FLASH .cinit : > FLASH .pinit : > FLASH .init_array : > FLASH .vtable : > RAM_BASE .data : > SRAM .bss : > SRAM .sysmem : > SRAM .stack : > SRAM } __STACK_TOP = __stack + 512;
The bootloader function for calling the application, the address given is 0x0000500c:
void callApplication(unsigned long ulStartAddr) { ROM_SysTickIntDisable(); ROM_SysTickDisable(); HWREG(NVIC_DIS0) = 0xffffffff; HWREG(NVIC_DIS1) = 0xffffffff; HWREG(NVIC_VTABLE) = ulStartAddr; // // Load the stack pointer from the application's vector table. // __asm(" ldr r1, [r0]\n" " mov sp, r1\n"); // // Load the initial PC from the application's vector table and branch to // the application's entry point. // __asm(" ldr r0, [r0, #4]\n" " bx r0\n"); }
The startup scripts are the default ones, just the interrupt handlers added.
Any idea what may be wrong here?
PS: one note that bootloader is situated at 0x0 -> 0x00005000, while app starts at 0x0000500c
The space between 5000 and 500c is used for CRC, length, etc. I noticed that in the boot_demo2 code, in startup_ccs.c those CRC, len, etc. bytes are set at the end of the vector table. Do I need to do this? Could this be related somehow?
Thanks in advance!