Skip to content

Commit

Permalink
Esp rust q1 2024 (#23)
Browse files Browse the repository at this point in the history
* draft

* draft 2

* fin
  • Loading branch information
MabezDev authored Apr 12, 2024
1 parent c8f97e2 commit 9dbea06
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions content/blog/posts/esp-rust-12-04-2024.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
+++
title="Rust on Espressif chips - 12-04-2024"
date=2024-04-12
draft=false
[taxonomies]
tags=["rust", "espressif", "esp32", "llvm"]
+++

This is the next quarterly update of the esp-rs effort, detailing the progress over Q1 2024.

## Xtensa Rust Compiler & LLVM Xtensa

LLVM has recently moved away from Phabricator to Github for active development, which meant we had to resubmit some of our patches. We took some time to split up the patches we previously submitted, and resubmitted them; one of which has already been merged! You can follow the [tracking issue](https://github.com/espressif/llvm-project/issues/4) we have open to follow along. Just a reminder that you only need the Xtensa compiler for the ESP32, ESP32-S2 and ESP32-S3, all other Espressif chips are RISC-V and work well with the upstream compiler.

## esp-hal

We've put a lot of focus on `esp-hal` this quarter, so we have a bunch of updates to share. The biggest update is that we have unified the HAL such that all chips are now supported by a singular package, `esp-hal`. This effort was months in the making, and the [original issue](https://github.com/esp-rs/esp-hal/issues/446) discussing merging it was opened just over a year ago! Previously we had a common library with shared implementations, which was then broken out into a hal package for each chip. With each new chip release by Espressif, we realized this was not scalable. We made the decision merge all the HALs into `esp-hal`, which has now been released on crates.io! Migration is quite straightforward, you can check out the [release notes](https://github.com/esp-rs/esp-hal/releases/tag/v0.16.0) for the details.

If you are a contributor, the workflow within the esp-hal repository has also changed. In unifying the HAL, we realized we had outgrown vanilla cargo as a build tool and needed something more configurable. We have switched to `cargo xtask` to manage building packages, examples, and running tests on hardware (more on that shortly!). If you are a developer or looking to run some examples, please run `cargo xtask help` in the main `esp-hal` repository to see what's available.

## Tooling

### probe-rs

In the last post, I mentioned that we now had support for all Espressif chips in probe-rs. Whilst this is an amazing achievement on its own which allows our users to use the wonderful probe-rs tooling, we also have had our eyes on something else, Hardware-In-Loop (HIL) testing. Building any reliable set of libraries and run-times _requires_ testing. Whilst we can run _some_ tests on the host machine to test certain bits of logic, testing drivers requires that they run on the actual intended target. Espressif already does tonnes of HIL testing for other projects such as ESP-IDF, Zephyr and NuttX, so we have the physical infrastructure, but as Rust developers, we wanted native Rust software to write and run our test cases. Enter [embedded-test](https://github.com/probe-rs/embedded-test), which is a test harness that can integrate with probe-rs to run test cases on real devices! It has first-class support for Espressif chips, and we're already using it in our ever-growing [esp-hal HIL test suite](https://github.com/esp-rs/esp-hal/tree/main/hil-test). We can't thank the author of embedded-test, [Timo](https://github.com/t-moe), and the [probe-rs team](https://github.com/probe-rs/probe-rs) enough!

### espflash

We have released v3 of espflash, the most notable change with this is that we are now using Rust-based stub (instead of the ones written in C) to flash Espressif chips. What is a stub you ask? It's a small program that is loaded into RAM which espflash talks to over serial to flash new programs to the chip. Espressif chips come with a ROM bootloader, which can manage flashing, but it is very simple and doesn't always leverage the full flashing potential of the chip resulting in slower development cycles. The stub program is available under [esp-rs/esp-flasher-stub](https://github.com/esp-rs/esp-flasher-stub) and leverages `esp-hal` under the hood to communicate with espflash. There are of course a tonne of bugfixes, enhancements and changes, so please check out the [changelog](https://github.com/esp-rs/espflash/blob/main/CHANGELOG.md) for all the details. In the spirit of testing, we've also added HIL testing to espflash, to ensure we minimize regressions between releases.

## Events

I wanted to post this before [Embedded World](https://www.embedded-world.de/en), however I wasn't able to, but I'd like to say thanks to everyone who turned and gave us feedback on Rust support, it was really nice to interact with you all! We will also be attending [RustNL](https://2024.rustnl.org/) next month, so if you are attending and you see us, come say hi!

<br/>

---

<br/>

0 comments on commit 9dbea06

Please sign in to comment.