Skip to content

Commit

Permalink
Add IDF 5 support and deprecate versions 4.1 and 4.2 (#176)
Browse files Browse the repository at this point in the history
* Update support for ESP 5

Signed-off-by: acuadros95 <[email protected]>

* C_STANDARD workarround

Signed-off-by: acuadros95 <[email protected]>

* Update docker, nightly and readme

Signed-off-by: acuadros95 <[email protected]>

* Generalice C_VERSION for different IDF versions

Signed-off-by: acuadros95 <[email protected]>

* Remove C_STANDARD from toolchain

Signed-off-by: acuadros95 <[email protected]>

* Fix embeddeRTPS

Signed-off-by: acuadros95 <[email protected]>

* Fix example

Signed-off-by: acuadros95 <[email protected]>

* Fix esp32c3 build

Signed-off-by: acuadros95 <[email protected]>

* Fix macro name

Signed-off-by: acuadros95 <[email protected]>

* Deprecate v4.1 and v4.2

Signed-off-by: acuadros95 <[email protected]>

* Deprecate galactic

Signed-off-by: acuadros95 <[email protected]>

* Revert XRCE client temporal branch

Signed-off-by: acuadros95 <[email protected]>

---------

Signed-off-by: acuadros95 <[email protected]>
  • Loading branch information
Acuadros95 authored Feb 16, 2023
1 parent 8311544 commit a71fb63
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 148 deletions.
14 changes: 3 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,8 @@ jobs:
fail-fast: false
matrix:
idf_target: [ esp32, esp32s2, esp32s3, esp32c3]
idf_version: [ "espressif/idf:release-v4.1", "espressif/idf:release-v4.2", "espressif/idf:release-v4.3", "espressif/idf:release-v4.4" ]
idf_version: [ "espressif/idf:release-v4.3", "espressif/idf:release-v4.4", "espressif/idf:release-v5.0" ]
exclude:
- idf_target: esp32s2
idf_version: "espressif/idf:release-v4.1"
- idf_target: esp32c3
idf_version: "espressif/idf:release-v4.1"
- idf_target: esp32c3
idf_version: "espressif/idf:release-v4.2"
- idf_target: esp32s3
idf_version: "espressif/idf:release-v4.1"
- idf_target: esp32s3
idf_version: "espressif/idf:release-v4.2"
- idf_target: esp32s3
idf_version: "espressif/idf:release-v4.3"

Expand All @@ -46,6 +36,8 @@ jobs:
pip3 install catkin_pkg lark-parser empy colcon-common-extensions
# This line avoids the error when using Python < 3.7 https://importlib-resources.readthedocs.io/en/latest/
pip3 install importlib-resources
# this installs the modules also for global python interpreter, needed for IDF v5
/usr/bin/pip3 install catkin_pkg lark-parser empy colcon-common-extensions importlib-resources
- name: Build sample - int32_publisher
shell: bash
Expand Down
18 changes: 5 additions & 13 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,10 @@ jobs:
strategy:
fail-fast: false
matrix:
branch: [foxy, main, galactic]
branch: [foxy, main, humble]
idf_target: [ esp32, esp32s2, esp32c3, esp32s3]
idf_version: [ "espressif/idf:release-v4.1", "espressif/idf:release-v4.2", "espressif/idf:release-v4.3", "espressif/idf:release-v4.4" ]
idf_version: [ "espressif/idf:release-v4.3", "espressif/idf:release-v4.4", "espressif/idf:release-v5.0" ]
exclude:
- idf_target: esp32s2
idf_version: "espressif/idf:release-v4.1"
- idf_target: esp32c3
idf_version: "espressif/idf:release-v4.1"
- idf_target: esp32c3
idf_version: "espressif/idf:release-v4.2"
- idf_target: esp32s3
idf_version: "espressif/idf:release-v4.1"
- idf_target: esp32s3
idf_version: "espressif/idf:release-v4.2"
- idf_target: esp32s3
idf_version: "espressif/idf:release-v4.3"
container:
Expand All @@ -49,6 +39,8 @@ jobs:
pip3 install catkin_pkg lark-parser empy colcon-common-extensions
# This line avoids the error when using Python < 3.7 https://importlib-resources.readthedocs.io/en/latest/
pip3 install importlib-resources
# this installs the modules also for global python interpreter, needed for IDF v5
/usr/bin/pip3 install catkin_pkg lark-parser empy colcon-common-extensions importlib-resources
- name: Build sample - int32_publisher
shell: bash
Expand Down Expand Up @@ -79,7 +71,7 @@ jobs:
idf.py build
- name: EmbeddedRTPS
if: ${{ matrix.branch == 'galactic' }}
if: ${{ matrix.branch == 'humble' }}
shell: bash
run: |
. $IDF_PATH/export.sh
Expand Down
26 changes: 25 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
idf_component_register(SRCS "network_interfaces/uros_ethernet_netif.c" "network_interfaces/uros_wlan_netif.c"
INCLUDE_DIRS "network_interfaces"
REQUIRES nvs_flash)
REQUIRES nvs_flash esp_wifi esp_eth lwip)

