Close

Hack Chat Transcript, Part 2

A event log for Embedded Rust Hack Chat

Rust never sleeps

Dan MaloneyDan Maloney 05/12/2021 at 20:120 Comments

Trevor R.H. Clarke12:43 PM
@James Munns I agree crates, etc. make the library management and board management easy to implemented...maybe some extensions to vscode or similar to add a nice gui to everything + a basic event loop already setup with a setup/loop...

James Munns12:43 PM
@dkhayes117 that would be cool! We put a lot of work to make sure tools like probe-run work with editors like VSCode

Timothy McKenna joined the room.12:43 PM

Funny, I was just going to ask about Rust in VSCode...

hpux73512:43 PM
It's _excellent_

James Munns12:43 PM
> I agree crates, etc. make the library management and board management easy to implemented...maybe some extensions to vscode or similar to add a nice gui to everything + a basic event loop already setup with a setup/loop...

Check out https://github.com/knurling-rs/app-template !

James Munns12:44 PM
We even include vscode configuration and unit tests (on/off hardware) already set up!

john12:44 PM
@James Munns , what about the other side of the wire? any production ready MQTT brokers? I've found some obscure bugs in mosquitto

Trevor R.H. Clarke12:44 PM
so in short....<generic question about embedded rust> Answer: Knurling

anfractuosity12:44 PM
What IDE do you use in linux out of interest (or does vscode work in linux now, i'm not sure?)

James Munns12:44 PM
I mean, Knurling is specifically my company's open source project to round off the rough edges of embedded development :)

Yes, VSCode works in Linux.

anfractuosity12:45 PM
aha, ta

WooDWorkeR12:45 PM
since years? or forever?

James Munns12:45 PM
> What IDE do you use in linux out of interest (or does vscode work in linux now, i'm not sure?)

I use SublimeText most of the time, other folks I know use VSCode mostly or some flavor of Vim!

Marek Miettinen12:45 PM
Are there any signs of MCU manufacturers putting any effort into official Rust support? As far as I understand all the current support comes from the community only?

deʃhipu12:46 PM
I suppose those who use emacs program in lisp ;-)

Trevor R.H. Clarke12:46 PM
not rust,,,but I've had a lot of luck with vernemq as an MQTT broker

john12:46 PM
yeah, the old erlang

James Munns12:46 PM
> I've been looking at using higher level but not interpreted languages on microcontrollers, and another contender seems to be Nim. Do you have any insight in why Rust or Nim would be the way to go?

I haven't had much experience with Nim! I really enjoyed circuitpython when I've used it for prototyping, but I've mostly been doing Rust only for the last 3-4 years.

James Munns12:47 PM
> Are there any signs of MCU manufacturers putting any effort into official Rust support? As far as I understand all the current support comes from the community only?

That is pretty accurate. We've talked with some folks, but big momentum to get them interested. We've already started to train larger tech + manufacturing companies. so the open source ecosystem doesn't seem to be a blocker for them! I hope the silicon companies will change their planning soon as well too :)

James Munns12:48 PM
Nordic Semiconductor has also sponsored a number of our events, like the Oxidize Conference, or our Knurling Sessions

skyfire36012:48 PM
@James Munns Do you get the impression that any vendors are catching on to the momentum that Rust is generating and are considering developing Rust SDKs?

James Munns12:49 PM
> Do you get the impression that any vendors are catching on to the momentum that Rust is generating and are considering developing Rust SDKs?

We've certainly talked to a lot, but I'm not aware of any official roadmaps yet. That being said, the OSS support is already huge, and filling the gaps is a bit tedious but pretty quick once you get started!

Marek Miettinen12:50 PM
Exciting to hear Nordic showing some support. I know nothing about the realities of this market, but a wild guess would be that if a manufacturer would make an early investment into great Rust support, they could gain a lot of market share (if embedded Rust catches on)

James Munns12:50 PM
We've build a couple drivers/added support for platform for a couple end-user customers, it's not an unreasonable amount of work.

James Munns12:50 PM
> xciting to hear Nordic showing some support. I know nothing about the realities of this market, but a wild guess would be that if a manufacturer would make an early investment into great Rust support, they could gain a lot of market share (if embedded Rust catches on)

That's what I try to tell them!

john12:51 PM
@James Munns , a lot of my colleagues swear by haskell and brag about how easy it is to make code without bugs ... is rust good enough to save me from learning haskell? ;) ;)

skyfire36012:52 PM
@James Munns SVD files tend to be a bit of a trainwreck from a lot of vendors, to the point where entire projects are spawned to correct them prior to code generation (`svdtools` + `stm32-rs`). Any idea why they're so neglected by manufacturers?

James Munns12:52 PM
> .. is rust good enough to save me from learning haskell? ;) ;)

I think they both share a lot of common benefits, as they come with more expressive type system! Depends on the kind of stuff you do :)

Trevor R.H. Clarke12:53 PM
and haskell is functional so very different paradign

hpux73512:53 PM
It's a funny idea having Haskell on microcontrollers, in a way, because the entire point is side effects

Trevor R.H. Clarke12:53 PM
what rust needs is something like the infamous arduino vibrator workshop

James Munns12:54 PM
> SVD files tend to be a bit of a trainwreck from a lot of vendors, to the point where entire projects are spawned to correct them prior to code generation (`svdtools` + `stm32-rs`). Any idea why they're so neglected by manufacturers?

I dunno, up to now, I think most use of svds were for debuggers, so little inaccuracies weren't so big of a deal. I'm really surprised they don't have a single source of truth between code, datasheets, and svds.

dkhayes11712:54 PM
I'm just a tinkerer, and I found Rust much more approachable than C when working on embedded stuff. Not sure why, maybe because I never drank the cool aid?

