I would like to build a gateway device which will use the ESP32. This should connect to the ModBus TCP port of a Sensor. For this purpose, I would like to use the Modbus Rust implementation, which already exists. But there is very little information on how I could get Rust code running on the ESP32.

Can anyone shed some light on this topic?


3 Answers 3


Rust uses the LLVM toolchain, which is a a set of programs used to compile LLVM's intermediate representation (IR) into platform-specific code. The process works a little like this:

Rust Code -> Rust Compiler -> LLVM IR -> Back-end -> Platform-specific code

Currently, there is no backend for the Xtensa architecture used by the ESP32. This, unfortunately, means that you cannot compile Rust code for the ESP32. You did say install in your question, but I assume you didn't mean that — rather, you want to run Rust code on the ESP32, not install the Rust compiler there.

If you're really desperate to use Rust, you could, in theory, use the LLVM C Backend, which converts LLVM IR -> C, then use the toolchain provided by Espressif to compile to ESP32 machine code. However, this will be difficult, and might not even work at all. You will find it a lot easier to bite the bullet and use C in this case, which is a shame, because Rust is a great language, but its embedded support is not as good as C's at the moment.

  • Are you aware of any other Hardware boards that support Rust? Yes, like you said I just want to run Rust programs on the device and I certainly do not want a compiler there!
    – joesan
    Commented Sep 19, 2017 at 17:37
  • @sparkr The list of supported platforms and architectures that Rust supports is available here; most of those platforms are either x86, x86-64 or various ARM architectures. I imagine all of those are far more capable (and expensive) than you want, so it does really limit your options with Rust. Notably, though, the TI MSP430 is listed as a 'Tier 3' supported device, so Rust might just about work. Can't speak from personal experience though, as I've not used Rust for embedded applications yet.
    – Aurora0001
    Commented Sep 19, 2017 at 17:42
  • There is now a community supported fork of rustc to support the Xtensa arch mabez.dev/blog/posts/esp32-rust Commented Nov 20, 2019 at 20:53

Xtensa have just released an official ESP32/Espressif LLVM backend and clang front end. See their announcement here: https://esp32.com/viewtopic.php?p=38466 Repos: https://github.com/espressif/llvm-xtensa & https://github.com/espressif/clang-xtensa As rust is based on LLVM, this new ESP32 LLVM backend should help make Rust support for the ESP32 more likely. The announcement even hints at this future Rust support.

  • 1
    Hey, welcome to IoT.SE! I would encourage you to edit this answer to make it more complete. As it stands, it's basically just a series of links with minimal explanation, and looks more like a comment than a complete answer. It would be far better to explain the answer in more detail, with the links for reference only. Thanks!
    – anonymous2
    Commented Feb 19, 2019 at 23:59
  • 1
    Just an update the previous LLVM-xtensa project has been moved to github.com/espressif/llvm-project
    – alanionita
    Commented Aug 23, 2020 at 21:41

Like Aurora0001 said, you can't run Rust on an ESP32 currently (or the older ESP8266).

There's a very similar chip, the RTL8710, that is recommended for use in situations where you'd use an ESP32, but want to use Rust.

Here is a website where someone walks through their setup.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.