if(CMAKE_GENERATOR STREQUAL "Unix Makefiles")
set(submake "$(MAKE)")
else()
set(submake "make")
endif()

if (${IDF_VERSION_MAJOR} EQUAL 5)
set(CMAKE_C_STANDARD 17)
else()
set(CMAKE_C_STANDARD 11)
endif()

set(APP_COLCON_META "${PROJECT_DIR}/app-colcon.meta")
if(NOT EXISTS "${APP_COLCON_META}")
set(APP_COLCON_META "")
Expand All @@ -26,6 +32,22 @@ message(STATUS "Using Micro XRCE-DDS middleware")
set(MIDDLEWARE "microxrcedds")
endif()

# Create a list of packages to get includes
idf_build_get_property(PACKAGES BUILD_COMPONENTS)

# Add includes for each package
foreach(package ${PACKAGES})
idf_component_get_property(${package}_dir ${package} COMPONENT_DIR)
idf_component_get_property(${package}_includes ${package} INCLUDE_DIRS)
list(TRANSFORM ${package}_includes PREPEND " -I${${package}_dir}/")
string(REPLACE ";" "" ${package}_includes_string "${${package}_includes}")
endforeach()

# Create a string with all packages with a for loop
foreach(package ${PACKAGES})
string(APPEND IDF_INCLUDES "${${package}_includes_string}")
endforeach()

