This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Ble connectivity example failed to receive packets gatt operation stress test

Hi support team,

I'm using nrf52840 with softdevice 6.1.0 and sdk 15.0. I started from the ble_connectivity example as my central and used pc-ble-driver on my host PC as my driver which use SPI to communicate with my central.
I have a ble peripheral which could send notification very fast repeatedly when the cccd notification was enabled.

In stress test, my peripheral will send notification repeatedly very fast to my central and my central will do gatt read and write repeatedly very fast in main loop.
However, I found an issue that my central (ble_connectivity example) cannot receive packets any more after running test for several minutes.
After debug, I found:

  1. All the packets include ACK and gatt operation were sent to Slip/Hci layer on my central through SPI correctly.
  2. The root cause was located at line 527 in a static function(ser_phi_hci_rx_byte) of ser_phy_hci_slip.c, there is a comment /* Both buffers are not available - cannot continue reception*/.
  3. I added many logs in ble_connectivity source code, and I found:

           (1)When a packet was received from SPI interface, the data in the packet will be passed into ser_phi_hci_rx_byte byte by byte

           (2) There are two buffers in ser_phy_hci_slip.c, mp_small_buffer and mp_big_buffer, which one will be used was decided by the length of packet.
           (3) If ser_phi_hci_rx_byte was processing the current received packet and suddenly interrupted by tx event. I noticed the phenomenon and I assume the priority of tx event was higher than rx event. After tx event done, rx event will be rescheduled by hci_rx_reschedule, however, the mp_big_buffer will never be released(always be NULL )!! Thus caused the issue. I added log on every place that mp_big_buffer was been changed, but I didn't see anyone who set mp_big_buffer to NULL from RTT log.I wonder if there has any race conditions problems here which will probably cause the issue.

Note: I didn't put SPI RX callback which will call ser_phi_hci_rx_byte into critical region, because I think rx callback will be synchronized and cannot be interrupted itself. Do you think I need to put it into critical region?

Could you please help me on the problem?? Thank you very much!

Best Regards,
Tengfei.

Parents Reply Children
No Data
Related