Bootloader jump problem

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
Dshadow
Posts: 1
Joined: Sat May 06, 2017 4:58 pm

Bootloader jump problem

Post 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!
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Bootloader jump problem

Post 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
Post Reply