Live data from Hacker News

Fearless concurrency in your microcontroller

blog.japaric.io

1–10 of 52 posts

Re: Fearless concurrency in your microcontroller

#2
Amazing writeup. Note the previous submission here as well: https://news.ycombinator.com/item?id=14225614

Rust actually gives me some hope that we might see better low-level code portability between some of these microcontrollers.

In theory I could develop a project on a beefy TI microcontroller using higher-level Rust primitives/libraries and port it over to the cheapest microcontroller I can find that still fits my I/O budget/speed/memory/timer constraints. All that without having to use a RTOS or having to drastically re-write interrupt/timer code to whatever system the new controller uses.

Does Rust support Atmel AVR through LLVM yet?

Re: Fearless concurrency in your microcontroller

#3
I really hope rust gains a foothold in the embedded market. We need these features badly. As uCs get more powerful (you can get 200mhz chips for a few dollars) with more RAM and complicated networked peripherals, it's a no-brainer to have these features available in a safe way. Currently if you have an application relying on dynamic memory usage, for instance, most developers will write their own simple memory management, usually in which you have an array that various things hold pointers to and get's freed all at once. All that just to spread some memory around, and concurrency is an even dirtier word than the heap...

Re: Fearless concurrency in your microcontroller

#4

I really hope rust gains a foothold in the embedded market. We need these features badly. As uCs get more powerful (you can get 200mhz chips for a few dollars) with more RAM and complicated networked peripherals, it's a no-brainer to have these features available in a safe way. Currently if you have an application relying on dynamic memory usage, for instance, most developers will write their own simple memory manage…

Otoh controllers cost almost nothing, so you can get safe concurrency just by duplicating the CPU.

Re: Fearless concurrency in your microcontroller

#5
post #4

I really hope rust gains a foothold in the embedded market. We need these features badly. As uCs get more powerful (you can get 200mhz chips for a few dollars) with more RAM and complicated networked peripherals, it's a no-brainer to have these features available in a safe way. Currently if you have an application relying on dynamic memory usage, for instance, most developers will write their own simple memory manage…

Otoh controllers cost almost nothing, so you can get safe concurrency just by duplicating the CPU.

You're not wrong, but this is sort of like saying that CPU's cost nothing, so just replace your i5 with 4 celerons. Distributed programming is even harder than multi-threaded programming if you need tightly coupled communication. Imagine you need to read an ADC (think oscilloscope output if you're not familiar) at 1MB/s and also need to be analyzing the data while talking to other devices on various peripherals about what you've found. You'll have to use Direct Memory Access most likely so communicating that data stream over SPI to another microcontroller might not be the best idea unless you have a lot of extra RAM to buffer everything in.

Edit: and the real reason you don't want to do this is because the EEs and manufacturing engineers on your project will try to kill you. Two uCs means two codebases and two devices to program during production, plus extra testing, more complicated design, and more parts to place (uC, crystal, caps, etc)

Re: Fearless concurrency in your microcontroller

#6
post #2

Amazing writeup. Note the previous submission here as well: https://news.ycombinator.com/item?id=14225614 Rust actually gives me some hope that we might see better low-level code portability between some of these microcontrollers. In theory I could develop a project on a beefy TI microcontroller using higher-level Rust primitives/libraries and port it over to the cheapest microcontroller I can find that still fits my…

> Does Rust support Atmel AVR through LLVM yet?

See http://dylanmckay.io/blog/rust/avr/llvm/2017/02/09/safer-mic... for an overview; 4.0 has been merged, but see https://github.com/rust-lang/rust/issues/37609#issuecomment-...

Re: Fearless concurrency in your microcontroller

#7

I really hope rust gains a foothold in the embedded market. We need these features badly. As uCs get more powerful (you can get 200mhz chips for a few dollars) with more RAM and complicated networked peripherals, it's a no-brainer to have these features available in a safe way. Currently if you have an application relying on dynamic memory usage, for instance, most developers will write their own simple memory manage…

Many of those features are already available in Ada, and to a lesser extent Pascal and Basic.

But yeah, more options is even better.

Re: Fearless concurrency in your microcontroller

#8
Nice article. Some good insights, as well as beginner how-to steps.

The embedded industry has proven to be very resistant to innovations and modern code-writing practices. Some platforms I coded for didn't even support/allow C99 standard. C++ is gaining some foothold (mbed, for example). Developers don't feel the urge to catch on with times, like in other industries. And yet, now they are expected to write secure IoT systems.

Hopefully Rust can demonstrate its worth and convert key industry specialists who would blog about it. Personally, I'm still waiting for perfect opportunity to apply it on medium-sized project before I fully commit (secretly I'm still rooting for Nim).

Re: Fearless concurrency in your microcontroller

#9
post #7

I really hope rust gains a foothold in the embedded market. We need these features badly. As uCs get more powerful (you can get 200mhz chips for a few dollars) with more RAM and complicated networked peripherals, it's a no-brainer to have these features available in a safe way. Currently if you have an application relying on dynamic memory usage, for instance, most developers will write their own simple memory manage…

Many of those features are already available in Ada, and to a lesser extent Pascal and Basic. But yeah, more options is even better.

On an ARM Cortex M4?

Re: Fearless concurrency in your microcontroller

#10
post #4

I really hope rust gains a foothold in the embedded market. We need these features badly. As uCs get more powerful (you can get 200mhz chips for a few dollars) with more RAM and complicated networked peripherals, it's a no-brainer to have these features available in a safe way. Currently if you have an application relying on dynamic memory usage, for instance, most developers will write their own simple memory manage…

Otoh controllers cost almost nothing, so you can get safe concurrency just by duplicating the CPU.

Never trust a sentence with the word "just" in it.

Duplicating the microcontroller on a project where people spend all afternoon arguing about 10 cents on the BOM is not a welcome idea. Also, the most eye-opening required course I took as an undergrad was reliability engineering. After you learn to do the reliability math, adding several solder joints to the product purely out of laziness looks profoundly stupid. Neither idea makes you look good to the old grey-beards on the other side of the table at the design review.

Post reply on HN