2020-04-17 02:50 AM
any body have example code for jump to application code for bootloader, or any specific settings need to made.
#define BPC_APPL_START_ADDRESS 0x08080000
U_INT32 JumpAddress = *(__IO U_INT32*)(BPC_APPL_START_ADDRESS+4);
pFunction Jump = (pFunction)JumpAddress;
osThreadSuspendAll();
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
HAL_RCC_DeInit();
__set_MSP(*(__IO U_INT32*)BPC_APPL_START_ADDRESS);
__disable_irq();
SCB->VTOR = BPC_APPL_START_ADDRESS;
Jump();
while(1);
In ASW, linker filer , ASW address is set as 0x08080000
can anybody please share the problem with above code, jump is no working and from dissembler i could see, hard fault handler is serviced.
2020-04-17 03:33 AM
try address 0x1FF09800, see here: https://community.st.com/s/article/STM32H7-bootloader-jump-from-application
2020-04-17 03:54 AM
The __IO's aren't necessary.
The app should probably config its own SCB_VTOR.
The osThreadSuspendAll and disabling systick aren't necessary if the app's SCB_VTOR and systick are configured before it reenables interrupts.
None of the above solve the hard fault though.
Disable interrupts before changing the stack pointer, de-init'ing clocks or de-init'ing systick too.
Does the app vector table's and stack and reset-handler pointers look good in memory, and does the reset-handler look good in memory (before jumping to it)?
Have you any MPU regions configured? Boot code unprivileged and reset-handler privileged would be bad. Reset-handler executable? Vector table readable? Stack read-writable, .bss and .data addresses writable, etc?
2020-04-17 04:30 AM
hi @alister ,yes, app is configured as its own SCB_VTOR = 0x08080000
Thank you in advance
2020-04-17 04:31 AM
hi, i use custom bootloader for jumping into Aapplication.
Above solution is good for system boot,
Thanks.
Anandh ram.
2020-04-17 05:32 AM
Look at what code specifically is faulting.
Have a proper Hard Fault Handler that can output actionable data. MCU can provide much detail.
If fault is in your loader then you likely have an interrupt. At the very least figure out which routines fault.
Sanity check the SP/PC values. Output telemetry and diagnostic messages.
Try doing the hand-off early to see if your loader/RTOS is creating a toxic environment.
2020-04-17 06:46 AM
hello all, thank you everyone for your support.
my jump to application from the boot i developed is working fine.
I am posting the working code, this may help others.
#define APPL_START_ADDRESS 0x08080000
void jump_appl()
{
U_INT32 JumpAddress = *(__IO U_INT32*)(APPL_START_ADDRESS+4);
pFunction Jump = (pFunction)JumpAddress;
uint32_t i=0;
__disable_irq();
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
HAL_RCC_DeInit();
for (i=0;i<5;i++)
{
NVIC->ICER[i]=0xFFFFFFFF;
NVIC->ICPR[i]=0xFFFFFFFF;
}
__set_MSP(*(__IO U_INT32*)APPL_START_ADDRESS);
SCB->VTOR = BPC_APPL_START_ADDRESS;
Jump();
while(1);
}