Rust on ESP32 - Getting started

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi I'm Frank and uh I would like to do some videos about using rust on esp32 microcontrollers uh I mainly aim for regular software developers like me to to get into microcontrollers because it's quite nice and especially given now we have a language like rust which is like a real modern language that people like us like a regular software Engineers can use embedded device as well of course you can always do that with something like in C or with Arduino but for many that's just not a very palatable language to do anything like an API or something like that everybody knows it's theoretically possible but also that yeah that a few people will actually want to do it so um I will try to keep the perspective of the software developer if you are embedded you're probably a face bomb a few times through those videos because I'm really not that's not really my thing it will be a pretty entry level but I do recommend to if you uh to get into rest and to get familiar with the tool set a little bit before you're going to embed it because it it adds another layer of difficulty so uh yeah first get familiar with rest I would say and then add the extra layer of microcontrollers which involves cross compiling for two different platform uh to they have to slightly weird tool change change so uh yeah I will assume that you are somewhat familiar with rust so starting with uh with uh um the setup I have a microcontroller here I'll put it on the camera here it has uh you can see the the headers and the chip something like this should cost you not much more than than 10 euros the chip itself is much cheaper it's a esp32 C3 which is an a risk 5 processor it has some it has onboard Wi-Fi which we will use and yeah you can connect or everything you want basically to those headers um but first let's get uh let's set up our environment I will probably need to fast forward a little league a few times because some of those builds are slow so first of all Let's uh we will use a template for it just doing cargo new and every and adding everything manually is really a very long process and now when I show you the result template you will probably understand why so let's have a look I will uh search for cargo template esp32 and that's a GitHub repository we will be using um ESP IDF IDF is a sort of uh real-time OS which is not really in OS but it's a it gives you some tools to work with some some facilities the most of the centered library and know that you still don't have really have an OS you don't can do system calls all you want some of the some of them you can work around but uh so yeah um let's start with the software part first um so this says this is how you generate a project so here my uh folder nothing here uh let's just do this and it says uh let's do esp32 video it's project name it says ask me which one C3 I will want to do the advanced ones don't unboxing walkway which is kind of an online emulator which is really nice but I'm not going to use it now 5.1 seems all right enable standard support yes please no Dev containers default features should be all right so now we have a a folder and let's see what's in there cargo Tomo build RS nothing should be super unexpected let's have a look at the cargo and already you can see there is quite a lot in here uh like the beginning normal stuff um but uh a bunch of dependencies a bunch of versions which is hard to get right uh manually I would say so uh let's um run a cargo build now wait before that there is also a DOT cargo folder which has extra configuration options for uh for the cargo build and if I show that one this config file in here it configures the standard Target so every time I do a build now this target will be targeted so it will be at the risk 5 processor and it will be using the ADF on top of the uh real-time OS so um yeah let me uh go back and I do I will probably need to fast forward it because that really takes a while Chicago built okay so uh it did take quite a while it didn't really say I think it was like four minutes or something like that but it actually failed and it says like something pretty uh down in the wheat about Wi-Fi that seems to have a missing um missing field this happens from time to time that something breaks that there is something updated and the matching update haven't been made yet or already run into this one before it has been fixed already on the master so I can make a a fix on the I make a patch on the cargo and then we can use the master version and then it should be all right but first let's set up our our developer environment so that will be something like I'm using pH code I'm gonna open in this environment and that will also take a while probably the moment I touch a registered file make sure you have the rest analytics integration enabled because otherwise you'll not have any help and that's really essential I think so looking at the main function here not exciting the link batches something that you apparently have to do and in initialize logging find and print hello world so uh yeah that's uh that's it so that's not super impressive but that's what you want from a hello world now this took quite long mostly because it was downloading a lot of the the sources or not so much resources like the build environment and then given that we're not really installing it onto the operating system like everything that needs to be there it needs to include in the binary so it does a lot more than uh uh compiling this single function so that's why it can take a while because if I go back to the terminal uh if I show the size of the folders like uh like guitar the target is pretty big it's one gigabyte and uh the M build so that's kind of the build environment for ESP IDF it's nearly two gigabytes so there is a uh yeah there's a lot of stuff going on it's not that just very slow and but it is built on python so maybe um so this kind of seems to at least work well enough for the editor to work but there is a problem that we need to address with the Wi-Fi integration thingy um so just to help it troubleshooting all right if I cleared it we need to patch the the cargo terminal and we can do that by adding a patch section and then saying that a certain uh dependency in this case ESP ief service we will point to uh git repository instead let me um look that up I will go to my own GitHub [Music] my repositories because I had exact same thing I'm not going through the entire troubleshooting uh phase here but let's have a look and the way it looks like is you can add a patch and this is the one I'm talking about I don't think we have any patches here [Music] yeah so we just want to add this one I'll copy the wall and then I remove the other ones so let's do it here I suppose these I don't need just this one so now instead of the the one on on crates that I owe it will use the one the GitHub master of that one so let's see if we can do the build we did before and see if it works this time shouldn't take as long of course cool so now it works um also I've kind of forgot to mention uh on the template there are a bunch of things you need to have installed before on the prerequisites basically those so I obviously have them all installed but uh yeah you need to do that first so uh to run it now I can do cargo ESP flash so oh no first I need to connect it of course let me switch again on my desk camera and this is that uh controller I have a USB cable this USB E I plug into my uh dongle um the other side is a micro USB for these ones plug it in and you see on the LED that it's powered up now then um let's uh run cargo USB flash that will flash it and dash dash monitor will when it has flashed it will connect the serial Port so you can see output output all right so let's go it will ask for a port so it already detected that it's there take the default and now it starts uploading again it will take a while not as bad and once it is uploaded it will start a binary and it will lock and then in this case the log is kind of essential because the only thing this program does is log lock the hello world line so uh yeah we it's a if you don't see that there's absolutely nothing happening so here you see this is the line we were looking for hello world and then it just returns from the app so that's uh on one hand an impressive but on the other hand it was pretty straightforward until now uh all right that's all for this one uh I'll follow up too
Info
Channel: Floodplain: Streaming, Rust and Embedded
Views: 20,305
Rating: undefined out of 5
Keywords:
Id: o8yNNVFzNnM
Channel Id: undefined
Length: 14min 8sec (848 seconds)
Published: Sun Jul 23 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.