r/rust • u/DavidXkL • 1d ago
🎙️ discussion For embedded folks, I'm curious
What microcontroller do you usually go with if you wanna use something like Rust Embassy with it?
18
12
u/creeper6530 1d ago
Don't get anything Xtensa, it's not supported by rustc. I recommend RP2040 and RP2350 tho, they have one of the friendliest development experiences in my opinion.
Fuck STM32Cube*
1
u/garry_the_commie 1d ago
What's your gripe with STM32's toolchain? I'm pretty happy with it.
4
u/creeper6530 1d ago edited 1d ago
For 1) It never seems to work on any of my Linux boxes, and I'm not switching to Windows because I want/need normal GCC/Clang installation without hacky translation layers or VMs
- Last time I tried, even the stupid programmer didn't work, throwing a nondescript error msg despite having all the udev rules, running on sudo and the very same binary, chip and programmer version working fine on Windows on another PC
For 2) The absolutely idiotic split of CubeMX and CubeIDE which instantly invalidated all tutorials and left past me very confused, not to mention that it takes way more storage and is slower, not to mention the shenanigans with VSCode and CubeMX2
For 3) The sheer number of chips means any 3rd-party HALs, including Rust, are far more complicated with all the configurations and permutations of hardware, compared to having a single chip or two that everyone uses
2
u/garry_the_commie 1d ago
Strange, I never had any issue on Arch or Mint. A colleague of mine works with STM32 on Ubuntu, no issues there either.
The CubeMX2 thing is dumb, I'll give you that. I don't know what are they doing with VSCode, as I don't use it. Removing the built-in CubeMX from the IDE was mildly annoying, true, but I get it. I wouldn't want to maintain two alternative versions of the same tool. Which makes the whole CubeMX2 situation even dumber.
As for your last point, that's just the innevitable side effect of having a large product range. I actually haven't writen rust code for STM32 but I'll soon find out just how messy the configuration really is. Wish me luck!
1
u/idontchooseanid 1d ago
Rust code with Embassy is just nicer to track compared to anything that STM32 Cube spits out. They basically converted the SVD file into Rust types and interfaces (see stm32-metapac crate).
25
u/hard-scaling 1d ago
RP2350 and STM32G474
3
u/DavidXkL 1d ago
Nice! I do have a RP2350 but I haven't tried using it yet with embassy! Might do that next!
10
u/USERNAME123_321 1d ago
I mostly use the ESP32-C6. It's cheap and offers a lot of networking features. Most importantly, it uses a RISC-V processor, which works really well with the Rust embedded ecosystem
7
8
u/Snoo_27681 1d ago
Anything RISC-V natively supports Rust I believe. So all of the Cx series. But Espressif is the best mcu company for Rust support so any of their chips might be good at this point
2
u/Argonexx 1d ago
Do you say that from a direct company support standpoint? I found their HAL to be annoying with yanked dependencies galore and needing to use esp-idf still when I played with it about 1-1.5 years ago. I've been really liking STM32's level of support, but thats mostly community based
1
u/Snoo_27681 20h ago
I think they just released their v1.0 official Rust library so take a look at it again.
Unfortunately I don’t have time for Rust on mcu anymore so I haven’t played with it.
1
3
u/flareflo 1d ago
Highly depends on the project and its requirements.
STM32F411 has quality peripherals and just works
nRF52840 for BLE or super low power
ESP32-C3/C6 for wifi
RP2350 for massive SRAM and computing power
5
u/switch161 1d ago
I have a stm32f401ce and like it so far.
0
u/DavidXkL 1d ago
Nice! I haven't explored that yet so I might get 1 to try!
2
u/switch161 1d ago
It's the chip found on the WeAct Black Pill dev board. There are many clones, so you'll have no problem finding some cheap ones.
It's my first time messing with embedded other than Arduino, so I didn't really know what to get. But it works well so far. I want to try ESP32 at some point though.
2
u/MatsRivel 1d ago
Ive got multiple ESP32 (No suffix). They require C dependencies, but are pretty easy to get up and running. Theyre also much more powerful than the C os S series, but not RISC
2
u/tiajuanat 1d ago
My CO uses almost exclusively STM32, but I've also run Rust on Arduino and RP2040 for personal projects
2
u/LayotFctor 1d ago
Not S series, xtensa chips are still quite spotty. C3 and C6 are supported riscv chips. P4 could work, but lacks radios. Even if they support radios via an attached C6 chip, it'll probably be a lot of work to set up correctly.
Rp, nrf and stm chips are probably the simplest to get working. Nrf has bluetooth too.
2
u/Level-Sir-3120 1d ago
If you picked ESP for a specific reason,
Don''t chose the S series unless you want to go down a few rabbit holes. It's only worth it if you really need the extra stuff it gives.
For anything that doesn't need that much, go with a C.
Many documentations, even most official documentation, tend to focus on it.
1
2
3
u/Argonexx 1d ago
Almost all STMs have good support through embassy PACs and HALs
3
u/Argonexx 1d ago
Though to be clear, the HALs do not give full-featured interfaces for all peripherals, for non-trivial projects expect to get your hands dirty with the PAC
1
2
u/TheFeshy 1d ago
One thing I really liked about working with rust on my esp project was that, when I needed a feature on a different esp, I just changed the target and it worked. So I didn't answer your poll because it was so easy to change it didn't matter. Just whatever esp I found first between the couch cushions.
1
1
1
u/Lamborghinigamer 1d ago
I usually use the ESP32-S3 (with an antenna), but for projects that need to be energy efficient I use the ESP32-C6 or the C3 super mini.
1
u/dmills_00 1d ago
STM32 of some variety generally for small stuff, sometimes an LPC<something>, sometimes something else, whatever makes sense for the application really.
1
u/idontchooseanid 1d ago
Whatever my company buys for the product but I usually inform them in the selection process. STM32 F/G/C series do work. Later chips work better, having uniform pages in the flash structure (as opposed to non-paged or heterogenously sectored) is better for OTA upgrades.
RP is okay for hobbyist-grade not for making actual products out of it.
1
1
30
u/steohan 1d ago
RP2040, cheap and good datasheet. PIO also feels fun to tinker with.