Skip to main content
HZHU.0
Associate
March 5, 2019
Question

STM32 F756, IAP jump to APP issue

  • March 5, 2019
  • 5 replies
  • 1310 views

I follow the AN4657, use the following piece of code, my IAP can jump to APP when boot up, and APP can jump to IAP.

BUT, after jump back to IAP from APP, it will NOT jump to APP successfully.

why same code, sometime it works but other time it doesn't work?

----------------The code -------------

typedef void (*pFunction)(void);

pFunction JumpToApplication;

uint32_t JumpAddress;

#define APPLICATION_ADDRESS   (uint32_t)0x08080000  (In APP, it is 0x08000000)

...........

 JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4);

 JumpToApplication = (pFunction) JumpAddress;

 /* Initialize user application's Stack Pointer */

 __set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);

 JumpToApplication();

------------------------------------

This topic has been closed for replies.

5 replies

Tesla DeLorean
Guru
March 5, 2019

So get a debugger out, output some diagnostic information, and try to better understand the nature of the problem. The description here doesn't really convey any information that could pin point a cause.

Make sure you set the vector table address properly, ie SCB->VTOR = &__Vectors;

Make sure you don't transfer under interrupts context, ie from IRQ Handler or Callback proxy

If using an RTOS make sure you understand the ramifications of System vs User mode.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Piranha
Principal III
March 6, 2019
HZHU.0
HZHU.0Author
Associate
March 7, 2019

Right now, I just use soft reset in my application so when in IAP again , It can jump successfully to APP. this seems meets my need.

BTW, I found that in my APP, if I jump to IAP in USBD code stack such as in MSC_BOT_DataOut() in usbd_msc_bot.c, it works! BUT, if I try to jump in main() , it won't work UNLESS I call  HAL_NVIC_DisableIRQ(OTG_FS_IRQn); HAL_NVIC_DisableIRQ(UART5_IRQn); 

So it seems interrupt context, it can jump, no need to disable some interrupt. but in main(), we have to disable the corresponding interrupt. Unfortunately when I try to do the same in my IAP code, it doesn't work if it is jumped back from APP.

HZHU.0
HZHU.0Author
Associate
March 22, 2019

OK, I revisited this issue. I found out the solution: call HAL_DeInit() before jump back to IAP in APP.

tommi
Visitor II
July 24, 2019

This helped in my issue as well. I had issues with getting my application started from bootloader. The bootloader must call HAL_Deinit() for the application to start. Here's my startup code in bootloader (almost identical to UM1709 STM32Cube Ethernet IAP example). MCU is F7, F746 specifically.

/* Check if valid stack address (RAM address) then jump to user application */

   if (((*(volatile uint32_t*)USER_FLASH_FIRST_PAGE_ADDRESS) & 0x2FF00000 ) == 0x20000000)

   {

     HAL_UART_Transmit(&huart3,(uint8_t*)"Application entry\n\r",18,10);

     HAL_DeInit(); /* This is necessary for the application to start */

     /** Jump to user application */

     JumpAddress = *(volatile uint32_t*) (USER_FLASH_FIRST_PAGE_ADDRESS + 4);

     JumpToApplication = (pFunction) JumpAddress;

     /** Initialize user application's Stack Pointer */

     __set_MSP(*(volatile uint32_t*) USER_FLASH_FIRST_PAGE_ADDRESS);

     JumpToApplication();

   }