Skip to content

Commit 6e172d5

Browse files
pablogs9Acuadros95
andauthored
ESP32c3 support (#52)
* 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>
1 parent 96a37cd commit 6e172d5

9 files changed

Lines changed: 35 additions & 14 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
idf_target: [ esp32, esp32s2 ]
15+
idf_target: [ esp32, esp32s2, esp32c3]
1616
idf_version: [ "espressif/idf:release-v4.1", "espressif/idf:release-v4.2", "espressif/idf:release-v4.3", "espressif/idf:latest" ]
1717
exclude:
1818
- idf_target: esp32s2
1919
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"
2024
container:
2125
image: ${{ matrix.idf_version }}
2226

@@ -48,6 +52,7 @@ jobs:
4852
4953
- name: Build sample - low_consumption
5054
shell: bash
55+
if: matrix.idf_target != 'esp32c3'
5156
run: |
5257
. $IDF_PATH/export.sh
5358
cd micro_ros_espidf_component/examples/low_consumption

.github/workflows/nightly.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
branch: [foxy, main]
18-
idf_target: [ esp32, esp32s2 ]
18+
idf_target: [ esp32, esp32s2, esp32c3]
1919
idf_version: [ "espressif/idf:release-v4.1", "espressif/idf:release-v4.2", "espressif/idf:release-v4.3", "espressif/idf:latest" ]
2020
exclude:
2121
- idf_target: esp32s2
2222
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"
2327
container:
2428
image: ${{ matrix.idf_version }}
2529

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# micro-ROS component for ESP-IDF
22

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

55
## Dependencies
66

@@ -32,6 +32,8 @@ In order to test a int32_publisher example:
3232
```bash
3333
. $IDF_PATH/export.sh
3434
cd examples/int32_publisher
35+
# Set target board [esp32|esp32s2|esp32c3]
36+
idf.py set-target esp32
3537
idf.py menuconfig
3638
# Set your micro-ROS configuration and WiFi credentials under micro-ROS Settings
3739
idf.py build

esp32_toolchain.cmake.in

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
include(CMakeForceCompiler)
22

33
set(CMAKE_SYSTEM_NAME Generic)
4-
set(CMAKE_SYSTEM_PROCESSOR xtensa)
4+
5+
set(idf_target "@IDF_TARGET@")
6+
7+
if("${idf_target}" STREQUAL "esp32c3")
8+
set(CMAKE_SYSTEM_PROCESSOR riscv)
9+
else()
10+
set(CMAKE_SYSTEM_PROCESSOR xtensa)
11+
endif()
12+
513
set(CMAKE_CROSSCOMPILING 1)
614
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
715
set(PLATFORM_NAME "LwIP")
@@ -24,7 +32,7 @@ add_definitions(-DLWIP_IPV4 -DLWIP_IPV6)
2432
include_directories(
2533
"@BUILD_CONFIG_DIR@"
2634
${idf_path}/components/soc/soc/include
27-
${idf_path}/components/freertos/port/xtensa/include
35+
${idf_path}/components/freertos/port/${CMAKE_SYSTEM_PROCESSOR}/include
2836
${idf_path}/components/hal/${idf_target}/include
2937
${idf_path}/components/hal/include
3038
${idf_path}/components/esp_hw_support/include
@@ -40,7 +48,7 @@ include_directories(
4048
${idf_path}/components/vfs/include
4149
${idf_path}/components/log/include
4250
${idf_path}/components/freertos/include
43-
${idf_path}/components/freertos/xtensa/include
51+
${idf_path}/components/freertos/${CMAKE_SYSTEM_PROCESSOR}/include
4452
${idf_path}/components/soc/soc/${idf_target}/include
4553
${idf_path}/components/wifi_provisioning/include
4654
${idf_path}/components/pthread/include
@@ -60,8 +68,8 @@ include_directories(
6068
${idf_path}/components/efuse/include
6169
${idf_path}/components/mbedtls/port/include
6270
${idf_path}/components/mbedtls/mbedtls/include
63-
${idf_path}/components/xtensa/${idf_target}/include
64-
${idf_path}/components/xtensa/include
71+
${idf_path}/components/${CMAKE_SYSTEM_PROCESSOR}/${idf_target}/include
72+
${idf_path}/components/${CMAKE_SYSTEM_PROCESSOR}/include
6573
${idf_path}/components/app_trace/include
6674
${idf_path}/components/nvs_flash/include
6775
${idf_path}/components/jsmn/include

examples/int32_publisher/main/Kconfig.projbuild

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ menu "micro-ROS example-app settings"
22

33
config MICRO_ROS_APP_STACK
44
int "Stack the micro-ROS app (Bytes)"
5-
default 15000
5+
default 16000
66
help
77
Stack size in Bytes of the micro-ROS app
88

examples/int32_publisher_custom_transport/main/Kconfig.projbuild

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ menu "micro-ROS example-app settings"
22

33
config MICRO_ROS_APP_STACK
44
int "Stack the micro-ROS app (Bytes)"
5-
default 15000
5+
default 16000
66
help
77
Stack size in Bytes of the micro-ROS app
88

examples/low_consumption/main/Kconfig.projbuild

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ menu "micro-ROS example-app settings"
22

33
config MICRO_ROS_APP_STACK
44
int "Stack the micro-ROS app (Bytes)"
5-
default 15000
5+
default 16000
66
help
77
Stack size in Bytes of the micro-ROS app
88

examples/low_consumption/main/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ void app_main(void)
117117
// automatic light sleep is enabled if tickless idle support is enabled.
118118
#ifdef CONFIG_IDF_TARGET_ESP32S2
119119
esp_pm_config_esp32s2_t pm_config = {};
120+
#elif CONFIG_IDF_TARGET_ESP32C3
121+
esp_pm_config_esp32c3_t pm_config = {};
120122
#else
121123
esp_pm_config_esp32_t pm_config = {};
122124
#endif

libmicroros.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ $(EXTENSIONS_DIR)/micro_ros_src/install: $(EXTENSIONS_DIR)/esp32_toolchain.cmake
9090
-DCMAKE_TOOLCHAIN_FILE=$(EXTENSIONS_DIR)/esp32_toolchain.cmake \
9191
-DCMAKE_VERBOSE_MAKEFILE=OFF; \
9292

93-
patch_atomic_esp32s2:$(EXTENSIONS_DIR)/micro_ros_src/install
93+
patch_atomic:$(EXTENSIONS_DIR)/micro_ros_src/install
9494
# Workaround https://github.com/micro-ROS/micro_ros_espidf_component/issues/18
95-
ifeq ($(IDF_TARGET), esp32s2)
95+
ifeq ($(IDF_TARGET),$(filter $(IDF_TARGET),esp32s2 esp32c3))
9696
echo $(UROS_DIR)/atomic_workaround; \
9797
mkdir $(UROS_DIR)/atomic_workaround; cd $(UROS_DIR)/atomic_workaround; \
9898
$(AR) x $(UROS_DIR)/install/lib/librcutils.a; \
@@ -103,7 +103,7 @@ ifeq ($(IDF_TARGET), esp32s2)
103103
cd ..;
104104
endif
105105

106-
$(EXTENSIONS_DIR)/libmicroros.a: $(EXTENSIONS_DIR)/micro_ros_src/install patch_atomic_esp32s2
106+
$(EXTENSIONS_DIR)/libmicroros.a: $(EXTENSIONS_DIR)/micro_ros_src/install patch_atomic
107107
mkdir -p $(UROS_DIR)/libmicroros; cd $(UROS_DIR)/libmicroros; \
108108
for file in $$(find $(UROS_DIR)/install/lib/ -name '*.a'); do \
109109
folder=$$(echo $$file | sed -E "s/(.+)\/(.+).a/\2/"); \

0 commit comments

Comments
 (0)