BLE and Wifi working together with Amazon FreeRTOS

darshu wrote on July 06, 2018:


I am working with a use case where I get data from BLE,and send it to AWS IoT over WiFi using ESP32.

Seperately, both components are working fine.
For example, I have created GATT server in ESP32 and BLE communication is working as expected.
Similarly, ESP32 is running fine with AFR and communicates with AWS IoT.

To integrate it, I added Bluetooth (bt) component to esp-idf folder in third_party folder.
Because of some dependencies, I had to add newlib and lwip components too.

However, now when I compile, I get errors as many variables that are defined in lwip are already defined in tcpip_adapter component which is already present.

What can be the optimum way in which I can use both BLE and WiFi together with Amazon FreeRTOS? Also, does it make sense to replace esp-idf folder by the latest esp-idf from github repository?

Thanks in advnace!

Update: I managed to remove the overlapping functions between lwip and tcpip_adapter. Now The compilation is almost happening. However, I had to upgrade some functions in components/esp32. Now, I am getting library errors after the compilation is complete.

FYI, I am using the Amazon FreeRTOS from github repo. Here is the log after compilation.

C:/AmazonFreeRTOS1/demos/espressif/esp32_devkitc_esp_wrover_kit/make/build/tcpip_adapter\libtcpip_adapter.a(tcpip_adapter.o):(.rodata.ethbroadcast+0x0): multiple definition of `ethbroadcast'
C:/AmazonFreeRTOS1/demos/espressif/esp32_devkitc_esp_wrover_kit/make/build/lwip\liblwip.a(ethernet.o):(.rodata.ethbroadcast+0x0): first defined here
C:/AmazonFreeRTOS1/demos/espressif/esp32_devkitc_esp_wrover_kit/make/build/esp32\libesp32.a(phy_init.o):(.literal.esp_phy_rf_init+0x8): undefined reference to `g_wifi_osi_funcs'
C:/AmazonFreeRTOS1/demos/espressif/esp32_devkitc_esp_wrover_kit/make/build/esp32\libesp32.a(phy_init.o):(.literal.esp_phy_rf_init+0x10): undefined reference to `wifi_osi_funcs_register'
C:/AmazonFreeRTOS1/demos/espressif/esp32_devkitc_esp_wrover_kit/make/build/esp32\libesp32.a(phy_init.o): In function `esp_phy_rf_init':
C:/AmazonFreeRTOS1/lib/third_party/mcu_vendor/espressif/esp-idf/components/esp32/phy_init.c:347: undefined reference to `wifi_osi_funcs_register'
C:/AmazonFreeRTOS1/demos/espressif/esp32_devkitc_esp_wrover_kit/make/build/amazon-freertos-common\libamazon-freertos-common.a(aws_wifi.o):(.literal.WIFI_On+0x14): undefined reference to `g_wifi_osi_funcs'
collect2.exe: error: ld returned 1 exit status
make: *** [/C/AmazonFreeRTOS1/demos/espressif/esp32_devkitc_esp_wrover_kit/make/../../../../lib/third_party/mcu_vendor/espressif/esp-idf/make/ /C/AmazonFreeRTOS1/demos/espressif/esp32_devkitc_esp_wrover_kit/make/build/aws_demos.elf] Error 1

Tiangang-AWS wrote on July 13, 2018:


Sorry for a delayed response. It looks like you also accidentally removed some WiFi source files which resulted in link errors. As you know, we don’t support BLE yet. But rest assured, we’re working on prioritizing our support for it.


darshu wrote on July 19, 2018:


I managed to solve all the errors that I had got before. Library errors still exist. I will look into the wifi source files.

Out of curiosity, as ESP32 already has all the required components and support for BLE, would it be possible for us to port the BLE for Amazon FreeRTOS. I am halfway through, but have no idea if it will work.

If it is possible, what would be the best approach for this?
(I am not an expert, so a bit detailed explanation helps a lot)


ravishankar-AWS wrote on July 31, 2018:

Recently I did a merge of the latest ESP-IDF code and Amazon FreeRTOS kernel and managed to get WIFI and BLE working together.
This is how I did:
I overwrote the existing components, make and tools folders under lib/third_party/mcu_vendor/espressif/esp-idf/ with their latest version from github repository:
I also had to update the portmacro and other portable FreeRTOS files with the latest changes from esp-idf.
Finally from the make folder, do make menuconfig , select component config --> Bluetooth -->Bluedroid Enable to enable ble stack.

Edited by: ravishankar-AWS on Jul 30, 2018 6:37 PM

darshu wrote on August 01, 2018:

Hi Ravishankar,

Thanks a lot for the reply. Even I did the similar thing but I got some library errors. I could not remove it yet.
Is there any chance that you can send me the link to the source codes with BLE working?
Or, is it planned to update the AFR anytime soon with these functionalities?

I have a very short duration left for completing this project I am working on. So, any information would be helpful.

Best regards.

PS: I am also waiting for the OTA feature!

ravishankar-AWS wrote on August 06, 2018:

Currently we don’t have support for BLE or a planned date of supporting BLE in Amazon FreeRTOS.
We value your query and take this into account in prioritizing the feature. Are you still having the issue?
I am happy to provide you with any additional suggestions or information on how to debug your issue.

DanN-AWS wrote on November 28, 2018:

You may have seen that we launched beta support for BLE in Amazon FreeRTOS this week.

Take a look at our “What’s New” post here: []