First Official SDK In Rust |
Written by Harry Fairhead | |||
Wednesday, 05 March 2025 | |||
We are all being urged to work in Rust because its safer, but this is easier said than done. The embedded world really needs a memory-safe language, but Rust gets surprisingly little support from manufacturers. SDKs are written in C and not Rust. The good news is that Espressif is working to produce an official Rust-based SDK for its microprocessors and you can start to work with the beta now. The world of embedded systems needs secure coding practices, but it can be out of reach due to the way development is supported via SDKs and tool chains. This has long been the province of C and nothing but C. Even C++ rarely gets a look in. If you want to work with Rust on a device such as the Raspberry Pi Pico, Arduino or any of the well-known products then you can usually find a way to compile a Rust program, but it will have to make use of the extensive C SDK which slighly negates the point of using Rust. Around six years ago when Espressif started work on its SDK in Rust, it wasn't obvious how to do it. The Rust compiler didn't support the Xtensa processor found in its devices. At first the work was done by enthusiasts, primarily Scott Mabin, but as Espressif got more and more interested, it eventually hired some of the enthusiasts and formed an official Rust team. At the time most Rust code supported ARM chips and not the Xtensa and RISC-V devices that Espressif uses. To cut a long but interesting story short, eventually the team settled on implementing esp-hal, an architecture- independent layer written in Rust. It wasn't long before they managed to add WiFi, BLE and ESP-NOW support - and working on a range of devices including Xtensa and RISC V targets. In addition they intend to support four core drivers to start with:
with the only major missing feature being PWM, which is particularly sophisticated on the ESP range of devices. The SDK also supports the time module and a few other APIs. If you want more then you have to opt for unstable features which should be stabilized over time. To give you some idea of what the code looks like here is a simplified Blinky - i.e. flashing an LED connected to GPIO7: #[main] You can see that this not only doesn't look like C, it doesn't look a lot like the Espressif IDF SDK - so there is much to learn. How important is a Rust SDK? Potentially very important. There are Rust projects for other manufacturers' devices but none, as far as I know, are backed by the manufacturer. For example, there is a project to implement Rust on the Pico without using the existing SDK, but for this to move to the mainstream Raspberry Pi would have to put some effort in. If Espressif continues to back the new esp-hal then it could give them a significant edge in this particular part of the embedded market. If I were Raspberry Pi I would be fairly worried and might just do something to catch up.
More Informationesp-hal 1.0.0 beta announcement Related ArticlesRust Foundation Update On Goals Rust 1.83 Improves Const Context Code Handling Rust 1.82 Improves Apple Support Rust Foundation Announces Safety-Critical Consortium
To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.
Comments
or email your comment to: comments@i-programmer.info <ASIN:1871962919> <ASIN:1871962927> <ASIN:187196282X> |
|||
Last Updated ( Wednesday, 05 March 2025 ) |