Esp-hal, A Stable-API ESP32 HAL Gift For Your Rust Code

The rust language logo being branded onto a microcontroller housing

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!

14 thoughts on “Esp-hal, A Stable-API ESP32 HAL Gift For Your Rust Code

  1. 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).

    1. 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!

    2. RP2040 probably not, as there are cheaper, more battle-tested alternatives, but nRF stuff definitely – better in every way.
      Save for WiFi, it requires a separate chip and most dev boards don’t bother.
      So nither are actually alternatives if you need WiFi – but you clearly have something against ESPs.

      1. RP2040 is also sold as Pico W with Wifi chip on a castellated board same as ESP32.. i.e. it’s surface mountable but the price is still cheap with ESP32 with standard architecture and standard debug port (SWD) and PIOs as essential features.

    3. oooo! Are we dumping on ESP’s? Can I join in? I really dislike them, for the reasons you list and more. The only thing I find them tolerable for is projects needing Wifi/IoT, and for me at least, those are few and far between.

    4. Looking at trying Rust here at some point on an RP2040 or RP2350. Majority of things I’ve wanted to do on the boards so far has only needed microPython and some C. It’ll be a learning curve.

      I simply don’t see a need for ESP hardware in my world. Not saying ESP is bad, just not needed.

    5. They newer design like C6/C3 are freaking amazing, you have build in USB-JTAG, no debugger need, works really well and they power draw can be pretty good too. And esp-hal is really good too.

  2. I find esp reliable and cost effective not to mention they are in tons of things. I guess if you don’t need wifi or Bluetooth or maybe have a tight energy budget there are better alternatives. Nice to see Espressif get on board too. They used to be that weird Chinese kinda open not open source thing they have been slowly warming to being more open.

  3. “$119 Lenovo N6000 4+0 cores 4/64 GB Windows 11 with 43 inch Insignia
    monitor/tv setup in preparation to try to flash a RP2040 … referenced by Voronova.
    esp-hal 1.0.0 beta announcement.”

    Can ARM M33 do 64 bit fixed floating point multiply accurate to 128 bits
    using transparent portable gcc c program?

    c code port from gcc c to another compiler required?

  4. What’s a recommended quick rust course for the very experienced coder? I’ve looked at it just long enough to see the concepts, not long enough to get comfortable with the syntax or conventions.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.