-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gatt_security_server example crash (Cache disabled but cached memory region accessed) (IDFGH-7342) #8928
Comments
More info about the reason why moving most of the internal memory to PSRAM is critically required, since our company is developing an IoT device that makes use of a few major components, e.g. esp-adf opus encoder(rec sound), aac decoder (play sound), WiFi/tcp/socket for cloud connectivity, BLE for near-field communication, GPIOs and many other esp components. The development got stuck since the Bluedroid BLE stack eats up 60KB from the already limited 160KB internal RAM, although the board has plenty of external 8MB PSRAM. |
The problem has been fixed. You can use the master branch or our latest 4.4 branch for testing. |
Thank you very much, Alson, for your prompt reply. |
@Alson-tang Unfortunately, upgrading to v4.4 does not completely resolve the BLE pairing crash issue when memory optimization is applied, say SPIRAM_MALLOC_ALWAYSINTERNAL=20 or 1. Compare with v4.1.2 and v4.4, v4.4 still crashes randomly when pairing. The crash happens in function btc_dm_save_ble_bonding_keys(), where it saves paired key info on nvs. v4.1.2 crashes much more likely than v4.4 To repeat the crash, simply repeat the steps below:
Again, memory optimization is critically required since there is only 160KB of internal RAM left for freeRTOS tasks' stack. |
What's your "git describe --tags" output? (Just to clarify if you are on v4.4 tag or v4.4 branch.) |
v4.4.1 |
From #8928 (comment), v4.4.1 still has the issue. |
@jw-redpanda @AxelLin You can try to verify on IDF v4.4 branch first. If you still have problems on ESP32, you can check whether the choice (High level interrupt) is enabled in menuconfig first.
|
The (High level interrupt) is default y and it is not a visible option on menuconfig, so it's unlikely users will disable it. |
@AxelLin Double confirm "CONFIG_BTDM_CTRL_HLI=y" is used in sdkconfig. In fact, this option is the default value. Hope this can be fixed soon. |
@Alson-tang @AxelLin I am trying the same test on ESP32-WROVER-E (ESP32-D0WD-V3) and it seems the crash is gone, although I need more tests to confirm. At least, ESP32-WROVER-B is able to repeat the crash easily. |
@jw-redpanda @AxelLin Thanks very much for your debug. I have read your sdkconfig and logs and have some conjectures, can you help me verify it? Just disable |
@blueMoods Trying out the following configs but pairing still causes random crashes. The crash logs are slightly different but all crashes happen in the function nvs_set_blob(). esp-idf: esp-idf v4.4.1 Config#1
Config#2 (CONFIG_SPIRAM_USE_MALLOC is disabled)
Crash log (config#1): Cache disabled but cached memory region accessed
Crash log (config#2): sudden reboot (TG1WDT_SYS_RESET)
According to the trace log, the crash is caused by writing to nvs during the pairing process. Since the point where the crash happens is quite clear, will it be able to resolve it soon? |
@jw-redpanda Thanks very mush for you help. The reason of this issues is not at I have find some issues will cause assceeing cache in interrupt: queue, sempher and mutex will be placed into PSRAM if Please make sure the queue, sempher and mutex you used in interrupt is mallocd in IRAM, you can refer to the function If this issue re-produce after changes, please save the log and .elf file and send to me. thanks. |
Thanks for reporting, will close due to short of feedback, feel free to reopen with more updates, thanks. |
@blueMoods Thanks for the patch. Then, I tried patching to a larger project, which has Bluetooth BLE, Wi-Fi, and many other components like esp-adf. However, the crash is still seen. After many trials, I suspect Wi-Fi may cause the crash. To help repeat the issue, I build a small project @Alvin1Zhang would you please re-open the issue? The issue can be repeated easily. |
@AxelLin @blueMoods Can I re-open the issue? I have prepared a project that is able to repeat the issue. It seems to be a Wi-Fi / BLE co-existence issue. Thank you. |
Environment
git describe --tags
to find it): v4.1.2-383-g23e8233506xtensa-esp32-elf-gcc --version
to find it): xtensa-esp32-elf-gcc (crosstool-NG esp-2020r3) 8.4.0Problem Description
Repeatable crash (Cache disabled but cached memory region accessed) in example: gatt_security_server example.
It crashes during the pairing process if enabled a small value of SPIRAM_MALLOC_ALWAYSINTERNAL, e.g. 50
Enabled options via menuconfig
The following is not enabled to ensure BT stack does not use dynamic allocation
Expected Behavior
Actual Behavior
In step3, the BLE server app crashes and the crash is repeatable with the following message:
Guru Meditation Error: Core 0 panic'ed (Cache disabled but cached memory region accessed)
Steps to reproduce
Simply enable the sdkconfig flags as described in the problem description. It crashes every time when pairing is performed.
If the value of SPIRAM_MALLOC_ALWAYSINTERNAL is larger, say 100, the crash is gone.
Code to reproduce this issue
use the example gatt_security_server example without code modification.
Debug Logs
Trying out to locate where it crashes, by inserting some debug log in esp-idf/components/bt/host/bluedroid/btc/core/btc_dm.c
When the app crashes, the debug log is seen.
Other items if possible
sdkconfig.txt
The issue is in fact found in a large ESP32 application that needs to reserve most IRAM/internal memory to FreeRTOS tasks' stack memory. So far, most components work perfectly with the memory optimization except for the crash issue found in Bluedroid.
The text was updated successfully, but these errors were encountered: