cancel
Showing results for 
Search instead for 
Did you mean: 

STM32WB ble disconnect with 0x08 reason after FLASH write operation

Nikta Gorbadey
Associate

Hello!

We are developing device on STM32WB55 MCU along with mobile app companion. We use stm32wb5x_BLE_Stack_light_fw. The MCU works as Peripheral, mobile app - as Central.

In our firmware we use internal FLASH to store some configurations. Our application accesses FLASH according to AN5289 4.7 Flash memory management. However, we noticed that even if there is no active BLE communication, sometimes after FLASH writing operation the BLE connection between the device and mobile companion breaks with reason 0x08. It seems like we lock FLASH and BLE stack stops executing for long enough to not send packet during connection interval.

My next step was to update connection parameters to tolerate BLE stack stalling. I use aci_l2cap_connection_parameter_update_req API with parameters:

Conn_Interval_Min = 0x18 (30 ms)

Conn_Interval_Max = 0x24 (45 ms)

Slave_latency = 30

Timeout_Multiplier = 600 (6 s)

Now I am testing on iPhone 11. This parameters look fine and complies with https://developer.apple.com/accessories/Accessory-Design-Guidelines.pdf 40.6 Connection Parameters (page 179). I can see that Central accepts these parameters, but still, sometimes, the connection breaks with the same 0x08 reason. I tested lot's of different parameters so far, but I can't get stable BLE connection and that's why I am here.

My questions are:

1) Am I right about the reason behind BLE connection loss?

2) How should I play with connection parameters in order to get stable connection and don't loose too much data throughput speed?

If you need more information, please let me know.

6 REPLIES 6
MM..1
Chief II
Remy ISSALYS
ST Employee

Hello,

You can look BLE_RfWithFlash example available in STM32CubeWB package (https://www.st.com/en/embedded-software/stm32cubewb.html) witch allow to use BLE and to do action with flash. In this example, the flash driver implements the algorithm described in AN5289 - Building a Wireless application. You can use the driver in your project.

How do you know if there is no BLE communication ?

Best Regards

CVinc.1
Associate

Hello,

I am in a situation similar to the original post. Using STM32WB as BLE peripheral, PC/Android/iOS as central. Our app has to erase and write the flash both periodically and following some events.

When using Android the flash operations often either break the BLE connection or crash the STM32WB execution. (hardfault and other similar issues)

It works quite well with Windows and iOS.

Note that we use the same PC/Android/iOS with other BLE devices. I'm in fact porting an old app to STM32WB. So our central apps are quite mature.

I restarted from BLE_RfWithFlash example available in STM32CubeWB package, which works fine, but when I modified it to start flash operations on periodical basis (instead of on SW3 push), then I started having similar issues. (using ST's Android app)

I'm still searching for explanations. Maybe this info can help you... Maybe you can help me...?

Best Regards,

Vincent

Nikta Gorbadey
Associate

Hello!

Here is some text from application note:

When the CPU2 needs to protect its timing versus erase either because it has been notified

by CPU1 with the command SHCI_C2_FLASH_EraseActivity(ERASE_ACTIVITY_ON) or

because internally it needs to execute the Flash memory erase operation to erase some

sectors in the NVM, any memory operation will be forbidden 25 ms before the radio activity

until the end of it. To execute Flash memory erase operation when BLE is running, the

application must make sure that there is some radio idle time longer than 25 ms.

From my experience, Android often set connection interval too low (15 ms), and if you try to get access to FLASH with hardware semaphore, you will wait forever, and if you don't - you will crash.

Our solution is to request connection interval update until the set parameter will be from 30 to 45 ms. And ensure that you don't lock FLASH for more than 25 ms

Regards,

Nikita

Remy ISSALYS
ST Employee

Hello Vincent,

When you start flash operation periodically, are you using the flash driver used in BLE_RfWithFlash ? Can you give more details about your procedure for the flash operation periodically ?

In case of little connection interval (e.g minus 25 ms), the flash operation isn't executed but there isn't any BLE connection lost normally.

Best Regards

CVinc.1
Associate

Thank you both. Connection interval seems to be one of the keys indeed.

Best Regards,