cancel
Showing results for 
Search instead for 
Did you mean: 

tick problem after jump to custom Bootloader

DAUSILI
Associate II
Hi,
I have a problem after jump from application to my custom Bootloader.
This the micro code: STM32G071KBU3.
I correctly jump from application to Bootloader, but after the jump I don't get anymore interrupt from tick.
I add an information: if I run directly the Bootloader from debug I correctly get interrupt from tick.
Here the code I use for the jump.
 
static void JumpToBootloader(void)
{
uint32_t jumpAddr;
void        (*jumpFunc)(void);
 
/* si imposta il puntatore a funzione utilizzato per il jump */
jumpAddr = *(__IO uint32_t*) (BOOTL_START_ADDR + 4);
jumpFunc = (void (*)(void)) jumpAddr;
 
    /* Initialize user application's Stack Pointer */
    __set_MSP((*(__IO uint32_t*) BOOTL_START_ADDR ));
 
// si salta al Bootloader
    jumpFunc();
1 ACCEPTED SOLUTION

Accepted Solutions

Really aren't that many registers in the NVIC, dump them, and review.

Are you calling from inside an Interrupt Handler or Call-back? Do you set the SCB->VTOR properly? Is it at the right address alignment, with the correct content?

Are you calling from an RTOS

Deinit all you peripheral interrupts at the *source*. Watch that you don't end up stuck in the Error_Handler() or HardFault_Handler(), instrument those so you know.

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

6 REPLIES 6
TDK
Guru

The code you shared doesn't mess with interrupts at all. Are you disabling them prior to the jump? When they are not happening, debug the chip, look at the appropriate systick-related registers to determine their state.

If you feel a post has answered your question, please click "Accept as Solution".

Hi,
thankyou for your reply.
About the interrupt disable before jump I make this:


NVIC_DisableIRQ(USART2_IRQn);
NVIC_ClearPendingIRQ(USART2_IRQn);

Is it enough?

About the regsters STK:
STK_CVR change his value going step by step in debug.
STK_CSR->COUNT_FLAG from 0 goes to 1 but going on with the debug remain always high.
It is proven by the breakpoint I put inside the interrupt routine. I never reach the breakpoint.

I attach a screenshot of the registers. The tick interrupt exeption is enabled.


Thank you.
Regards.

DAUSILI
Associate II

I also verifyed that the PRIMASK register bit PM is correctly at 0.
Maybe the problem is on NVIC?
Any suggestion about what can I check on NVIC?

Really aren't that many registers in the NVIC, dump them, and review.

Are you calling from inside an Interrupt Handler or Call-back? Do you set the SCB->VTOR properly? Is it at the right address alignment, with the correct content?

Are you calling from an RTOS

Deinit all you peripheral interrupts at the *source*. Watch that you don't end up stuck in the Error_Handler() or HardFault_Handler(), instrument those so you know.

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

Thank you for your reply.

The problem was SCB->VTOR. The vector table was not aligned. In the apllication the vector table start address is at 0x08008000. In bootloader execution on 0x08000000. On the Bootloader I have to make explicit the offset that is 0 by SCB->VTOR. Otherwise if I come from Application the vector table address is still 0x08008000 after the jump. 
thank you.

Piranha
Chief II

Just drop that fragile and complex design and implement a better and simpler one:

https://community.st.com/t5/embedded-software-mcus/using-nvic-systemreset-in-bootloader-lt-gt-application-jumps/m-p/398389