Using Embassy on ESP32-C3 and C6 targets, in 2024.
Based on jessebraham/esp-hal-template
, but:
- supports
stable
in addition tonightly
toolchain - not a template repo, but a normal one
The idea is to support two kinds of targets:
ESP32-C3-DevkitC-02
with JTAG/USB cable soldered onESP32-C6-DevKitM-1
(with a dedicated JTAG/USB connector)
Follow ESP32-Mac to set up:
-
Multipass
-
rust-emb
VMPlease update
probe-rs
to an upcoming (> 0.24.0) version. Otherwise, only works onesp32c6
chips.$ cargo install --git https://github.com/probe-rs/probe-rs probe-rs-tools --force
-
USB/IP setup
-
one or more of:
-
ESP32-C3-DevKitC-02
with a USB cable soldered for JTAG access -
This one has two USB ports (and they are USB-C :)). You can use one of them for JTAG.
-
For
esp32c3
, useriscv32imc-unknown-none-elf
andesp32c3
.
$ cargo build --release --features=esp32c6 --target=riscv32imac-unknown-none-elf
$ probe-rs run --chip esp32c6 target/riscv32imac-unknown-none-elf/release/app
$ cargo +nightly-2024-06-01 run --features nightly,esp32c6 --release --target=riscv32imac-unknown-none-elf
Note: For the moment, one needs to have
nightly
< 2024-06-13 (or perhaps the patch forembassy-executor-macros
). source
Running as above.
See embassy-executor
> Task arena documentation.
TL;DR:
nightly
would be better. No need to provide an intended "task arena size".- On stable, one can do that in a couple of ways (but it's presumably optional).
If you get USB errors:
Caused by:
0: USB Communication Error
-
reset the devkit by:
- pushing both RST and BOOT buttons
- release the RST button
- then release BOOT button
-
reconnect the USB/IP connection:
- RPi:
usbipd bind -b 1-1.2
- VM:
usbip attach -r 192.168.1.199 -b 1-1.2
Obviously, you'll need to use the IP and bus-id that apply to your system.
There are ways to make a board automatically rebind on the host side; this is not covered here. Windows
usbipd
seems to rebind automatically. - RPi:
-
and try again.
Sample error case
$ make run
probe-rs run --chip esp32c6 target/riscv32imac-unknown-none-elf/release/app
Erasing ✔ [00:00:01] [###############################################################################################################] 128.00 KiB/128.00 KiB @ 71.85 KiB/s (eta 0s )
Programming ✔ [00:00:12] [##################################################################################################################] 26.10 KiB/26.10 KiB @ 2.12 KiB/s (eta 0s ) Finished in 15.477s
INFO RWDT watchdog enabled!
└─ app::____embassy_main_task::{async_fn#0} @ src/bin/app.rs:47
ERROR !! A panic occured in '/home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/esp-hal-embassy-0.2.0/src/time_driver/mod.rs', at line 102, column 42:
└─ esp_backtrace::panic_handler @ /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/esp-backtrace-0.13.0/src/lib.rs:29
ERROR "panicked at /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/esp-hal-embassy-0.2.0/src/time_driver/mod.rs:102:42:\ncalled `Option::unwrap()` on a `None` value"
└─ esp_backtrace::panic_handler @ /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/esp-backtrace-0.13.0/src/lib.rs:29
ERROR Backtrace:
└─ esp_backtrace::panic_handler @ /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/esp-backtrace-0.13.0/src/lib.rs:29
ERROR No backtrace available - make sure to force frame-pointers. (see https://crates.io/crates/esp-backtrace)
└─ esp_backtrace::panic_handler @ /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/esp-backtrace-0.13.0/src/lib.rs:29
WARN probe_rs::session: Could not clear all hardware breakpoints: An error with the usage of the probe occurred
Caused by:
0: USB Communication Error
1: endpoint STALL condition
thread 'main' panicked at probe-rs/src/probe/espusbjtag/protocol.rs:375:37:
range end index 77 out of range for slice of length 64
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
make: *** [Makefile:53: run] Error 101
$ usbip list -r 192.168.1.199
usbip: info: no exportable devices found on 192.168.1.199
-
Reset the board as instructed above (both buttons; release
RST
; releaseBOOT
). -
RPi:
$ sudo usbip bind -b 1-1.2
-
VM:
$ usbip list -r 192.168.1.199 Exportable USB devices ====================== - 192.168.1.199 1-1.2: unknown vendor : unknown product (303a:1001) : /sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2 : Miscellaneous Device / ? / Interface Association (ef/02/01)
That's it.