Skip to content

Commit

Permalink
Add support for ESP-IDF v4.4 (backport #110) (#111)
Browse files Browse the repository at this point in the history
* Add support for ESP-IDF v4.4 (#110)

* Add support for ESP-IDF v4.4

* Add includes

* Add includes

* Fix atomics

(cherry picked from commit 56ff175)

# Conflicts:
#	esp32_toolchain.cmake.in
#	libmicroros.mk

* Fix conflicts

* Fix includes

* Fix

Co-authored-by: Pablo Garrido <pablogs9@gmail.com>
  • Loading branch information
mergify[bot] and pablogs9 committed Nov 10, 2021
1 parent c0c003d commit 37841e4
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
idf_target: [ esp32, esp32s2, esp32c3]
idf_version: [ "espressif/idf:release-v4.1", "espressif/idf:release-v4.2", "espressif/idf:release-v4.3" ]
idf_version: [ "espressif/idf:release-v4.1", "espressif/idf:release-v4.2", "espressif/idf:release-v4.3", "espressif/idf:release-v4.4" ]
exclude:
- idf_target: esp32s2
idf_version: "espressif/idf:release-v4.1"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
matrix:
branch: [foxy, main, galactic]
idf_target: [ esp32, esp32s2, esp32c3]
idf_version: [ "espressif/idf:release-v4.1", "espressif/idf:release-v4.2", "espressif/idf:release-v4.3" ]
idf_version: [ "espressif/idf:release-v4.1", "espressif/idf:release-v4.2", "espressif/idf:release-v4.3", "espressif/idf:release-v4.4" ]
exclude:
- idf_target: esp32s2
idf_version: "espressif/idf:release-v4.1"
Expand Down
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ externalproject_add(libmicroros_project
CONFIGURE_COMMAND ""
BUILD_COMMAND
${submake} -j -f libmicroros.mk
CC=${CMAKE_C_COMPILER}
AR=${CMAKE_AR}
STRIP=${CMAKE_STRIP}
CFLAGS=${CMAKE_C_FLAGS}
CXX=${CMAKE_CXX_COMPILER}
CXXFLAGS=${CMAKE_CXX_FLAGS}
X_CC=${CMAKE_C_COMPILER}
X_AR=${CMAKE_AR}
X_STRIP=${CMAKE_STRIP}
X_CFLAGS=${CMAKE_C_FLAGS}
X_CXX=${CMAKE_CXX_COMPILER}
X_CXXFLAGS=${CMAKE_CXX_FLAGS}
BUILD_DIR=${CMAKE_BINARY_DIR}
IDF_PATH=${IDF_PATH}
IDF_TARGET=${IDF_TARGET}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# micro-ROS component for ESP-IDF

This component has been tested in ESP-IDF v4.1, v4.2 and v4.3 with ESP32, ESP32-S2 and ESP32-C3.
This component has been tested in ESP-IDF v4.1, v4.2, v4.3 and v4.4 with ESP32, ESP32-S2 and ESP32-C3.

## Dependencies

Expand Down
147 changes: 96 additions & 51 deletions esp32_toolchain.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -30,70 +30,115 @@ set(idf_target "@IDF_TARGET@")
add_definitions(-DLWIP_IPV4 -DLWIP_IPV6 -DPLATFORM_NAME_FREERTOS)

include_directories(
"@BUILD_CONFIG_DIR@"
${idf_path}/components/soc/soc/include
"@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/hal/${idf_target}/include
${idf_path}/components/hal/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/newlib/platform_include
${idf_path}/components/protocomm/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/esp_timer/include
${idf_path}/components/soc/src/${idf_target}/include
${idf_path}/components/driver/include
${idf_path}/components/wear_levelling/include
${idf_path}/components/vfs/include
${idf_path}/components/log/include
${idf_path}/components/freertos/include
${idf_path}/components/freertos/include/freertos
${idf_path}/components/freertos/${CMAKE_SYSTEM_PROCESSOR}/include
${idf_path}/components/soc/soc/${idf_target}/include
${idf_path}/components/wifi_provisioning/include
${idf_path}/components/pthread/include
${idf_path}/components/libsodium/libsodium/src/libsodium/include
${idf_path}/components/coap/port/include
${idf_path}/components/coap/libcoap/include
${idf_path}/components/tcp_transport/include
${idf_path}/components/unity/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/asio/port/include
${idf_path}/components/asio/asio/asio/include
${idf_path}/components/app_update/include
${idf_path}/components/driver/include
${idf_path}/components/driver/${idf_target}/include
${idf_path}/components/esp_ringbuf/include
${idf_path}/components/soc/${idf_target}/include
${idf_path}/components/efuse/test/include
${idf_path}/components/efuse/${idf_target}/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/${CMAKE_SYSTEM_PROCESSOR}/${idf_target}/include
${idf_path}/components/${CMAKE_SYSTEM_PROCESSOR}/include
${idf_path}/components/app_trace/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/jsmn/include
${idf_path}/components/esp_eth/include
${idf_path}/components/spiffs/include
${idf_path}/components/ulp/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/freemodbus/modbus/include
${idf_path}/components/freemodbus/common/include
${idf_path}/components/esp_event/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/bootloader_support/include
${idf_path}/components/heap/include
${idf_path}/components/wpa_supplicant/port/include
${idf_path}/components/wpa_supplicant/include
${idf_path}/components/tcpip_adapter/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/sdmmc/include
${idf_path}/components/esp_local_ctrl/include
${idf_path}/components/esp_common/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/lwip/lwip/src/include/lwip/apps
${idf_path}/components/lwip/lwip/src/include/compat/posix
${idf_path}/components/lwip/lwip/src/include
${idf_path}/components/lwip/port/esp32/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}/.
)
28 changes: 16 additions & 12 deletions libmicroros.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ else
BUILD_TYPE = Release
endif

CFLAGS_INTERNAL := $(CFLAGS) -ffunction-sections -fdata-sections
CXXFLAGS_INTERNAL := $(CXXFLAGS) -ffunction-sections -fdata-sections
CFLAGS_INTERNAL := $(X_CFLAGS) -ffunction-sections -fdata-sections
CXXFLAGS_INTERNAL := $(X_CXXFLAGS) -ffunction-sections -fdata-sections

all: $(EXTENSIONS_DIR)/libmicroros.a

Expand All @@ -25,8 +25,8 @@ clean:
$(EXTENSIONS_DIR)/esp32_toolchain.cmake: $(EXTENSIONS_DIR)/esp32_toolchain.cmake.in
rm -f $(EXTENSIONS_DIR)/esp32_toolchain.cmake; \
cat $(EXTENSIONS_DIR)/esp32_toolchain.cmake.in | \
sed "s/@CMAKE_C_COMPILER@/$(subst /,\/,$(CC))/g" | \
sed "s/@CMAKE_CXX_COMPILER@/$(subst /,\/,$(CXX))/g" | \
sed "s/@CMAKE_C_COMPILER@/$(subst /,\/,$(X_CC))/g" | \
sed "s/@CMAKE_CXX_COMPILER@/$(subst /,\/,$(X_CXX))/g" | \
sed "s/@CFLAGS@/$(subst /,\/,$(CFLAGS_INTERNAL))/g" | \
sed "s/@CXXFLAGS@/$(subst /,\/,$(CXXFLAGS_INTERNAL))/g" | \
sed "s/@IDF_TARGET@/$(subst /,\/,$(IDF_TARGET))/g" | \
Expand All @@ -42,7 +42,7 @@ $(EXTENSIONS_DIR)/micro_ros_dev/install:
git clone -b foxy https://github.com/ament/ament_package src/ament_package; \
git clone -b foxy https://github.com/ament/googletest src/googletest; \
git clone -b foxy https://github.com/ros2/ament_cmake_ros src/ament_cmake_ros; \
colcon build;
colcon build;

$(EXTENSIONS_DIR)/micro_ros_src/src:
rm -rf micro_ros_src; \
Expand Down Expand Up @@ -98,27 +98,31 @@ patch_atomic:$(EXTENSIONS_DIR)/micro_ros_src/install
ifeq ($(IDF_TARGET),$(filter $(IDF_TARGET),esp32s2 esp32c3))
echo $(UROS_DIR)/atomic_workaround; \
mkdir $(UROS_DIR)/atomic_workaround; cd $(UROS_DIR)/atomic_workaround; \
$(AR) x $(UROS_DIR)/install/lib/librcutils.a; \
$(STRIP) atomic_64bits.c.obj --strip-symbol=__atomic_fetch_add_8; \
$(X_AR) x $(UROS_DIR)/install/lib/librcutils.a; \
$(X_STRIP) atomic_64bits.c.obj --strip-symbol=__atomic_fetch_add_8; \
if [ $(IDF_VERSION_MAJOR) -ge 4 ] && [ $(IDF_VERSION_MINOR) -ge 3 ]; then \
$(STRIP) atomic_64bits.c.obj --strip-symbol=__atomic_exchange_8; \
$(X_STRIP) atomic_64bits.c.obj --strip-symbol=__atomic_exchange_8; \
fi; \
$(AR) rc -s librcutils.a *.obj; \
if [ $(IDF_VERSION_MAJOR) -ge 4 ] && [ $(IDF_VERSION_MINOR) -ge 4 ]; then \
$(X_STRIP) atomic_64bits.c.obj --strip-symbol=__atomic_load_8; \
$(X_STRIP) atomic_64bits.c.obj --strip-symbol=__atomic_store_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; \
cd ..;
cd ..;
endif

$(EXTENSIONS_DIR)/libmicroros.a: $(EXTENSIONS_DIR)/micro_ros_src/install patch_atomic
mkdir -p $(UROS_DIR)/libmicroros; cd $(UROS_DIR)/libmicroros; \
for file in $$(find $(UROS_DIR)/install/lib/ -name '*.a'); do \
folder=$$(echo $$file | sed -E "s/(.+)\/(.+).a/\2/"); \
mkdir -p $$folder; cd $$folder; $(AR) x $$file; \
mkdir -p $$folder; cd $$folder; $(X_AR) x $$file; \
for f in *; do \
mv $$f ../$$folder-$$f; \
done; \
cd ..; rm -rf $$folder; \
done ; \
$(AR) rc -s libmicroros.a *.obj; cp libmicroros.a $(EXTENSIONS_DIR); \
$(X_AR) rc -s libmicroros.a *.obj; cp libmicroros.a $(EXTENSIONS_DIR); \
cd ..; rm -rf libmicroros; \
cp -R $(UROS_DIR)/install/include $(EXTENSIONS_DIR)/include;

0 comments on commit 37841e4

Please sign in to comment.