2021-04-15 12:15 AM
Hello there.
I'm using a stm32F417VGT6 to perform an IAP in Keil IDE.
in the bootloader, using the Bin file on a SD card, I read executed Binary program and write it on flash memory. then i use Jump_To_Application() to start the new app. Everything works just fine and we've got no problems.
also if we want to jump to app in the middle of the process in main() (before the flashing new file for sure), it's still OK and application runs fine.
*BUT* when i want to use the jumping function from a timer interrupt callback function or SysTick_Handler() (for example after 20 sec) , the remote app won't work. it Looks like a Hard fault or any type of stucking the code and unfortunately, theres no way to debug because the MCU is not on the bootloader anymore. So i can't jump to app from an interrupt function.
(PS. Note that in this scenario, we don't want to flash the new Binary file. only jumping to the specified SCB->VTOR address from a timer interrupt is needed).
and here's the set of codes i use to perform the jump:
JumpAddress = *(uint32_t*) (FLASH_USER_START_ADDR + 4);
Jump_To_Application = (pFunction) JumpAddress;
Jump_To_Application();
I would be appreciated if you share your solutions.
or if you needed more details, feel free to ask.
regards
Seyed
2021-04-15 03:00 AM
Solved.
the code was making a Hard fault problem was the interrupts priority. in the default CubeMX interrupt priority, All priorities are set to 0. by changing the priority of TIM2 into 2 the jumping was ok from the PeriodElapsedCallback.
2021-04-15 03:05 AM
You need to unwind the call stack and NVIC state properly, jumping to entirely different code flow from interrupt/callback is highly problematic.