Posted on

This edition is to check in on the state of Rust for Embedded Systems

Hello, Rustaceans!

Welcome to this week's edition of the Rust Trends newsletter. We have an exciting lineup of articles prepared for you, packed with valuable insights and updates from the world of Rust programming.

In this edition, we focus on embedded systems and the roadblocks that stand in the way of Rust adoption. We will also introduce you to a hex viewer written in Rust, for your binary data analysis needs.

So grab your favorite beverage, sit back, and let's dive right in!

Embedded Systems and the 5 Roadblocks to Rust Adoption

Microcontroller

Rust has been making progress as a language for adoption in the embedded systems world. However, several significant roadblocks hinder its widespread acceptance. This article on Embedded.com highlights 5 roadblocks to Rust adoption in embedded systems. These are the takeaways:

  1. Rust faces roadblocks in embedded systems adoption due to limited commercial support from microcontroller vendors, leaving developers to figure things out on their own.
  2. The learning curve for Rust is steeper than other languages, leading to higher training costs and longer development times for teams interested in using it for embedded systems.
  3. Conservative adoption of technologies in the embedded industry, coupled with the investment in existing workflows and talent, makes switching to Rust less appealing for many companies.
  4. Rust's integration with existing toolchains and development processes in embedded systems may require significant rework, potentially leading to lost insights and additional development time.
  5. The lack of a formal specification and standardization in Rust poses challenges for commercial support and consistency, particularly in safety-critical applications with long product lifetimes.

Moreover, the author mentions, "I hate to say it, but an experienced professional can do the same things in C or C++ that a Rust programmer can do just as safely." I strongly disagree with this statement. The reason why embedded firmware has so many vulnerabilities is that languages like C and C++ do not provide inherent protection against making mistakes in the first place. As humans, we are prone to errors, and in my opinion, enforcing programming practices that ensure the correct approach is the only truly safe way forward.

The key food for thought is: How can the industry strike a balance between risk aversion and embracing new technologies to drive progress?

Embedded Rust: the lay of the land

Microcontroller with Rust

For starters a nice overview for Embedded Rust is the repository Awesome Embedded Rust. The official Embedded Rust Book and a great blogpost by the Mbedded Ninja.

Moreover several microcontroller vendors have started providing support (un) officially for the Rust programming language. Here are a few notable ones:

  • Nordic Semiconductor support for Rust for their nrf52, and nrf53 series of microcontrollers. They provide a Rust-enabled software hardware abstraction layer called nrf-hal, which allows developers to write firmware using Rust for their microcontrollers.

  • STMicroelectronics Rust support for their STM32 microcontroller family. They offer a Rust-specific hardware abstraction layer (HAL) called stm32-rs, enabling developers to write embedded software in Rust for STM32 microcontrollers.

  • NXP Semiconductors Rust support for their i.MX RT series of microcontrollers. They offer the imxrt-rs crate, which is a Rust API for programming i.MX RT microcontrollers, allowing developers to leverage the Rust language for embedded development.

  • Espressif official support for the popular ESP32 controllers. They offer esp-rs crate and the ESP32 book.

  • Infineon official support for Rust for their (Automotive) Microcontrollers.

It's important to note that the availability and extent of Rust support may vary among different microcontroller vendors and their specific microcontroller families. It's always recommended to consult the official documentation and resources provided by the respective vendors for the most up-to-date information on Rust support.

Hex Viewer: Empowering Binary Data Analysis with Rust

Pac-Man kill screen

Hex editors play a crucial role in low-level data analysis and manipulation. Every embedded system developer should have one in their toolkit.

Hexyl, a powerful hex viewer for the terminal, is written entirely in Rust. It utilizes colored output to differentiate various categories of bytes, offering an efficient and intuitive approach to working with binary data.

An example of a well-known hack that involved the use of a hex editor:

Is the case of the "Pac-Man Kill Screen" in the classic arcade game Pac-Man. In the original Pac-Man arcade machine, a bug caused the game to reach an unplayable level 256, known as the "kill screen." This bug occurred due to an integer overflow issue, where the game's code was unable to handle a higher level number.

In order to bypass this issue and reach the kill screen intentionally, some skilled players and hackers used a hex editor to modify the game's code. By locating the specific section of code responsible for the level counter and adjusting it, they were able to bypass the limitations and continue playing beyond level 256. If you want to learn more about it watch this youtube movie.


Do not hesitate to explore new possibilities in Rust. Pushing yourself out of your comfort zone can be a great way to learn and grow as a programmer.

Thanks for reading! Bob Peters

Feel free to connect with me on LinkedIn

Ps. Did someone forward this email to you? Sign up here for our newsletter.