Rust on Espressif chips - 29-09-2023
This is the next quarterly update of the esp-rs effort, detailing the progress over Q3 2023.
Rust Xtensa Compiler
We had one big bugfix around hardware floating point unit for ESP32 & ESP32-S3, shout out to @zRedShift for finding the bug and providing the fix in llvm-project#76. Along with the bugfix, @zRedShift also contributed two code generation improvement patches, one to improve the performance of cttz
and another to improve the performance of abs
, min
and max
. The Xtensa-related LLVM patches upstream are still in review but are slowly making progress.
esp-hal - no_std
Q3 saw the v0.11
and v0.12
release of esp-hal. Highlights include updating the embedded-hal-*
packages to 1.0.0-rc.1
, ready for the long awaited 1.0
release of embedded-hal
; The addition of deep-sleep support for the ESP32-S3
, and new cryptographic accelerator support for ECC, HMAC and RSA. We've made a start on adding support for the low-power core of the ESP32-C6, with some basic GPIO drivers and support for loading the LP code from the main core. Check out the full changelog for all the details.
esp-wifi - no_std
We added BLE support for the ESP32-C6 in esp-wifi#262, improved the esp-now async API in #232 along with a bunch of other smaller fixes and improvements! We're gearing up for our first crates.io release, which is long overdue. We've had all the pieces in place for a release, we just didn't get around to doing it! We're currently in the process of improving the docs, and doing some final testing before the release.
esp-idf-hal - std
Async I2S, SPI, ADC and GPIO were added in esp-idf-hal#279, with a follow up PR for UART in esp-idf-hal#306. Huge props to @ivmarkov for the tremendous effort here. From the latest v0.42.0
release, ESP-IDF version 4.3 is now deprecated for use with Rust. Please see ESP-IDFs support schedule for upgrade paths. See the full changelog for esp-idf-hal here.
esp-idf-svc - std
Bluetooth classic support (for the esp32 only at the moment) has been added, behind the experimental
feature flag; BLE is also planned. We are also discussing how to go about adding generic Bluetooth traits in embedded-svc, here. From the latest release, it will no longer be required to depend on the esp-idf-sys crate or the esp-idf-hal crate directly in your project, instead, this crate will be re-exported by esp-idf-svc as esp_idf_svc::sys
and esp_idf_svc::hal
respectively.
matter-rs / rs-matter
rs-matter (previously, matter-rs, but has been renamed due to an existing crate registered on crates.io) has had its first crates.io release! It is now async first (executor agnostic), with support for no_std out of the box, even including QR generation. The rs-matter repo now has some examples which can be run on std platforms, including the espidf std port! For no_std
there are two examples of matter usage, one using an esp32c3 (blocking) and another using a rp-2040 (async).
Tooling
espflash
Just a small patch release to report, v2.0.1
which added more help text on the CLI commands, and fixed a compilation issue in the cargo
dependency.
espsegs
espsegs is a tool to see what memory is being used by which sections and where on an esp. Once installed, you can simply point the tool to an elf file, and you'll get an output like below:
❯ espsegs target\riscv32imc-unknown-none-elf\release\examples\embassy_dhcp --chip esp32c3
.text_dummy 3c000000 458784 DROM [█████████████ ]
.rodata 3c070020 53060 DROM [ █ ]
.rodata.wifi 3c07cf64 21756 DROM [ ▏ ]
.rwdata_dumm 3fc80000 16948 DRAM [██████ ]
.data 3fc84238 4652 DRAM [ █ ]
.bss 3fc85468 121544 DRAM [ ████████████████████████████████████████████ ]
.data.wifi 3fca2f30 360 DRAM [ ▏ ]
.trap 40380000 3188 IRAM [ ▏ ]
.rwtext 40380c74 2080 IRAM [ ▏ ]
.rwtext.wifi 40381494 11680 IRAM [ ███ ]
.text_init 42000020 244 IROM [▏ ]
.text 42000114 402684 IROM [███████████ ]
RFCs
This section is mainly for users of esp-rs; we have various issues open in which we would like user feedback.
esp-hal
We are considering removing direct-boot support: esp-hal#803, if you think this might affect you, please state your case in that issue.
Talks
Espressif recently hosted their annual developer conference, Espressif DevCon. Myself and my colleague Juraj Sadel did a short talk on using async in Rust, which you can check out below.
I also did a talk at the Rust Copenhagen monthly meet up in August. This talk is more focused on introducing embedded programming to those who already know Rust. Check it out below if you are interested.