Skip to content

Commit eda833b

Browse files
MaartenS11tolauwae
andauthored
Zephyr ESP32 support (#318)
* Initial work on getting the ESP32 to work on zephyr * Rename overlay file * Add build instructions Zephyr * 🎨 Clang format `main.cpp` * Add esp32 c3 super mini overlay * Re-enable debugger thread Appears to work fine on the esp32 c3 super mini * Add basic wroom overlay + misc changes * Add wrover kit overlay * Renamed overlay files to work out of the box for the wrover kit, devkitc_wrover and devkitc_wroom * Disable trace mode by default * clang-format * Fix support for rpi_pico and stm32l496g_disco boards De cdc acm and console is now configured at the board level instead of globally. * Update README --------- Co-authored-by: tolauwae <Tom.Lauwaerts@UGent.be>
1 parent b4448cd commit eda833b

File tree

11 files changed

+188
-14
lines changed

11 files changed

+188
-14
lines changed

β€ŽREADME.mdβ€Ž

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,47 @@ make flash
8484

8585
Or simply run `idf.py flash`.
8686

87+
### Build for Zephyr
88+
89+
First, install the [Zephyr SDK](https://docs.zephyrproject.org/latest/develop/getting_started/index.html#getting-started-guide), then follow these steps:
90+
91+
1. Activate your Zephyr environment:
92+
```bash
93+
source ~/zephyrproject/.venv/bin/activate
94+
source ~/zephyrproject/zephyr/zephyr-env.sh
95+
```
96+
97+
2. Go to the Zephyr folder:
98+
```bash
99+
cd platforms/Zephyr
100+
```
101+
102+
3. Build your WebAssembly binary; for example:
103+
```bash
104+
wat2wasm --no-canonicalize-leb128s --disable-bulk-memory --debug-names -v -o upload.wasm ../../tutorials/wat/main/blink.wat
105+
```
106+
> [!NOTE]
107+
> The binary should be called `upload.wasm` and placed in the `platforms/Zephyr` folder.
108+
109+
4. Build for Zephyr; for example, the esp32_devkitc_wroom/esp32/procpu:
110+
```bash
111+
west build -b esp32_devkitc_wroom/esp32/procpu
112+
```
113+
> [!NOTE]
114+
> Overlay files for the supported boards can be found in the `platforms/Zephyr/boards` folder.
115+
116+
5. Now you are ready to flash your software with the following command:
117+
```bash
118+
west flash
119+
```
120+
121+
This command also rebuilds the virtual machine, so you only need to run the build command from the previous step once.
122+
After flashing, you can monitor the serial port, with the following command (when using an Espressif board):
123+
124+
```bash
125+
west espressif monitor
126+
```
127+
87128
### Build for Arduino
88129

89130
First, install the [arduino-cli](https://arduino.github.io/arduino-cli/0.21/installation/).

β€Žplatforms/Zephyr/CMakeLists.txtβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,9 @@ target_sources(app PRIVATE
3333
upload.h
3434
)
3535

36+
add_definitions(-DINFO=0)
37+
add_definitions(-DDEBUG=0)
38+
add_definitions(-DTRACE=0)
39+
add_definitions(-DWARN=0)
40+
3641
include_directories(../../lib/json/single_include/)

β€Žplatforms/Zephyr/app.overlayβ€Ž

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1 @@
1-
/ {
2-
chosen {
3-
zephyr,console = &cdc_acm_uart0;
4-
};
5-
};
61

7-
&zephyr_udc0 {
8-
cdc_acm_uart0: cdc_acm_uart0 {
9-
compatible = "zephyr,cdc-acm-uart";
10-
};
11-
};
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include "../app.overlay"
2+
3+
/ {
4+
zephyr,user {
5+
warduino-gpios =
6+
<&gpio0 0 0>,
7+
<&gpio0 1 0>,
8+
<&gpio0 2 0>,
9+
<&gpio0 3 0>,
10+
<&gpio0 4 0>,
11+
<&gpio0 5 0>,
12+
<&gpio0 6 0>,
13+
<&gpio0 7 0>,
14+
<&gpio0 8 0>,
15+
<&gpio0 9 0>,
16+
<&gpio0 10 0>,
17+
<&gpio0 11 0>,
18+
<&gpio0 12 0>,
19+
<&gpio0 13 0>,
20+
<&gpio0 14 0>,
21+
<&gpio0 15 0>,
22+
<&gpio0 16 0>,
23+
<&gpio0 17 0>,
24+
<&gpio0 18 0>,
25+
<&gpio0 19 0>,
26+
<&gpio0 20 0>,
27+
<&gpio0 21 0>,
28+
<&gpio0 22 0>,
29+
<&gpio0 23 0>,
30+
<&gpio0 24 0>,
31+
<&gpio0 25 0>,
32+
<&gpio0 26 0>,
33+
<&gpio0 27 0>,
34+
<&gpio0 28 0>,
35+
<&gpio0 29 0>,
36+
<&gpio0 30 0>,
37+
<&gpio0 31 0>;
38+
};
39+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include "../app.overlay"
2+
3+
/ {
4+
zephyr,user {
5+
warduino-gpios =
6+
<&gpio0 0 0>,
7+
<&gpio0 1 0>,
8+
<&gpio0 2 0>,
9+
<&gpio0 3 0>,
10+
<&gpio0 4 0>,
11+
<&gpio0 5 0>,
12+
<&gpio0 6 0>,
13+
<&gpio0 7 0>,
14+
<&gpio0 8 0>,
15+
<&gpio0 9 0>,
16+
<&gpio0 10 0>,
17+
<&gpio0 11 0>,
18+
<&gpio0 12 0>,
19+
<&gpio0 13 0>,
20+
<&gpio0 14 0>,
21+
<&gpio0 15 0>,
22+
<&gpio0 16 0>,
23+
<&gpio0 17 0>,
24+
<&gpio0 18 0>,
25+
<&gpio0 19 0>,
26+
<&gpio0 20 0>,
27+
<&gpio0 21 0>;
28+
};
29+
};
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include "../app.overlay"
2+
3+
/ {
4+
zephyr,user {
5+
warduino-gpios =
6+
<&gpio0 0 0>,
7+
<&gpio0 1 0>,
8+
<&gpio0 2 0>,
9+
<&gpio0 3 0>,
10+
<&gpio0 4 0>,
11+
<&gpio0 5 0>,
12+
<&gpio0 6 0>,
13+
<&gpio0 7 0>,
14+
<&gpio0 8 0>,
15+
<&gpio0 9 0>,
16+
<&gpio0 10 0>,
17+
<&gpio0 11 0>,
18+
<&gpio0 12 0>,
19+
<&gpio0 13 0>,
20+
<&gpio0 14 0>,
21+
<&gpio0 15 0>,
22+
<&gpio0 16 0>,
23+
<&gpio0 17 0>,
24+
<&gpio0 18 0>,
25+
<&gpio0 19 0>,
26+
<&gpio0 20 0>,
27+
<&gpio0 21 0>,
28+
<&gpio0 22 0>,
29+
<&gpio0 23 0>,
30+
<&gpio0 24 0>,
31+
<&gpio0 25 0>,
32+
<&gpio0 26 0>,
33+
<&gpio0 27 0>,
34+
<&gpio0 28 0>,
35+
<&gpio0 29 0>,
36+
<&gpio0 30 0>,
37+
<&gpio0 31 0>;
38+
};
39+
};

β€Žplatforms/Zephyr/boards/rpi_pico.overlayβ€Ž

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
#include "../app.overlay"
22

3+
/ {
4+
chosen {
5+
zephyr,console = &cdc_acm_uart0;
6+
};
7+
};
8+
9+
&zephyr_udc0 {
10+
cdc_acm_uart0: cdc_acm_uart0 {
11+
compatible = "zephyr,cdc-acm-uart";
12+
};
13+
};
14+
315
/ {
416
zephyr,user {
517
warduino-gpios =

β€Žplatforms/Zephyr/boards/stm32l496g_disco.overlayβ€Ž

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
#include "../app.overlay"
22

3+
/ {
4+
chosen {
5+
zephyr,console = &cdc_acm_uart0;
6+
};
7+
};
8+
9+
&zephyr_udc0 {
10+
cdc_acm_uart0: cdc_acm_uart0 {
11+
compatible = "zephyr,cdc-acm-uart";
12+
};
13+
};
14+
315
/ {
416
zephyr,user {
517
warduino-gpios =

β€Žplatforms/Zephyr/main.cppβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#define DEBUGGER_STACK_SIZE 2048
99
#define DEBUGGER_PRIORITY 0
1010

11-
BUILD_ASSERT(DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_console), zephyr_cdc_acm_uart),
12-
"Console device is not ACM CDC UART device");
11+
/*BUILD_ASSERT(DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_console),
12+
zephyr_cdc_acm_uart), "Console device is not ACM CDC UART device");*/
1313

1414
static struct tty_serial console_serial;
1515

β€Žplatforms/Zephyr/prj.confβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@ CONFIG_MAIN_STACK_SIZE=8192
3434
# Allow flashing the board without reset (increases power consumption so should only be used for development)
3535
CONFIG_STM32_ENABLE_DEBUG_SLEEP_STOP=y
3636

37+
# This needs to be enabled for older espressif boards
38+
#CONFIG_ESP32_USE_UNSUPPORTED_REVISION=y

0 commit comments

Comments
Β (0)