cancel
Showing results for 
Search instead for 
Did you mean: 

Hard Fault in BLE_OTA demo application

DWalk.3
Associate III

When I compile the BLE_OTA demo application and run it, it hard faults in APPE_Init when it configures the BLE processor to control flash activity using hardware semaphore SEM7:

SHCI_C2_SetFlashActivityControl(FLASH_ACTIVITY_CONTROL_SEM7);

Stepping through the code, I found that in "shci_send", it accesses "pCmdBuffer" and stores several variables. I found that the pCmdBuffer gets initialized in "appe_Tl_Init" that gets called from APPE_Init right at the end. By moving the SHCI_C2_SetFlashActivityControl call after this, the hard fault was eliminated. My final APPE_Init function is:

void APPE_Init( void )
{
  /* Select which mechanism is used by CPU2 to protect its timing versus flash operation */
//  SHCI_C2_SetFlashActivityControl(FLASH_ACTIVITY_CONTROL_SEM7);
 
  SystemPower_Config(); /**< Configure the system Power Mode */
 
  HW_TS_Init(hw_ts_InitMode_Full, &hrtc); /**< Initialize the TimerServer */
 
  APPD_Init( );
 
  /**
   * The Standby mode should not be entered before the initialization is over
   * The default state of the Low Power Manager is to allow the Standby Mode so an request is needed here
   */
  UTIL_LPM_SetOffMode(1 << CFG_LPM_APP, UTIL_LPM_DISABLE);
 
  Led_Init();
 
  Button_Init();
 
  appe_Tl_Init();	/**< Initialize all transport layers */
  /* Select which mechanism is used by CPU2 to protect its timing versus flash operation */
  SHCI_C2_SetFlashActivityControl(FLASH_ACTIVITY_CONTROL_SEM7);
 
  /**
   * From now, the application is waiting for the ready event ( VS_HCI_C2_Ready )
   * received on the system channel before starting the Stack
   * This system event is received with APPE_SysUserEvtRx()
   */
 
  return;
}

Is this a bug or is there something else going on?

2 REPLIES 2
Imen.D
ST Employee

Hello @Community member​ and welcome to the Community :)

Have a look at this AN5289, in the hardfault section, and check if you have the same conditions as described.

Try to follow the recommendations related to the BLE_OTA application.

When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

I checked out the app note. The hardfault section refers to CPU2 hardfaulting. In my case, CPU1 hardfaulted because of the uninitialized "pCmdBuffer" variable in function "shci_send." Are you saying that the demo builds fine for you? Maybe there's something funky with my environment.