This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

STM32L4: Bootloader Jump to App fails depending of optimization level

Hello,

I am trying to write a bootloader for STM32L496(ZGT) and I am pretty new to ARM and RTX.
The Bootloader works over USB HID and uses RTX5 (RTOS 2).
I use µVision V5.36 with compilter V6.16 (With AC5 like warnings).

I encounter a strange behavior.
If I use optimization level o0 my Jump function "failes". I jump but get stuck in the main app. As far as I know at some point where some IRQ should be disabled.
If I use level o1 it jumps.

My Jump funcion:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
typedef void (*pFunction)(void);
void JumpToApplication(uint32_t uiAppAdress)
{
uint32_t JumpAddress = *(__IO uint32_t*)(uiAppAdress + 4);
pFunction Jump = (pFunction)JumpAddress;
HAL_RCC_DeInit();
HAL_DeInit();
NVIC->ICER[ 0 ] = 0xFFFFFFFF ;
NVIC->ICER[ 1 ] = 0xFFFFFFFF ;
NVIC->ICER[ 2 ] = 0xFFFFFFFF ;
NVIC->ICER[ 3 ] = 0xFFFFFFFF ;
NVIC->ICER[ 4 ] = 0xFFFFFFFF ;
NVIC->ICER[ 5 ] = 0xFFFFFFFF ;
NVIC->ICER[ 6 ] = 0xFFFFFFFF ;
NVIC->ICER[ 7 ] = 0xFFFFFFFF ;
NVIC->ICPR[ 0 ] = 0xFFFFFFFF ;
NVIC->ICPR[ 1 ] = 0xFFFFFFFF ;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Maybe anyone has an idea why it get stucks?

Thanks Stefan

0