AnsweredAssumed Answered

HAL init code does not work when executed a second time

Question asked by achterop.sietse on Dec 20, 2016
Latest reply on Mar 2, 2018 by Ghassen HALLEB

I am porting older code to the HAL library using cubemx for an STM32F4_Discovery board.

My application consists of a "bootloader" that resides in the lower segment of flash.

The actual application resides in higher segments.

The bootloader can optionally flash those segments with new code and will then jump to that code.

 

This code is regular code created via cubemx with a little different loader script to make the code reside higher in memory.

So when the bootloader jumps to that code ALL initialization is done for the SECOND time, but now for the application in high memory. This used to work fine, but with the HAL library at least the Systick interrupt is NOT coming.

So function HAL_Delay() is not working for example.

 

I would have hoped that the HAL init code would work irrespective of the state of the processor, but alas...

What I have tried is to execute some DeInit-functions before the jump, e.g.

 

USBD_LL_DeInit(&hUsbDeviceFS);

HAL_DeInit();

jumptoapp();

 

But that doesn't work.

The question is how can I start the app from the bootloader so that the initialization done in the app works and my code runs.

 

  Thanks in advance,

         Sietse

Outcomes