My Raspberry Pi Pico fell to a bucket of water during doing some plant watering project, I'm pretty sure it runs Rust now...
@alexdubois65852 жыл бұрын
safely
@trayambakrai Жыл бұрын
@@alexdubois6585 and it cannot race anymore!
@dieSpinnt Жыл бұрын
Only direct short circuits and then also with a clear path e.g. between the 5V section and sensitive 3V logic and with a correspondingly high current flow can seriously endanger your board/parts. This basically happens when measuring or when trying around on the breadboard. In the water this is very unlikely. Of course, there are sensitive components where water damage in and of itself affects the function, but a little patience will probably suffice for you. It's best to use a few dry cloths and not even a (hot-air) hair dryer or the oven ... because you can damage more with them than with water. Have fun bathing and crafting! :)
@aayushmaharjan6412 Жыл бұрын
🤣🤣🤣
@andersonwaithaka3720 Жыл бұрын
😂😂😂
@Dygear2 жыл бұрын
Excellent! There are a couple of erratas. You don't actually need a variable to be marked mut to borrow it out to another function. You will actually have a much harder time borrowing a mut variable because rust wants only one place to be able to handle changing the underlying variable at any given time.
@r.pizzamonkey73792 жыл бұрын
Yup. You can only have one mutable reference OR multiple read-only references.
@FreedumbHS2 жыл бұрын
erratum to your comment, errata is plural already
@rumplstiltztinkerstein2 жыл бұрын
@@r.pizzamonkey7379 In rust speech, & implements Copy and &mut doesn't
@r.pizzamonkey73792 жыл бұрын
@@rumplstiltztinkerstein sort of but not quite. I'm pretty sure it's a different system which supercedes traits.
@rumplstiltztinkerstein2 жыл бұрын
@@r.pizzamonkey7379 maybe they're just special pointers
@alemartinezz10222 жыл бұрын
Please keep up with the low level Rust videos. That's one reason why I chose Rust for learning!
@LowLevel-TV2 жыл бұрын
More to come!
@JaJakubYT2 жыл бұрын
Check out videos on my channel. I have 6 videos on Rust embedded and more to come.
@nathan12581 Жыл бұрын
I second this
@santaclause80902 жыл бұрын
Nice getting started video :) Thanks Just one small correction abouth the push-pull output part: it's not called push-pull because you can "pull" data from it to read: it's still an output. It's called that way because it's built with 2 transistors, one can push the output towards the supply voltage and one can pull the output to ground. Just clarifying it here before somebody tries to read data through an output :D
@fltfathin2 жыл бұрын
to make it more clear, other type of output is open drain in which you need to add pullup resistor to keep it high
@louiscloete33072 жыл бұрын
Wanted to say the same. Thanks!
@keylanoslokj18062 жыл бұрын
What an era to live in. When such content is available
@selfscience2 жыл бұрын
Specially for knowledge hoarders like ourselves.
@notsojharedtroll232 жыл бұрын
@@selfscience yesir 🤙🤙🤙
@test403232 жыл бұрын
Nice walkthrough. HAL does make codes more readable as it is more standardized. Good low level C programmers wrap registers/dma access in small functions. Thank you!
@LowLevel-TV2 жыл бұрын
Good tip!
@Mr.Leeroy2 жыл бұрын
What's wrong with proper commenting? Do you have to add pointless jump commands around your low-level instructions, complicate the things happening in stack, etc?
@iqwit4 ай бұрын
@@Mr.LeeroyYou underestimate how smart compilers are, if it can inline, it will 90% of the time
@kingderderder2 жыл бұрын
"Push pull output" is actually referring to the type of output in electrical terms. It means the pin can "pull" to ground/low and "push" the voltage on the pin to vcc/high. There are other types of output types such as "open drain" which only pulls to ground, no pushing. The line setting the pin to push/pull output is equivalent to arduino pinMode(...).
@mydearaniryx78292 жыл бұрын
There is actually an open-source operating system written in Rust for embedded systems called Tock OS and it has support for rp2040 too (and many other Cortex-M and RISC-V based MCU's). You can then compile and run c or rust apps on top, without needing to know all low level stuff. But if you like the low level stuff you can always contribute to Tock OS :))
@SandwichMitGurke2 жыл бұрын
Dude how awesome is the fact that you run the crate and it automatically uploads to the pico in the shortest amount of time? this is crazy, I have to try it
@apocalypseio2 жыл бұрын
After watching your last video I was tickled to see you steering folks towards installing the whole environment. I am doing a similar exploration with ESP32 and diverted to try the 2040 along with you this time. Good Stuff!
@kenworks6068 Жыл бұрын
Perfect level of instruction for me. I just ordered the picos, am reading the the new Rust book and have an application to code. You are cutting to the chase and having arduino experience your explanations are clear and organized - Thank You I am so pumped to be part of the Rust Everywhere world
@LowLevel-TV Жыл бұрын
Glad it was helpful!
@fotnite_ Жыл бұрын
Extremely well documented seems to be a pattern with Rust IMO. It's not just the core language, but the entire ecosystem that is well-documented, and even though Rust has a ton of very unique features that I like, it's the superb documentation that wins me over in the end.
@arjayUU2 жыл бұрын
that is a ton of initialization for a blink xD does this scale for more complex projects. also wondering where tbe benefits of embedded rust lie and how one would handle DMA access conpared to c++ for let's say fast ADC sampling.
@rafaelbachmann72462 жыл бұрын
Gotta setup those clocks :) DMA usage is currently same as C or C++: write to registers and make sure no races etc. can happen. Some HAL implementations make this ridiculously easy, see e.g. h7 hal. In the future, some efforts such as embedded-dma and bbqueue might standardise this, but it's hard.
@markday31452 жыл бұрын
Yes, it's very verbose. The Rust style is to encode as much as possible into the type, so the compiler can check it for you. But that means you need ownership of a lot of pieces of data, and that means a lot of source code (which may boil down to very little code at runtime). For example, you'd need a separate variable for each GPIO pin you want to use, and you have to pass those variables to any function that needs to access that pin. You can hide some of that complexity by putting that initialization and extraction of variables into your own library function. The downside there is that your function has to return a lot of pieces of data. It would certainly be possible to create a much simpler API (similar to Arduino, for example) that is in some sense less safe. For example, if you pass pin numbers as integers, you end up having to do runtime sanity checking of that number, and it's easier to accidentally type the wrong number or have two routines manipulating the same pin when they should be manipulating different pins.
@doctorbobstone2 жыл бұрын
In C or C++ (or any language, really) you generally have to do all this stuff to setup the hardware. Some environments like Arduino hide much more if it. This usually means you have less ability to customize, but you have less boilerplate in your code, too. All the setup code is still being called for you, though. The level of detail exposed is a trade off of simplicity vs. control. I think what we've seen here looks like a pretty reasonable level of detail, at least in my opinion.
@bspringer9 ай бұрын
Very nice, one thing I noticed: Push-Pull actually refers to being able to push it to 1, or pull it to 0. One alternative is High Impedance (Hi-Z), which is an input (no possibility of writing any value), and another alternative is open-drain (you can only pull it down to 0, but if you want it to go up, you need an external pullup. Useful for combining multiple output pins and the output will go low if any of the output pins of different ICs goes low)
@herrxerex84842 жыл бұрын
Loved this , people like you make this world a better place !!!
@maikha89632 жыл бұрын
*slowly opens another tab and typing rust language*
@act0r3992 жыл бұрын
Man, this is incredible, thanks KZbin that show you in recommendations, you explaining every fucking line code , just amazing, keep creating tutorial like this, thanks
@frostifish2 жыл бұрын
Lovely video! Now I can finally grasp what the panic handler does and why unwarp is always called. Also, perhaps you could check out the secondary core and Programmable I/O for the Pico in Rust in a future video :)
@harrytsang1501 Жыл бұрын
Thanks, this video made me realise that C/C++ is not the pain point of embedded systems, the configurations and quality of documentation is. C/C++ are nice as in I know what my code will compile to assembly. Rust makes that memory safe but does not help with the pain of configuration.
@MrAnandml2 жыл бұрын
Oh this Rust series is going to be great...
@johnknight72932 жыл бұрын
Thanks, don't forget the link to the embedded Rust doc page as you promised !
@LowLevel-TV2 жыл бұрын
Thank you for the reminder! Done.
@messiweltmeista2 жыл бұрын
Pretty neat explanation, thanks! I'm gonna try this myself. I've always wanted to use rust in some projects, now I found how to do it having fun.
@kenworks6068 Жыл бұрын
Great job, I was able to follow your explanations and get the program running on my pico from my Mac.
@TobyMole Жыл бұрын
Ex-C embedded engineer here. Semi-following these embedded rust videos, interested to see just how Rust compares to C in embedded, great to see HAL coming in! When you say the HAL prevents using unsafe sections, does it mean that the HAL has unsafe parts that it does for you, or does it have some way of performing the needed operations without being unsafe at all?
@zachbrown7272 Жыл бұрын
The HAL itself has unsafe parts that it does for you. From what I can tell reading the HAL source though, they are beyond what a c dev would consider "good enough" about how they manage their memory though.
@debuti2 жыл бұрын
Good! I have a primitive rust scheduler running in the rp2040. It was a funny project
@wChris_2 жыл бұрын
There is actually a project template you can use, to get started on your own project!
@scheimong2 жыл бұрын
Love it. I've coded in Rust for nearly two years now, but embedded Rust has always been somewhat intimidating. This video series has been an excellent quick start guide for people like me who are pretty experienced in general programming but have little experience working with embedded code.
@LowLevel-TV2 жыл бұрын
Great to hear!
@first-thoughtgiver-of-will24562 жыл бұрын
Thank you for bringing more attention to this.
@mattg52622 жыл бұрын
Amazing video! For future videos writing a driver for a simple i2c device using embedded hal traits would be super helpful. There are barely any up to date tutorials out there on it. There are so many hardware devices that don't have abstractions yet and a video on it would be a huge help to the community.
@markbratcher9095 Жыл бұрын
Where did /mnt2/rp-hal come from? You didn't mention creating it or mounting it for a particular purpose. It looks like you created it as a dedicated location for the rp stuff.
@criptouni2 жыл бұрын
Great videos and keep 'em coming! given the high-quality of your videos could you share your setup? workstation, mic/headset, software used? We want to start making some videos ourselves for Spanish speakers about Rust but we're not too sure on hardware equipment required. Thanks!
@Fleebee.7 ай бұрын
If you're using a pico W this wont blink the onboard led. pick a different pin and connect it to a circuit to check its working
@louiscloete33072 жыл бұрын
Tip: `cargo build` is aliased to `cargo b`; similarly, `cargo run` is aliased to `cargo r`. It gets handy when you have to type it a lot.
@soumen_pradhan2 жыл бұрын
Is there a similar thing for --release ?
@louiscloete33072 жыл бұрын
@@soumen_pradhan cargo b --release and cargo r --release
@NathanLTPK2 жыл бұрын
keep doing these rust & pi pico tutorials with showcasing more peripherals connected to the board. great job, like and sub-ed
@echoptic7752 жыл бұрын
I love i found out about this channel, right as u started programming in rust, i know that rust is a viable c alternative, but without the crazy things that can happen in c. I think its finally time for c to not be the best solution for embedded systems
@IamSentient3142 жыл бұрын
Hi. I love these videos you make on the Pi Pico. If you can, could you cover DMA on the Pi Pico? Mem to mem, DMA SPI & DMA I2C etc.
@TrolleyMC2 жыл бұрын
I think arch repos keep an up to date version of rust, so really depending on your distro or UNIX-like OS, it may or may not be necessary to use rustup
@thewilltejeda9 ай бұрын
This is pretty cool, ive learning rust ( as a typescript/python dev ) and have been wondering about rust and the rp2040
@michawhite76132 жыл бұрын
You don't need the ok() call on line 67. Results also have an unwrap() method
@markalanboyd10 ай бұрын
Great video! Would love to see some hardware audio DSP like a little guitar FX pedal or something.
@jotrockenmitlocken10 ай бұрын
This video is a beauty. Thanks very much for this.
@taylorh1402 жыл бұрын
22.50 KB, seems like a lot for a blinky example.
@Niohimself7 ай бұрын
11:19 that's not what push-pull means. Push-pull means the pin can push the voltage high (sending current into the wire) or pull the voltage low (sinking current FROM the wire). This is opposed to "Open collector" that can pull but can't push. The reason you would ever want OC mode for a pin is when you want to connect several outputs to a single input, as in this case one pin outputting 1 and the other outputting 0 will just result in an overal value of zero instead of frying both pins.
@taraskornuta2 жыл бұрын
And what is the binary size the rust produces compared to do the same application compiled by gcc?
@Dygear2 жыл бұрын
There is both a gcc and llvm implementation now. They are almost always around the same +/- a few precent.
@rafaelbachmann72462 жыл бұрын
Realistically, a rust binary compiled with default settings will be rather large. But by setting a few options in Cargo.toml you can get it much smaller. Also by avoiding formatting code and using something like defmt you can get it even much lower.
@falxie_2 жыл бұрын
This is making me want to buy a Pico, but I have no real projects to work on for it
@NishchalGautam7 ай бұрын
Hello there, I was wondering if you could do a basic starter for NodeMCU (ESP8266) with rust
@sourabhk23732 жыл бұрын
keep making rust + embedded videos please!
@typeer2 жыл бұрын
Love this series thanks man
@akasakasvault75972 жыл бұрын
Rust on everything : Devs : let's go Chemists : ...
@MichaelFlynnhasneatv Жыл бұрын
I literally have an entire module dedicated to programming and debugging this board using C and Assembly. Seeing how it's done at a higher level of abstraction with rust is really interesting. Maybe the video already exists but how does rust handle hardware interrupts?
@tk57822 жыл бұрын
Fantastic, thank you! For anybody else who might be getting soem build issues on windows, I had to use the following 2 commands to get the environment set up. Now I have blinky on my RP Pico but it doesn't work on an RP2040 Connect. Is that a different HAL? rustup target add thumbv6m-none-eabi cargo install elf2uf2-rs
@therealjpster2 жыл бұрын
Same HAL but it has a different flash chip so you need to change the boot2 line. The bit that says W25Q80 is actually telling you the part number of the flash chip that particular boot2 supports. Or use the Nano Connect 2040 BSP which sets this up for you.
@michaelscholten36392 жыл бұрын
I had build issues on Linux (Ubuntu) and after using those commands, my code worked. Thanks for your help.
@Alex-hr2df Жыл бұрын
Brilliant, man!
@ILsupereroe675 ай бұрын
At 12:05 you say if you had activated the watchdog you'd need to feed it within the loop, but isn't the delay implicitly doing that already?
@echoptic7752 жыл бұрын
What are ur plans with rust? I just saw u had a series of making an os, will u do sth similar with rust?
@chairmakerPete2 жыл бұрын
This looks super-exciting. Cannot get into python at all, but rust seems shockingly brilliant.
@codeman99-dev Жыл бұрын
Serious question: Is there significant advantage to using embassy over using the HAL directly?
@tabletopjam48942 жыл бұрын
now if only i could find a free resource for learning rust
@mikafoxx27172 жыл бұрын
Try typing "cargo docs --book" into your terminal. That's the official rust book and it's quite well written.
@alexloktionoff68338 ай бұрын
Do you have a video about RTIC, how to use both cores of RP2040?
@AstroMechanicalEngineer2 жыл бұрын
Nice! Thanks for this video, my guy. I didn't even know Rust worked on MCUs. :D
@JeremyChone2 жыл бұрын
Thanks, great video. On a related topic, somehow, I cannot figure out how to read from PWM? The rp-hal/rp-pico have write example, but not read (I might be missing something).
@lambsauce5445 Жыл бұрын
Maybe you could do an entire series. As a beginner, I'm not entirely sure where I'd go next from here...
@RonSheely Жыл бұрын
Excellent. Thank you.
@Stowy2 жыл бұрын
that nice ! but seems like a lot of boiler plate code, would it be possible to not have all of that written all the time ?
@chaddaifouche5362 жыл бұрын
Basically, you need all this code to initialize your board properly (the joy of embedded code). On the other hand since most of this doesn't change and the "real" code specific to your purpose here is only a few line, there are templates that already have all the boilerplate and you can just reuse when needed.
@wertia3918 ай бұрын
Please, do these kind of videos but with embedded C!
@omarmhaimdat2 жыл бұрын
Excellent and honest video, keep going !
@alirezaalavi15042 жыл бұрын
dude I have the same wallpaper as you and for couple of seconds I was so confused :))
@gideonz74b Жыл бұрын
It's a nice video... but how about setting up the environment if you are using a board that you made yourself, running a custom SoC, based on RiscV for example? You are using runners and all, but how do you specify how to connect to the hardware, for which target cargo should emit code, etc? This video only shows how to use someone else's configuration.
@jonathan28472 жыл бұрын
Where you hve `.ok().unwrap()` on lines 67 and 68, I beleive you could remove the `.ok()` and it should result in the exact same behaviour of panicking if something goes wrong (I don't know if something special applies here but that is how it behaves in typical Rust usage)
@ZenoTasedro2 жыл бұрын
Great video! Will def subscribe and catch up
@HeadakusMaximus2 жыл бұрын
You might wish to use purge rather than remove when uninstalling.
@dibyojyotibhattacherjee8972 жыл бұрын
Very much awaited series!, although looks a bit verbose, is there any nicer or shorter way!
@JaJakubYT2 жыл бұрын
Check out videos on my channel. I have 6 videos on Rust embedded and more to come.
@etopowertwon2 жыл бұрын
Maybe I'm spoiled by ATmega, where to init the chip you need to write a value to the same address two times, but this looks ugly. I have a very strong belief if you pass 3+ fields to a function, such function should be a method (or has method to wrap the call). Something like `let mut watchdog, clocks = pac.init_clocks(XTAL_FREQ_HZ)` would be cleaner abstraction. Pins initialization smells: bank0 is specified three times, so much DRY. boot sector needs to be set up manually (Can't rust macro emit it? We already use [entry] as a macro) halt as panic feels half-baked. We don't send messages over UART or blink, we just halt.
@justins77962 жыл бұрын
subbed. dude this is great work
@LowLevel-TV2 жыл бұрын
Thanks for the sub!
@doctorgreatengineer68342 жыл бұрын
I want to know how HDL like Verilog works inside FPGA. Am i gonna get any video future here?
@LowLevel-TV2 жыл бұрын
I plan on doing FPGA content in the future but I still have a lot of work to do, purchases to make. Stay tuned!
@doctorgreatengineer68342 жыл бұрын
@@LowLevel-TV thanks a lot
@MrGTAfan932 жыл бұрын
Doom runs on almost everything, but rust? Surely the graphics will be terrible... Ohh is't a programming language... I was ready to kill the heli...
@fammioli2 жыл бұрын
Watched three minutes of this under the impression that we were talking about rust the video game
@nathanruben33727 ай бұрын
I use asdf to manage rust, node, ruby, python and many other langage versions and environments....
@atomatopia12 жыл бұрын
And here I was expecting the steam game…
@asksejsbo3312 жыл бұрын
A question: a lot of no_std libraries are able to run with vectors using "extern crate alloc", would this be the same for the pico's?
@pup43012 жыл бұрын
Thank you are. Your talking my language. ;)
@konstantinnikitin6883 Жыл бұрын
I didn't understand anything, but I like it :-)
@triularity2 жыл бұрын
But don't you just hate it when you call hal::podbay::Doors::open() and get the error ""I'm sorry Dave, I'm afraid I can't do that"?
@RixtronixLAB2 жыл бұрын
Nice video, thank you for sharing :)
@greatgruff14422 жыл бұрын
Open the door HAL
@LowLevel-TV2 жыл бұрын
I can’t let you do that Dave
@dabunnisher296 ай бұрын
I keep getting this when I try to build it: cargo build --release --example blinky error: target `blinky` in package `rp2040-hal` requires the features: `critical-section-impl` Consider enabling them by passing, e.g., `--features="critical-section-impl"` Im assuming I need to adjust my toml file?
@bartoszk.64515 ай бұрын
Hi, I got the same problem, just tell the build system to include additional dependencies to support critical sections: cargo build --release --example blinky --features="critical-section-impl" you'll probaly need to install additional components i.e.: rustup target add thumbv6m-none-eabi and cargo install elf2uf2-rs
@dabunnisher295 ай бұрын
@@bartoszk.6451 YOU ARE AWESOME!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! That worked. Thank you sooooooo much!!!!!!!!!!!!!!
@AlbinoCordeiroJunior2 жыл бұрын
Thanks!
@jellyfin4492 жыл бұрын
You do a good job of breaking the code down linexline
@sinushkin Жыл бұрын
Does it handle with Wifi stack, 2 core usage without linux?
@martijn31517 ай бұрын
Doesn’t every byte code compiled language run on everything?
@Slushee2 жыл бұрын
This is amazing! I would really really appreciate if you did the same but for the ESP32
@truuumingtruuum65862 жыл бұрын
good luck trying to run exe compiled by latest rust toolchain on windows xp
@edgeeffect2 жыл бұрын
This seems hellishly over-complicated when compared to C or Assembly Language.... All of that boiler-plate initialising things I would never intend to use. I was initially optimistic about Rust because I can't stand C and I've been looking for a modern replacement for years. But 50-ish lines of boiler plate is making Ada look like a simpler alternative. Do we really really need a bootloader in our binary? To load a program that's already in the flash? :(
@9names7832 жыл бұрын
You really *do* need a 2nd stage bootloader for RP2040 if you want to access flash or want a program larger than 256 bytes - regardless of the language you use. This is one of the trade-offs of using external SPI flash for program storage on a microcontroller, and is not unique to RP2040 - other flashless micros have similar requirements. We just don't hide them from you in an SDK that only works for one board.
@alerey43632 жыл бұрын
what are the advantages of rust? is there really a need for this language?
@vsevhpme Жыл бұрын
How to return to factory settings?
@Maric182 жыл бұрын
well if rust runs on everything, can someone please help me compile songbird-py on aarch64?
@connorcantrell18832 жыл бұрын
What is a boot block?
@blokhype30742 жыл бұрын
i think this is for mac or raspberry pi 4 what do i need for windows to get started
@diegogutierrez84732 жыл бұрын
Very good. Great containt
@LowLevel-TV2 жыл бұрын
Thank you very much
@talhakhalid6302 Жыл бұрын
Its more like writi g a bootloader that burn sletch onto eeprom like one in Arduino