Trevor R.H. Clarke12:54 PM
where there was a maker faire in the same hotel at the same time as the annual porn film awards...they setup a workshop to show the actresses how to modify and program their vibrators with arduino

James Munns12:54 PM
> and haskell is functional so very different paradign

You can do a lot of functional stuff on embedded

skyfire36012:55 PM
"I'm really surprised they don't have a single source of truth between code, datasheets, and svds." That makes two-... err, well, I guess a lot of us :)

Trevor R.H. Clarke12:55 PM
I do a fair amount of Forth on micros...not functional but similar ideas

James Munns12:55 PM
Like this iterator-driven, DMA SPI driver:

https://github.com/nrf-rs/nrf-hal/blob/master/nrf-hal-common/src/spim.rs#L296-L344

James Munns12:55 PM
(it ended up compiling smaller/faster than my old for-loop approach)

James Munns12:56 PM
> "I'm really surprised they don't have a single source of truth between code, datasheets, and svds." That makes two-... err, well, I guess a lot of us :)

If any silicon vendor teams are out there, I'd love to talk to you about code and document generation :)

john12:58 PM
is there any site that offers a way to learn rust by solving challenges?

James Munns12:58 PM
Theres Rustlings!

James Munns12:58 PM

https://github.com/rust-lang/rustlings

GitHub rust-lang

rust-lang/rustlings

Greetings and welcome to rustlings. This project contains small exercises to get you used to reading and writing Rust code. This includes reading and responding to compiler messages! ...looking for the old, web-based version of Rustlings? Try here Alternatively, for a first-time Rust learner, there are several other resources: The Book - The most comprehensive resource for learning Rust, but a bit theoretical sometimes.

Read this on GitHub

James Munns12:58 PM
There are a lot of good/free/maintained resources linked here too: https://www.rust-lang.org/learn

dkhayes11712:59 PM
@john https://doc.rust-lang.org/stable/rust-by-example/

James Munns12:59 PM
and https://rustbeginners.github.io/awesome-rust-mentors/ if you are looking for mentors!

skyfire3601:00 PM
@James Munns Out of curiosity, have you seen m4vga-rs from Cliff Biffle? 800x600@60fps VGA on an stm32f4... in Rust. And amazingly well commented/documented too

dkhayes1171:01 PM
@James Munns the mentorship thing looks very cool. I gotta check that out.

James Munns1:01 PM
Nice! I think I have! There's also the Neotron which is a similar project!

James Munns1:01 PM

https://neotron-compute.github.io/Neotron-Book/

Neotron-compute

Neotron - The Embedded Rust Home Computer Platform

Neotron is an attempt to make computers simple again, whilst also taking advantage of the very latest in programming language development. We are saddened by chat clients that require multi-Gigabyte installs, and systems with hundreds of millions of lines of source code that no one person could ever hope to understand.

Read this on Neotron-compute

So we're up against the end of our hour today, and I just want to say thanks to James for his time today. I'm always keen to learn something new, and learning Rust might be a great self-improvement project for me to tackle.

john1:02 PM
I've stripped a hello world for x64, and is still in the hundreds of KB, what's the catch to make it fit in 1KB?

john1:02 PM
besides the I/O library

Trevor R.H. Clarke1:02 PM
Are you using the embedded crates? or standard rust?

And I want to say thanks to everyone for turning out with so many great questions, I really appreciate it. Feel free to keep the conversation going -- the Hack Chat is always open!

Nicolas Tremblay1:03 PM
Tanks @James Munns for this lively chat

James Munns1:03 PM
> I've stripped a hello world for x64, and is still in the hundreds of KB, what's the catch to make it fit in 1KB?

Probably writing it in assembly! Though there are also lots of demo groups like logicoma that do 64K demos in Rust as well

James Munns1:03 PM
Thanks all! It was a ton of questions, but I'll stick around for a bit longer!

James Munns1:03 PM
You can always find me on twitter: twitter.com/bitshiftmask, or on matrix as `jamesmunns`!

James Munns1:04 PM
> Are you using the embedded crates? or standard rust?

On embedded, there are a ton of embedded crates! It's totally the same language/tooling as regular rust, just with a slightly smaller standard library!

FYI, I'll be posting a transcript in a few minutes, in case anyone missed anything and wants to refer back.

James Munns1:05 PM
(my 1KiB example was for a bare metal MCU, not a desktop program!)

john1:05 PM
I have to check the links again, but the names of the typical embedded crates, are available somewhere?

Trevor R.H. Clarke1:05 PM
> On embedded, there are a ton of embedded crates! It's totally the same language/tooling as regular rust, just with a slightly smaller standard library!

that's what I Was getting at...if he's compiling standard rust there's a lot more stuff in there so 1kb isn't going to happen

James Munns1:05 PM
https://github.com/rust-embedded/awesome-embedded-rust is a good list to browse!

john1:06 PM
@James Munns , thank you very much for your time, and all the answers!

Matt1:06 PM
Are there any good libraries or approaches for parsing protocols or files with data not falling on byte boundaries?

James Munns1:07 PM
Things like bit packing?

Matt1:07 PM
yes

James Munns1:08 PM
docs.rs/nom/ for parsing, and docs.rs/bitvec for working in-mem are probably my best suggestions!

James Munns1:08 PM
But for most serialzation/deserialization, the Serde ecosystem is really good! serde.rs/

James Munns1:08 PM
(it typically more works on the byte level tho, but it's not a hard requirement)

Matt1:09 PM
Thanks for all the advice, hopefully I will get a chance to take the Knurling stuff for a spin soon!

Discussions