Repository navigation
Open
Description
Is it possible to use this module on an ESP chip (I'm trying to use it on ESP32)?
I'm able to build 'micro_ros_zephyr_module' using 'west build -b disco_l475_iot1' but I'm having errors caused by 'app.overlay' content when building with 'west build -p auto -b esp32_devkitc_wroom':
-- west build: generating a build systemwroom
Loading Zephyr default modules (Zephyr base).
-- Application: /home/ognjen/zephyrproject/applications/micRobbit-firmware/app/modules/micro_ros_zephyr_module
-- CMake version: 3.22.1
-- Found Python3: /usr/bin/python3 (found suitable version "3.10.12", minimum required is "3.8") found components: Interpreter
-- Cache files will be written to: /home/ognjen/.cache/zephyr
-- Zephyr version: 3.5.99 (/home/ognjen/zephyrproject/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: esp32_devkitc_wroom
-- ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK
-- Found host-tools: zephyr 0.16.3 (/opt/zephyr-sdk-0.16.3)
-- Found toolchain: zephyr 0.16.3 (/opt/zephyr-sdk-0.16.3)
-- Found Dtc: /opt/zephyr-sdk-0.16.3/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6")
-- Found BOARD.dts: /home/ognjen/zephyrproject/zephyr/boards/xtensa/esp32_devkitc_wroom/esp32_devkitc_wroom.dts
-- Found devicetree overlay: /home/ognjen/zephyrproject/applications/micRobbit-firmware/app/modules/micro_ros_zephyr_module/app.overlay
devicetree error: /home/ognjen/zephyrproject/applications/micRobbit-firmware/app/modules/micro_ros_zephyr_module/app.overlay:2 (column 14): parse error: undefined node label 'usbotg_fs'
-- In: /home/ognjen/zephyrproject/applications/micRobbit-firmware/app/modules/micro_ros_zephyr_module/build/zephyr, command: /usr/bin/python3;/home/ognjen/zephyrproject/zephyr/scripts/dts/gen_defines.py;--dts;/home/ognjen/zephyrproject/applications/micRobbit-firmware/app/modules/micro_ros_zephyr_module/build/zephyr/zephyr.dts.pre;--dtc-flags;'';--bindings-dirs;/home/ognjen/zephyrproject/zephyr/dts/bindings;--header-out;/home/ognjen/zephyrproject/applications/micRobbit-firmware/app/modules/micro_ros_zephyr_module/build/zephyr/include/generated/devicetree_generated.h.new;--dts-out;/home/ognjen/zephyrproject/applications/micRobbit-firmware/app/modules/micro_ros_zephyr_module/build/zephyr/zephyr.dts.new;--edt-pickle-out;/home/ognjen/zephyrproject/applications/micRobbit-firmware/app/modules/micro_ros_zephyr_module/build/zephyr/edt.pickle;--vendor-prefixes;/home/ognjen/zephyrproject/zephyr/dts/bindings/vendor-prefixes.txt
CMake Error at /home/ognjen/zephyrproject/zephyr/cmake/modules/dts.cmake:268 (message):
gen_defines.py failed with return code: 1
Call Stack (most recent call first):
/home/ognjen/zephyrproject/zephyr/cmake/modules/zephyr_default.cmake:129 (include)
/home/ognjen/zephyrproject/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
/home/ognjen/zephyrproject/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
CMakeLists.txt:7 (find_package)
-- Configuring incomplete, errors occurred!
FATAL ERROR: command exited with status 1: /usr/bin/cmake -DWEST_PYTHON=/usr/bin/python3 -B/home/ognjen/zephyrproject/applications/micRobbit-firmware/app/modules/micro_ros_zephyr_module/build -GNinja -DBOARD=esp32_devkitc_wroom -S/home/ognjen/zephyrproject/applications/micRobbit-firmware/app/modules/micro_ros_zephyr_module
I found in this issue statement that this module should be usable on any board supported by Zephyr.
Thanks in advance.
Metadata
Metadata
Assignees
Labels
No labels
Activity
pablogs9 commentedon Nov 28, 2023
Does it works if you revert this changes: #125 ?
OgnjenX commentedon Nov 28, 2023
Thanks for the fast response @pablogs9.
If I revert the whole commit, I have problems with undefined references to ring buffer related functions... But if I just remove the 'app.overlay' build works.
I managed to build my project with the microROS library by just linking 'libmicroros' (https://github.com/micro-ROS/micro_ros_zephyr_module/tree/iron/modules/libmicroros), so I'm not sure if that is the way to go? (and if yes, then building 'micro_ros_zephyr_module' as a whole is probably less relevant?)
pablogs9 commentedon Nov 28, 2023
This repo is an example of a micro-ROS application for
disco_l475_iot1, in that sense, you will need to tune the main folder to fit your platform and "reuse" the module (https://github.com/micro-ROS/micro_ros_zephyr_module/tree/iron/modules/libmicroros).Let me know if you have any questions.
OgnjenX commentedon Dec 4, 2023
I linked libmicroros as it is done in the example in this repo (basically I just copied 'libmicroros' module and put it in the 'modules' subdirectory for now). The strange thing is that when I enable CPP support (even with minimal parts of the std library, I have dram0_0_seg overflows (it is also happening if I try to compile for other boards, RAM and flash are being overflowed...). I wonder if that is a known limitation, or if I have something misconfigured.
Thank you in advance.
pablogs9 commentedon Dec 4, 2023
I do not know how big is your flash. CPP std lib tends to be big and micro-ROS is also a big library (depending on the types and features you use). Normally is a good idea to build with -Os and with -ffuntions -fsections to allow the linker to optimize out not used code sections.
OgnjenX commentedon Dec 4, 2023
It has a 4MiB flash size. I set the CONFIG_SIZE_OPTIMIZATIONS flag to 'y' (which should result in setting -the Os flag to the compiler) but did not resolve the issue. I suspect the flash size of the chip is a problem because I used the same chip with esp-idf and https://github.com/micro-ROS/micro_ros_espidf_component (Zephyr and FreeRTOS probably have different footprint sizes, but I guess it should not be that much in difference).
I'm not sure how to provide -ffuntions -fsections flags to compiler in Zephyr's build system (I tried 'zephyr_library_compile_options' and 'zephyr_compile_options' but it reports that those flags are not recognized).
Thanks.
towen commentedon Dec 6, 2023
I managed to build for the
esp32s3_devkitmboard. The main thing I needed to do, was to moveapp.overlaytoboards/disco_l475_iot1.overlay(it contains stuff for enabling USB console on ST devices, so it is specific to that board)However, in order to enable UDP transport over WiFi, I did have to modify the library code slightly. In
modules/libmicroros/microros_transports/udp/microros_transports.h, I had to dotowen commentedon Dec 6, 2023
Unfortunately though,
rclc_support_initcauses a fatal exception. I have added a printk at the beginning of main to check the code is running, and unless I return out of main before the lineRCCHECK(rclc_support_init(&support, 0, NULL, &allocator));then I get the followingI'm not sure how to debug further on esp32.
OgnjenX commentedon Dec 7, 2023
I have similar issue during runtime:
That is happening in my app (using UDP as microros transport), as well as in your example.
OgnjenX commentedon Dec 7, 2023
@towen I believe we are experiencing the same issue... For some reason it breaks when
rcl_support_initis called (concretely it breaks on linesrand(uxr_nanos());- I wondered if newlibc in espressif toolchain is missing).Any help would be appreciated.
Thanks.
towen commentedon Dec 7, 2023
Interesting. I have occasionally had "multiple definition of 'random()'" errors, but been unable to pin them down. Is
CONFIG_TEST_RANDOM_GENERATORset?Also of note, if CONFIG_MICROROS=y then NET_L2_WIFI_SHELL crashes on any command e.g.
wifi scanorwifi statusbut no idea atm if this is related.OgnjenX commentedon Dec 8, 2023
CONFIG_TEST_RANDOM_GENERATORhas not resolved the issue. I also tried adding full libc support (CONFIG_REQUIRES_FULL_LIBC) but also did not resolve the issue.towen commentedon Dec 9, 2023
This seems like a Zephyr bug (if I try to use rand/srand in
samples/hello_worldit still crashes) - perhaps it is to do with recent work on the random subsystem -maybe they neglected the POSIX API when they did this work. I will try to see if it is a regression or whether it has never worked, before I file the issue with ZephyrHowever, I think if Zephyr is using a proper random number generator (e.g. from hardware) then calling
srand()makes no sense.We could perhaps remove all calls to
srandand replacerand()withsys_rand32_get()which does work, and should produce better random numbers.There's also
sys_rand_get()which can produce faster random numbers for large blocks of memory, so we can get rid of a loop.OgnjenX commentedon Dec 9, 2023
I tried replacing srand and rand, but there is an issue with all libc functions. I'm just wondering if that is happening on other targets or if that is a problem specific to espressif's toolchain in Zephyr...
OgnjenX commentedon Dec 9, 2023
Replacing POSIX functions with Zephyr specifics for random number generation would require modifying 'rmw-microxrcedds' source code (which, I think, is not an ideal option - I think it is using POSIX APIs for easier portability on different platforms).
Assuming that the project example contained in this repo works on the 'disco_l475_iot' board (which I cannot check because I do not have one), that would mean that there is a problem with espressif toolchain in Zephyr (it could probably mean something else, but I do not have better explanation currently in mind).
sylvioalves commentedon Dec 11, 2023
@OgnjenX, while I don't have a proper fix for this issue yet, please, would you try commenting this line?
https://github.com/zephyrproject-rtos/hal_espressif/blob/zephyr/zephyr/esp32/CMakeLists.txt#L77
Let me know if it solves it for now.
OgnjenX commentedon Dec 11, 2023
@sylvioalves That solves the issue with newlib functions used in the app, so I guess it is a reasonable workaround until the issue is fixed.
Thank you very much!
OgnjenX commentedon Dec 11, 2023
There is still the issue with
rclc_support_init, it always returnsRMW_RET_ERROR(in my application, as well as in a sample app from this repo) @pablogs9Any help would be appreciated.
nilskiefer commentedon Jul 17, 2025
Any progress on this? I am also seeing
RMW_RET_ERRORfromrclc_support_init