Skip to main content
Associate III
August 4, 2023
Solved

tick problem after jump to custom Bootloader

  • August 4, 2023
  • 3 replies
  • 2624 views
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();
    This topic has been closed for replies.
    Best answer by Tesla DeLorean

    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.

    3 replies

    TDK
    Super User
    August 4, 2023

    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""."
    DAUSILIAuthor
    Associate III
    August 4, 2023

    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.

    DAUSILIAuthor
    Associate III
    August 4, 2023

    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?

    Tesla DeLorean
    Tesla DeLoreanBest answer
    Guru
    August 4, 2023

    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 VenmoUp vote any posts that you find helpful, it shows what's working..
    DAUSILIAuthor
    Associate III
    August 6, 2023

    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
    Principal III
    August 6, 2023