Skip to content

Commit bd4c425

Browse files
Add IDF 5 support and deprecate versions 4.1 and 4.2 (backport #176) (#177)
* Add IDF 5 support and deprecate versions 4.1 and 4.2 (#176) * Update support for ESP 5 Signed-off-by: acuadros95 <acuadros1995@gmail.com> * C_STANDARD workarround Signed-off-by: acuadros95 <acuadros1995@gmail.com> * Update docker, nightly and readme Signed-off-by: acuadros95 <acuadros1995@gmail.com> * Generalice C_VERSION for different IDF versions Signed-off-by: acuadros95 <acuadros1995@gmail.com> * Remove C_STANDARD from toolchain Signed-off-by: acuadros95 <acuadros1995@gmail.com> * Fix embeddeRTPS Signed-off-by: acuadros95 <acuadros1995@gmail.com> * Fix example Signed-off-by: acuadros95 <acuadros1995@gmail.com> * Fix esp32c3 build Signed-off-by: acuadros95 <acuadros1995@gmail.com> * Fix macro name Signed-off-by: acuadros95 <acuadros1995@gmail.com> * Deprecate v4.1 and v4.2 Signed-off-by: acuadros95 <acuadros1995@gmail.com> * Deprecate galactic Signed-off-by: acuadros95 <acuadros1995@gmail.com> * Revert XRCE client temporal branch Signed-off-by: acuadros95 <acuadros1995@gmail.com> --------- Signed-off-by: acuadros95 <acuadros1995@gmail.com> (cherry picked from commit a71fb63) # Conflicts: # .github/workflows/nightly.yml * Fix conflicts Signed-off-by: acuadros95 <acuadros1995@gmail.com> --------- Signed-off-by: acuadros95 <acuadros1995@gmail.com> Co-authored-by: Antonio Cuadros <49162117+Acuadros95@users.noreply.github.com> Co-authored-by: acuadros95 <acuadros1995@gmail.com>
1 parent f426aa2 commit bd4c425

11 files changed

Lines changed: 58 additions & 148 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,8 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
idf_target: [ esp32, esp32s2, esp32s3, esp32c3]
16-
idf_version: [ "espressif/idf:release-v4.1", "espressif/idf:release-v4.2", "espressif/idf:release-v4.3", "espressif/idf:release-v4.4" ]
16+
idf_version: [ "espressif/idf:release-v4.3", "espressif/idf:release-v4.4", "espressif/idf:release-v5.0" ]
1717
exclude:
18-
- idf_target: esp32s2
19-
idf_version: "espressif/idf:release-v4.1"
20-
- idf_target: esp32c3
21-
idf_version: "espressif/idf:release-v4.1"
22-
- idf_target: esp32c3
23-
idf_version: "espressif/idf:release-v4.2"
24-
- idf_target: esp32s3
25-
idf_version: "espressif/idf:release-v4.1"
26-
- idf_target: esp32s3
27-
idf_version: "espressif/idf:release-v4.2"
2818
- idf_target: esp32s3
2919
idf_version: "espressif/idf:release-v4.3"
3020

@@ -46,6 +36,8 @@ jobs:
4636
pip3 install catkin_pkg lark-parser empy colcon-common-extensions
4737
# This line avoids the error when using Python < 3.7 https://importlib-resources.readthedocs.io/en/latest/
4838
pip3 install importlib-resources
39+
# this installs the modules also for global python interpreter, needed for IDF v5
40+
/usr/bin/pip3 install catkin_pkg lark-parser empy colcon-common-extensions importlib-resources
4941
5042
- name: Build sample - int32_publisher
5143
shell: bash

.github/workflows/nightly.yml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,10 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
branch: [foxy, main, galactic, humble]
17+
branch: [foxy, main, humble]
1818
idf_target: [ esp32, esp32s2, esp32c3, esp32s3]
19-
idf_version: [ "espressif/idf:release-v4.1", "espressif/idf:release-v4.2", "espressif/idf:release-v4.3", "espressif/idf:release-v4.4" ]
19+
idf_version: [ "espressif/idf:release-v4.3", "espressif/idf:release-v4.4", "espressif/idf:release-v5.0" ]
2020
exclude:
21-
- idf_target: esp32s2
22-
idf_version: "espressif/idf:release-v4.1"
23-
- idf_target: esp32c3
24-
idf_version: "espressif/idf:release-v4.1"
25-
- idf_target: esp32c3
26-
idf_version: "espressif/idf:release-v4.2"
27-
- idf_target: esp32s3
28-
idf_version: "espressif/idf:release-v4.1"
29-
- idf_target: esp32s3
30-
idf_version: "espressif/idf:release-v4.2"
3121
- idf_target: esp32s3
3222
idf_version: "espressif/idf:release-v4.3"
3323
container:
@@ -49,6 +39,8 @@ jobs:
4939
pip3 install catkin_pkg lark-parser empy colcon-common-extensions
5040
# This line avoids the error when using Python < 3.7 https://importlib-resources.readthedocs.io/en/latest/
5141
pip3 install importlib-resources
42+
# this installs the modules also for global python interpreter, needed for IDF v5
43+
/usr/bin/pip3 install catkin_pkg lark-parser empy colcon-common-extensions importlib-resources
5244
5345
- name: Build sample - int32_publisher
5446
shell: bash
@@ -79,7 +71,7 @@ jobs:
7971
idf.py build
8072
8173
- name: EmbeddedRTPS
82-
if: ${{ matrix.branch == 'galactic' }}
74+
if: ${{ matrix.branch == 'humble' }}
8375
shell: bash
8476
run: |
8577
. $IDF_PATH/export.sh

CMakeLists.txt

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
idf_component_register(SRCS "network_interfaces/uros_ethernet_netif.c" "network_interfaces/uros_wlan_netif.c"
22
INCLUDE_DIRS "network_interfaces"
3-
REQUIRES nvs_flash)
3+
REQUIRES nvs_flash esp_wifi esp_eth lwip)
44

55
if(CMAKE_GENERATOR STREQUAL "Unix Makefiles")
66
set(submake "$(MAKE)")
77
else()
88
set(submake "make")
99
endif()
1010

11+
if (${IDF_VERSION_MAJOR} EQUAL 5)
12+
set(CMAKE_C_STANDARD 17)
13+
else()
14+
set(CMAKE_C_STANDARD 11)
15+
endif()
16+
1117
set(APP_COLCON_META "${PROJECT_DIR}/app-colcon.meta")
1218
if(NOT EXISTS "${APP_COLCON_META}")
1319
set(APP_COLCON_META "")
@@ -26,6 +32,22 @@ message(STATUS "Using Micro XRCE-DDS middleware")
2632
set(MIDDLEWARE "microxrcedds")
2733
endif()
2834

35+
# Create a list of packages to get includes
36+
idf_build_get_property(PACKAGES BUILD_COMPONENTS)
37+
38+
# Add includes for each package
39+
foreach(package ${PACKAGES})
40+
idf_component_get_property(${package}_dir ${package} COMPONENT_DIR)
41+
idf_component_get_property(${package}_includes ${package} INCLUDE_DIRS)
42+
list(TRANSFORM ${package}_includes PREPEND " -I${${package}_dir}/")
43+
string(REPLACE ";" "" ${package}_includes_string "${${package}_includes}")
44+
endforeach()
45+
46+
# Create a string with all packages with a for loop
47+
foreach(package ${PACKAGES})
48+
string(APPEND IDF_INCLUDES "${${package}_includes_string}")
49+
endforeach()
50+
2951
execute_process(
3052
WORKING_DIRECTORY ${COMPONENT_DIR}
3153
COMMAND
@@ -36,8 +58,10 @@ execute_process(
3658
X_CFLAGS=${CMAKE_C_FLAGS}
3759
X_CXX=${CMAKE_CXX_COMPILER}
3860
X_CXXFLAGS=${CMAKE_CXX_FLAGS}
61+
C_STANDARD=${CMAKE_C_STANDARD}
3962
MIDDLEWARE=${MIDDLEWARE}
4063
BUILD_DIR=${CMAKE_BINARY_DIR}
64+
IDF_INCLUDES=${IDF_INCLUDES}
4165
IDF_PATH=${IDF_PATH}
4266
IDF_TARGET=${IDF_TARGET}
4367
APP_COLCON_META=${APP_COLCON_META}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# micro-ROS component for ESP-IDF
55

6-
This component has been tested in ESP-IDF v4.1, v4.2, v4.3 and v4.4 with ESP32, ESP32-S2, ESP32-S3 and ESP32-C3.
6+
This component has been tested in ESP-IDF v4.3, v4.4, and v5.0 with ESP32, ESP32-S2, ESP32-S3 and ESP32-C3.
77

88
## Dependencies
99

@@ -64,7 +64,7 @@ It's possible to build this example application using preconfigured docker conta
6464
docker run -it --rm --user espidf --volume="/etc/timezone:/etc/timezone:ro" -v $(pwd):/micro_ros_espidf_component -v /dev:/dev --privileged --workdir /micro_ros_espidf_component microros/esp-idf-microros:latest /bin/bash -c "cd examples/int32_publisher; idf.py menuconfig build flash monitor"
6565
```
6666

67-
Dockerfile for this container is provided in the ./docker directory and available in dockerhub.
67+
Dockerfile for this container is provided in the ./docker directory and available in dockerhub. This approach uses ESP-IDF v5.
6868

6969
## Using serial transport
7070

docker/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

3-
FROM espressif/idf:release-v4.3
3+
FROM espressif/idf:release-v5.0
44

55
ENV DEBIAN_FRONTEND noninteractive
66
RUN echo "Set disable_coredump false" >> /etc/sudo.conf
@@ -16,9 +16,10 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
1616
COPY ./install_micro_ros_deps_script.sh /install_micro_ros_deps_script.sh
1717

1818
RUN mkdir -p /tmp/install_micro_ros_deps_script && mv /install_micro_ros_deps_script.sh /tmp/install_micro_ros_deps_script/ && \
19-
/tmp/install_micro_ros_deps_script/install_micro_ros_deps_script.sh && \
19+
IDF_EXPORT_QUIET=1 /tmp/install_micro_ros_deps_script/install_micro_ros_deps_script.sh && \
2020
rm -rf /var/lib/apt/lists/*
21-
21+
22+
RUN /usr/bin/pip3 --no-cache-dir install catkin_pkg lark-parser empy colcon-common-extensions importlib-resources
2223
ARG USER_ID=espidf
2324

2425
RUN useradd --create-home --home-dir /home/$USER_ID --shell /bin/bash --user-group --groups adm,sudo $USER_ID && \

esp32_toolchain.cmake.in

Lines changed: 5 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ set(idf_path "@IDF_PATH@")
77

88
if("${idf_target}" STREQUAL "esp32c3")
99
set(CMAKE_SYSTEM_PROCESSOR riscv)
10+
set(FLAGS "-ffunction-sections -fdata-sections" CACHE STRING "" FORCE)
1011
else()
1112
set(CMAKE_SYSTEM_PROCESSOR xtensa)
13+
set(FLAGS "-mlongcalls -ffunction-sections -fdata-sections" CACHE STRING "" FORCE)
1214
endif()
1315

1416
set(CMAKE_CROSSCOMPILING 1)
@@ -22,121 +24,12 @@ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
2224
set(CMAKE_C_COMPILER @CMAKE_C_COMPILER@)
2325
set(CMAKE_CXX_COMPILER @CMAKE_CXX_COMPILER@)
2426

25-
set(CMAKE_C_FLAGS_INIT "@CFLAGS@" CACHE STRING "" FORCE)
26-
set(CMAKE_CXX_FLAGS_INIT "@CXXFLAGS@" CACHE STRING "" FORCE)
27+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAGS} ${IDF_INCLUDES}")
28+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti ${FLAGS} ${IDF_INCLUDES}")
2729

28-
add_definitions(-DESP_PLATFORM -DLWIP_IPV4 -DLWIP_IPV6 -DPLATFORM_NAME_FREERTOS)
30+
add_compile_definitions(ESP_PLATFORM LWIP_IPV4 LWIP_IPV6 PLATFORM_NAME_FREERTOS)
2931

3032
include_directories(
3133
"@BUILD_CONFIG_DIR@"
32-
${idf_path}/components/newlib/platform_include
33-
${idf_path}/components/freertos/include
34-
${idf_path}/components/freertos/${CMAKE_SYSTEM_PROCESSOR}/include
35-
${idf_path}/components/freertos/port/${CMAKE_SYSTEM_PROCESSOR}/include
36-
${idf_path}/components/esp_hw_support/include
37-
${idf_path}/components/hal/include
38-
${idf_path}/components/hal/${idf_target}/include
39-
${idf_path}/components/heap/include
40-
${idf_path}/components/log/include
41-
${idf_path}/components/lwip/include/apps
42-
${idf_path}/components/lwip/include/apps/sntp
43-
${idf_path}/components/lwip/lwip/src/include
44-
${idf_path}/components/lwip/port/esp32/include
45-
${idf_path}/components/lwip/port/esp32/include/arch
46-
${idf_path}/components/lwip/port/esp32/tcp_isn
47-
${idf_path}/components/soc/src/${idf_target}/.
48-
${idf_path}/components/soc/src/${idf_target}/include
49-
${idf_path}/components/soc/include
5034
${idf_path}/components/soc/${idf_target}/include
51-
${idf_path}/components/esp_rom/include
52-
${idf_path}/components/esp_common/include
53-
${idf_path}/components/esp_system/include
54-
${idf_path}/components/${CMAKE_SYSTEM_PROCESSOR}/include
55-
${idf_path}/components/${CMAKE_SYSTEM_PROCESSOR}/${idf_target}/include
56-
${idf_path}/components/${idf_target}/include
57-
${idf_path}/components/driver/include
58-
${idf_path}/components/driver/${idf_target}/include
59-
${idf_path}/components/esp_ringbuf/include
60-
${idf_path}/components/efuse/include
61-
${idf_path}/components/efuse/${idf_target}/include
62-
${idf_path}/components/espcoredump/include
63-
${idf_path}/components/esp_timer/include
64-
${idf_path}/components/esp_ipc/include
65-
${idf_path}/components/soc/soc/${idf_target}/include
66-
${idf_path}/components/soc/soc/${idf_target}/../include
67-
${idf_path}/components/soc/soc/${idf_target}/private_include
68-
${idf_path}/components/vfs/include
69-
${idf_path}/components/esp_wifi/include
70-
${idf_path}/components/esp_wifi/${idf_target}/include
71-
${idf_path}/components/esp_event/include
72-
${idf_path}/components/esp_netif/include
73-
${idf_path}/components/esp_eth/include
74-
${idf_path}/components/tcpip_adapter/include
75-
${idf_path}/components/app_trace/include
76-
${idf_path}/components/mbedtls/port/include
77-
${idf_path}/components/mbedtls/mbedtls/include
78-
${idf_path}/components/mbedtls/esp_crt_bundle/include
79-
${idf_path}/components/bootloader_support/include
80-
${idf_path}/components/app_update/include
81-
${idf_path}/components/spi_flash/include
82-
${idf_path}/components/wpa_supplicant/include
83-
${idf_path}/components/wpa_supplicant/port/include
84-
${idf_path}/components/wpa_supplicant/include/esp_supplicant
85-
${idf_path}/components/nvs_flash/include
86-
${idf_path}/components/pthread/include
87-
${idf_path}/components/perfmon/include
88-
${idf_path}/components/asio/asio/asio/include
89-
${idf_path}/components/asio/port/include
90-
${idf_path}/components/cbor/port/include
91-
${idf_path}/components/coap/port/include
92-
${idf_path}/components/coap/port/include/coap
93-
${idf_path}/components/coap/libcoap/include
94-
${idf_path}/components/coap/libcoap/include/coap2
95-
${idf_path}/components/console
96-
${idf_path}/components/nghttp/port/include
97-
${idf_path}/components/nghttp/nghttp2/lib/includes
98-
${idf_path}/components/esp-tls
99-
${idf_path}/components/esp_adc_cal/include
100-
${idf_path}/components/esp_gdbstub/include
101-
${idf_path}/components/esp_hid/include
102-
${idf_path}/components/tcp_transport/include
103-
${idf_path}/components/esp_http_client/include
104-
${idf_path}/components/esp_http_server/include
105-
${idf_path}/components/esp_https_ota/include
106-
${idf_path}/components/protobuf-c/protobuf-c
107-
${idf_path}/components/protocomm/include/common
108-
${idf_path}/components/protocomm/include/security
109-
${idf_path}/components/protocomm/include/transports
110-
${idf_path}/components/mdns/include
111-
${idf_path}/components/esp_local_ctrl/include
112-
${idf_path}/components/sdmmc/include
113-
${idf_path}/components/esp_serial_slave_link/include
114-
${idf_path}/components/esp_websocket_client/include
115-
${idf_path}/components/expat/expat/expat/lib
116-
${idf_path}/components/expat/port/include
117-
${idf_path}/components/wear_levelling/include
118-
${idf_path}/components/fatfs/diskio
119-
${idf_path}/components/fatfs/vfs
120-
${idf_path}/components/fatfs/src
121-
${idf_path}/components/freemodbus/common/include
122-
${idf_path}/components/idf_test/include
123-
${idf_path}/components/idf_test/include/${idf_target}
124-
${idf_path}/components/jsmn/include
125-
${idf_path}/components/json/cJSON
126-
${idf_path}/components/libsodium/libsodium/src/libsodium/include
127-
${idf_path}/components/libsodium/port_include
128-
${idf_path}/components/mqtt/esp-mqtt/include
129-
${idf_path}/components/openssl/include
130-
${idf_path}/components/spiffs/include
131-
${idf_path}/components/ulp/include
132-
${idf_path}/components/unity/include
133-
${idf_path}/components/unity/unity/src
134-
${idf_path}/components/wifi_provisioning/include
135-
136-
${idf_path}/components/freertos/include/esp_additions/freertos
137-
${idf_path}/components/freertos/include/esp_additions
138-
${idf_path}/components/esp_hw_support/include
139-
${idf_path}/components/esp_hw_support/include/soc
140-
${idf_path}/components/esp_hw_support/include/soc/${idf_target}
141-
${idf_path}/components/esp_hw_support/port/${idf_target}/.
14235
)

examples/int32_publisher/main/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void timer_callback(rcl_timer_t * timer, int64_t last_call_time)
2828
{
2929
RCLC_UNUSED(last_call_time);
3030
if (timer != NULL) {
31-
printf("Publishing: %d\n", msg.data);
31+
printf("Publishing: %d\n", (int) msg.data);
3232
RCSOFTCHECK(rcl_publish(&publisher, &msg, NULL));
3333
msg.data++;
3434
}

examples/int32_publisher_custom_transport/main/esp32_serial_transport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ size_t esp32_serial_write(struct uxrCustomTransport* transport, const uint8_t *
4949

5050
size_t esp32_serial_read(struct uxrCustomTransport* transport, uint8_t* buf, size_t len, int timeout, uint8_t* err){
5151
size_t * uart_port = (size_t*) transport->args;
52-
const int rxBytes = uart_read_bytes(*uart_port, buf, len, timeout / portTICK_RATE_MS);
52+
const int rxBytes = uart_read_bytes(*uart_port, buf, len, timeout / portTICK_PERIOD_MS);
5353
return rxBytes;
5454
}

examples/int32_publisher_embeddedrtps/main/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void timer_callback(rcl_timer_t * timer, int64_t last_call_time)
2424
{
2525
RCLC_UNUSED(last_call_time);
2626
if (timer != NULL) {
27-
printf("Publishing: %d\n", msg.data);
27+
printf("Publishing: %d\n", (int) msg.data);
2828
RCSOFTCHECK(rcl_publish(&publisher, &msg, NULL));
2929
msg.data++;
3030
}

examples/int32_sub_pub/main/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ void timer_callback(rcl_timer_t * timer, int64_t last_call_time)
3131
(void) last_call_time;
3232
if (timer != NULL) {
3333
RCSOFTCHECK(rcl_publish(&publisher, &send_msg, NULL));
34-
printf("Sent: %d\n", send_msg.data);
34+
printf("Sent: %d\n", (int) send_msg.data);
3535
send_msg.data++;
3636
}
3737
}
3838

3939
void subscription_callback(const void * msgin)
4040
{
4141
const std_msgs__msg__Int32 * msg = (const std_msgs__msg__Int32 *)msgin;
42-
printf("Received: %d\n", msg->data);
42+
printf("Received: %d\n", (int) msg->data);
4343
}
4444

4545
void micro_ros_task(void * arg)

0 commit comments

Comments
 (0)