IAP check condition before jumping to application.
I'm using STM32L4S5 to develop an IAP application following the example provided on STM32L4CubeV1.11.0 under STM32L476G-EVAL directory.
Following the code bellow, before jumping to the Application region, we have to check if the content of the first application addresse is in the RAM region (0x20000000 ->0x20017FFF ).
if (((*(__IO uint32_t*)APPLICATION_ADDRESS) & 0x2FFE0000 ) == 0x20000000)
{
/* Jump to user application */
JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4);
JumpToApplication = (pFunction) JumpAddress;
/* Initialize user application's Stack Pointer */
__set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);
JumpToApplication();
}In our case, the RAM region in the STM32L4S5 is between 0x20000000 ->0x2002FFFF. So we have changed the check condition to :
#define RAM_START_ADDR SRAM_BASE
#define RAM_END_ADDR (RAM_START_ADDR + SRAM1_SIZE_MAX )
if ( ( (*(__IO uint32_t*)APP_START_ADDR) > RAM_START_ADDR ) && ( (*(__IO uint32_t*)APP_START_ADDR) < RAM_END_ADDR ) )Does this implementation carry no risk ?
Best Regards
Mehdi.