cancel
Showing results for 
Search instead for 
Did you mean: 

Getting hardfault on STM32WB at initialization after power up randomly

vgFweng_2
Associate II

By some reason I am not able to figure out I randomly get a hard-fault that causes to not initialize the BLE stack, I occasionally get to this hard-fault just by having the board that is using the  STM32WB55 by doing powering up and powering down (cutting the power) directly on the board and eventually when I repeat this for a few 3 to 6 cycles  it gets to this condition. 

If add code to supervise this failure and trigger a software reboot it successfully initializes and starts working (no hard fault seen)

I am trying to understand what is the cause, I have suspect that something in the initialization or startup code needs to happen (or wait) to avoid this hardfault

I know that is a hardfault since I am reading the @SRAM2A_BASE and getting the following

keyword : 0x1170fd0f 

pc : 0x7628 

link_reg : 0x7265 

sp : 0x20037c28 

 

However that stack pointer address seems to be related to the SRAM that is used for CPU2 and not sure what is telling me, Any ideas what can I either do or enable to find out more information on what is causing this ? 

 

The product has the Ble_Ota as bootloader and the application firmware is using FreeRTOS, its using a STM32WB55RGV6 and  running with the Wireless Firmware version 1.17.3 with stm32wb5x_BLE_Stack_full_fw.bin.

 

 

 

5 REPLIES 5
Remy ISSALYS
ST Employee

Hello,

When the hardfault occurs, can you check the value of FLASH_SR registrer and share it, please?

Best Regards

Hi @Remy ISSALYS   this is what I see on that FLASH_SR register

 

[16:02:29:434] keyword : 0x1170fd0f ␊

[16:02:29:434] ␍pc : 0x7628 ␊

[16:02:29:441] ␍link_reg : 0x7265 ␊

[16:02:29:452] ␍sp : 0x20037c28 ␊

[16:02:29:463] ␍FLASH->SR : 0x000400a0 ␊

 

From what I understand is that the CFGBSY is Set , but not sure what I should do here or what am I not properly setting (since this not always occur) 

 

Remy ISSALYS
ST Employee

Hello,

According to FLASH_SR register value, the following bits are set, which means that the flash is in error:

  • CFGBSY
  • PGAERR
  • PGSERR

When the hardfault occurs are you running BLE_Ota or your application?

Do you perform flash write/erase in your application? If yes, are you using the flash driver available in STM32CubeWB package (see BLE_RfWithFlash project), or follow the algorithm to perform these actions describes in AN5289

Best Regards

vgFweng_2
Associate II

- When the Hard fault occurs is running the Application (not the BLE_Ota).

- The Application does not have any Flash Write/Erase functionality

Remy ISSALYS
ST Employee

Hello,

You can check if when you jump on your application from your bootloader, the flash is already in error or not. If not, something during the initialization generates this fault for example a null pointer. To find which instruction generate the fault, you can add breakpoint on each initialization function and check FLASH_SR register or use the MPU refer to my comment in this post. Are you using timer? If yes, which ones?   
Best regards