Skip to main content
Associate
April 2, 2025
Solved

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

  • April 2, 2025
  • 2 replies
  • 562 views

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.

This topic has been closed for replies.
Best answer by milidam

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.

2 replies

ST Technical Moderator
May 12, 2025

Hello @milidam 

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

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Saket_Om
milidamAuthorBest answer
Associate
May 12, 2025

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.