cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H743ZI - jump issue with custom bootloader

Anand Ram
Associate III

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.

6 REPLIES 6
JConradt
Associate II
alister
Lead

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?

hi @alister​ ,yes, app is configured as its own SCB_VTOR = 0x08080000

  1. disabled interrupts , deinit clock and systick too before changing SCB_VTOR.
  2. app vector table is fine and located at 0x08080000, yes reset handlers looks fine and located at 0x080824b4.(breakpoint is hit here while executing jump())
  3. MPU regions from boot is not configured but from asw , its configured for ethernet
  4. what does it mean "Boot code unprivileged and reset-handler privileged would be bad"? how to fix this?
  5. Reset handler is executable, after that jumping into hardfault.
  6. vector table readable, could see from disassember with debug mode.
  7. how to verify stack read/write, yes .bss,.data aritable , i use stm work bench.

Thank you in advance

hi, i use custom bootloader for jumping into Aapplication.

Above solution is good for system boot,

Thanks.

Anandh ram.

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.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Anand Ram
Associate III

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);

}