cancel
Showing results for 
Search instead for 
Did you mean: 

Bootloader jump to app not working on STM32G491

Yves Bmnt
Associate III

Hi all,

I am trying to launch the app from a bootloader code that I copied from a project on an STM32L0 and STM32F446, it worked fine there but somehow my app doesn't start on the STM32G491.

Here's the code for the jump:

 

 

static void bootloader_jump_to_app(void)
{
    uint32_t  JumpAddress = *(__IO uint32_t*)(APP_ADDRESS + 4u);

    pFunction Jump = (pFunction)JumpAddress;


    if (!bootloader_check_integrity())
    {
        bootloader_send_message("Abort\r", 8u);
        bootloader_init();
    }
    else
    {
		bootloader_send_message("Starting\r", 9u);

		HAL_FLASH_Lock(); // lock flash after memory erase + write

		HAL_RCC_DeInit();
		HAL_DeInit();

		SysTick->CTRL = 0u;
		SysTick->LOAD = 0u;
		SysTick->VAL  = 0u;

		SCB->VTOR = (__IO uint32_t)APP_ADDRESS;

		__set_MSP(*(__IO uint32_t*)APP_ADDRESS);

		Jump();
		while(1);
    }
}

 

 

I have modified my .ld file accordingly with app start address 0x08003000, I compared the memory part with the app to the bin file and it's similar, I don't understand where the problem comes from, even though I noticed some differences in the APIs between STM32L0 and G4 series, all the code examples seem to match, or maybe I missed something, can anybody help please?

17 REPLIES 17

sure, I use 0x08003000 as Flash origin:

/* Memories definition */
MEMORY
{
  RAM    (xrw)    : ORIGIN = 0x20000000,   LENGTH = 112K
  FLASH    (rx)    : ORIGIN = 0x8003000,   LENGTH = 244K
}

 

I'm sorry, I don't understand

It was already uncommented:

/************************* Miscellaneous Configuration ************************/
/* Note: Following vector table addresses must be defined in line with linker
         configuration. */
/*!< Uncomment the following line if you need to relocate the vector table
     anywhere in Flash or Sram, else the vector table is kept at the automatic
     remap of boot address selected */
#define USER_VECT_TAB_ADDRESS

#if defined(USER_VECT_TAB_ADDRESS)
/*!< Uncomment the following line if you need to relocate your vector Table
     in Sram else user remap will be done in Flash. */
/* #define VECT_TAB_SRAM */
#if defined(VECT_TAB_SRAM)
#define VECT_TAB_BASE_ADDRESS   SRAM_BASE       /*!< Vector Table base address field.
                                                     This value must be a multiple of 0x200. */
#define VECT_TAB_OFFSET         0x00000000U     /*!< Vector Table base offset field.
                                                     This value must be a multiple of 0x200. */
#else
#define VECT_TAB_BASE_ADDRESS   FLASH_BASE      /*!< Vector Table base address field.
                                                     This value must be a multiple of 0x200. */
#define VECT_TAB_OFFSET         0x00000000U     /*!< Vector Table base offset field.
                                                     This value must be a multiple of 0x200. */
#endif /* VECT_TAB_SRAM */
#endif /* USER_VECT_TAB_ADDRESS */
/******************************************************************************/

 

I don't understand why you don't understand the 2 simple steps

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.

@Yves Bmnt wrote:

It was already uncommented:

 

/************************* Miscellaneous Configuration ************************/
/* Note: Following vector table addresses must be defined in line with linker
         configuration. */
/*!< Uncomment the following line if you need to relocate the vector table
     anywhere in Flash or Sram, else the vector table is kept at the automatic
     remap of boot address selected */
#define USER_VECT_TAB_ADDRESS

#if defined(USER_VECT_TAB_ADDRESS)
/*!< Uncomment the following line if you need to relocate your vector Table
     in Sram else user remap will be done in Flash. */
/* #define VECT_TAB_SRAM */
#if defined(VECT_TAB_SRAM)
#define VECT_TAB_BASE_ADDRESS   SRAM_BASE       /*!< Vector Table base address field.
                                                     This value must be a multiple of 0x200. */
#define VECT_TAB_OFFSET         0x00000000U     /*!< Vector Table base offset field.
                                                     This value must be a multiple of 0x200. */
#else
#define VECT_TAB_BASE_ADDRESS   FLASH_BASE      /*!< Vector Table base address field.
                                                     This value must be a multiple of 0x200. */
#define VECT_TAB_OFFSET         0x00000000U     /*!< Vector Table base offset field.
                                                     This value must be a multiple of 0x200. */
#endif /* VECT_TAB_SRAM */
#endif /* USER_VECT_TAB_ADDRESS */
/******************************************************************************/

 

 


I only see that you did step 1.

 

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.

you are right, I read your message too fast!

It works fine now, thanks a lot :)

In my other projects using STM32L010 and STM32F446, I didn't change the VECT_TAB_OFFSET and the jump to app works fine, but the #define USER_VECT_TAB_ADDRESS is still commented.

Thanks again for your help!

Just commented the #define USER_VECT_TAB_ADDRESS now in my STM32G491 project, and the jump works fine this way too