cancel
Showing results for 
Search instead for 
Did you mean: 

HAL init code does not work when executed a second time

Sietse
Associate III

Posted on December 20, 2016 at 15:00

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

1 ACCEPTED SOLUTION

Accepted Solutions
Sietse
Associate III
Posted on December 23, 2016 at 11:11

To answer my own question.

I had to change the  vector table location in the system control block by changing the value of VECT_TABLE_OFFSET in system_stm32f4xx.c

Its working fine now.

View solution in original post

4 REPLIES 4
Oliver Beirne
Senior

Posted on December 20, 2016 at 15:42

Hi

Achterop.Sietse

I have moved your post to

https://community.st.com/s/topic/0TO0X000000BSqSWAW/

where product related questions are asked.

Thanks

Oli

Sietse
Associate III
Posted on December 23, 2016 at 11:11

To answer my own question.

I had to change the  vector table location in the system control block by changing the value of VECT_TABLE_OFFSET in system_stm32f4xx.c

Its working fine now.

Posted on December 23, 2016 at 11:15

Hi

Achterop.Sietse

‌,

Thank you for posting your findings and how you fixed the issue, it is good to hear that it was solved.

-Nesrine-

Ghassen HALLEB
Associate
Posted on March 02, 2018 at 17:16

I had the same issue, your suggestion was the solution.

Thank you very much