esp-idf: undefined reference to `_bt_bss_start' (IDFGH-9017)
Answers checklist.
- I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
- I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
- I have searched the issue tracker for a similar issue and not found a similar issue.
IDF version.
v4.4.3-316-ge86181704a
Operating System used.
Linux
How did you build your project?
Command line with idf.py
If you are using Windows, please specify command line type.
None
What is the expected behavior?
I expect incremental builds to work as well as see the same behavior from one build to the next.
What is the actual behavior?
When doing an incremental build I will get the following output from the link portion of the build 100% of the time
/opt/esp/tools/xtensa-esp32-elf/esp-2021r2-patch5-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: esp-idf/bt/libbt.a(bt.c.obj):(.literal.esp_bt_mem_release+0x0): undefined reference to `_bt_bss_start'
/opt/esp/tools/xtensa-esp32-elf/esp-2021r2-patch5-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: esp-idf/bt/libbt.a(bt.c.obj):(.literal.esp_bt_mem_release+0x4): undefined reference to `_bt_bss_end'
I then have to run idf.py fullclean
and do a build from scratch and it will succeed. Sometimes even after running fullclean
I will get the same error. I run fullclean
again, build again and everything compiles and links properly.
I recently migrated from 4.4.1 to 4.4.3. I never experienced this issue on 4.4.1 and have not changed anything in our codebase surrounding the bluetooth functionality. From the code it looks like the error is generated from the statements here but the linker can’t find definitions for them.
The weird thing is that it works by simply doing a fullclean
and building again…most of the time. That is from one build to the next without changing a line of code.
Steps to reproduce.
I created a repo with the minimum amount of code that allowed me to reproduce the issue. Instructions are in the README. https://github.com/sidwarkd/idf-build-issue. Please ensure you are using the exact version of ESP-IDF.
Build or installation Logs.
No response
More Information.
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 28
Commits related to this issue
- Fix linker error in bt component if bss to extram is used Fix for https://github.com/espressif/esp-idf/issues/10427. So far we did not encounter any problems. — committed to Eltako/esp-idf by dbahrdt a year ago
- Fix linker error in bt component if bss to extram is used Fix for https://github.com/espressif/esp-idf/issues/10427. So far we did not encounter any problems. (cherry picked from commit f24ab66e67a0... — committed to Eltako/esp-idf by dbahrdt a year ago
- fix(bt): Fix missing linker symbol when ESP_ALLOW_BSS_SEG_EXTERNAL_MEMORY enabled 1. Closes https://github.com/espressif/esp-idf/issues/10427 2. add two linker script to unify linker script symbols f... — committed to ep-whwong/esp-idf by wmy-espressif 3 months ago
- fix(bt): Fix missing linker symbol when ESP_ALLOW_BSS_SEG_EXTERNAL_MEMORY enabled 1. Closes https://github.com/espressif/esp-idf/issues/10427 2. add two linker script to unify linker script symbols f... — committed to espressif/esp-idf by wmy-espressif 3 months ago
Hi @michaelboeding , backport for branch "release/v5.2 " is ongoing, the fix is expected to be included in v5.2.2. Here is the patch if you use latest commit branch release/v5.2: patch_for_v5.2.tar.gz
Extract the files and use
git apply patch_for_v5.2/*.patch
Hi @AntoineSX , thanks for your reported issue, I have added the fix of this issue in my proposed formal fix which is being reviewed.
Hi @AntoineSX @lnayman Sorry for the late response. We are considering a fix for this linker issue which will support the option
ESP_ALLOW_BSS_SEG_EXTERNAL_MEMORY
as well as the APIesp_bt_mem_release
considering all of the Espressif SoCs in esp-idf, which will be different from the patch you are using. Hopefully the formal fix can be provided before the end of this month.Also thanks for your bug report @AntoineSX , I will evaluate the issue you pointed and provide my feedback later on.
While trying to debug another issue I may have found an error in the code that would cause the proposed fix to cause a crash when esp_bt_mem_release is called. This happens if, for example, you use wifi provisioning and have
.scheme_event_handler = WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM
, meaning the associated memory is released after provisioning.At line 1012 the comparison is made between the values at the _bt_bss_end and btdm_bss_start instead of the corresponding addresses. This does not ensure that both the btdm and bt memory blocks are consecutive. https://github.com/espressif/esp-idf/blob/b3f7e2c8a4d354df8ef8558ea7caddc07283a57b/components/bt/controller/esp32c3/bt.c#L1009-L1019 Line 1012 should be changed to :
With this change, no crash occurs when esp_bt_mem_release is called.
Hi guys. I have also been using the patch from https://github.com/Eltako/esp-idf/commit/c886e1578297faedcf00b9378f734fc0e1c4a6a0 and wondering when this will make it into esp-idf repo?
I’ve been using this patch https://github.com/Eltako/esp-idf/commit/c886e1578297faedcf00b9378f734fc0e1c4a6a0 for the past month without any issues. I would like to know if this fix will be looked into and applied to the official esp-idf repo ?
Hi folks, I reported the issue to the team responsible for this component. Further investigations are needed to make sure that BSS can indeed be put in external RAM for this component.
If you are having problems at link time, can you try removing the following lines from the
component/bt/linker.lf
file:and try compiling again.
@sidwarkd As soon as it is merged, it will be backported to
release/v5.0
. I also plan to backport it torelease/v4.4
. I will keep you informed