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
@Kaptime4 ай бұрын
This is the exact kind of top to bottom project breakdown that can onboard people very quickly 10/10 video.
@jackkendall64205 ай бұрын
Now this is *content*.
@danjadaveАй бұрын
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!
@FedynaPavlo4 ай бұрын
I’m now half way through the genius „Zero2Prod in Rust“ book. You should *absolutely* write one but for embedded in Rust.
@therustybits4 ай бұрын
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...
@vikaspoddar0013 ай бұрын
@@therustybits you can write it, can you create a crate for extending cargo for managing embedded development. like we have platformIO
@JordanRobinson-w6w4 ай бұрын
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!
@anandmoon57015 ай бұрын
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.
@heinzhaberle332614 күн бұрын
It is a long one. And yes I was watching til the end. Amazing story from classic embedded over to more advanced state machines and finally into the full asyn executer connectd to the rust compiler. So many patterns done in simple code and even later on adapted to the real world. I am really impreessed. And I am also writing this as a true believer in embedded asyn.
@FernandoMumbach5 ай бұрын
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!
@thegrandnil7644 ай бұрын
Arena allocators.
@FernandoMumbach4 ай бұрын
@@thegrandnil764 ha, if only
@НиколаевВасилий-н3б4 ай бұрын
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.
@indierusty5 ай бұрын
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.
@jan_the_man4 ай бұрын
Damn this is some quality explanation! Answered a lot of questions I had related to embedded. Keep it up man!
@timello23 күн бұрын
I really liked how you presented the content. I bet you are one of the minds behind embassy-rs :). Embassy makes things so easy.
@therustybits23 күн бұрын
I wish! Those guys are awesome.. next video will properly introduce embassy, should be out later this week.
@J-Kimble4 ай бұрын
Great video! Low level async and embedded, two of my high interest topics at the moment!
@davidbronke548417 күн бұрын
That was great, and showed why Embassy is so useful, since you don't have to implement all that stuff yourself! And despite what Ferris might have said, I did watch all the way to the end. 🦀
@namr20004 ай бұрын
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!
@Eekhoornz2 ай бұрын
You made me sit down and think how concurrent tasks are usually implemented using state machines, thanks for this amazing work!
@Jon4as5 ай бұрын
Waiting for a 1 hour Video was so worth it!
@philippsteiner198724 күн бұрын
I have never done anything with Rust in embedded, but actually this tutorial convinced me to learn Rust!
@jvcrules4 ай бұрын
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.
@mehmethekimolu5 ай бұрын
Amazing work, was waiting your next video, perfect as always
@ChidleyITComputeАй бұрын
Excellent. I'll be rewatching this to understand how Embassy works "under the hood".
@thaejsooriya33135 ай бұрын
Wooo new video! Love the content and super useful topic!🎉🎉
@irlshrek4 ай бұрын
Duuuuuude so sick!! Thanks for this!
@descriptionsuchandsuch47095 ай бұрын
Oooooo NICE! A new video from my new favourite Rust channel! Can't wait to watch it this evening!
@farukhalilagic20704 ай бұрын
Thanks!
@jeffthekiller22924 күн бұрын
Hey, just discovered your channel, what a great start ! Subscribed instantly. keep going !
@MaxWeninger4 ай бұрын
Picking embassy going forward is a very good choice.
@Sillyvan4 ай бұрын
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
@thelethalmoo4 ай бұрын
Awesome! the world needs rust content like this 11/10
@JeroenL1114 ай бұрын
Excellent! Very well explained!
@auggiebuerkle66604 ай бұрын
i'm glad you're back
@indierusty5 ай бұрын
This is a really good tutorial. Thank you so much for making quality education video.
@IvanDeMarino5 ай бұрын
Yeah, new video! Just yesterday I was leaving a message asking for one, and here we go!!!
@MrMassaraksh4 ай бұрын
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
@topper2kuk3 ай бұрын
Dude! loving the execution and format of videos. Looking forward to the next rusty bit
@driedurchin4 ай бұрын
Instant sub. So good!
@oof-software4 ай бұрын
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
@therustybits4 ай бұрын
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.
@unaimillian4 ай бұрын
Very great video and visuals during the discussion! 🎉
@ThomasLockney4 ай бұрын
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.
@marcopaolovaleriovezzoli57764 ай бұрын
Excellent video as usual. I definitely need to find some time and do my homework.
@teuluPaul4 ай бұрын
fabulous video (again!) - many thanks for sharing!
@HybridRobotixАй бұрын
I watched the whole video. PLEASE consider doing a complete tutorial for Rust. I like the way you explain things.
@jorgegomezreus70194 ай бұрын
The video I was waiting for
@evertonoriente71504 ай бұрын
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.
@trejohnson76774 ай бұрын
some of your points map to react incredibly well, interestingly
@lorenzorossi20004 ай бұрын
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!
@nathanbanks23544 ай бұрын
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.
@joehopfield29 күн бұрын
I did lots of (painful) multi-thread safe kernel and library code back in the day. Lately I've been playing with some mcus using async/await on circuitpython. At least in my toys so far, far superior for code that doesn't need kernel-code level control.
@maexlich4 ай бұрын
Amazing video, great job! It is very very helpful!
@PlayerOne19995 ай бұрын
Lets GOoooo. love your soft voice😊😊.
@daniellarson62794 ай бұрын
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.
@therustybits4 ай бұрын
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
@daniellarson62794 ай бұрын
@@therustybits D'oh, that's on me for not noticing it wasn't the std Mutex. That makes sense.
@driedurchin4 ай бұрын
What still blows my mind about Rust's async is that, in essence, it's identical to the original code, just smarter.
@therustybits4 ай бұрын
Automatically generated state-machines FTW
@driedurchin4 ай бұрын
@@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!
@The_Nova_Glow4 ай бұрын
Jackpot!
@matpala24 ай бұрын
Great video!
@cunningham.s_law5 ай бұрын
you should probably test each change on the hardware to make the video more interesting by showing the effect of the change
@therustybits5 ай бұрын
Ah yep, good call... did that in blinky but forgot in this one. Next time!
@krauterbaguette36454 ай бұрын
Love this so much ❤
@danielprimostuart4 ай бұрын
Looking forward to the atomic ordering video!
@christopherpetersen3423 ай бұрын
in english, it's usually pronounced few-jit which doesn't quite match the original latin "tempus fugit" - generally translated as "time flies"
@evertonoriente71503 ай бұрын
When is coming your video of embassy? :) Thanks for this amazing video explain everything inside of the logic of the embassy framework.
@therustybits14 күн бұрын
The future is now! kzbin.info/www/bejne/pnXHZqCOd6tnqrs
@Flourish3817 күн бұрын
This video explains async better than anything else I’ve ever seen. Maybe I won’t complain as much about colored functions now that I know the demons that they’re hiding from me…
@Iswimandrun5 ай бұрын
Thank you for the great tutorials.
@orhundev4 ай бұрын
big W
@vikaspoddar0015 ай бұрын
He is back from the hiatus
@not_yet_implemented5 ай бұрын
This is great 👍
@UsatiyNyan5 ай бұрын
Actually 🔥
@commissariomontanaro29315 ай бұрын
babe wake up, an hour long got posted
@johnwu59085 ай бұрын
So babe can be polled?
@borkomne4 ай бұрын
Great video, thanks! Btw, what software do you use to create text animations?
@therustybits4 ай бұрын
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..
@borkomne4 ай бұрын
Thanks@@therustybits, the quality of your videos is excellent! Please keep up the great work!
22 күн бұрын
How does looking at the schematic for the buttons, shows that it is low when pressed, and how would the schematics look if it were the other way around?
@therustybits22 күн бұрын
The diagram shows the buttons (symbols SW2 and SW3) connected on one side to ground (set of tapering lines), and the other side to VREG (supply voltage) through resistors R4 and R5. The buttons are normally open, which weakly pulls the BTN_A and BTN_B signal lines up to the positive (high state) voltage VREG through the resistors: when they're pressed, these signal lines get directly connected to ground, causing the voltage seen at the input pins to drop to 0 (the low state). The circuit could be rearranged so that the signal lines are instead pulled low by default, and high when pressed, by moving both the resistors and signal lines on the other side of the switch: one side of the switch would then directly connect to VREG, the other side to the signal & resistor (& ground).
@NotherPleb5 ай бұрын
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.
@roiborromeo79214 ай бұрын
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.
@takeiteasyeh2 ай бұрын
My favorite part about Rust .. rewritting something you just wrote lol
@therustybits2 ай бұрын
This is the way 😅
@skydandelion25604 ай бұрын
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!
@justinliu77884 ай бұрын
Walker getters is stabilized now!
@justinliu77884 ай бұрын
Rust pull 129919 btw
@therustybits4 ай бұрын
Sweet!
@AdarshKumar3705 ай бұрын
Thanks
@markocvejic6416Ай бұрын
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Ай бұрын
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 😀
@10e9994 ай бұрын
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!
@therustybits4 ай бұрын
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.
@10e9994 ай бұрын
@@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 !
@orrenjenkins2894 ай бұрын
Is the RefCell needed inside the mutex??
@therustybits4 ай бұрын
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
@mateusztocha92605 ай бұрын
wow
@thearrow46244 ай бұрын
Could I ask what a tool/plugin do you use to make your vscode's integrated terminal so powerful?
@therustybits4 ай бұрын
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 kzbin.info/www/bejne/rX-0oXeNgdhnitE
@JulianBolivarGaleno743 ай бұрын
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.
@therustybits3 ай бұрын
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.
@tommasoclini99024 ай бұрын
Will there be an stm32 version of this video?
@therustybits4 ай бұрын
No: while the code is specific to the nRF series of controllers, the concepts are applicable to any microcontroller.
@erentas73915 ай бұрын
What is the name of the book on the table?
@therustybits5 ай бұрын
"The Linux Programming Interface" by Michael Kerrisk
@chris-duncan-arauz2 ай бұрын
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?
@therustybits2 ай бұрын
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..
@wlcrutch26 күн бұрын
What motivated you to use the microbit? I was looking into that after discovering your channel, and people seem to think it’s for kids. You’re obviously not a kid, so what went into that decision?
@therustybits26 күн бұрын
This is the board selected by the Rust Embedded Working Group for their most recent ‘Discovery’ book, that teaches about how to use Rust on a microcontroller (docs.rust-embedded.org/discovery/microbit/). I wanted to provide my own interpretation of that resource (which at the time was a bit outdated), so I figured I’d just use the hardware they used, and have just kind of continued with it ever since. Will have two more videos that use the microbit, then we’ll move on to other hardware.
@elijahpo38004 ай бұрын
What code editor do you use?
@therustybits4 ай бұрын
VS Code; check out this video for full setup: kzbin.info/www/bejne/ioCkqqGamc6oa68
@samuelhomberg90754 ай бұрын
Here a comment for the algorithm, because you are still criminally low on subscribers!
@therustybits4 ай бұрын
For the algorithm! 🙌
@billytalentrocks3454 ай бұрын
A bit fast, but very good.
@urmok6iv2 ай бұрын
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.
@therustybits14 күн бұрын
Sorry to hear it! You might find this one a bit more approachable: kzbin.info/www/bejne/pnXHZqCOd6tnqrs
@ederbarrero55854 ай бұрын
This looks like an awesome video, sadly I'm too stupid for it 😔
@therustybits4 ай бұрын
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 🙂
@ederbarrero55854 ай бұрын
@@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 :)
@jad.k.haddad4 ай бұрын
My dude rewrote embassy in one hour
@pierreyao72214 ай бұрын
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
@therustybits4 ай бұрын
Thanks for the feedback! In future videos I’ll be more selective about when RA is enabled.
@JeffHanke4 ай бұрын
I assume it was a joke, but "fugit" is likely from "tempus fugit" (latin for "time flies") and would probably be pronounced "foojit".
@clivedsouza62132 ай бұрын
Pieces of this video went right over my head due to inexperience, but this talk [kzbin.info/www/bejne/fmixpa2vhZ6kbqcsi=eeVPFC9iHGsHWivR] by the Embassy creator helped clear things a lot more.
@therustybits14 күн бұрын
Can confirm, Dario's embassy presentation from RustNL is excellent 👍 Made an 'Intro to Embassy' video you might also like: kzbin.info/www/bejne/pnXHZqCOd6tnqrs
@thegrandnil7644 ай бұрын
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.
@imanidioli4 ай бұрын
Do you really explain for "from zero" sort of learners?
@therustybits4 ай бұрын
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.
@imanidioli4 ай бұрын
@@therustybits Thanks, I felt like a homo erectus around the middle of the tutorial 😂.