-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[General] Cannot use Bluedroid, NVS crashes/panics #3536
Comments
I'm going to start looking into this. I hope to have an answer for you in the next few days. |
A few things I noticed...
This library being the esp-idf library?
I don't think so. This configuration looks to be set in an sdk configuration file provided by esp-idf. See this. You may need to set this value. Can you provide a link to whatever you're basing your demo off of? Looking through your code I see where you create the Bluetooth task but I'm not seeing the scheduler being started anywhere. Is this being started somewhere else? Near the very top of your stack trace points to this function in esp-idf. From there it spirals into the esp-idf framework a bit. Your post may be better answered by the Espressif/ESP32 forums as this might be as simple as a configuration issue. |
Hello,
I mean the library I translated from here into my project.
I changed the configurations on the file you are mentioning to:
But I still see the line:
I am not sure how to start the scheduler, you mean
I will ask, but it is strange because this works on ESP-IDF, so there is something different going on with AFR, causing this error. The only difference in the implementation on ESP-IDF are these functions on my main.c which I do not know why I need them on AFR, but without them I cannot compile Amazon-FreeRTOS:
|
Hey, I've cloned down your repository and have started looking into your problem. I'll continue this effort to see if I can better assist you with your issue. In the meantime I was wondering if you had tried starting with an existing bluetooth demo for the STM32 board and then from there adding your needed functionality? This could ensure that you have the board and device properly working by following our documentation, at which point you could begin adding in your functions for your personal use case? We have a doc for our bluetooth demos available here, as well as a GitHub link to some demos here. If any of these resources help you solve your problem please let me know! |
Hello, @taherrera! Currently, Amazon FreeRTOS uses ESP-IDF |
Hello @laukik-hase , I tried PR #3541 , with these commands
But it fails on
However, I tried ESP-IDF checkout release/v4.2 and I can pair successfully, so it works con ESP-IDF 4.2 and 4.4. Now I am pretty sure there is something not allowing me to run this code with Amazon-FreeRTOS and it is not an issue originating in ESP-IDF. Hello @Skptak,
I have not tried other bluetooth solutions, because I think there is an underlying issue behind this that causes us not only not be able to use this bluetooth code, but also we have not been able to use NVS storage and cannot use the ESP-IDF 4.2 OTA functions. So since there are 3 problems related somehow to the flash storage in Amazon-FreeRTOS, we have not tried it. I first published this NVS problem as a bug but it was rapidly dismissed (see #3531) . So I lifted this issue with this bluetooth code which is more reproducible. |
Hey again,
Sorry, my intention was not to tell you to use a different bluetooth solution. I was trying to offer that by starting with one of our bluetooth demos you could verify that everything in your build system and board is working correctly. For example if you take a look at this app_main() function from the demos. You can see that there are some additional checks that happen, and functions that are called when performing the BLE setup. I felt that it might relevant to look over some of this since you're running into several different issues, directly related to using the board. Additionally, I can't speak to the error you're receiving on the update to that pull request. I was able to do the update to that PR and then perform the build. I don't currently have access to an ESP32 to run your code to further assist you, but I'm in the process of getting one so I can help you further. If you have any updates while I work on getting a board, please let me know. |
To reaffirm, you changed the esp32 configs as such?
If so then the the Bluetooth controller is configured for Classic Bluetooth only, but the amazon-freertos bluetooth services are GATT services that require BLE. Can you try setting Bluetooth controller to Bluetooth Dual Mode instead? You should be able to use Bluedroid, but building with amazon-freertos, NimBLE is set as the default. Also amazon-freertos BLE services also directly use the bluedroid/nimBLE APIs. There may be some collision/clobbering, for example amazon-freertos bluetooth middleware also configures GAP. Additionally, to clarify amazon-freertos does not technically use any version of ESP-IDF, rather it uses a fork specifically maintained for amazon-freertos, by Espressif: espressif/esp-afr-sdk. The version of it currently used by amazon-freertos is seeded from ESP-IDF v4.2.2 with some patches applied. @mahavirj May have additional info to add. |
Thanks @dachalco , I will try your suggested change and inform you asap. Also, I forgot to mention, that when I do not initialize the nvs, the bluetooth implementation works (although I have to pair each time to the device before connecting). |
Having to pair every time, due to omitting NVS, is expected. The bond information is supposed to persist, but if it doesn't then devices need to negotiate and exchange key information again, since it wasn't saved. |
The thing I am trying to point out is that Bluetooth works as expected and does not panic if I do not initialize the nvs. |
How are you building this code in amazon-freertos? From what I understand you've modifed the Additionally, as I understand your code was based on IDF v4.4, but as mentioned amazon-freertos uses a fork based on v4.2. Have you reviewed that functions and usage are the same for both? |
I set this in menuconfig: The application that throws these errors is here: https://github.com/taherrera/AFR-Bluedroid) |
In the AFR demos, there are a number of conflicts with a bluedroid SPP configuration. These conflicts are in iot_ble_hal_common_gap.c. This file configures the bluetooth for BLE GAP and only does incomplete for bluedroid intialization if the bluedroid menu option is selected. Compiling with the IDF 4.2 SPP demo incorporated is possible but a lot of work is required to get SPP functioning. |
The Amazon FreeRTOS product does not support bluetooth classic. It does support bluedroid in BLE mode. |
Hello,
I am trying to use bluetooth classic on the ESP32. For this I basically copied the Arduino implementation of bluetooth for the ESP32.
On ESP-IDF v4.4, this bluetooth implementation works perfectly, however on Amazon-Freertos it does not work.
To use this library, I have to change the menuconfig and use these configurations:
Bluetooth controller -> BR/EDR Only
Bluetooth Host -> Bluedroid - Dual-mode
Bluedroid options -> Classic Bluetooth
Bluedroid options -> Classic Bluetooth -> SPP
When I build the project, these lines stand out for me:
Is Bluedroid being disabled by Amazon-FreeRTOS ? I am confused by this line.
When I initialize bluetooth I can see it broadcasting on my phone, however, when I try to pair I get this error:
As you can see, there seems to be a problem with writing to a partition. I can also see that the partition differs on Amazon FreeRTOS versus ESP-IDF.
System information
This is the Arduino Implementation of Bluetooth, I initialize Bluetooth by just calling
nvs_flash_init()
and thenBluetoothSerial_begin("test", 0)
And this is the .h file:
The text was updated successfully, but these errors were encountered: