Repository navigation
Closed
Description
- Hardware description: esp32
- RTOS: FreeRTOS
- Installation type: espidf, component
- Version or commit hash: humble
Steps to reproduce the issue
Clone this repo in components folder, then as always:
idf.py set-target esp32
idf.py build Actual behavior
build fails:
/home/raphael/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/newlib/libnewlib.a(stdatomic.c.obj): in function `__atomic_exchange_8':
/home/raphael/esp/v5.3/esp-idf/components/newlib/stdatomic.c:77: multiple definition of `__atomic_exchange_8'; /home/raphael/idf_components/micro_ros_espidf_component/libmicroros.a(librcutils-atomic_64bits.c.obj):atomic_64bits.c:(.text.__atomic_exchange_8+0x0): first defined here
/home/raphael/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/newlib/libnewlib.a(stdatomic.c.obj): in function `__atomic_fetch_add_8':
/home/raphael/esp/v5.3/esp-idf/components/newlib/stdatomic.c:77: multiple definition of `__atomic_fetch_add_8'; /home/raphael/idf_components/micro_ros_espidf_component/libmicroros.a(librcutils-atomic_64bits.c.obj):atomic_64bits.c:(.text.__atomic_fetch_add_8+0x0): first defined here
/home/raphael/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/newlib/libnewlib.a(stdatomic.c.obj): in function `__atomic_load_8':
/home/raphael/esp/v5.3/esp-idf/components/newlib/stdatomic.c:77: multiple definition of `__atomic_load_8'; /home/raphael/idf_components/micro_ros_espidf_component/libmicroros.a(librcutils-atomic_64bits.c.obj):atomic_64bits.c:(.text.__atomic_load_8+0x0): first defined here
/home/raphael/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/newlib/libnewlib.a(stdatomic.c.obj): in function `__atomic_store_8':
/home/raphael/esp/v5.3/esp-idf/components/newlib/stdatomic.c:77: multiple definition of `__atomic_store_8'; /home/raphael/idf_components/micro_ros_espidf_component/libmicroros.a(librcutils-atomic_64bits.c.obj):atomic_64bits.c:(.text.__atomic_store_8+0x0): first defined here
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
ninja failed with exit code 1, output of the command is in the
Additional information
By modifying the file libmicroros.mk i was able to make it work:
in line 110 i added esp32 as target too. So the full line looks like this then:
ifeq ($(IDF_TARGET),$(filter $(IDF_TARGET), esp32 esp32s2 esp32c3))
However, i`m not experienced enough to know whether this has any side effects and is a valid change.
Reacted by Ihor Ziuba, Burak, Henry, Katsuhiko Kageyama and Cyril Jourdan
Metadata
Metadata
Assignees
Labels
No labels
Activity
Care-Again commentedon Jun 27, 2025
I met the same error:( with my ESP32-S3. libnewlib.a form ESP-IDF & newlib and libmicroros.a form micro-ROS
is conficting, which means my ESPIDF-V5.4 has no idea on __atomic_exchange_8、__atomic_fetch_add_8
Roboprotos commentedon Jun 28, 2025
Hi, I'm experiencing the same issue with micro-ros on ESP32 S3 using ESP-IDF V5.3.1.
esp-idf/components/newlib/stdatomic.c:77: multiple definition of __atomic_fetch_add_8';Has this issue been patched or solved ?
EDIT: however, adding esp32s3 to the patch_atomic section in libmicroros.mk worked for me:
feq ($(IDF_TARGET),$(filter $(IDF_TARGET),esp32s3 esp32s2 esp32c3 esp32c6))ESP32 S3 is quite popular, it would be great if someone could add it to patch_atomic.
Care-Again commentedon Jun 29, 2025
@Roboprotos
My issue was just as same as yours. My ESPIDF told me those __atomic__functions were defined for twice. I had tried plenty of methods but none works.
I tried to give a clear order in my Cmakelists to make sure those functions from ESPIDF should be "neglected" while only the ones from Micro-ROS are on thery duty but this DIDN'T WORK.
Then I tried to delete these functions in /esp-idf/newlib/stdatomic.c. BUT the error occurred again.
At last I had to use a complete OS from the shop which I bought my ESP32-S3 from. This time it works with no error.
HOPE you could find the solutions !
Care-Again commentedon Jun 29, 2025
@Roboprotos
You can try previous versions of ESPIDF. The owner of the shop tells me to use ROS2-humble, Micro-ROS-humble and ESPIDF-V5.1.2.
MAYBE this works !
Roboprotos commentedon Jun 29, 2025
@Care-Again Thank you for your feedback. I wrote the solution I found at the end of my previous comment. It works for me using ESP-IDF v5.3.1, ESP32 S3 and jazzy branch of micro-ros espidf component.
kmarques-24 commentedon Oct 19, 2025
@Care-Again For future reference, the combination of ROS2-humble, MicroROS-humble, and ESPIDF-v5.1.2 worked for me!
JoseGomesJr commentedon Jan 23, 2026
I am encountering the exact same issue with ESP-IDF v5.5 (Master) targeting the ESP32-S3.
Context:
I cannot downgrade to the stable version (v5.3) because my project strictly requires specific DMA features for the ESP32-S3 that are currently only available in v5.5.
Workaround:
Since GCC 14 (bundled with IDF v5.5) now includes built-in atomic implementations that conflict with
rcutils, I managed to fix the build by patching theCMakeLists.txtof the component to force the linker to accept multiple definitions.In
components/micro_ros/CMakeLists.txt, append the interface link option at the end:After applying this change and running a full clean (
rm -rf build/idf.py build), the project compiles successfully.Fix rolling builds
Fix rolling builds
Fix rolling builds
Fix rolling builds
Narukara commentedon Apr 13, 2026
I ran a test: based on the
humblebranch of this repository, I tried building theexamples/int32_publisherusing different versions of ESP-IDF and for different target chips. Here are the test results:T:
libmicroros.acontains atomic operations.U:
libmicroros.adoes not contain atomic operations.❌: Build failed due to duplicate definition of atomic operations.
✅: Build succeeded.
ESP-IDF 6.0: Build failed, possibly because ESP-IDF has been using
picolibcby default since 6.0.Narukara commentedon Apr 13, 2026
On ESP-IDF 5.2,
libmicroros.aincludes atomic operations but does not cause a build failure. This appears to be because atomic operations are not used internally by ESP-IDF, so its built-in atomic operations are not actually linked. On version 5.3, however, ESP-IDF has introduced some atomic operations internally. See:This then leads to a build failure.
One more thing: I tried adding atomic operations manually in ESP-IDF version 5.2 and successfully triggered a duplicate definition error for atomic operations.
Narukara commentedon Apr 13, 2026
The
patch_atomicmechanism in thelibmicroros.mkcomes from #18. It was introduced to address the issue that ESP-IDF only provided partial atomic operations. From version 5.2 onward, it seems that ESP-IDF provides complete atomic operations. Therefore, perhaps we can simply disable the micro-ROS 64-bit atomic extension and removepatch_atomic? I'll give it a try later.micro_ros_espidf_component/colcon.meta
Line 20 in b2af7b2
Fix rolling builds
Narukara commentedon May 27, 2026
Since the atomic patch has been removed, this issue can be closed.