Live data from Hacker News

Embassy: Modern embedded framework, using Rust and async

github.com

51–60 of 167 posts

Re: Embassy: Modern embedded framework, using Rust and async

#51
post #43

I am a big fan of the embassy project and it’s a great example of why async Rust is so great: Because this is possible. It works without a heap, is a really low cost abstraction and you can do stuff concurrently on a single core chip (where you can’t just spawn a new “thread”) and you don’t have the complexity of an RTOS. I believe there is a great future for embassy ahead and it’s so great how far the team has come.…

If you had to pick a MCU to try this out on, do you have a preference for a devkit to test this with?

Also espressif RISC V mcu's like the ESP32-C3 and -C6 are fantastic.

Some Nordic MCUs are easy too, specifically nrf52840.

Have fun!

Re: Embassy: Modern embedded framework, using Rust and async

#52
post #50

> It obsoletes the need for a traditional RTOS with kernel context switching Uh, what does async have to do with hard real-time guarantees?

It doesn't have anything to do with it. It's some nice syntax over cooperative multitasking.

The README should be corrected then. It is currently making a very false claim.

Re: Embassy: Modern embedded framework, using Rust and async

#53

Probably off topic, but what's the best way to get started with embedded development? I've been a web developer for over a decade, but I'd really love to try something much lower level, and I'm currently making my way through the Rust book. I've got a Raspberry Pi on the way, but I assume that's not truly embedded development.

I'm a fan of the RP2040 chip. It's a good trade-off between being simple and capable. There are more powerful chips like the STM32's, but frankly there are too many variants and their data-sheets are nightmarish. And there are simpler chips like the Atmel AVRs, but the tooling sucks. ESP chips are also good, but I haven't kept up with them so can't give much advice.

You'll want a dev board, which has the chip plus some supporting components on it. The Raspberry Pi Pico is a good choice because it's so widely used and well documented.

If you care about Rust, you'll also want to get the Debug Probe. Worth the money.

If you don't care about Rust, any Adafruit dev board should run CircuitPython, have good documentation, and likely some projects you can start with. The reason I don't recommend these for Rust is because many of their dev boards do not "break out"/make available the connections for a debug probe.

Edit: Having a project you want to do is good, but just making an LED blink can be magical, too, especially if you haven't done anything with hardware.

Re: Embassy: Modern embedded framework, using Rust and async

#54
post #23

Earlier quoted context omitted.

How async works with embassy is also interesting. In effect it works like a work queue, when something is waiting on a waker (interrupt) and is woken, the Future (task) is enqueued to be polled (run) by the executor. There’s good and bad things about this. It’s clever for sure but there can be variable latency between when the hardware event occurs and when the next step in the task starts. This is a lot like zephyr/…

Here's a good technical writeup on latency and jitter (latency standard deviation) for interrupts when it comes to Embassy, FreeRTOS, and RTIC: https://tweedegolf.nl/en/blog/65/async-rust-vs-rtos-showdown Obviously if you're working on something truly hard real-time you probably wouldn't be reaching for these tools to begin with, but for the average embedded project it seems you will enjoy quite good latency and jitt…

I've read this, and frankly its comparing apples to oranges. These are not the same things though naively they may appear the same.

Re: Embassy: Modern embedded framework, using Rust and async

#55
post #51
post #43

Earlier quoted context omitted.

If you had to pick a MCU to try this out on, do you have a preference for a devkit to test this with?

Also espressif RISC V mcu's like the ESP32-C3 and -C6 are fantastic. Some Nordic MCUs are easy too, specifically nrf52840. Have fun!

Just got my first esp32-c6 and really excited to start playing with it. The p4 looks like a beast and want to try that out eventually as well. Feels good to be back hacking on embedded again.

Re: Embassy: Modern embedded framework, using Rust and async

#56

Probably off topic, but what's the best way to get started with embedded development? I've been a web developer for over a decade, but I'd really love to try something much lower level, and I'm currently making my way through the Rust book. I've got a Raspberry Pi on the way, but I assume that's not truly embedded development.

I bought one of these on Amazon last week for $25:

https://www.waveshare.com/esp32-c6-touch-lcd-1.47.htm

I've been really impressed. It's basically a hackable Fitbit with no strap or battery. Full wifi, BLE, 6-axis motion. It's was really easy to get the C demos running. LVGL is awesome. Can't speak to Rust. I get enough of that complexity in my day job.

Other brands that look good for beginners are Elecrow and Makerfabs.

