cancel
Showing results for 
Search instead for 
Did you mean: 

Rust support.

NMan.11
Associate II

From what i've seen the Rust programming language is becoming more and more popular and since it does not rely on a virtual machine, like java or python, it could be a good option for embedded development and other low-level programs.

I know that there are ways to get Rust on STM32 MCUs running, but without official support its really hard to start a series project using those tools. At this point i see it as something fun to try out and benchmark and compare with a traditional C program + FreeRTOS.

Does anyone know if there are any official plans from ST to have a Rust wrapper on the existing C HAL or a complete ground-up Rust HAL? Maybe support in CubeIDE for both C and Rust?

7 REPLIES 7
Knut_Knusper
Associate III

Push

JamesF
Associate

I am also interested in Rust support from ST.

Louis Cloete
Associate III

IMO Rust doesn't need official ST support. The HALs and PACs (Peripheral Access Crates) are already quite good for some chips. If your chip doesn't have a good HAL yet, try to use a similar family as basis and start writing one. You can get support from the rust-embedded and stm32-rs Matrix rooms. What would be nice though, is to see ST contribute to the open source efforts already there.

Hi @Community member​ @Knut_Knusper​  Could you share your impression from Rust on STM32 or other Cortex-M where you used it?

Is it much better/easier/reliable than C++?

DOCon.1
Senior

I've found Rust to work well on Stm32, due to outstanding PAC and Cortex-M libs. I've released a commercial product using it with Stm32 L4, plan to release another using Rust+Nordic, and a third with ​Stm32H7 in a few months. Overall, Rust is a very nice language to work with, due to it's ergonomics and builtin tools/docs.

Here's the HAL lib I wrote for the job: ​STM32-HAL

I wasn't aware of this HAL! I'll see if I can get some time to compare it with the stm32xxx-hal crates some time.

I have used Rust and C++, both professionally and as a hobbyist.

Rust has many small advantages that are exciting to me as a hobbyist, but as a professional that is concerned with shipping products on time the biggest advantage is the cost of debug. Rust has significantly fewer ways to create buggy code, and when bugs do occur they are often easier to locate due to the syntax of the language forcing developers to mark potentially dangerous code as "unsafe".

My experience is that rust takes longer to write, mostly due to fledgling ecosystem and developer inexperience, but the time savings in debug reduces the overall development cost.