cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L496: HardFault in FreeRTOS's xPortPendSVHandler when booting on bank 2

milidam
Associate

Hi,

 

I am trying to use the dual-bank mechanism of a STM32L496 MCU.

Using `BFB2` bit of User Configuration register, I am able to switch between bank 1 and bank 2.

My application, using FreeRTOS, runs without problem in bank 1.

However, when I set the `BFB2` bit, it properly boots from bank 2 (I can follow traces sent on the UART proving it), but I systematically get a HardFault, forced from a UNALIGNED fault, that seems to occur during the execution of FreeRTOS's `xPortPendSVHandler`.

 

Any idea what could be the cause of it ? or how to workaround it?

 

Thanks in advance for your help.

1 ACCEPTED SOLUTION

Accepted Solutions
milidam
Associate

Hi @Saket_Om ,

 

Thanks for the hint. However, that is the solution I could find on several forums when looking for similar problems, but it did not solve mine.

On the other hand, I think I found a solution: I was using FreeRTOS' `ARM_CM3` port, instead of the `ARM_CM4` (STM32L496 is Cortex-M4-based). With the later, I can run from bank2, so far, without HardFault.

View solution in original post

2 REPLIES 2
Saket_Om
ST Employee

Hello @milidam 

Please, ensure that the vector table offset register (VTOR) point to the correct address in the bank 2.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om
milidam
Associate

Hi @Saket_Om ,

 

Thanks for the hint. However, that is the solution I could find on several forums when looking for similar problems, but it did not solve mine.

On the other hand, I think I found a solution: I was using FreeRTOS' `ARM_CM3` port, instead of the `ARM_CM4` (STM32L496 is Cortex-M4-based). With the later, I can run from bank2, so far, without HardFault.