Skip to content

Commit 2b91ab8

Browse files
committed
feat(yml): Add ESP32-P4 and ESP32-C5 support
1. Add ESP32-P4 and ESP32-C5 support 2. Support for compiler options of different floating-point types in various RISC-V chips
1 parent 3cce6fd commit 2b91ab8

File tree

4 files changed

+125
-14
lines changed

4 files changed

+125
-14
lines changed

build-scripts/esp-idf/wamr/CMakeLists.txt

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55
if (NOT CMAKE_BUILD_EARLY_EXPANSION)
66

77
if (CONFIG_IDF_TARGET_ARCH_RISCV)
8-
set (WAMR_BUILD_TARGET "RISCV32")
8+
if (CONFIG_IDF_TARGET_ESP32P4)
9+
set (WAMR_BUILD_TARGET "RISCV32_ILP32F")
10+
else ()
11+
set (WAMR_BUILD_TARGET "RISCV32_ILP32")
12+
endif ()
913
elseif (CONFIG_IDF_TARGET_ARCH_XTENSA)
10-
set (WAMR_BUILD_TARGET "XTENSA")
14+
set (WAMR_BUILD_TARGET "XTENSA")
1115
else ()
12-
message (FATAL_ERROR "Arch ${CONFIG_IDF_TARGET_ARCH} is not supported")
16+
message (FATAL_ERROR "Arch ${CONFIG_IDF_TARGET_ARCH} is not supported")
1317
endif ()
1418

1519
set (WAMR_BUILD_PLATFORM "esp-idf")
@@ -41,31 +45,31 @@ if (NOT CMAKE_BUILD_EARLY_EXPANSION)
4145
endif ()
4246

4347
if (CONFIG_WAMR_ENABLE_MULTI_MODULE)
44-
set (WAMR_BUILD_MULTI_MODULE 1)
48+
set (WAMR_BUILD_MULTI_MODULE 1)
4549
endif ()
4650

4751
if (CONFIG_WAMR_ENABLE_SHARED_MEMORY)
48-
set (WAMR_BUILD_SHARED_MEMORY 1)
52+
set (WAMR_BUILD_SHARED_MEMORY 1)
4953
endif ()
5054

5155
if (CONFIG_WAMR_ENABLE_MEMORY_PROFILING)
52-
set (WAMR_BUILD_MEMORY_PROFILING 1)
56+
set (WAMR_BUILD_MEMORY_PROFILING 1)
5357
endif ()
5458

5559
if (CONFIG_WAMR_ENABLE_PERF_PROFILING)
56-
set (WAMR_BUILD_PERF_PROFILING 1)
60+
set (WAMR_BUILD_PERF_PROFILING 1)
5761
endif ()
5862

5963
if (CONFIG_WAMR_ENABLE_REF_TYPES)
60-
set (WAMR_BUILD_REF_TYPES 1)
64+
set (WAMR_BUILD_REF_TYPES 1)
6165
endif ()
6266

6367
if (CONFIG_WAMR_ENABLE_LIBC_WASI)
64-
set (WAMR_BUILD_LIBC_WASI 1)
68+
set (WAMR_BUILD_LIBC_WASI 1)
6569
endif ()
6670

6771
if (CONFIG_WAMR_ENABLE_LIB_PTHREAD)
68-
set (WAMR_BUILD_LIB_PTHREAD 1)
72+
set (WAMR_BUILD_LIB_PTHREAD 1)
6973
endif ()
7074