execute_process(
WORKING_DIRECTORY ${COMPONENT_DIR}
COMMAND
Expand All @@ -36,8 +58,10 @@ execute_process(
X_CFLAGS=${CMAKE_C_FLAGS}
X_CXX=${CMAKE_CXX_COMPILER}
X_CXXFLAGS=${CMAKE_CXX_FLAGS}
C_STANDARD=${CMAKE_C_STANDARD}
MIDDLEWARE=${MIDDLEWARE}
BUILD_DIR=${CMAKE_BINARY_DIR}
IDF_INCLUDES=${IDF_INCLUDES}
IDF_PATH=${IDF_PATH}
IDF_TARGET=${IDF_TARGET}
APP_COLCON_META=${APP_COLCON_META}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# micro-ROS component for ESP-IDF

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.
This component has been tested in ESP-IDF v4.3, v4.4, and v5.0 with ESP32, ESP32-S2, ESP32-S3 and ESP32-C3.

## Dependencies

Expand Down Expand Up @@ -64,7 +64,7 @@ It's possible to build this example application using preconfigured docker conta
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"
```

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

## Using serial transport

Expand Down
7 changes: 4 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


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

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

RUN mkdir -p /tmp/install_micro_ros_deps_script && mv /install_micro_ros_deps_script.sh /tmp/install_micro_ros_deps_script/ && \
/tmp/install_micro_ros_deps_script/install_micro_ros_deps_script.sh && \
IDF_EXPORT_QUIET=1 /tmp/install_micro_ros_deps_script/install_micro_ros_deps_script.sh && \
rm -rf /var/lib/apt/lists/*


RUN /usr/bin/pip3 --no-cache-dir install catkin_pkg lark-parser empy colcon-common-extensions importlib-resources
ARG USER_ID=espidf

RUN useradd --create-home --home-dir /home/$USER_ID --shell /bin/bash --user-group --groups adm,sudo $USER_ID && \
Expand Down
117 changes: 5 additions & 112 deletions esp32_toolchain.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ set(idf_path "@IDF_PATH@")

if("${idf_target}" STREQUAL "esp32c3")
set(CMAKE_SYSTEM_PROCESSOR riscv)
set(FLAGS "-ffunction-sections -fdata-sections" CACHE STRING "" FORCE)
else()
set(CMAKE_SYSTEM_PROCESSOR xtensa)
set(FLAGS "-mlongcalls -ffunction-sections -fdata-sections" CACHE STRING "" FORCE)
endif()

set(CMAKE_CROSSCOMPILING 1)
Expand All @@ -22,121 +24,12 @@ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_C_COMPILER @CMAKE_C_COMPILER@)
set(CMAKE_CXX_COMPILER @CMAKE_CXX_COMPILER@)

set(CMAKE_C_FLAGS_INIT "@CFLAGS@" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_INIT "@CXXFLAGS@" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAGS} ${IDF_INCLUDES}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti ${FLAGS} ${IDF_INCLUDES}")

add_definitions(-DESP_PLATFORM -DLWIP_IPV4 -DLWIP_IPV6 -DPLATFORM_NAME_FREERTOS)
add_compile_definitions(ESP_PLATFORM LWIP_IPV4 LWIP_IPV6 PLATFORM_NAME_FREERTOS)

include_directories(
"@BUILD_CONFIG_DIR@"
${idf_path}/components/newlib/platform_include
${idf_path}/components/freertos/include
${idf_path}/components/freertos/${CMAKE_SYSTEM_PROCESSOR}/include
${idf_path}/components/freertos/port/${CMAKE_SYSTEM_PROCESSOR}/include
${idf_path}/components/esp_hw_support/include
${idf_path}/components/hal/include
${idf_path}/components/hal/${idf_target}/include
${idf_path}/components/heap/include
${idf_path}/components/log/include
${idf_path}/components/lwip/include/apps
${idf_path}/components/lwip/include/apps/sntp
${idf_path}/components/lwip/lwip/src/include
${idf_path}/components/lwip/port/esp32/include
${idf_path}/components/lwip/port/esp32/include/arch
${idf_path}/components/lwip/port/esp32/tcp_isn
${idf_path}/components/soc/src/${idf_target}/.
${idf_path}/components/soc/src/${idf_target}/include
${idf_path}/components/soc/include
${idf_path}/components/soc/${idf_target}/include
${idf_path}/components/esp_rom/include
${idf_path}/components/esp_common/include
${idf_path}/components/esp_system/include
${idf_path}/components/${CMAKE_SYSTEM_PROCESSOR}/include
${idf_path}/components/${CMAKE_SYSTEM_PROCESSOR}/${idf_target}/include
${idf_path}/components/${idf_target}/include
${idf_path}/components/driver/include
${idf_path}/components/driver/${idf_target}/include
${idf_path}/components/esp_ringbuf/include
${idf_path}/components/efuse/include
${idf_path}/components/efuse/${idf_target}/include
${idf_path}/components/espcoredump/include
${idf_path}/components/esp_timer/include
${idf_path}/components/esp_ipc/include
${idf_path}/components/soc/soc/${idf_target}/include
${idf_path}/components/soc/soc/${idf_target}/../include
${idf_path}/components/soc/soc/${idf_target}/private_include
${idf_path}/components/vfs/include
${idf_path}/components/esp_wifi/include
${idf_path}/components/esp_wifi/${idf_target}/include
${idf_path}/components/esp_event/include
${idf_path}/components/esp_netif/include
${idf_path}/components/esp_eth/include
${idf_path}/components/tcpip_adapter/include
${idf_path}/components/app_trace/include
${idf_path}/components/mbedtls/port/include
${idf_path}/components/mbedtls/mbedtls/include
${idf_path}/components/mbedtls/esp_crt_bundle/include
${idf_path}/components/bootloader_support/include
${idf_path}/components/app_update/include
${idf_path}/components/spi_flash/include
${idf_path}/components/wpa_supplicant/include
${idf_path}/components/wpa_supplicant/port/include
${idf_path}/components/wpa_supplicant/include/esp_supplicant
${idf_path}/components/nvs_flash/include
${idf_path}/components/pthread/include
${idf_path}/components/perfmon/include
${idf_path}/components/asio/asio/asio/include
${idf_path}/components/asio/port/include
${idf_path}/components/cbor/port/include
${idf_path}/components/coap/port/include
${idf_path}/components/coap/port/include/coap
${idf_path}/components/coap/libcoap/include
${idf_path}/components/coap/libcoap/include/coap2
${idf_path}/components/console
${idf_path}/components/nghttp/port/include
${idf_path}/components/nghttp/nghttp2/lib/includes
${idf_path}/components/esp-tls
${idf_path}/components/esp_adc_cal/include
${idf_path}/components/esp_gdbstub/include
${idf_path}/components/esp_hid/include
${idf_path}/components/tcp_transport/include
${idf_path}/components/esp_http_client/include
${idf_path}/components/esp_http_server/include
${idf_path}/components/esp_https_ota/include
${idf_path}/components/protobuf-c/protobuf-c
${idf_path}/components/protocomm/include/common
${idf_path}/components/protocomm/include/security
${idf_path}/components/protocomm/include/transports
${idf_path}/components/mdns/include
${idf_path}/components/esp_local_ctrl/include
${idf_path}/components/sdmmc/include
${idf_path}/components/esp_serial_slave_link/include
${idf_path}/components/esp_websocket_client/include
${idf_path}/components/expat/expat/expat/lib
${idf_path}/components/expat/port/include
${idf_path}/components/wear_levelling/include
${idf_path}/components/fatfs/diskio
${idf_path}/components/fatfs/vfs
${idf_path}/components/fatfs/src
${idf_path}/components/freemodbus/common/include
${idf_path}/components/idf_test/include
${idf_path}/components/idf_test/include/${idf_target}
${idf_path}/components/jsmn/include
${idf_path}/components/json/cJSON
${idf_path}/components/libsodium/libsodium/src/libsodium/include
${idf_path}/components/libsodium/port_include
${idf_path}/components/mqtt/esp-mqtt/include
${idf_path}/components/openssl/include
${idf_path}/components/spiffs/include
${idf_path}/components/ulp/include
${idf_path}/components/unity/include
${idf_path}/components/unity/unity/src
${idf_path}/components/wifi_provisioning/include

${idf_path}/components/freertos/include/esp_additions/freertos
${idf_path}/components/freertos/include/esp_additions
${idf_path}/components/esp_hw_support/include
${idf_path}/components/esp_hw_support/include/soc
${idf_path}/components/esp_hw_support/include/soc/${idf_target}
${idf_path}/components/esp_hw_support/port/${idf_target}/.
)
2 changes: 1 addition & 1 deletion examples/int32_publisher/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void timer_callback(rcl_timer_t * timer, int64_t last_call_time)
{
RCLC_UNUSED(last_call_time);
if (timer != NULL) {
printf("Publishing: %d\n", msg.data);
printf("Publishing: %d\n", (int) msg.data);
RCSOFTCHECK(rcl_publish(&publisher, &msg, NULL));
msg.data++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ size_t esp32_serial_write(struct uxrCustomTransport* transport, const uint8_t *

size_t esp32_serial_read(struct uxrCustomTransport* transport, uint8_t* buf, size_t len, int timeout, uint8_t* err){
size_t * uart_port = (size_t*) transport->args;
const int rxBytes = uart_read_bytes(*uart_port, buf, len, timeout / portTICK_RATE_MS);
const int rxBytes = uart_read_bytes(*uart_port, buf, len, timeout / portTICK_PERIOD_MS);
return rxBytes;
}
2 changes: 1 addition & 1 deletion examples/int32_publisher_embeddedrtps/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void timer_callback(rcl_timer_t * timer, int64_t last_call_time)
{
RCLC_UNUSED(last_call_time);
if (timer != NULL) {
printf("Publishing: %d\n", msg.data);
printf("Publishing: %d\n", (int) msg.data);
RCSOFTCHECK(rcl_publish(&publisher, &msg, NULL));
msg.data++;
}
Expand Down
4 changes: 2 additions & 2 deletions examples/int32_sub_pub/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ void timer_callback(rcl_timer_t * timer, int64_t last_call_time)
(void) last_call_time;
if (timer != NULL) {
RCSOFTCHECK(rcl_publish(&publisher, &send_msg, NULL));
printf("Sent: %d\n", send_msg.data);
printf("Sent: %d\n", (int) send_msg.data);
send_msg.data++;
}
}

void subscription_callback(const void * msgin)
{
const std_msgs__msg__Int32 * msg = (const std_msgs__msg__Int32 *)msgin;
printf("Received: %d\n", msg->data);
printf("Received: %d\n", (int) msg->data);
}

void micro_ros_task(void * arg)
Expand Down
10 changes: 9 additions & 1 deletion libmicroros.mk
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ $(EXTENSIONS_DIR)/micro_ros_src/install: $(EXTENSIONS_DIR)/esp32_toolchain.cmake
-DBUILD_TESTING=OFF \
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \
-DCMAKE_TOOLCHAIN_FILE=$(EXTENSIONS_DIR)/esp32_toolchain.cmake \
-DCMAKE_VERBOSE_MAKEFILE=OFF; \
-DCMAKE_VERBOSE_MAKEFILE=OFF \
-DIDF_INCLUDES='${IDF_INCLUDES}' \
-DCMAKE_C_STANDARD=$(C_STANDARD) \
-DUCLIENT_C_STANDARD=$(C_STANDARD);

patch_atomic:$(EXTENSIONS_DIR)/micro_ros_src/install
# Workaround https://github.com/micro-ROS/micro_ros_espidf_component/issues/18
Expand All @@ -119,6 +122,11 @@ ifeq ($(IDF_TARGET),$(filter $(IDF_TARGET),esp32s2 esp32c3))
$(X_STRIP) atomic_64bits.c.obj --strip-symbol=__atomic_load_8; \
$(X_STRIP) atomic_64bits.c.obj --strip-symbol=__atomic_store_8; \
fi; \
if [ $(IDF_VERSION_MAJOR) -ge 5 ] && [ $(IDF_VERSION_MINOR) -ge 0 ]; then \
$(X_STRIP) atomic_64bits.c.obj --strip-symbol=__atomic_load_8; \
$(X_STRIP) atomic_64bits.c.obj --strip-symbol=__atomic_store_8; \
$(X_STRIP) atomic_64bits.c.obj --strip-symbol=__atomic_exchange_8; \
fi; \
$(X_AR) rc -s librcutils.a *.obj; \
cp -rf librcutils.a $(UROS_DIR)/install/lib/librcutils.a; \
rm -rf $(UROS_DIR)/atomic_workaround; \
Expand Down

0 comments on commit a71fb63

Please sign in to comment.