Skip to main content
TGeor.1
Associate II
December 31, 2020
Solved

we were using bootloader code on stm32f429i disc1 where we could find that a hard fault when switching from bootloader to user application. We have changed main stack pointer as well as reset the handler before switching to the user application.

  • December 31, 2020
  • 5 replies
  • 2171 views

..

This topic has been closed for replies.
Best answer by waclawek.jan

I definitively wouldn't use printf() there.

Do you disable all potential interrupt source and bring all peripherals to reset state before calling this function?

Other than that, debug hardly as usually, search on this forum for hints how to do that.

JW

5 replies

waclawek.jan
Super User
December 31, 2020

Do you change VTOR register accordingly to the change of vector table address?

JW

TGeor.1
TGeor.1Author
Associate II
January 1, 2021

This is how I switch to user application from bootloader.

0693W000006HItMQAW.png

waclawek.jan
waclawek.janBest answer
Super User
January 1, 2021

I definitively wouldn't use printf() there.

Do you disable all potential interrupt source and bring all peripherals to reset state before calling this function?

Other than that, debug hardly as usually, search on this forum for hints how to do that.

JW

TGeor.1
TGeor.1Author
Associate II
January 1, 2021

thanks ,

i as i removed removed printf debugger Break at address "0x20030000" but did not start executing user application.

In this code i haven't enabled any interrupts.0693W000006HIuFQAW.png

waclawek.jan
Super User
January 1, 2021

I'm talking about the interrupts in the bootloader. You essentially ought to revert everything you've done in the bootloader to the peripherals, but first of all you should stop any sources of interrupt.

The best to experiment is to use a "stub"/simplified "bootloader" which does nothing just jumps to "main". Then evolve from that.

I don't know what's the reason for what you see. Try to single-step in the disasm view, i.e. instruction-by-instruction, and observe the processor registers' content, to gain understanding of what your code does.

JW

TGeor.1
TGeor.1Author
Associate II
January 4, 2021

0693W000006HMEIQA4.pngAfter jumping to reset handler,control goes to 0x20030000.

waclawek.jan
Super User
January 4, 2021

Ok, but what were the instructions that lead to this state? Place as breakpoint before the jump, single step and observe the processor registers content. Observe also the content of the applications vector table.

JW

TGeor.1
TGeor.1Author
Associate II
January 4, 2021

the function, app_resert_handler() is called just before.

Tesla DeLorean
Guru
January 4, 2021

Dump the vector table content, and addresses of various stuctures and pointers.

C​hanging the stack pointer in C is problematic, try not changin the current one and setting the default one in the applications Reset_Handler

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
TGeor.1
TGeor.1Author
Associate II
January 5, 2021

Thank you.

can you tell me how to implement that, like with some example code.