Looking to write Rust on the ESP32? You’re in luck, a new challenger has entered the scene, looking to help you write code that lasts – [Scott Mabin] and the team from Espressif have brought us the esp-hal
1.0.0-beta. From a personal project to an Espressif-sponsored one to an effort under Espressif’s wing, [Scott] tells us about the arduous journey of bringing first-class Rust support to ESP32 chips, Xtensa and RISC-V alike.
In particular, esp-hal
, with the hal
part standing for Hardware Abstraction Layer, focuses on providing you with a stable API to access hardware, making sure your code can remain stable for years to come. For now, you get drivers for GPIO, UART, SPI and I2C, as well as a number of auxiliary features like time and SoC reset, more than enough for a large amount of projects we hackers build with a generic MCU in mind.
Next stop? WiFi and BLE support, of course, an ESP32 just doesn’t feel the same without these two. Rust is a fun and seriously promising language, and it’s a joy to use! So, if you have a wireless-less project in mind and you’re looking for a HAL, try out the esp-hal
, it might just be exactly what you need.
If you’re looking for examples, here’s an STM32 touchpad project with Rust firmware, a PIC32 Rust blinky demo, and we’ve even featured larger projects like this ESP32 open-source (reverse-engineered) WiFi MAC stack being written in Rust. In case you missed it, we’ve introduced Rust to you a couple of times, even as far as 2015!
If you want to try Rust then Embassy-rs with both nRF52840 a RP2040 is a blessing.
Btw. Rust or not both are substantially better value for money then some ESP unless you create your totally artificial metric (like everything I ever wanted is power hungry expensive super nonstandard architecture with broken debugging on many variants).
ESP32 chips have quite a few great features over an RP2040 (no idea on the nRF) – off the top of my head, more RAM (native PSRAM support too), more ADCs, WiFi/BLE built-in, touch scanning built-in. All depends on the type of project you build, of course, but there’s defo still plenty of usecases where I wouldn’t go for an RP2040!