Skip to content

Commit

Permalink
ESP32c3 support (#52)
Browse files Browse the repository at this point in the history
* Initial

* Update readme

* Avoid low consumption in esp32c3


Update

* Increase Stack size and update readme for ESP32C3

Co-authored-by: Antonio cuadros <acuadros1995@gmail.com>
  • Loading branch information
pablogs9 and Acuadros95 committed Mar 31, 2021
1 parent 96a37cd commit 6e172d5
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 14 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ jobs:
strategy:
fail-fast: false
matrix:
idf_target: [ esp32, esp32s2 ]
idf_target: [ esp32, esp32s2, esp32c3]
idf_version: [ "espressif/idf:release-v4.1", "espressif/idf:release-v4.2", "espressif/idf:release-v4.3", "espressif/idf:latest" ]
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"
container:
image: ${{ matrix.idf_version }}

Expand Down Expand Up @@ -48,6 +52,7 @@ jobs:
- name: Build sample - low_consumption
shell: bash
if: matrix.idf_target != 'esp32c3'
run: |
. $IDF_PATH/export.sh
cd micro_ros_espidf_component/examples/low_consumption
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ jobs:
fail-fast: false
matrix:
branch: [foxy, main]
idf_target: [ esp32, esp32s2 ]
idf_target: [ esp32, esp32s2, esp32c3]
idf_version: [ "espressif/idf:release-v4.1", "espressif/idf:release-v4.2", "espressif/idf:release-v4.3", "espressif/idf:latest" ]
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"
container:
image: ${{ matrix.idf_version }}

Expand Down
4 changes: 3 additions & 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 and ESP32-S2.
This component has been tested in ESP-IDF v4.1, v4.2 and v4.3 with ESP32, ESP32-S2 and ESP32-C3.

## Dependencies

Expand Down Expand Up @@ -32,6 +32,8 @@ In order to test a int32_publisher example:
```bash
. $IDF_PATH/export.sh
cd examples/int32_publisher
# Set target board [esp32|esp32s2|esp32c3]
idf.py set-target esp32
idf.py menuconfig
# Set your micro-ROS configuration and WiFi credentials under micro-ROS Settings
idf.py build
Expand Down
18 changes: 13 additions & 5 deletions esp32_toolchain.cmake.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
include(CMakeForceCompiler)

set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR xtensa)

set(idf_target "@IDF_TARGET@")

if("${idf_target}" STREQUAL "esp32c3")
set(CMAKE_SYSTEM_PROCESSOR riscv)
else()
set(CMAKE_SYSTEM_PROCESSOR xtensa)
endif()

set(CMAKE_CROSSCOMPILING 1)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
set(PLATFORM_NAME "LwIP")
Expand All @@ -24,7 +32,7 @@ add_definitions(-DLWIP_IPV4 -DLWIP_IPV6)
include_directories(
"@BUILD_CONFIG_DIR@"
${idf_path}/components/soc/soc/include
${idf_path}/components/freertos/port/xtensa/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
Expand All @@ -40,7 +48,7 @@ include_directories(
${idf_path}/components/vfs/include
${idf_path}/components/log/include
${idf_path}/components/freertos/include
${idf_path}/components/freertos/xtensa/include
${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
Expand All @@ -60,8 +68,8 @@ include_directories(
${idf_path}/components/efuse/include
${idf_path}/components/mbedtls/port/include
${idf_path}/components/mbedtls/mbedtls/include
${idf_path}/components/xtensa/${idf_target}/include
${idf_path}/components/xtensa/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/nvs_flash/include
${idf_path}/components/jsmn/include
Expand Down
2 changes: 1 addition & 1 deletion examples/int32_publisher/main/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ menu "micro-ROS example-app settings"

config MICRO_ROS_APP_STACK
int "Stack the micro-ROS app (Bytes)"
default 15000
default 16000
help
Stack size in Bytes of the micro-ROS app

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ menu "micro-ROS example-app settings"

config MICRO_ROS_APP_STACK
int "Stack the micro-ROS app (Bytes)"
default 15000
default 16000
help
Stack size in Bytes of the micro-ROS app

Expand Down
2 changes: 1 addition & 1 deletion examples/low_consumption/main/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ menu "micro-ROS example-app settings"

config MICRO_ROS_APP_STACK
int "Stack the micro-ROS app (Bytes)"
default 15000
default 16000
help
Stack size in Bytes of the micro-ROS app

Expand Down
2 changes: 2 additions & 0 deletions examples/low_consumption/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ void app_main(void)
// automatic light sleep is enabled if tickless idle support is enabled.
#ifdef CONFIG_IDF_TARGET_ESP32S2
esp_pm_config_esp32s2_t pm_config = {};
#elif CONFIG_IDF_TARGET_ESP32C3
esp_pm_config_esp32c3_t pm_config = {};
#else
esp_pm_config_esp32_t pm_config = {};
#endif
Expand Down
6 changes: 3 additions & 3 deletions libmicroros.mk
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ $(EXTENSIONS_DIR)/micro_ros_src/install: $(EXTENSIONS_DIR)/esp32_toolchain.cmake
-DCMAKE_TOOLCHAIN_FILE=$(EXTENSIONS_DIR)/esp32_toolchain.cmake \
-DCMAKE_VERBOSE_MAKEFILE=OFF; \

patch_atomic_esp32s2:$(EXTENSIONS_DIR)/micro_ros_src/install
patch_atomic:$(EXTENSIONS_DIR)/micro_ros_src/install
# Workaround https://github.com/micro-ROS/micro_ros_espidf_component/issues/18
ifeq ($(IDF_TARGET), esp32s2)
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; \
Expand All @@ -103,7 +103,7 @@ ifeq ($(IDF_TARGET), esp32s2)
cd ..;
endif

$(EXTENSIONS_DIR)/libmicroros.a: $(EXTENSIONS_DIR)/micro_ros_src/install patch_atomic_esp32s2
$(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/"); \
Expand Down

0 comments on commit 6e172d5

Please sign in to comment.