- 12
- 301 514
The Rusty Bits
United States
Приєднався 16 лют 2023
Embedded software development in Rust 🦀
#rust #embedded #firmware
#rust #embedded #firmware
Embedded Rust's logging sorcery
This time we're looking into the no-std logging crate defmt, which has a very clever trick to keep your firmware binaries small...
Chapters:
0:00 Intro
0:35 Part I - Lord of the Strings
4:48 Part II - The Setup
Special thanks to `word` and `long` Patreon supporters!
- David King
- Χάρης Αμαράντηγος
References:
The defmt book | defmt.ferrous-systems.com/introduction
rzCOBS | github.com/Dirbaio/rzcobs
github.com/knurling-rs/defmt
github.com/rust-embedded/cargo-binutils
github.com/johnthagen/min-sized-rust
Chapters:
0:00 Intro
0:35 Part I - Lord of the Strings
4:48 Part II - The Setup
Special thanks to `word` and `long` Patreon supporters!
- David King
- Χάρης Αμαράντηγος
References:
The defmt book | defmt.ferrous-systems.com/introduction
rzCOBS | github.com/Dirbaio/rzcobs
github.com/knurling-rs/defmt
github.com/rust-embedded/cargo-binutils
github.com/johnthagen/min-sized-rust
Переглядів: 10 559
Відео
From Zero to Async in Embedded Rust
Переглядів 29 тис.3 місяці тому
Today we learn about async/await and how it works in an embedded environment by... building an async runtime from scratch in embedded Rust! We also cover time-keeping, state-machines, interrupts and futures.. and a smidge of embassy, which we'll use extensively in future videos. Chapters: 0:00 Intro 1:22 Project Setup 4:11 Timekeeping 8:04 State Machines 18:12 Interrupts 26:23 Futures 45:20 asy...
Blinking an LED: Embedded Rust ecosystem explored
Переглядів 24 тис.7 місяців тому
Today we find several ways to blink an LED, and explore the various layers of abstraction within the embedded Rust ecosystem. Chapters: 0:00 Intro 0:36 Peripheral Control 3:47 Unsafe Rust 6:13 Peripheral Access Crate 8:09 Hardware Abstraction Layer 10:56 Some(Rust) 14:00 Board Support Package 17:03 The Rusty.. Kit? References: ua-cam.com/video/TOAynddiu5M/v-deo.html @letsgetrusty ua-cam.com/vid...
Embedded Rust setup explained
Переглядів 94 тис.9 місяців тому
In this episode we get our development environment prepared for building bare-metal Rust projects. Follow along with your preferred editor & hardware as we begin our journey into the landscape of embedded Rust... and check the errata in the pinned comment below if you run into issues! Chapters: 0:00 Intro 1:03 Tooling 3:00 Hardware 4:10 Cross compiling 6:07 Bare Metal Rust 8:13 Dependency Manag...
Moving from C to Rust for embedded software development
Переглядів 90 тис.10 місяців тому
Writing production-grade firmware is hard, but maybe we're making it harder than it needs to be. Join me in exploring some of the common pitfalls of embedded software development in C, and how Rust appears to be well-positioned to address these issues. Oh, and welcome to the channel! 👋 Resources: @letsgetrusty | ua-cam.com/video/usJDUSrcwqI/v-deo.html @NoBoilerplate | ua-cam.com/video/br3GIIQee...
Ok i got to say I'm really disappointed. Not with the defmt crate, that is great. And not with rust, that is a great language and i've enjoyed using it for native PC apps. I'm disappointed with embedded Rust. Let me set the stage. I've written embedded C code for the last 10 years as a full time job. I have a small personal project that handles several I2C busses with ADCs and DACs, a small display and a USB CDC driver. I originally wrote it in C a few months ago and it took me around 2000-3000 lines. Not a long app, but not a trivial one either, so i decided to try and rewrite it in Rust, as an exercise. It had a good bit of DMA and IRQs that needed quick handling, so i was quite curious how the rust crates handled that one. Now my problems: - The tooling barely works. I was trying to use my Segger Jlink for debugging, and not only did i have to use custom drivers, because probe-rs is utter crap, it still randomly disconnected half the time and you have to restart the session. At some point i'll assemble an original probe-rs probe and see if it works better with their hardware. I hope it does. I skimmed the schematics and it does look like a professional debugger, with level shifters and everything. I also love that its open source. - Crates.io is great, if the damn crates designers decide to use it! Embassy has older versions of the drivers there, the newest once are on GitHub, and all of the examples are for the newest versions!!!! so its just like using C libs, with google random git repositories, but this time the files end with .rs and not .c/.h. - No IDEs provided by chip manufacturers. Its like using STM32 with Eclipse back in 2015. You jumble together 1000 different addons, you configure all of them manually and hope the versions you downloaded are compatible with each other. And of course they are not, and of course the config files online are outdated since, the versions changed, and you have to go digging around for hours in order to get basic functionality to work properly. Somehow f**ing Microchip with their bloated, slow and huge IDE have a better dev experience. - And not the big two - size and speed. I implemented only a the ADC handling from the original app in Rust and nothing else! Yet the binary was almost the same size as my full C app. The C app that had multiple fonts for the display stored in flash was comparable in size with the rust app, that had some I2C DMA code and some printing. - And the speed ... dont even get me started on the speed. The delays between the DMA I2C transfers is orders of magnitude slower in the rust app! I measured it with a logic analyser. I know its not a problem of the language. If i had to guess its a problem with Embassy, but given how wide spread it appears to be, i'm basing my assumption in it. With all that being said, the state of embedded Rust is a lot better compared to 4 years ago when i first had a play with it. I'll give embedded Rust a try every now and then to see how its progressed. I really hope i can switch to it soon, because i'm not a fan of C's memory unsafety. And yes, i'm fairly new to rust and this may all be skill issues. Still i feel like i'm fighting the tooling all of the damn time.
Thank you for a such helpfull embedded rust world intro! Also, it would be interesting to compare such a simple example with the blinking led between rust and C. I'm a bit confused about the pros and cons of low-level programming using rust in such baremetal cases, since to deal with it we need to go into unsafe mode anyway.
Excellent. I'll be rewatching this to understand how Embassy works "under the hood".
I've been programming for decades, but I'm quite new to Rust. Having watched about half of your videos so far, I really like how you don't just jump right to the end-state offloading all the inner workings to a library. Instead, you start from first principals and work-up a basic implementation that clearly demonstrates the concept before showing the library short-cut. This kind of teaching really helps developers grow from committers to _contributors_! ☺ Look forward to seeing more!
+1
Amazing video! Fantastic quality.
Im curious, is async aproach good for lets say real time audio. For guitar amps or pedals.. When you have audio thread that is highest priority, and must not be blocked ever. Is classical RTOS aproach better than?
In `embassy`, you can run multiple executors even in a single-core system, with lower priority tasks running on the default thread-mode executor, and higher-priority tasks running in interrupt executor(s) (running in ISRs). For extremely time-sensitive stuff, you can always run your own ISR logic in tandem with the normal async executor, or use a framework like RTIC that is usually better-suited for that type of thing. A long way of saying.. it depends 😀
o9veoy v8de9ö
I have never subscribed this quickly before. Well done. :)
Have you ever had any issues where messages are randomly not shown? Thanks so much for this video!
This could be caused by an undersized RTT buffer: by default, if you try to add a new message into a full RTT buffer, the new message(s) will be dropped.
Thanks!
Thanks again! 😊
Thanks!
Thank you! 🙏
I watched the whole video. PLEASE consider doing a complete tutorial for Rust. I like the way you explain things.
All I can say is KEEP DOING WHAT YOU ARE DOING! I am starting out with Rust with the intent that I am also going to use it in embedded systems. You are top drawer and I am going to keep coming back for more!
I would love to see some STM32H based projects. My favorite board now is the Arduino Giga R1 (STM32H747XI) with the Giga Display board. This is for my Robot Smart Home Controller.
i think you have done a great video on the topic! thank you so much!
Pieces of this video went right over my head due to inexperience, but this talk [ua-cam.com/video/H7NtzyP9q8E/v-deo.htmlsi=eeVPFC9iHGsHWivR] by the Embassy creator helped clear things a lot more.
I aprreciate the work put into this video. But when I tried following it myself I found the explanations to be too advanced to the point where I couldn't make sense of anything and I got really discoureaged by the experience.
You made me sit down and think how concurrent tasks are usually implemented using state machines, thanks for this amazing work!
I see that you convert a Result type to an Option type in several lines of code using the the .ok function but not using the resulting value. Why convert the Result into an Option without using the value?
I believe this is in reference to the calls to drive the LED: the `embedded-hal`'s `OutputPin` trait methods `set_low()`/`set_high()`/`toggle()` are specified to return a `Result`, but because this is effectively just a write to memory, the implementation in the HAL always returns `Ok(())`. This is the case for the `nrf52833-hal` used by the `microbit-v2` BSP, but I suppose maybe its possible in some other hardware that has to do something more complicated than an MMIO write might fail, so having that flexibility of returning a `Result` in the trait definition is probably a good thing, although having to deal with it in the vast majority of use-cases is a bit unfortunate..
What crate is being used at 0:11 for interfacing with the ublox module? I just noticed it in passing. I have found a the ublox-cellular-rs crate, but was wondering if there was another I missed.
This is unfortunately just a simulation of driver debugging via logging and not an actual crate… Used a number of cellular modems in my last job and discovered a lot of undocumented behavior this way.
This is gold, thank you
fantastic teacher.
Realy looking forward to the next one. Your channel will blow up, trust me. Can I invest somehow? 😅
My favorite part about Rust .. rewritting something you just wrote lol
This is the way 😅
Great Job, good starting point. I'll change to Rust.
This video is life! Love it top to bottom. This is why I love engineering and love my fellow engineers. I literally laughed out loud several times. #subscribed
I've been using Rust in quite a few embedded systems, bit fan here :)
Fascinating video
Very clear. Nice. I especially appreciated the tail joke.
Very good. I'd love to see something similar at an even lower level - i.e. getting something running with no code dependencies and then building up slowly until it becomes obvious what the dependencies are (at least roughly) doing.
I like that your RTT buffer is 8 times the total SRAM on one of my favourite microcontrollers. :)
Yeap, subscribed! Amazing video
This feels a lot like Windows ETW. Nice.
Please continue making videos. You are clearly an expert and have consistently high quality.
Content ok.... All the goofiness and over the top drama? not so much really.
Oh, I think I have a nice usecase for this Having a tiny MCU in a device and bigger wi-fi enabled mcu as an addon will allow me to keep firmware tiny and have formatting happen on big MCU if it's connected
Thank you for your videos!😊
Amazingly presented, love the editing and storytelling and the pace
Can't wait for that future video now!
These videos are great! After coming from Arduino serial printing, using defmt for the first time straight up blew my mind. I am also at the point now where I would benefit greatly from being able to transmit my defmt logs wirelessly, and have also wondered about the versioning issue. Looking forward to your next video!
I was wondering about how to accomplish that. Do you have any ideas about how to actually accomplish that?
Would love to see a non debug probe setup for this. Great video as always!
Isn't this basically like protocol buffers
It does give the same vibe. There's a crate called postcard-rpc that implements that for embedded systems (but your PC would need to run postcard-rpc too to decide the messages)
Good video
Keep going, you deserve more subs
What about the tracing crate, is it used in embedded?
AFAIK tracing isn’t used in embedded/no-std systems
I've read the thumbnail as "Deform your legs". Insert "instructions unclear" meme
Nicely explained, can't wait for the follow up video about this topic!
Now I finally understand what defmt does differently, thank you
This is really fantastic! Thank you! I loved zero2prod. You’ve accomplished the same thing here for embedded Rust. I was an embedded C++ dev for four years. Now, for the first time in ages, I’ve got the itch to play with a microcontroller - this time in Rust 😛
Wow, love that defmt after what I've seen here😆