Page 1 of 1

Bootloader jump problem

Posted: Sat May 06, 2017 5:32 pm
by Dshadow
Hello Giovanni,

I'm using STMF105 and have a problem when I try to jump from bootloader to application.

Bootloader jumped fine when my application was with FreeRTOS, and now jumps fine only when I do blink tests in chibiOS.
Application runs fine when I load it from GDB, but when I run "monitor reset halt" bootloader fails to jump.

Application:
Inside chconf.h:

Code: Select all

#define CORTEX_VTOR_INIT                    0x00006000 

In linker file:

Code: Select all

flash : org = 0x08006000, len = 128k - 24k


Bootloader does only jump AND does not use chibi os:

Code: Select all

//mainAppStartAddress is 0x08006000
void _jumpToApp(void){
    /* Disable global interrupt */
    __disable_irq();
    __set_CONTROL(0);
   
    uint32_t *pMem = (uint32_t *)mainAppStartAddress;
   
    /* First address is the stack pointer initial value */
    __set_MSP(*pMem); // Set stack pointer
   
    /* Now get main app entry point address */
    pMem++;
    void (*pMainApp)(void) = (void (*)(void))(*pMem);
    pMainApp();
}


Maybe I have to set explicitly the main stack pointer in Application main(), or I should enable interrupts?
I've tried various scenarious with __enable_irq() and set_MSP inside application main but with no luck.

Please advice.

Thank you in advance!

Re: Bootloader jump problem

Posted: Sat May 06, 2017 5:47 pm
by Giovanni
Hi,

The main stack is assumed to be set properly (it is setup in HW usually), the process stack is initialized in crt0. In general you need to make sure to jump into the startup code in the same conditions you have post-reset.

Giovanni