3 ms·
I kept hearing rust was ready for embedded pretty early on (like 2018), and I fooled with it for a bit in 2021 and it definitely was not, on the platform I chos
by uxp100 3y ago
I kept hearing rust was ready for embedded pretty early on (like 2018), and I fooled with it for a bit in 2021 and it definitely was not, on the platform I chose at least. Updating compiler version (minor update) broke existing code, I was relying on one guys hobby to support the relatively popular (though fading) mcu I pulled out of my parts bin.
What about rust today makes it suitable for replacing some code but not all of it? What’s better, what still isn’t there yet?
I guess from my limited experience register fiddling ergonomics in rust were miserable, but I was blessed with working with an extremely safe and ergonomic set of c macros at work (you could do something like rmw(i2s, clockconfig, enable, set) and know if it compiled that such a value corresponded to a valid value in a field that existed in such a register in such a peripheral) and I know some vendors provided c “pac” equivalents that were pretty sloppy and error prone, if still nicer than all the punctuation needed to set a bit in a register in rust. How is HAL quality for popular platforms? How much does that matter? The stm provided c HAL is extremely limiting in my experience, anything fancy requires bypassing it, and I worked places without touching the vendor provided libraries ever but I guess having it as an option for popular platforms is important.
- Yoric 3y agoFor what it's worth, there's bare metal Rust in orbit right now (https://www.gamaspace.com/ https://www.gamaspace.com/). We'll see how that goes, but I'd like to see it work!
- estebank 3y ago> Updating compiler version (minor update) broke existing code Could you elaborate on that? That's not something that's supposed to happen and if it has, I would like to make sure we register it in our issue tracker.
- deciduously 3y agoWow, you really are vigilant and omnipresent. Thank you for the DX!
- uxp100 3y agoI don't really remember, its approaching 3 years now, but the target was msp430-none-elf, and some function I had to implement had its signature change? abort! i guess? I don't think it was accidental or unknown, I think i found some conversation on a mailing list when I went to look for it.
- AlotOfReading 3y agoPanic changed quite a bit in no_std around 2018 [0], perhaps that's what you're remembering? You could only see that issue on nightly though, and at that point no_std / embedded rust was very much a work in progress that was limited to nightly no matter what random people were saying. [0] https://users.rust-lang.org/t/psa-breaking-change-panic-fmt-language-item-removed-in-favor-of-panic-implementation/17875 https://users.rust-lang.org/t/psa-breaking-change-panic-fmt-...
- uxp100 3y agoI think this was the issue, but it wasn’t 2018 when it I ran into it (looking at some notes it seems like 2020, not 2021). Perhaps it was slow to propagate to the tier 3 supported toolchain I was using? Somehow I got an old version? Idk, it was something I spent a few hours on years ago. I was on nightly, I had to be for msp430 iirc.
- AlotOfReading 3y agoI'm definitely not the best person to answer this, but honestly it's not bad. Here's an example of a moderately complex peripheral, the cortex-m MPU, and how one rust OS handles it: https://github.com/tock/tock/blob/3a0527d586702b8ae8cb242391fa72eb3a412f49/arch/cortex-m/src/mpu.rs https://github.com/tock/tock/blob/3a0527d586702b8ae8cb242391... Reads and writes turn into volatile reads, so everything works out under the hood. You get the benefits of everything having good names, declared sizes, and proper typing on your register accesses. You can extend that to bit accesses as well. Rust still has a few areas it isn't competitive in, like your hyper limited or obscure chips (e.g. 8051s, XAP), mature tooling around formal methods, and a certification story for safety critical code. People are working on these latter two issues (e.g. ferrocene) and supposedly very close to public delivery, but you know how slow the industry is to adopt new things even then.