9 ms·
Rust on Espressif chips
- aulin 5y agoas someone who occasionally dabbles in diy esp based home automation devices (mostly with esp8266) but completely new to Rust, where's the best place to get started? some code example to look at?
- eklbt 5y agoI'm curious about this as someone who is interested in making DIY smart home products as well as their recently announced Zigbee radio module. But genuine question, is Rust ever going to catch on in the mainstream? It seems to have a bunch of nice to have features and great optimization. But the pick up, from what I've seen, has been less than stellar.
- trevyn 5y agoAre there specific areas where you would expect to see greater adoption at this point on the curve? "Mainstream" adoption of a brand-new language takes time, and it's still early on the curve for Rust. If anything, the hype-train might make it seem like it's a more mature ecosystem than it really is. The questions to ask are, what's causing the hype, and does the product deliver.
- RuiJCS 5y agoFrom what I've seen in my company there seems to be some resistance to rust due to it already having a lot of code written in other languages and them kinda of being the default go to choice.
- bitdivision 5y agoIn what space? If you're talking about embedded, it's going to be pretty slow for industry to start using rust en masse. There's a huge amount of inertia in embedded, and the developers are somewhat beholden to manufacturers to release tooling around rust. In the software space, rust is being used by quite a few companies [0]. 0: https://www.rust-lang.org/production/users https://www.rust-lang.org/production/users
- davidhyde 5y agoIt may be true that manufacturers are ignoring Rust but that certainly does not stop or hinder me. Tools like svd2rust mean I only need to rely on the accuracy of their svd files (industry standard register maps) - see https://github.com/rust-embedded/svd2rust https://github.com/rust-embedded/svd2rust Additionally, I use vanilla VS Code and rust analyser so no need to use manufacturer supplied lock-in IDEs. There are many compiler targets to choose from for cross compilation and tools like probe-run to flash chips. One major issue is lack of manufacturer provided code examples written in Rust. For that I rely on the Rust community. A typical example being nrf-hal for Nordic Bluetooth chips.
- tlamponi 5y agoFWIW, the Rust embedded size also lists a few production embedded users: https://www.rust-lang.org/what/embedded https://www.rust-lang.org/what/embedded
- chewmieser 5y agoRust is gaining momentum at a decent pace IMO. It's not necessarily a web technology so expect slower adoption but still it's been steadily growing.
- allochthon 5y ago> It's not necessarily a web technology And honestly, I've been toying around with an Actix web server written in Rust, and the experience is not bad. As someone new to Rust, the main pain points have been along the lines of figuring out how to type a parameter to accept both a database pool and a database transaction (which turns out to be quite hard to figure out). Other than that kind of friction, the experience has been nice.
- _xyub 5y agoYeah, I personally feel Rust is the future for web. The community just needs to invest in itself to build a bigger ecosystem. The rest will follow. If you want to try out rust for web, check out this project: https://github/wulf/create-rust-app https://github/wulf/create-rust-app
- nicoburns 5y ago> But genuine question, is Rust ever going to catch on in the mainstream? It seems to have a bunch of nice to have features and great optimization. But the pick up, from what I've seen, has been less than stellar. I'm not sure where you've gotten that impression. Rust is mainstream at this point. All the big companies (e.g. FAAMG) are using Rust. Lots of large products are: Firefox of course, but also, parts of AWS, npm, VS Code, Android. And even key infrastructure products like Linux are looking at integrating it.
- eklbt 5y agoI understand that it is very popular and is increasing adoption. But I was more targeting the embedded systems/hardware. Obviously this blog post is a step in that direction, but I'm still curious if hardware manufacturers will want to spend time adopting it.
- follower 5y ago> I'm still curious if hardware manufacturers will want to spend time adopting it. The interesting thing I'm observing[0] is that embedded developers aren't wasting any time waiting for hardware manufacturers to do anything about Rust because they know manufacturers...well, let's express it as: "just don't care about software". Bluntly, regardless of whether it's perfect or not, Rust is currently pretty much the only hope for devs who are desperate to move on from C for embedded work and if they have reverse engineer every last proprietary bitstream, protocol & application they will. It's not just about the language itself (which depending on one's perspective has both pluses & minuses) but also the ecosystem/tooling (e.g. libraries with `no_std` support, build/test/doc systems, etc). (And, from my perspective, the community from which this has all grown--and why.) Maybe it won't succeed but it won't be for lack of trying. :D Also, one of the interesting aspects of Rust for me is how broad the domains of application are--using the same language from microcontroller level, through UEFI/firmware, OS, applications, & web is pretty appealing and leads to easier migration between domains. [0] Including in a comment a few comments down from this one (when I first read it): https://news.ycombinator.com/item?id=29001985 https://news.ycombinator.com/item?id=29001985
- 5y ago
- po1nt 5y agoI think many people are trying to make Rust real deal and some of them make really good job. There was a guy who develops Linux ABI compatible kernel in rust, Tor is being rewritten in to Rust and some of the projects are just amazing. I believe it will catch on as soon as people realize it's a C performance with modern syntax and memory safety mitigating most of the security flaws and bugs introduced by mismanaged memory. I fell in love as soon as I saw descriptive scalar types like "i32".
- tlamponi 5y ago@work we do most of our new development in rust and did so since 2019, its quite a lot more than stellar than most other things we work(ed) with, and we had some interpreted dynamic and some compiled C stuff, its an improvement from either direction.. While at work I'm doing more software development I originally studied comp. eng. and dabbled around quite a bit with embedded systems, mainly in C, ASM and tinyOS with its nesC dialect+framework. Rust is a god send in lots of areas there too, you can establish zero-cost (well some compile cost, but zero runtime ones) contracts and static guarantees with the type systems, like disallowing that code that would produce a register pull up/down configuration with a short-circuit from happening, or shared access to resources can also be done in such ways. Check the respective chapter of the rust embedded book for more info: https://docs.rust-embedded.org/book/static-guarantees/index.html https://docs.rust-embedded.org/book/static-guarantees/index....
- po1nt 5y agoI was looking forward to trying Rust on my ESP32 projects but always had a hard time. All the tooling is too complicated. There is flasher coded in python, IDF coded in C, you need to run MinWin on Windows which makes it even harder. You can't run all of this in docker because docker for windows doesn't allow mapping COM ports into container and stuff. Everything about just compiling a code seems so tiresome and unstable in comparison with STM or Atmel environment. Yet still I love ESP32 even though I gave up trying to code it in Rust. Even C++ was not working well and had to make several pull requests to add `extern "C"`s into IDF codebase for my code to work. I'm looking forward to improvements on the Rust environment. Wouldn't abandoning Xtensa architecture for RISC-V help? Are there any plans to simplify the stack?
- tlamponi 5y agoI did not liked the old ESP flasher tool much either. FYI: There's already an official rust based rewrite of it: https://github.com/esp-rs/espflash https://github.com/esp-rs/espflash
- tlamponi 5y ago> Wouldn't abandoning Xtensa architecture for RISC-V help? Are there any plans to simplify the stack? I mean, the new one's are already risc-v based and they added tier-3 compiler support for those in rust recently (1.56 IIRC), not sure if they still plan to release xtensa based ones in the future.
- po1nt 5y agoYes but they didn't yet release dual-core RISC-V based or did I miss it? I use it's dual-core capabilities extensively as I heavily utilize WiFi and still have to maintain low-latency processing of IO input. Didn't look much into RISC-V ESP but does it have some interrupts without multiplexor?
- tlamponi 5y agoYes, esp32-c3 [0] can be bought already, e.g., from mouser [1] or sparkfun [2] either as dev kit or as native module for a self-designed PCB. [0]: https://www.espressif.com/en/products/socs/esp32-c3 https://www.espressif.com/en/products/socs/esp32-c3 [1]: https://www.mouser.de/new/espressif/espressif-esp32c3wroom02-wifi-ble-module/ https://www.mouser.de/new/espressif/espressif-esp32c3wroom02... [2]: https://www.sparkfun.com/products/18034 https://www.sparkfun.com/products/18034
- Hendrikto 5y agoAt first, I thought the article was about oxidizing chips.
- jeroenhd 5y agoOh, this is exciting. I've been trying to get PlatformIO to play nicely with my ESP32C3's but it's been a pain. Only the standard Espressif RTOS tooling seems to do anything but hang the chip for some reason, and I don't know enough about PlatformIO to modify my config to make it work or to open an issue on Github. Replacing one complex, half broken tool chain with another isn't such a bad deal, and I'm very much in favour of writing Rust instead of C(++).
- tlamponi 5y agoI may not had to much nerves to just wrestle the initial learning curve, but my experience for PlatformIO was so bad that I do not plan to touch it ever again... All you need is a compiler, a flash tool and maybe (nice to have but for a lot of stuff not a requirement) a JTAG debugger, so why the heck does I need that half baked, overly complex monster of pseudo IDE? The tooling shown by ESP-rs seems nice and simple, I like that way more.
- stavros 5y agoPlatformIO doesn't have an IDE, it's a dependency/compilation/flashing manager, and is fantastic. There's also PlatformIO IDE, which I've never used.
- jeroenhd 5y agoTo be fair to PIO, when I used another chip (an ESP8266) the entire process was plug and play. Just install the VS Code extension, follow the wizard, and you can start with an Arduino-compatible system loop that just works. Adding libraries is easy and intuitive, as is keeping them up to date. If you need to manually configure the tool for your devices, well... I haven't figured out how to configure it for my ESP32C3 yet, so that's not as easy as I'd hoped.
- nextaccountic 5y ago> The custom toolchain is a hindrance to developer onboarding, especially if developers have to build it themselves. We now offer a prebuilt toolchain's for all common OS's under the esp-rs/rust-build repository. Is it possible to install and manage this pre-compiled custom toolchain with rustup? Maybe using the RUSTUP_DIST_SERVER variable to point rustup to a different server, https://rust-lang.github.io/rustup/environment-variables.html https://rust-lang.github.io/rustup/environment-variables.htm...
- hedgehog 5y agoDoes anybody do this for other platforms? It would be rather convenient to have installable docs for stable-aarch64-apple-darwin.
- eggy 5y agoI am toying with SPARK on smaller chips. You can gradually replace parts of C code, like I think you can in Rust too, and work up to doing full-scale replacement or projects from scratch with SPARK on embedded devices, which has a lot of the benefits of Rust and then some[1][2]. I am a polyglot with certain biases/strengths in some PLs over others, so perhaps my early 80s experience with Pascal makes Ada/SPARK2014 easier for me than Rust. I understand the Ada/SPARK concepts better. I think Zig[3] will also become more popular on embedded devices for existing C programmers because its a smaller jump to make than in learning Rust, at least that has been my experience. I also enjoyed reading "Building High Integrity Applications with SPARK" which involves the , and maybe if there were a similar book for Rust, I would attempt Rust again. Because SPARK is "a formally analyzable subset of Ada 2012", it benefits from Ada's age. VTC (Vermont Technical College) launched a Cubesat into orbit on November 19, 2013 running SPARK. Rust and SPARK/Ada have been cross pollinating each other with advances in software integrity which is a win-win scenario. [1] https://blog.adacore.com/ada-on-the-esp8266 https://blog.adacore.com/ada-on-the-esp8266 [2] https://blog.adacore.com/how-to-prevent-drone-crashes-using-spark https://blog.adacore.com/how-to-prevent-drone-crashes-using-... [3] https://ziglang.org/ https://ziglang.org/ Edit: I hope Amazon's involvement in Rust helps it to mature.
- jamincan 5y agoOut of curiousity, what do you feel Rust would need to reach maturity?
- eggy 5y agoIt needs more resources coming from practitioners rather than early adopters or software engineers; it needs more time to mature, and I think it will. It is just not there for me yet, and I am no longer a spring chicken. The SPARK book I cited is an excellent book written by end users with sufficient background on the subject matter and a pretty cool real world application (Cubesats), rather than by software engineers or developers. I bought another great book, "Analysable Real Time Systems: Programmed in Ada" by Alan Burns and Andy Wellings. I am learning so much from these two books. I've played with over 20 PLs in my life, and syntax is not important as it once was, although I love APL's symbols! But even in APL it is the sophistication and expressivity of the language that amazes me whenever I play with it. Verifiable software, high-integrity software, and the like are best taught by being able to study or use working and proven applications. The uptake of Rust is impressive, so all of this is starting to happen, and maturity just means anything beyond its nascence with some long term applications under its belt, not a hard date or time period.
- ahepp 5y agodoes esp32-rs have working wifi yet?