7175
set (WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..)
@@ -89,7 +93,11 @@ idf_component_register(SRCS ${srcs}
8993
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
9094

9195
if (CONFIG_IDF_TARGET_ARCH_RISCV)
92-
target_compile_definitions(${COMPONENT_LIB} PUBLIC -DBUILD_TARGET_RISCV32_ILP32=1)
96+
if (CONFIG_IDF_TARGET_ESP32P4)
97+
target_compile_definitions(${COMPONENT_LIB} PUBLIC -DBUILD_TARGET_RISCV32_ILP32F=1)
98+
else ()
99+
target_compile_definitions(${COMPONENT_LIB} PUBLIC -DBUILD_TARGET_RISCV32_ILP32=1)
100+
endif ()
93101
elseif (CONFIG_IDF_TARGET_ARCH_XTENSA)
94102
target_compile_definitions(${COMPONENT_LIB} PUBLIC -DBUILD_TARGET_XTENSA=1)
95103
endif ()

idf_component.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "2.0.0"
1+
version: "2.2.0~3"
22
description: WebAssembly Micro Runtime - A lightweight standalone WebAssembly (Wasm) runtime with small footprint, high performance and highly configurable features
33
url: https://bytecodealliance.org/
44
repository: https://github.com/bytecodealliance/wasm-micro-runtime.git
@@ -11,5 +11,7 @@ targets:
1111
- esp32s3
1212
- esp32c3
1313
- esp32c6
14+
- esp32p4
15+
- esp32c5
1416
examples:
1517
- path: product-mini/platforms/esp-idf
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# How to Use WAMR with ESP-IDF
2+
3+
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.
4+
5+
## 1. Setup the ESP-IDF Development Environment
6+
7+
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).
8+
9+
### Prerequisites
10+
11+
#### Software Requirements
12+
13+
* ESP-IDF v4.4.0 and above.
14+
15+
#### Hardware Requirements
16+
17+
* A development board with one of the following SoCs:
18+
19+
- ESP32
20+
21+
- ESP32-C3
22+
23+
- ESP32-S3
24+
25+
- ESP32-C6
26+
27+
- ESP32-P4
28+
29+
- ESP32-C5
30+
31+
* See [Development Boards](https://www.espressif.com/en/products/devkits) for more information about it.
32+
33+
> 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.
34+
35+
### Installation Steps
36+
37+
1. Navigate to the ESP-IDF root directory.
38+
39+
2. Run the installation script based on your OS:
40+
41+
- Linux/MacOS
42+
43+
```
44+
./install.sh
45+
```
46+
47+
- Windows
48+
49+
```
50+
./install.bat
51+
```
52+
53+
3. If successful, you should see:
54+
55+
```
56+
All done! You can now run:
57+
58+
. ./export.sh
59+
```
60+
61+
## 2. Compiling and Running the Project
62+
63+
### Set the Target Chip
64+
65+
Switch to the project directory and specify the target chip:
66+
67+
```bash
68+
idf.py set-target <chip_name>
69+
```
70+
71+
### Configure the project
72+
73+
Open the configuration menu:
74+
75+
```bash
76+
idf.py menuconfig
77+
```
78+
79+
To modify WAMR settings, navigate to: `Component config -> WASM Micro Runtime`
80+
81+
### Build and Flash
82+
83+
Run the following command to compile, flash, and monitor the application:
84+
85+
```bash
86+
idf.py -p PORT flash monitor
87+
```
88+
89+
(To exit the serial monitor, type ``Ctrl-]``.)
90+
91+
See the [Getting Started Guide](https://idf.espressif.com/) for full steps to configure and use ESP-IDF to build projects.

product-mini/platforms/esp-idf/build_and_run.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@ ESP32_TARGET="esp32"
77
ESP32C3_TARGET="esp32c3"
88
ESP32S3_TARGET="esp32s3"
99
ESP32C6_TARGET="esp32c6"
10+
ESP32P4_TARGET="esp32p4"
11+
ESP32C5_TARGET="esp32c5"
1012

1113
usage ()
1214
{
1315
echo "USAGE:"
14-
echo "$0 $ESP32_TARGET|$ESP32C3_TARGET|$ESP32S3_TARGET"
16+
echo "$0 $ESP32_TARGET|$ESP32C3_TARGET|$ESP32S3_TARGET|$ESP32C6_TARGET|$ESP32P4_TARGET|$ESP32C5_TARGET"
1517
echo "Example:"
1618
echo " $0 $ESP32_TARGET"
1719
echo " $0 $ESP32C3_TARGET"
1820
echo " $0 $ESP32S3_TARGET"
1921
echo " $0 $ESP32C6_TARGET"
22+
echo " $0 $ESP32P4_TARGET"
23+
echo " $0 $ESP32C5_TARGET"
2024
exit 1
2125
}
2226

@@ -26,12 +30,18 @@ fi
2630

2731
TARGET=$1
2832

33+
if [ "$TARGET" = "$ESP32C5_TARGET" ]; then
34+
IDF_ST_CMD="idf.py --preview set-target $TARGET"
35+
else
36+
IDF_ST_CMD="idf.py set-target $TARGET"
37+
fi
38+
2939
if [[ -z "${WAMR_PATH}" ]]; then
3040
export WAMR_PATH=$PWD/../../..
3141
fi
3242

3343
rm -rf build
34-
idf.py set-target $TARGET
44+
$IDF_ST_CMD
3545
idf.py build
3646
idf.py flash
3747

0 commit comments

Comments
 (0)