3 years, 2 months ago.
nRF51822 keeps crashing after random duration. Possible memory problem?
Hi. I have a bug that is proving difficult very difficult for me to solve but I think is due to low-memory / memory leak:
I have an application for the nRF51822 that polls various peripherals (SPI, I2C etc.) and feeds data to various BLE services. I currently have 4 BLE services amounting to 15 characteristics in total (possible near upper limits?).
There are two possibly distinct issues:
1. When running on nRF51-DK (that uses nRF51422 with 32kB SRAM) the application runs & connects fine. However after subscribing to all relevant characteristics with an iOS app the app will randomly crash between 3-7mins of runtime. The soft device appears to remain active as no "disconnection" occurs but the device is unresponsive to application-level functions. Is this probably due to memory allocation problems or a memory leak? Or is there something fundamentally difficult about using this many ble services with constant updating of data?
2. When trying to run the same code on an nRF51822 module (using the correct compilation target) the code, with all 4 BLE services, crashes before even reaching the advertising stage. When I remove one (or more) services it manages to start properly and I can even connect, but now the same random crash as above will usually occur in a similar timeframe. This symptom a main reason I believe this is a memory issue.
Other than general advice on what to look for here some questions are:
- Does this look like a memory-related issue as I believe?
- Is it really best to allocate Ble services to heap memory with the "new" command as is done in all BLE examples?
- Do I not need to do anything special to prevent memory leaks here? Is there a chance the stack & heap will collide and cause this kind of crash (where the soft device appears to remain alive)?
2 years, 12 months ago.
Having multiple ticker objects on the nRF51822 results in problems exactly like i'm experiencing. Basically the tickers may collide (after random duration) and result in all application interrupts being killed. Hence why it doesn't completely crash.
From what I see in the mbed code base, the ticker use extensively core_util_critical_section_enter and core_util_critical_section_exit which are not softdevice aware in the current form. That might be the cause of your troubles, blocking all interrupt is not allowed by the softdevice and the ticker functions can takes a lot of time.
One way to test it would be to use the functions in this file: https://github.com/ARMmbed/core-util/blob/master/source/critical_nordic.c
Which are softdevice aware.
You need to log in to post a question