I specifically wanted to get into RISC-V, but they all have boards for other architectures as well.

Re: Embassy: Modern embedded framework, using Rust and async

#57

Earlier quoted context omitted.

I don't think a regular Raspberry Pi counts as embedded, although from Embassy's documentation, there is a version of embassy for the Rapberry Pi Microcontroller. https://docs.embassy.dev/embassy-rp/git/rp2040/index.html https://www.raspberrypi.com/documentation/microcontrollers/

I think you’re aware of this already but for everyone else: There’s different kinds of embedded. What traditionally was referred to as embedded is microcontrollers (e.g., 32-bit ARM Cortex M devices like the STM32 or an NXP IMX106x chip ). A configuration for a Cortex-M7 chip (that some may consider on the high end of traditional embedded) is a 600MHz clock, 1MB of RAM, and 4MB of flash memory. These run either bare…

I'm still a noob but it seems like there's also a distinction between bare metal embedded and RTOS, which is higher level. I think STMs are more commonly run bare metal but esp32s use a version of FreeRTOS.

Also libc is bloat :P

Re: Embassy: Modern embedded framework, using Rust and async

#58
post #2

Been using this to build a LoRa relay for the Bitchat app running on nrf52, it's actually very smooth for the most part. The only panics I seem to get are from the Nordic's SoftDevice, not for the ebasssy-rust code itself.

Bitchat is BLE right? Are you using a custom LoRa protocol or bridging to Meshtastic or something?

Re: Embassy: Modern embedded framework, using Rust and async

#59
post #43

I am a big fan of the embassy project and it’s a great example of why async Rust is so great: Because this is possible. It works without a heap, is a really low cost abstraction and you can do stuff concurrently on a single core chip (where you can’t just spawn a new “thread”) and you don’t have the complexity of an RTOS. I believe there is a great future for embassy ahead and it’s so great how far the team has come.…

If you had to pick a MCU to try this out on, do you have a preference for a devkit to test this with?

STM is popular because their lineup is cheap, offers a lot of features, and the documentation is readily available. The flip side is that their errata is lengthy, the Rust HAL is complex to support lots of different designs under the same product names, the documentation from STM is poorly organized and spread out over a zillion different documents, and Mac compatibility needs a gigantic asterisk. You can also get a BlackPill (get the F411 version with 8MB flash) off of AliExpress for $0.99 from WeAct's official store. Unlike STM's own dev boards (Nucleo) you'll need a separate debug probe. Nucleos that'll give you a lot of breathing room can be had for $10-15.

RP is also cheap and has that pretty sweet programmable GPIO and documentation that everyone seems to love. Adafruit has an RP2040 Feather for $12, RP2350 for $15, or with an ESP32-C6 (RISC-V) for $15. NXP has chips with similarly programmable GPIO but they're not well supported by Rust. The RP's PIO stuff is bonkers and potentially very interesting if you wanted to make random protocol dongles. VGA out? Why not?

Nordic stuff looks pretty sweet (and their Bluetooth support seems well loved) but is generally a bit expensive. Dev boards are available from micro:bit and Adafruit, among others.

I've been working on a HAL for an older Atmel SoC and absolutely loved the documentation. But Atmel stuff is expensive. Quality of the Chinese clones is iffy. I set myself back a bit by bricking my one board but am hoping to have a beta release in a month or so.

More recent Atmel/Microchip stuff (D21, D51, E51) has a HAL that the Embassy folks seem to have overlooked. You can get them on Adafruit boards at varying price points.

Or just pick something unsupported and start writing a HAL. It's a great way to get up close and personal with how everything fits together.

The one thing I wouldn't do is get some high end thing to start with. Teensy's (NXP i.MXRT) pack a lot of punch but even their native Arduino libs don't really let you exploit the power. STM's H7 series as well, they're way too complex to use as a learning tool even if they are fairly cheap.

Re: Embassy: Modern embedded framework, using Rust and async

#60
post #43

Earlier quoted context omitted.

If you had to pick a MCU to try this out on, do you have a preference for a devkit to test this with?

RP2040 is really great experience. You can get a debug probe (either buy or make yourself with another RP2040) I cant tell you how awesome it is with minimal setup to get - Full print logging - Option to attach a debugger - cargo r will just flash your code and reset the RP2040

probe-rs is amazing. In ARM land it works with pretty much any CMSIS compliant gear, and yeah you get debugging and logging on pretty much anything as a result.
Post reply on HN