Invalid reset cause after jumping from bootloader
Hello Team,
I am using STM32F767ZI Nucleo board in my project.
Bootloader flash start address - 0x08000000
Bootloader to application jump address - 0x08020200
Application flash start address - 0x08020000
Read reset cause snippet:
if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST))
{
reset_cause = RESET_CAUSE_INDEPENDENT_WATCHDOG_RESET;
}
else if (__HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST))
{
reset_cause = RESET_CAUSE_SOFTWARE_RESET;
}
else if (__HAL_RCC_GET_FLAG(RCC_FLAG_PORRST))
{
reset_cause = RESET_CAUSE_POWER_ON_POWER_DOWN_RESET;
}
else if (__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST))
{
reset_cause = RESET_CAUSE_EXTERNAL_RESET_PIN_RESET;
}
else if (__HAL_RCC_GET_FLAG(RCC_FLAG_BORRST))
{
reset_cause = RESET_CAUSE_BROWNOUT_RESET;
}
else
{
reset_cause = RESET_CAUSE_UNKNOWN;
}Clear reset cause snippet:
__HAL_RCC_CLEAR_RESET_FLAGS();Jump to application snippet:
typedef void (*pFunction)(void);
HAL_RCC_DeInit();
HAL_DeInit();
HAL_MPU_Disable();
uint32_t bootAddress = UINT32_C(0x08020200);
pFunction jumpToAddress;
uint32_t JumpAddress = *(uint32_t *) (bootAddress + 4);
jumpToAddress = (pFunction) JumpAddress;
/* Reset System Ticks*/
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
/* Reallocate vector table */
SCB->VTOR = bootAddress;
/* Initialize user application's Stack Pointer */
__set_MSP(*(__IO uint32_t*) bootAddress);
jumpToAddress();When the reset cause is read in bootloader, I get valid values.
In the similar way, when i read in the application instead of boot loader, I always get RESET_CAUSE_UNKNOWN for any type of reset.
Note : Always the register is cleared after reading.
Is the jumping operation affecting the RCC_CSR register somehow ?
Any clue regarding this behavior would be of great help.
