From Zero to Async in Embedded Rust

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ธ.ค. 2024

ความคิดเห็น • 123

  • @therustybits
    @therustybits  3 หลายเดือนก่อน +3

    FAQ
    - 21:53 : Is `RefCell` really needed with `Mutex`? Doesn't `Mutex` already provide interior mutability?
    - The `critical_section::Mutex` is a bit different from the `std::sync::Mutex` in that the former does not provide interior mutability, for reasons described here: docs.rs/critical-section/1.1.3/critical_section/struct.Mutex.html#design

  • @Kaptime
    @Kaptime 3 หลายเดือนก่อน +21

    This is the exact kind of top to bottom project breakdown that can onboard people very quickly 10/10 video.

  • @danjadave
    @danjadave 9 วันที่ผ่านมา +1

    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!

  • @FernandoMumbach
    @FernandoMumbach 3 หลายเดือนก่อน +120

    After developing for years C/C++ in anger for embedded, I can see now why people talk good about rust. A lot of verbosity, but things make sense. And it seems like it won't give you nightmares at night while you wonder if your medical unit will kill somebody some day because you had a dangling pointer!

    • @thegrandnil764
      @thegrandnil764 3 หลายเดือนก่อน +4

      Arena allocators.

    • @FernandoMumbach
      @FernandoMumbach 3 หลายเดือนก่อน +1

      @@thegrandnil764 ha, if only

    • @НиколаевВасилий-н3б
      @НиколаевВасилий-н3б 3 หลายเดือนก่อน

      Ha.
      Like complete novice in embedded that seems to me like endless pulsing pain.
      I can say I'll take that pointer and heck I'll take the road. Metal oxidation forms let me begin.

  • @jackkendall6420
    @jackkendall6420 3 หลายเดือนก่อน +98

    Now this is *content*.

  • @FedynaPavlo
    @FedynaPavlo 3 หลายเดือนก่อน +33

    I’m now half way through the genius „Zero2Prod in Rust“ book. You should *absolutely* write one but for embedded in Rust.

    • @therustybits
      @therustybits  3 หลายเดือนก่อน +19

      Zero to Production is a fantastic book; I don't think I have it in me to write one though 😅
      In my case, the video series is the book/course...

    • @vikaspoddar001
      @vikaspoddar001 2 หลายเดือนก่อน

      @@therustybits you can write it, can you create a crate for extending cargo for managing embedded development. like we have platformIO

  • @anandmoon5701
    @anandmoon5701 3 หลายเดือนก่อน +18

    This comprehensive guide delves deeply into Rust programming, covering all the techniques used in this program.
    Great job!, I’ll try out this code on my end.

  • @indierusty
    @indierusty 3 หลายเดือนก่อน +20

    Loved that it is Project based explanation. I now understand how concurrent programming work. I was struggling with the concept for months really. Im a in high school student so this is very useful video. Thank you.

  • @JordanRobinson-w6w
    @JordanRobinson-w6w 3 หลายเดือนก่อน +5

    I just recently watched your other videos and when I discovered that they were from 5+ months ago and you only had 3 others I was so sad. So imagine my surprise and absolute joy to find that there is a new video now. I'm so glad you're still continuing with these videos I find them imeasurably helpful and I am captivated by the way you present and discuss topics. Please never stop, your content is amazing!

  • @ChidleyITCompute
    @ChidleyITCompute 5 วันที่ผ่านมา

    Excellent. I'll be rewatching this to understand how Embassy works "under the hood".

  • @J-Kimble
    @J-Kimble 3 หลายเดือนก่อน +6

    Great video! Low level async and embedded, two of my high interest topics at the moment!

  • @farukhalilagic2070
    @farukhalilagic2070 2 หลายเดือนก่อน +1

    Thanks!

  • @jan_the_man
    @jan_the_man 3 หลายเดือนก่อน +5

    Damn this is some quality explanation! Answered a lot of questions I had related to embedded. Keep it up man!

  • @Eekhoornz
    @Eekhoornz หลายเดือนก่อน

    You made me sit down and think how concurrent tasks are usually implemented using state machines, thanks for this amazing work!

  • @namr2000
    @namr2000 2 หลายเดือนก่อน +1

    Very nice video, I am thinking about using Embassy for some new embedded projects at work but was a little queasy on using something (async/await) that I did not fully understand. This video gave me a lot of insight and (slightly) more confidence. Thank you for taking the time to make such a great resource!

  • @Sillyvan
    @Sillyvan 3 หลายเดือนก่อน +1

    Best Embedded Rust out there so far. For me a tick fast in some places due to not being to familiar with the embedded eco system in general but its probably smarter to pick up those skills with C first

  • @mehmethekimolu
    @mehmethekimolu 3 หลายเดือนก่อน +6

    Amazing work, was waiting your next video, perfect as always

  • @thaejsooriya3313
    @thaejsooriya3313 3 หลายเดือนก่อน +7

    Wooo new video! Love the content and super useful topic!🎉🎉

  • @irlshrek
    @irlshrek 3 หลายเดือนก่อน +4

    Duuuuuude so sick!! Thanks for this!

  • @MrMassaraksh
    @MrMassaraksh 3 หลายเดือนก่อน +2

    Ahhhh, I just finally manage to make it using rtic and interrupts and here we go new pattern 😂😂
    As always thank you!
    Thrilling to try it

  • @jvcrules
    @jvcrules 3 หลายเดือนก่อน +2

    This is awesome! Ive recently been working on an async executor using C++ coroutines for embedded systems at work, so it was really neat to see some of the parallels.

  • @indierusty
    @indierusty 3 หลายเดือนก่อน +5

    This is a really good tutorial. Thank you so much for making quality education video.

  • @MaxWeninger
    @MaxWeninger 3 หลายเดือนก่อน +5

    Picking embassy going forward is a very good choice.

  • @JeroenL111
    @JeroenL111 3 หลายเดือนก่อน +3

    Excellent! Very well explained!

  • @Jon4as
    @Jon4as 3 หลายเดือนก่อน +3

    Waiting for a 1 hour Video was so worth it!

  • @descriptionsuchandsuch4709
    @descriptionsuchandsuch4709 3 หลายเดือนก่อน +1

    Oooooo NICE! A new video from my new favourite Rust channel! Can't wait to watch it this evening!

  • @IvanDeMarino
    @IvanDeMarino 3 หลายเดือนก่อน +2

    Yeah, new video! Just yesterday I was leaving a message asking for one, and here we go!!!

  • @topper2kuk
    @topper2kuk 2 หลายเดือนก่อน

    Dude! loving the execution and format of videos. Looking forward to the next rusty bit

  • @teuluPaul
    @teuluPaul 3 หลายเดือนก่อน +1

    fabulous video (again!) - many thanks for sharing!

  • @HybridRobotix
    @HybridRobotix 24 วันที่ผ่านมา

    I watched the whole video. PLEASE consider doing a complete tutorial for Rust. I like the way you explain things.

  • @thelethalmoo
    @thelethalmoo 3 หลายเดือนก่อน +1

    Awesome! the world needs rust content like this 11/10

  • @unaimillian
    @unaimillian 3 หลายเดือนก่อน +1

    Very great video and visuals during the discussion! 🎉

  • @marcopaolovaleriovezzoli5776
    @marcopaolovaleriovezzoli5776 3 หลายเดือนก่อน +1

    Excellent video as usual. I definitely need to find some time and do my homework.

  • @ThomasLockney
    @ThomasLockney 3 หลายเดือนก่อน +1

    I'm just here to appreciate the copy of Linux Programming Interface sitting on your table in the back. 😂 Seriously, though, love this content and happy to see you're back to it. Just ordered a Micro:bit finally to follow along.

  • @oof-software
    @oof-software 3 หลายเดือนก่อน +1

    I remember when first learning about futures and async, I somehow completely missed the concept of wakers and was really confused until I finally learned about them and it all clicked into place :D

    • @therustybits
      @therustybits  3 หลายเดือนก่อน +2

      I think the approach to teaching async is often top-down, but I much prefer bottom-up: us low-level folks like to know what's going on at the lowest layers, and if you're coming from C then you're likely already familiar with state-machines, so this seems natural.

  • @lorenzorossi2000
    @lorenzorossi2000 3 หลายเดือนก่อน +2

    At 38:37 you may be able to use the mutex directly without the refcell since mutexes already implements mutually exclusive access so you already get a mutable reference. RefCell should ne used when you want to have mutability from an immutable setting (ex. Immutable ref to mutable ref)
    EDIT: Sorry, after some research this is the mutex of the critical section crate that confusingly does not provide interior mutability for better performance 0_o. Embedded rust is quite weird.
    Thanks for the great video! I'll surely recommend it to teach advanced embedded rust!

  • @evertonoriente7150
    @evertonoriente7150 3 หลายเดือนก่อน +1

    Thanks very much about this video, I haven't seen yet but I know is going to be a lot of good information, all your videos it is really helpfull, thanks for this channel.

  • @auggiebuerkle6660
    @auggiebuerkle6660 3 หลายเดือนก่อน +1

    i'm glad you're back

  • @driedurchin
    @driedurchin 3 หลายเดือนก่อน +2

    Instant sub. So good!

  • @trejohnson7677
    @trejohnson7677 3 หลายเดือนก่อน

    some of your points map to react incredibly well, interestingly

  • @maexlich
    @maexlich 3 หลายเดือนก่อน

    Amazing video, great job! It is very very helpful!

  • @jorgegomezreus7019
    @jorgegomezreus7019 3 หลายเดือนก่อน +1

    The video I was waiting for

  • @nathanbanks2354
    @nathanbanks2354 3 หลายเดือนก่อน

    I'm looking forward to the next videos where Embassy is assumed!
    It's somewhat interesting seeing the journey through different ways to do this, and I can see why someone would learn things this way. However it seems to be a video about why async is useful by showing how everything else is worse. The video builds A, replaces it with B, replaces it with C, where A, B, & C do the same thing. An alternative is building A, then go on to A' and A'' where each step adds new functionality using the same system (eg. start with 1 button & 1 LED, add movement, then add blinking, all with async). On the other hand, I've come across async in other languages and in rust web server libraries, and I never tried running or even fully grokking the code, so I thought "Oh cool, async for embedded" rather than "What's async? Why would I need it?"
    Embassy sounds great! I hope the five minute outro is a sign of things to come.

  • @cunningham.s_law
    @cunningham.s_law 3 หลายเดือนก่อน +7

    you should probably test each change on the hardware to make the video more interesting by showing the effect of the change

    • @therustybits
      @therustybits  3 หลายเดือนก่อน +5

      Ah yep, good call... did that in blinky but forgot in this one. Next time!

  • @evertonoriente7150
    @evertonoriente7150 2 หลายเดือนก่อน

    When is coming your video of embassy? :)
    Thanks for this amazing video explain everything inside of the logic of the embassy framework.

  • @daniellarson6279
    @daniellarson6279 3 หลายเดือนก่อน

    Fantastic video! Async and embedded rust are something I've been meaning to get more comfortable with, and this is about as concise as the combination of those two things can be!
    One thing I noticed though while watching was that you used a Mutex, and I'm pretty sure Mutex has interior mutability on its own, so the RefCell isn't necessary.
    I could be mistaken, like I said, this isn't really my wheelhouse, but it just popped out to me.

    • @therustybits
      @therustybits  3 หลายเดือนก่อน

      Thanks! The `critical-section` crate's `Mutex` doesn't provide interior mutability, for reasons described here: docs.rs/critical-section/1.1.3/critical_section/struct.Mutex.html#design

    • @daniellarson6279
      @daniellarson6279 3 หลายเดือนก่อน

      @@therustybits D'oh, that's on me for not noticing it wasn't the std Mutex. That makes sense.

  • @PlayerOne1999
    @PlayerOne1999 3 หลายเดือนก่อน

    Lets GOoooo. love your soft voice😊😊.

  • @danielprimostuart
    @danielprimostuart 3 หลายเดือนก่อน

    Looking forward to the atomic ordering video!

  • @matpala2
    @matpala2 3 หลายเดือนก่อน

    Great video!

  • @krauterbaguette3645
    @krauterbaguette3645 3 หลายเดือนก่อน

    Love this so much ❤

  • @Iswimandrun
    @Iswimandrun 3 หลายเดือนก่อน

    Thank you for the great tutorials.

  • @borkomne
    @borkomne 3 หลายเดือนก่อน +1

    Great video, thanks! Btw, what software do you use to create text animations?

    • @therustybits
      @therustybits  3 หลายเดือนก่อน +1

      Keyframes in Final Cut Pro, just changing position. The default behavior seems to have a nice acceleration/deceleration ramp at the beginning and end, which is nice..

    • @borkomne
      @borkomne 3 หลายเดือนก่อน

      Thanks@@therustybits, the quality of your videos is excellent! Please keep up the great work!

  • @driedurchin
    @driedurchin 3 หลายเดือนก่อน +1

    What still blows my mind about Rust's async is that, in essence, it's identical to the original code, just smarter.

    • @therustybits
      @therustybits  3 หลายเดือนก่อน +2

      Automatically generated state-machines FTW

    • @driedurchin
      @driedurchin 3 หลายเดือนก่อน

      @@therustybits The even more fun part is I got to do this transition for real from state machines in a super loop to asynchronous rust at my work!

  • @vikaspoddar001
    @vikaspoddar001 3 หลายเดือนก่อน

    He is back from the hiatus

  • @The_Nova_Glow
    @The_Nova_Glow 3 หลายเดือนก่อน +1

    Jackpot!

  • @timvw01
    @timvw01 3 หลายเดือนก่อน

    This is great 👍

  • @commissariomontanaro2931
    @commissariomontanaro2931 3 หลายเดือนก่อน +4

    babe wake up, an hour long got posted

    • @johnwu5908
      @johnwu5908 3 หลายเดือนก่อน +2

      So babe can be polled?

  • @justinliu7788
    @justinliu7788 3 หลายเดือนก่อน +1

    Walker getters is stabilized now!

    • @justinliu7788
      @justinliu7788 3 หลายเดือนก่อน

      Rust pull 129919 btw

    • @therustybits
      @therustybits  3 หลายเดือนก่อน

      Sweet!

  • @skydandelion2560
    @skydandelion2560 3 หลายเดือนก่อน

    Sir... Can you make another dedicated Video Tutorial for STM32 discovery development with RUST? A Complete guideline will be also ok. And This video was really helpful for beginners. Thank you!

  • @NotherPleb
    @NotherPleb 3 หลายเดือนก่อน

    I was really confused by the Mutex pattern until I looked at the docs. The critical_section::Mutex does not offer interior mutability like the std::sync::Mutex.

  • @orhundev
    @orhundev 3 หลายเดือนก่อน +1

    big W

  • @christopherpetersen342
    @christopherpetersen342 2 หลายเดือนก่อน

    in english, it's usually pronounced few-jit which doesn't quite match the original latin "tempus fugit" - generally translated as "time flies"

  • @takeiteasyeh
    @takeiteasyeh หลายเดือนก่อน

    My favorite part about Rust .. rewritting something you just wrote lol

    • @therustybits
      @therustybits  หลายเดือนก่อน

      This is the way 😅

  • @UsatiyNyan
    @UsatiyNyan 3 หลายเดือนก่อน

    Actually 🔥

  • @AdarshKumar370
    @AdarshKumar370 3 หลายเดือนก่อน

    Thanks

  • @roiborromeo7921
    @roiborromeo7921 3 หลายเดือนก่อน

    I'm a 4th year IT student of course I know so little about all these, but the async and concurrent code in esp32 sucks that it can't escape a loop and just blocks all these, I don't know how to do that, so I might be excited with these.

  • @10e999
    @10e999 3 หลายเดือนก่อน +1

    I'm not sure I understand why you use an ISR in the timer.
    Why not configure the RTC's prescaler of 32 (1000 Hz) ? Doing so, you get millisecond accuracy and an overflow only every 50 days.
    Thanks for the video!

    • @therustybits
      @therustybits  3 หลายเดือนก่อน

      The RTC's low power oscillator frequency is 32,768 Hz, so a prescaler of 32 would get you 1,024 Hz, which might be OK for tracking system time if you can tolerate the error. But even then, the counter register is only 24-bits (counting up to 16,777,216), which is an overflow every 4.66 hours, so you still need somewhere to keep track of overflows. Alternatively, you could keep the native frequency and use one of the CC registers to count up to ~1ms (32 ticks, so still some error) and just increment a single 64-bit tick counter value in memory.

    • @10e999
      @10e999 3 หลายเดือนก่อน

      ​@@therustybits Thanks for your answer. What I don't understand is why you need more than a few seconds before overflow.
      With the unsigned integer overflow rule, the following code is garantee to work:
      u32 elapsed = now() - start;
      if elapsed >= 100 { do_something(); }
      Anyway, thanks for sharing !

  • @thearrow4624
    @thearrow4624 3 หลายเดือนก่อน

    Could I ask what a tool/plugin do you use to make your vscode's integrated terminal so powerful?

    • @therustybits
      @therustybits  3 หลายเดือนก่อน

      I'm using "Oh My Zsh" to manage my zsh config, and have added `zsh-autosuggestions` (github.com/zsh-users/zsh-autosuggestions) and `zsh-syntax-highlighting` (github.com/zsh-users/zsh-syntax-highlighting). Basically just followed @typecraft_dev's video th-cam.com/video/wNQpDWLs4To/w-d-xo.html

  • @orrenjenkins289
    @orrenjenkins289 3 หลายเดือนก่อน

    Is the RefCell needed inside the mutex??

    • @therustybits
      @therustybits  3 หลายเดือนก่อน

      The `critical_section::Mutex` is a bit different from the `std::sync::Mutex` in that it does not provide interior mutability, for reasons described here: docs.rs/critical-section/1.1.3/critical_section/struct.Mutex.html#design

  • @markocvejic6416
    @markocvejic6416 17 วันที่ผ่านมา

    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?

    • @therustybits
      @therustybits  17 วันที่ผ่านมา

      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 😀

  • @erentas7391
    @erentas7391 3 หลายเดือนก่อน +1

    What is the name of the book on the table?

    • @therustybits
      @therustybits  3 หลายเดือนก่อน +3

      "The Linux Programming Interface" by Michael Kerrisk

  • @tommasoclini9902
    @tommasoclini9902 3 หลายเดือนก่อน

    Will there be an stm32 version of this video?

    • @therustybits
      @therustybits  3 หลายเดือนก่อน

      No: while the code is specific to the nRF series of controllers, the concepts are applicable to any microcontroller.

  • @JulianBolivarGaleno74
    @JulianBolivarGaleno74 2 หลายเดือนก่อน

    It is a RTOS implemented on RUST? I only can find some old (dead) projects and some FreeRTOS wrappers... 🤔because the Embassy framework is most an event oriented framework.

    • @therustybits
      @therustybits  2 หลายเดือนก่อน +1

      An RTOS is a bit of a different animal than what we build in this video, which is more like a stripped down version of embassy. And you’re right, AFAIK there aren’t many RTOS efforts in Rust at the moment. For real-time stuff there’s RTIC, but that works much differently than something like FreeRTOS.

  • @mateusztocha9260
    @mateusztocha9260 3 หลายเดือนก่อน +1

    wow

  • @elijahpo3800
    @elijahpo3800 3 หลายเดือนก่อน

    What code editor do you use?

    • @therustybits
      @therustybits  3 หลายเดือนก่อน +1

      VS Code; check out this video for full setup: th-cam.com/video/TOAynddiu5M/w-d-xo.html

  • @billytalentrocks345
    @billytalentrocks345 3 หลายเดือนก่อน

    A bit fast, but very good.

  • @chris-duncan-arauz
    @chris-duncan-arauz หลายเดือนก่อน

    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?

    • @therustybits
      @therustybits  หลายเดือนก่อน

      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..

  • @samuelhomberg9075
    @samuelhomberg9075 3 หลายเดือนก่อน +5

    Here a comment for the algorithm, because you are still criminally low on subscribers!

    • @therustybits
      @therustybits  3 หลายเดือนก่อน +1

      For the algorithm! 🙌

  • @jad.k.haddad
    @jad.k.haddad 3 หลายเดือนก่อน +1

    My dude rewrote embassy in one hour

  • @ederbarrero5585
    @ederbarrero5585 3 หลายเดือนก่อน

    This looks like an awesome video, sadly I'm too stupid for it 😔

    • @therustybits
      @therustybits  3 หลายเดือนก่อน

      I doubt that! I knew literally nothing about async a few months ago, and now I know.. slightly more! Seriously though, learning anything new is a process, you just need to stick with it 🙂

    • @ederbarrero5585
      @ederbarrero5585 3 หลายเดือนก่อน

      @@therustybits Heh, I think I needed to hear that, thanks! I'll try my best to absorb more about the basic concepts and come back to this :)

  • @urmok6iv
    @urmok6iv หลายเดือนก่อน

    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.

  • @JeffHanke
    @JeffHanke 3 หลายเดือนก่อน

    I assume it was a joke, but "fugit" is likely from "tempus fugit" (latin for "time flies") and would probably be pronounced "foojit".

  • @thegrandnil764
    @thegrandnil764 3 หลายเดือนก่อน

    Hiding things under abstractions can get you in trouble in the type of code I write so C is preferred, however I see this being very useful as a embedded C++ replacement.
    I might incorporate futures into my own systems in C/asm.

  • @clivedsouza6213
    @clivedsouza6213 28 วันที่ผ่านมา

    Pieces of this video went right over my head due to inexperience, but this talk [th-cam.com/video/H7NtzyP9q8E/w-d-xo.htmlsi=eeVPFC9iHGsHWivR] by the Embassy creator helped clear things a lot more.

  • @pierreyao7221
    @pierreyao7221 2 หลายเดือนก่อน

    Please turn off the editor suggestions when typing the code. It's difficult to follow the code with the rust analyzer suggestions popping up. Especially at the accelerated render of the video

    • @therustybits
      @therustybits  2 หลายเดือนก่อน

      Thanks for the feedback! In future videos I’ll be more selective about when RA is enabled.

  • @imanidioli
    @imanidioli 3 หลายเดือนก่อน

    Do you really explain for "from zero" sort of learners?

    • @therustybits
      @therustybits  3 หลายเดือนก่อน +1

      There is an extremely popular (and excellent) book “Zero to Production in Rust” by Luca Palmieri, and so this title is a play on that, though the “learn by doing” style is similar. Like Luca, my assumption is that you’ve read the Rust Book (link in description) and so have some familiarity with the concepts and now want to seem them in action. But yeah, if I also had to teach all the underlying concepts this video would be 10x longer.

    • @imanidioli
      @imanidioli 3 หลายเดือนก่อน

      @@therustybits Thanks, I felt like a homo erectus around the middle of the tutorial 😂.