Live data from Hacker News

Embassy: Modern embedded framework, using Rust and async

github.com

141–150 of 167 posts

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

#141
post #66

I'm loving Embassy. Coming from a lot of bare metal C and FreeRTOS it finally feels like embedded is getting a toolchain that is actually modern and better. Some of that isn't just Embassy but the surrounding ecosystem, some highlights: * probe-rs w/cargo run integration * defmt logging (combined with probe-rs and rtt it's very nice) * embedded_hal (and in my case stm32-rs) I have also tried RTIC but I decided to kee…

Can it use multiple cores, eg on the ESP32? It doesn't so say on the landing page. UPDATE: it seems so, using a second executor. There is "embassy_sync" to communicate.

Absolutely. I'm using it on RP2040, and it's actually superfun to have real low-level code working in parallel.

In my case, one CPU is doing the CAN-based communication and the device control loop, and the other core is providing the IP-based interface with SNMP-based monitoring.

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

#142

I’ve been enjoying Embassy most at the application pattern layer: long-lived device tasks that hide timing and coordination behind a small, typed async API. For example: loop { let btn = ir.wait_for_press().await; // use btn } Meanwhile the compiler builds the state machine for you. I think this style is an emergent property of async + no-std that hasn’t really been collected or named yet. A lot of discussion focuses…

This isn't just useful for high-level application logic! (If I'm catching your drift from "the compiler writes the state machines for you). I used to write extremely low-lebel NIC firmware that was basically a big bundle of state machines. Rust wasn't ready back then but I was desperate for something like coroutines/async. I think it would have been incredibly valuable. (There are tricks to do coroutines in C but I t…

A way to implement coroutines in C is via protothreads. I admit that they are a bit hacky - but you can get quite far with them. I used them to implement an Esterel/Blech like environment: https://github.com/frameworklabs/proto_activities

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

#143

Earlier quoted context omitted.

>Watchdogs exist on MCUs but also on some "proper" computers All modern computers have watchdog. You can check your logs `journalctl -b | grep watchdog` https://access.redhat.com/articles/7129255

Yes, but those are done in software

https://www.freedesktop.org/software/systemd/man/latest/syst...

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

#144

Earlier quoted context omitted.

A watchdog is a piece of hardware that will automatically restart the chip if it detects the code as being stuck. The way it detects this is that you have to poke a register of the watchdog every so often, and if the register hasn't been poked for a certain timeout (usually configurable), the chip is restarted. Watchdogs exist on MCUs but also on some "proper" computers. The Raspberry Pi has one for example.

>Watchdogs exist on MCUs but also on some "proper" computers All modern computers have watchdog. You can check your logs `journalctl -b | grep watchdog` https://access.redhat.com/articles/7129255

That's a software watchdog. The comment you're replying to is talking about hardware watchdogs.

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

#145
post #61

Earlier quoted context omitted.

The claim is you can get embedded concurrency without an OS. Do you disagree? I prefer C for embedded but must admit that's pretty compelling.

The claim is it "obsoletes the need for a traditional RTOS with kernel context switching." I don't think the authors understand what an RTOS is, because it has very little to do with concurrency. It is about providing hard guarantees about execution timing of interrupt events. E.g. you need to poll an input port every 20ms, or something like that, because that's when the signal will be on the wire. Not "Please wait a…

My perspective is that RT is not the most important thing for most or all of my projects. Concurrency on the other hand is very useful to me, and one of the main reasons I would need an RTOS. So for me embassy would potentially obselete the need. I agree that's not going to be the case for everyone though.

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

#146

Earlier quoted context omitted.

This isn't just useful for high-level application logic! (If I'm catching your drift from "the compiler writes the state machines for you). I used to write extremely low-lebel NIC firmware that was basically a big bundle of state machines. Rust wasn't ready back then but I was desperate for something like coroutines/async. I think it would have been incredibly valuable. (There are tricks to do coroutines in C but I t…

A way to implement coroutines in C is via protothreads. I admit that they are a bit hacky - but you can get quite far with them. I used them to implement an Esterel/Blech like environment: https://github.com/frameworklabs/proto_activities

Protothreads are amazing, but really expose you to a lot of subtle bugs. I would not recommend them for any new projects if something like async rust or an RTOS are options.

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

#147
post #66

I'm loving Embassy. Coming from a lot of bare metal C and FreeRTOS it finally feels like embedded is getting a toolchain that is actually modern and better. Some of that isn't just Embassy but the surrounding ecosystem, some highlights: * probe-rs w/cargo run integration * defmt logging (combined with probe-rs and rtt it's very nice) * embedded_hal (and in my case stm32-rs) I have also tried RTIC but I decided to kee…

>it finally feels like embedded is getting a toolchain that is actually modern and better Last time i tried embassy, it pulled over 100 dependencies just to build a blinky. Its great for hobbyist programming but i doubt its going to be used in any industrial application any time soon.

A lot of those dependencies are from the same project, though. It's just split into multiple crate so you don't need to pull in one mega-lump of code for everything.

(Also, I am currently using it for an industrial application)

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

#148

Earlier quoted context omitted.

And you are downvoted for understanding the issue, of course.

Yup! Which is also the reason why I distrust projects like these in general: bold claims when there is nothing to be backed up with. What else is hiding behind such bold claims?

The claims, including in comments in this thread read to me as "I will make this claim". Then, someone points out that the claim is inaccurate. "I didn't really mean that, I meant slightly softer version". It feels disingenuous.

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

#149

Earlier quoted context omitted.

Yup! Which is also the reason why I distrust projects like these in general: bold claims when there is nothing to be backed up with. What else is hiding behind such bold claims?

The claims, including in comments in this thread read to me as "I will make this claim". Then, someone points out that the claim is inaccurate. "I didn't really mean that, I meant slightly softer version ". It feels disingenuous.

What I'm seeing is an Embassy dev giving hard evidence of how this can be used for real-time tasks ironically proving that the weirdly upset people, who are claiming no one here knows what they are talking about, are in fact the ones who don't know what they are talking about.

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

#150

Earlier quoted context omitted.

Also Xous which is completely independent of Embassy but applicable if you're looking for preemptive multitasking: https://www.youtube.com/watch?v=DaWkfSmIgRs

But requires an MMU.

Well then: https://hubris.oxide.computer/
Post reply on HN