cancel
Showing results for 
Search instead for 
Did you mean: 

Custom bootloader and application initialization

I have a question on initialization in a custom booloader and application code.

Usually initialization of a bootloader is as follows:

  • startup_x.s calls SystemInit(), where SCB->VTOR is set to 0x08008000
  • Clocks are configured by calling SystemClock_Config()
  • HAL_Init() is called
  • Peripherals are initialized
  • interrupts are configured and enabled

When jumping to application (after disabling interrupts) I usually employ all of the above, re-initializing clocks and peripherals again and enabling interrupts. I also modify SCB->VTOR in a SystemInit() to set it to 0x08008000.

The question is - since all registers are kept intact (are they?) after jump, would it be legal and advisable to do the following in application initialization:

  • comment out SystemInit() call in a startup_x.s
  • use SCB->VTOR = 0x08008000; in application code
  • skip clock init calls since clocks are the same as in bootloader
  • skip call to HAL_Init()
  • configure peripherals used additionally in application
  • enable interrupts

Of coarse, all skipped steps should be conditionally employed in debugging by USE_DEBUG option.

Is anything wrong with this approach?

Would it be safer just to use all the routines in both bootloader and application?

Thank you,

Gennady

This discussion is locked. Please start a new topic to ask your question.
0 REPLIES 0