cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with STM32F107 bootloader. The jump to application fails

Karthika ML
Associate
Posted on October 16, 2017 at 05:50

Hi, I have got an issue with STM32F107 bootloader. The jump to application fails and results in hardfault. Before jumping, I have disabled all interrupts including systick timer and also set the MSP to the initial value as needed for the application program. Is there anything else to be taken care of, before making the jump? Could someone help? I have just copied the relevant part of my code below.

/********************************* declarations  and defines     ****************************/

unsigned               *p;

void                       (*user_code_entry)(void);

unsigned int          Address_PgrmCounter;

#define                  APPLICATIONADDRESS          (unsigned int)0x800e000

/********************************* reset system and disable all interrupts****************/

HAL_RCC_DeInit(); 

HAL_DeInit();

SysTick->CTRL &= ~0x00000011; /* Disable systick counter*/

__HAL_RCC_TIM2_CLK_DISABLE();

__disable_irq();

for(i=0;i<68;i++)

{

HAL_NVIC_DisableIRQ(i);

}

for(i=0;i<=15;i++)

{

__HAL_GPIO_EXTI_CLEAR_IT(i);

}

SCB->ICSR &= ~(0x10000000) ;

/********************************* set MSP  **********************************************/

__set_MSP(APPLICATIONADDRESS);

/********************************* Jump to application 

********************************/

Address_PgrmCounter = APPLICATIONADDRESS + 4;

p = (unsigned *)(Address_PgrmCounter);

user_code_entry = (void *) *p;

user_code_entry();
1 ACCEPTED SOLUTION

Accepted Solutions
Posted on October 16, 2017 at 10:19

Can we try to not jam the entire question in the title, edit to fix.

You want the MSP to be a RAM address. Ie the value AT the application address and NOT the application address.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

3 REPLIES 3
Posted on October 16, 2017 at 10:19

Can we try to not jam the entire question in the title, edit to fix.

You want the MSP to be a RAM address. Ie the value AT the application address and NOT the application address.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on October 17, 2017 at 14:41

__disable_irq(); // if you do this you must enable on the other side

__set_MSP(*((uint32_t *)APPLICATIONADDRESS)); // the content of SP describe IN the vector table

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on October 17, 2017 at 14:37

Thanks for the reply. It helped! Jumping to application is successful after rectifying the MSP value.