From 8cc22babde27dabcfa2337869fe8b43226b9506f Mon Sep 17 00:00:00 2001 From: Narukara Date: Wed, 24 Jun 2026 16:46:04 +0800 Subject: [PATCH] add esp32p4 support --- .github/workflows/ci.yml | 7 +++++-- Kconfig.projbuild | 7 +++++-- README.md | 6 +++--- esp32_toolchain.cmake.in | 17 +++++++++++++++-- examples/addtwoints_server/.gitignore | 2 ++ examples/handle_static_types/.gitignore | 2 ++ examples/int32_publisher/.gitignore | 2 ++ .../int32_publisher_custom_transport/.gitignore | 2 ++ .../int32_publisher_embeddedrtps/.gitignore | 2 ++ examples/int32_sub_pub/.gitignore | 2 ++ examples/low_consumption/.gitignore | 2 ++ examples/multithread_publisher/.gitignore | 2 ++ examples/parameters/.gitignore | 2 ++ examples/ping_pong/.gitignore | 2 ++ idf_component.yml | 9 +++++++++ 15 files changed, 57 insertions(+), 9 deletions(-) create mode 100644 idf_component.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 035942bc..20110a87 100755 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,8 +23,11 @@ jobs: strategy: fail-fast: false matrix: - idf_target: [esp32, esp32s2, esp32s3, esp32c3, esp32c6] + idf_target: [esp32, esp32s2, esp32s3, esp32c3, esp32c6, esp32p4] idf_version: [v5.2, v5.3, v5.4, v5.5] + exclude: + - idf_target: esp32p4 + idf_version: v5.2 container: image: "espressif/idf:release-${{ matrix.idf_version }}" @@ -59,7 +62,7 @@ jobs: - name: Build sample - low_consumption shell: bash - if: matrix.idf_target != 'esp32c3' && matrix.idf_target != 'esp32s3' && matrix.idf_target != 'esp32c6' + if: matrix.idf_target != 'esp32c3' && matrix.idf_target != 'esp32s3' && matrix.idf_target != 'esp32c6' && matrix.idf_target != 'esp32p4' run: | . $IDF_PATH/export.sh cd micro_ros_espidf_component/examples/low_consumption diff --git a/Kconfig.projbuild b/Kconfig.projbuild index 5e50b372..466a9705 100644 --- a/Kconfig.projbuild +++ b/Kconfig.projbuild @@ -71,13 +71,13 @@ menu "Ethernet Configuration" choice MICRO_ROS_ETHERNET_TYPE prompt "Ethernet Type" - default MICRO_ROS_USE_INTERNAL_ETHERNET if IDF_TARGET_ESP32 + default MICRO_ROS_USE_INTERNAL_ETHERNET if IDF_TARGET_ESP32 || IDF_TARGET_ESP32P4 default MICRO_ROS_USE_W5500 help Select which kind of Ethernet will be used in the example. config MICRO_ROS_USE_INTERNAL_ETHERNET - depends on IDF_TARGET_ESP32 + depends on IDF_TARGET_ESP32 || IDF_TARGET_ESP32P4 select ETH_USE_ESP32_EMAC bool "Internal EMAC" help @@ -140,12 +140,14 @@ menu "Ethernet Configuration" config MICRO_ROS_ETH_MDC_GPIO int "SMI MDC GPIO number" + default 31 if IDF_TARGET_ESP32P4 default 23 help Set the GPIO number used by SMI MDC. config MICRO_ROS_ETH_MDIO_GPIO int "SMI MDIO GPIO number" + default 52 if IDF_TARGET_ESP32P4 default 18 help Set the GPIO number used by SMI MDIO. @@ -203,6 +205,7 @@ menu "Ethernet Configuration" config MICRO_ROS_ETH_PHY_RST_GPIO int "PHY Reset GPIO number" + default 51 if IDF_TARGET_ESP32P4 default 5 help Set the GPIO number used to reset PHY chip. diff --git a/README.md b/README.md index a7a50a0f..26e4568b 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ # micro-ROS component for ESP-IDF -This component has been tested in ESP-IDF v5.2, v5.3, v5.4, and v5.5 with ESP32, ESP32-S2, ESP32-S3, ESP32-C3 and ESP32-C6. +This component has been tested in ESP-IDF v5.2, v5.3, v5.4, and v5.5 with ESP32, ESP32-S2, ESP32-S3, ESP32-C3, ESP32-C6, and ESP32-P4. ## Dependencies @@ -40,7 +40,7 @@ In order to test a int32_publisher example: ```bash . $IDF_PATH/export.sh cd examples/int32_publisher -# Set target board [esp32|esp32s2|esp32s3|esp32c3|esp32c6] +# Set target board [esp32|esp32s2|esp32s3|esp32c3|esp32c6|esp32p4] idf.py set-target esp32 idf.py menuconfig # Set your micro-ROS configuration and WiFi credentials under micro-ROS Settings @@ -76,7 +76,7 @@ cd micro_ros_espidf_component/ pip install catkin_pkg colcon-common-extensions lark cd examples/int32_publisher -# Set target board [esp32|esp32s2|esp32s3|esp32c3|esp32c6] +# Set target board [esp32|esp32s2|esp32s3|esp32c3|esp32c6|esp32p4] idf.py set-target esp32 idf.py menuconfig # Set your micro-ROS configuration and WiFi credentials under micro-ROS Settings diff --git a/esp32_toolchain.cmake.in b/esp32_toolchain.cmake.in index 5bc33a7c..a71a9a63 100644 --- a/esp32_toolchain.cmake.in +++ b/esp32_toolchain.cmake.in @@ -5,11 +5,18 @@ set(CMAKE_SYSTEM_NAME Generic) set(idf_target "@IDF_TARGET@") set(idf_path "@IDF_PATH@") -set(RISCV_TARGETS "esp32c3" "esp32c6") +set(RISCV_TARGETS "esp32c3" "esp32c6" "esp32p4") +set(RISCV_HARD_FLOAT_TARGETS "esp32p4") if("${idf_target}" IN_LIST RISCV_TARGETS) set(CMAKE_SYSTEM_PROCESSOR riscv) - set(FLAGS "-ffunction-sections -fdata-sections" CACHE STRING "" FORCE) + if("${idf_target}" IN_LIST RISCV_HARD_FLOAT_TARGETS) + # ESP32-P4 uses hardware floating point + set(FLAGS "-march=rv32imafc -mabi=ilp32f -ffunction-sections -fdata-sections" CACHE STRING "" FORCE) + else() + # ESP32-C3/C6 use soft-float + set(FLAGS "-ffunction-sections -fdata-sections" CACHE STRING "" FORCE) + endif() else() set(CMAKE_SYSTEM_PROCESSOR xtensa) set(FLAGS "-mlongcalls -ffunction-sections -fdata-sections" CACHE STRING "" FORCE) @@ -35,3 +42,9 @@ include_directories( "@BUILD_CONFIG_DIR@" ${idf_path}/components/soc/${idf_target}/include ) + +if("${idf_target}" IN_LIST RISCV_TARGETS) + include_directories( + ${idf_path}/components/riscv/include + ) +endif() diff --git a/examples/addtwoints_server/.gitignore b/examples/addtwoints_server/.gitignore index 9b375231..72cca8bc 100644 --- a/examples/addtwoints_server/.gitignore +++ b/examples/addtwoints_server/.gitignore @@ -1,3 +1,5 @@ build +managed_components +dependencies.lock sdkconfig sdkconfig.old \ No newline at end of file diff --git a/examples/handle_static_types/.gitignore b/examples/handle_static_types/.gitignore index 9b375231..72cca8bc 100644 --- a/examples/handle_static_types/.gitignore +++ b/examples/handle_static_types/.gitignore @@ -1,3 +1,5 @@ build +managed_components +dependencies.lock sdkconfig sdkconfig.old \ No newline at end of file diff --git a/examples/int32_publisher/.gitignore b/examples/int32_publisher/.gitignore index 9b375231..72cca8bc 100644 --- a/examples/int32_publisher/.gitignore +++ b/examples/int32_publisher/.gitignore @@ -1,3 +1,5 @@ build +managed_components +dependencies.lock sdkconfig sdkconfig.old \ No newline at end of file diff --git a/examples/int32_publisher_custom_transport/.gitignore b/examples/int32_publisher_custom_transport/.gitignore index 9b375231..72cca8bc 100644 --- a/examples/int32_publisher_custom_transport/.gitignore +++ b/examples/int32_publisher_custom_transport/.gitignore @@ -1,3 +1,5 @@ build +managed_components +dependencies.lock sdkconfig sdkconfig.old \ No newline at end of file diff --git a/examples/int32_publisher_embeddedrtps/.gitignore b/examples/int32_publisher_embeddedrtps/.gitignore index 9b375231..72cca8bc 100644 --- a/examples/int32_publisher_embeddedrtps/.gitignore +++ b/examples/int32_publisher_embeddedrtps/.gitignore @@ -1,3 +1,5 @@ build +managed_components +dependencies.lock sdkconfig sdkconfig.old \ No newline at end of file diff --git a/examples/int32_sub_pub/.gitignore b/examples/int32_sub_pub/.gitignore index 9b375231..72cca8bc 100644 --- a/examples/int32_sub_pub/.gitignore +++ b/examples/int32_sub_pub/.gitignore @@ -1,3 +1,5 @@ build +managed_components +dependencies.lock sdkconfig sdkconfig.old \ No newline at end of file diff --git a/examples/low_consumption/.gitignore b/examples/low_consumption/.gitignore index 9b375231..72cca8bc 100644 --- a/examples/low_consumption/.gitignore +++ b/examples/low_consumption/.gitignore @@ -1,3 +1,5 @@ build +managed_components +dependencies.lock sdkconfig sdkconfig.old \ No newline at end of file diff --git a/examples/multithread_publisher/.gitignore b/examples/multithread_publisher/.gitignore index 9b375231..72cca8bc 100644 --- a/examples/multithread_publisher/.gitignore +++ b/examples/multithread_publisher/.gitignore @@ -1,3 +1,5 @@ build +managed_components +dependencies.lock sdkconfig sdkconfig.old \ No newline at end of file diff --git a/examples/parameters/.gitignore b/examples/parameters/.gitignore index 9b375231..72cca8bc 100644 --- a/examples/parameters/.gitignore +++ b/examples/parameters/.gitignore @@ -1,3 +1,5 @@ build +managed_components +dependencies.lock sdkconfig sdkconfig.old \ No newline at end of file diff --git a/examples/ping_pong/.gitignore b/examples/ping_pong/.gitignore index d054d843..16038b4d 100644 --- a/examples/ping_pong/.gitignore +++ b/examples/ping_pong/.gitignore @@ -1,3 +1,5 @@ build +managed_components +dependencies.lock sdkconfig sdkconfig.old diff --git a/idf_component.yml b/idf_component.yml new file mode 100644 index 00000000..9f2115e0 --- /dev/null +++ b/idf_component.yml @@ -0,0 +1,9 @@ +dependencies: + espressif/esp_wifi_remote: + version: ">=0.10,<2.0" + rules: + - if: "target in [esp32p4]" + espressif/esp_hosted: + version: "~2" + rules: + - if: "target in [esp32p4]"