I'm trying to connect to 15 BLE devices. I've followed the code at: https://github.com/NordicMatt/multi-NUS/ but have modified it to filter by the device name and then write to a specific characteristic once it has discovered the services. I'm using a nRF528040-DK and the nRF Connect SDK v2.4.1
This works great up to about 12 devices. However when I try to connect to more than 12 devices I will intermittently get this error
The error however doesn't occur after the 12th connection but right after I run this code:
at a random connection (i.e. one time it occurs after the 15th connection, another time after the 3rd connection). However the error only occurs when I'm trying to connect to more than 12 devices (i.e. when I run bt_scan_filter_add 12 or more times)
but before my discovery_complete callback is called from logging at different points in my application.
I saw some other issues like this and took steps to address the issues from them:
From RE: MPU FAULT occurs when discovering attributes of client I enabled CONFIG_THREAD_NAME=y and saw that the error occurs in the Current thread: 0x200021c0 (BT RX) I then increased added CONFIG_BT_RX_STACK_SIZE=4096 to my prj.conf
From MPU Fault with NCS Zephyr on nrf52840s I tried looking at the thread stack usage but everything seems normal (this is with CONFIG_THREAD_ANALYZER_AUTO_INTERVAL=5)
I'm new to the nRF5280 so any help with ways I can further debug this would be appreciated.
Here's my prj.conf as a reference:
I also saw RE: MPU Fault when attempting to subscribe to BLE notifications and in my zephyr.map I found that the faulting faulting instruction address (0x20011efc) is
The surrounding area looks like:
For reference here is my code
Update 03/08/23
Following Understanding a FATAL ERROR in my application tried running the code with the debugger. However it didn't break when the fault occurred, instead I had to manually pause it after seeing the fault be logged.
The call stack is interesting. While the log says the fault occurred in the BT RX thread the call stack says it occured in the BT TX Thread (see image above). When I commend out my bt_gatt_write the error does stop. However I don't know how to fix the error while still being able to write to the characteristics