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?


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! – sparkr Sep 19 '17 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 Sep 19 '17 at 17:42

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.


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.

  • 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 Feb 19 at 23:59

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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