Closed mmackh closed 3 months ago
Hi @mmackh ,
Crash 1:
Is there any custom service being added in your code ? If yes, then suggest to check the cpfd being set while declaring the service .
https://github.com/espressif/esp-nimble/blob/c0dd77a8355dd82d0bc1b501e6d118a91eb14df1/nimble/host/src/ble_gatts.c#L745 This function basically confirms the validity of the values. if any of the checks fails, then the function returns 0, which will result in assert.
Crash 2:
From backtrace it looks the control is still in the application code . So NimBLEServer.cpp line 191 can be checked for the reason for the crash.
Thank you for the fast reply @rahult-github - the ble_gatt_cpfd is not being set. Is this a requirement?
As for crash number 2, it calls ble_gatts_start();
void NimBLEServer::start() {
if(m_gattsStarted) {
NIMBLE_LOGW(LOG_TAG, "Gatt server already started");
return;
}
int rc = ble_gatts_start();
if (rc != 0) {
NIMBLE_LOGE(LOG_TAG, "ble_gatts_start; rc=%d, %s", rc,
NimBLEUtils::returnCodeToString(rc));
abort();
}
Hi @mmackh ,
the ble_gatt_cpfd is not being set
Ok, this is little weird. The code will get executed only if cpfd is part of the service . https://github.com/espressif/esp-nimble/blob/28844aaa7fa5dd2587ea4fb297e0a71af8c5465c/nimble/host/src/ble_gatts.c#L3102 . May be some memory corruption is happening , somehow.
As for crash number 2, it calls ble_gatts_start();
So, your applicaiton is catching the return value of ble_gatts_start and invoking abort . Can you possibly capture the return value for this function ?
Please also share your sdkconfig, we will try to give more tries at our end to reproduce this.
May be some memory corruption is happening , somehow.
You were exactly right. In the library esp-nimble-cpp the struct was initialised using:
pChr_a = new ble_gatt_chr_def[numChrs + 1];
I assigned the cpfd
to NULL and it's finally stable again.
Thank you so much!
Hello,
I'm trying to track down a crash that happens randomly on launch somewhere in the BLE stack with the latest release of ESP-IDF (5.2.1) and and ESP32-WROOM-32E. Attached are the crash reports - it's both random which one causes the system to reboot and when. So it sometimes get stuck on boot for a few times and then it goes through ok.
Previously I was on 5.1.2, no crashes. I'm also not sure if it is related to my UUID. What changed that could lead to this behaviour?