Эх сурвалжийг харах

feat(yml): Add ESP32-P4 and ESP32-C5 support (#4270)

- Add ESP32-P4 and ESP32-C5 support
- Support for compiler options of different floating-point types in various RISC-V chips
ChenWen 7 сар өмнө
parent
commit
f4f33b6a76

+ 19 - 11
build-scripts/esp-idf/wamr/CMakeLists.txt

@@ -5,11 +5,15 @@
 if (NOT CMAKE_BUILD_EARLY_EXPANSION)
 
   if (CONFIG_IDF_TARGET_ARCH_RISCV)
-      set (WAMR_BUILD_TARGET "RISCV32")
+    if (CONFIG_IDF_TARGET_ESP32P4)
+      set (WAMR_BUILD_TARGET "RISCV32_ILP32F")
+    else ()
+      set (WAMR_BUILD_TARGET "RISCV32_ILP32")
+    endif ()
   elseif (CONFIG_IDF_TARGET_ARCH_XTENSA)
-      set (WAMR_BUILD_TARGET "XTENSA")
+    set (WAMR_BUILD_TARGET "XTENSA")
   else ()
-      message (FATAL_ERROR "Arch ${CONFIG_IDF_TARGET_ARCH} is not supported")
+    message (FATAL_ERROR "Arch ${CONFIG_IDF_TARGET_ARCH} is not supported")
   endif ()
 
   set (WAMR_BUILD_PLATFORM "esp-idf")
@@ -41,31 +45,31 @@ if (NOT CMAKE_BUILD_EARLY_EXPANSION)
   endif ()
 
   if (CONFIG_WAMR_ENABLE_MULTI_MODULE)
-      set (WAMR_BUILD_MULTI_MODULE 1)
+    set (WAMR_BUILD_MULTI_MODULE 1)
   endif ()
 
   if (CONFIG_WAMR_ENABLE_SHARED_MEMORY)
-      set (WAMR_BUILD_SHARED_MEMORY 1)
+    set (WAMR_BUILD_SHARED_MEMORY 1)
   endif ()
 
   if (CONFIG_WAMR_ENABLE_MEMORY_PROFILING)
-      set (WAMR_BUILD_MEMORY_PROFILING 1)
+    set (WAMR_BUILD_MEMORY_PROFILING 1)
   endif ()
 
   if (CONFIG_WAMR_ENABLE_PERF_PROFILING)
-      set (WAMR_BUILD_PERF_PROFILING 1)
+    set (WAMR_BUILD_PERF_PROFILING 1)
   endif ()
 
   if (CONFIG_WAMR_ENABLE_REF_TYPES)
-      set (WAMR_BUILD_REF_TYPES 1)
+    set (WAMR_BUILD_REF_TYPES 1)
   endif ()
 
   if (CONFIG_WAMR_ENABLE_LIBC_WASI)
-      set (WAMR_BUILD_LIBC_WASI 1)
+    set (WAMR_BUILD_LIBC_WASI 1)
   endif ()
 
   if (CONFIG_WAMR_ENABLE_LIB_PTHREAD)
-      set (WAMR_BUILD_LIB_PTHREAD 1)
+    set (WAMR_BUILD_LIB_PTHREAD 1)
   endif ()
 
   set (WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..)
@@ -89,7 +93,11 @@ idf_component_register(SRCS ${srcs}
 target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
 
 if (CONFIG_IDF_TARGET_ARCH_RISCV)
-  target_compile_definitions(${COMPONENT_LIB} PUBLIC -DBUILD_TARGET_RISCV32_ILP32=1)
+  if (CONFIG_IDF_TARGET_ESP32P4)
+    target_compile_definitions(${COMPONENT_LIB} PUBLIC -DBUILD_TARGET_RISCV32_ILP32F=1)
+  else ()
+    target_compile_definitions(${COMPONENT_LIB} PUBLIC -DBUILD_TARGET_RISCV32_ILP32=1)
+  endif ()
 elseif (CONFIG_IDF_TARGET_ARCH_XTENSA)
   target_compile_definitions(${COMPONENT_LIB} PUBLIC -DBUILD_TARGET_XTENSA=1)
 endif ()

+ 3 - 1
idf_component.yml

@@ -1,4 +1,4 @@
-version: "2.0.0"
+version: "2.2.0~3"
 description: WebAssembly Micro Runtime - A lightweight standalone WebAssembly (Wasm) runtime with small footprint, high performance and highly configurable features
 url: https://bytecodealliance.org/
 repository: https://github.com/bytecodealliance/wasm-micro-runtime.git
@@ -11,5 +11,7 @@ targets:
   - esp32s3
   - esp32c3
   - esp32c6
+  - esp32p4
+  - esp32c5
 examples:
   - path: product-mini/platforms/esp-idf

+ 91 - 0
product-mini/platforms/esp-idf/README.md

@@ -0,0 +1,91 @@
+# How to Use WAMR with ESP-IDF
+
+ESP-IDF is the official development framework for Espressif SoCs, supporting Windows, Linux, and macOS. WAMR (WebAssembly Micro Runtime) can be integrated as a standard [ESP-IDF](https://github.com/espressif/esp-idf) component.
+
+## 1. Setup the ESP-IDF Development Environment
+
+This example demonstrates how to use WAMR with ESP-IDF. Before proceeding, ensure you have the ESP-IDF development environment installed. For the relevant process, please refer to ESP-IDF [documents](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html).
+
+### Prerequisites
+
+#### Software Requirements
+
+* ESP-IDF v4.4.0 and above.
+
+#### Hardware Requirements
+
+* A development board with one of the following SoCs:
+
+  - ESP32
+
+  - ESP32-C3
+
+  - ESP32-S3
+
+  - ESP32-C6
+
+  - ESP32-P4
+
+  - ESP32-C5
+
+* See [Development Boards](https://www.espressif.com/en/products/devkits) for more information about it.
+
+> Note: Different chips require different ESP-IDF versions, please check [ESP-IDF Release and SoC Compatibility](https://github.com/espressif/esp-idf?tab=readme-ov-file#esp-idf-release-and-soc-compatibility) before proceeding.
+
+### Installation Steps
+
+1. Navigate to the ESP-IDF root directory.
+
+2. Run the installation script based on your OS:
+
+  - Linux/MacOS
+
+    ```
+    ./install.sh
+    ```
+
+  - Windows
+
+    ```
+    ./install.bat
+    ```
+
+3. If successful, you should see:
+
+    ```
+    All done! You can now run:
+
+      . ./export.sh
+    ```
+
+## 2. Compiling and Running the Project
+
+### Set the Target Chip
+
+Switch to the project directory and specify the target chip:
+
+```bash
+idf.py set-target <chip_name>
+```
+
+### Configure the project
+
+Open the configuration menu: 
+
+```bash
+idf.py menuconfig
+```
+
+To modify WAMR settings, navigate to: `Component config -> WASM Micro Runtime`
+
+### Build and Flash
+
+Run the following command to compile, flash, and monitor the application:
+
+```bash
+idf.py -p PORT flash monitor
+```
+
+(To exit the serial monitor, type ``Ctrl-]``.)
+
+See the [Getting Started Guide](https://idf.espressif.com/) for full steps to configure and use ESP-IDF to build projects.

+ 12 - 2
product-mini/platforms/esp-idf/build_and_run.sh

@@ -7,16 +7,20 @@ ESP32_TARGET="esp32"
 ESP32C3_TARGET="esp32c3"
 ESP32S3_TARGET="esp32s3"
 ESP32C6_TARGET="esp32c6"
+ESP32P4_TARGET="esp32p4"
+ESP32C5_TARGET="esp32c5"
 
 usage ()
 {
         echo "USAGE:"
-        echo "$0 $ESP32_TARGET|$ESP32C3_TARGET|$ESP32S3_TARGET"
+        echo "$0 $ESP32_TARGET|$ESP32C3_TARGET|$ESP32S3_TARGET|$ESP32C6_TARGET|$ESP32P4_TARGET|$ESP32C5_TARGET"
         echo "Example:"
         echo "        $0 $ESP32_TARGET"
         echo "        $0 $ESP32C3_TARGET"
         echo "        $0 $ESP32S3_TARGET"
         echo "        $0 $ESP32C6_TARGET"
+        echo "        $0 $ESP32P4_TARGET"
+        echo "        $0 $ESP32C5_TARGET"
         exit 1
 }
 
@@ -26,12 +30,18 @@ fi
 
 TARGET=$1
 
+if [ "$TARGET" = "$ESP32C5_TARGET" ]; then
+        IDF_ST_CMD="idf.py --preview set-target $TARGET"
+else
+        IDF_ST_CMD="idf.py set-target $TARGET"
+fi
+
 if [[ -z "${WAMR_PATH}" ]]; then
         export WAMR_PATH=$PWD/../../..
 fi
 
 rm -rf build
-idf.py set-target $TARGET
+$IDF_ST_CMD
 idf.py build
 idf.py flash