How to Run Linux on an ESP32

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome back to element 14 presents I'm Clen and this is our Raspberry Pi compute module 4 it runs Linux and this is an ESP 42 it does not or does [Music] it myself and all the other hosts have used a lot of raspberry pies in our projects but very often this is just too bulky to embed into a project for such cases there is the commute module 4 and you can directly embed it into your project like on a carrier board I even did one for a previous project but the realistic sad truth is that very often you don't actually need a single board computer a little microcontroller could do your project perfectly well even if you want to use Python code or Wi-Fi or Bluetooth specialized microcontrollers like the USB 42 are perfectly capable of that so there are cases where where a Raspberry Pi might be super easy to use but it actually isn't the best solution it's too big it uses a lot more power than you need and you don't even really need Linux on there but quite often an ESP 42 is just not big enough and you want want to have like an operating system where can give it tasks and have a bit more control like you would do on a Linux system so people are always asking could you run Linux on an ESP 42 until very recently you could just say no you can't run Linux on a microcontroller but actually we've seen a lot of proof of Concepts where people ran Linux on very very unpe microcontrollers it took hours to boot so they were basically just proofs of concept but now there is actually a Linux port for the extensa variants of ESP 42 cores so ESP 42s are not all created equal some of them have risk 5 course others have the ex tza cores some have more than one and some only have one core so the project we're going to do requires a specific variant the ESP 42 S3 there is a cross-compiled port of the current Linux kernel yes the current one to this platform made by wonderful people that put a lot of time into this and because I will butcher their names completely I will put their handles and their contact details on the screen so you can see that and also of course they are l in the show notes so our project is now I want to be able to flash Linux onto an ESP 42s fre I want to embed that on a module that is formfactor compatible and pinout compatible with the compute module 4 so I could use that instead of an original compute module and that would take a lot less power and it would still be like a usable Linux with Wi-Fi connection stuff for all the projects where a Raspberry Pi might be Overkill or a microcontroller might not just be up to the task because of the requirements of an operating system so let's hop over over to Kat and draft our first prototype welcome to my computer and Kad as you can see this is a pretty complicated sheet we have our ESP 42 S3 module in here we have a few other parts like the USB port but we also have all these sub sheets here and that is because this is actually a template that I made for not carriers for compute modules but compute modules so you actually have all the sections broken out into different parts H so you have your sections for all the uh different uh ways to connect to your Raspberry Pi and you can make sub schematics on here so here are the connectors and all the these pins are then copied over to specific sub sheets so it's easier to organize one I call this the pseudo suom template because PSE sudo Su is the name that I gave this thing which means PSE Sudo is the command that you take control of everything and then some means system on module so we have our main MCU SL system on chip on here that should run Linux in the end we have uh some connections for debug and for flashing uh reset circuitry and some caps to make it run stable uh some protection the USB port and uh otherwise we just have some voltage Regulators that's it and the connectors of course so we put that into a PCB it looks like this and it needed four layers just because when you look in here the section where it goes uh with all the gpios to the actual gpos it gets really complicated throughout and that is not because I want it to be complicated I'm pretty sure I could do this on two layers but I actually want the PIN numbers to still correspond so if you use like GPO 21 on your Raspberry Pi compute module then that code would still work with GP 21 on the USP on the same thing so as many pins that I could match to each other to have the same gpio number I did match them up but I this is not as much IO as the compu module so we can't have all the pins be the same but whenever there's a chance to have the same pin number corresponding so it's easier to transition your projects and stuff then I did that really important we have here this little boot header if you close that header module goes into download mode and it can Flash stuff to it if you remove that it boots normally of course this doesn't only run Linux you could also like run circuit python on there or flash it with the uinu ID as usual it's just in a form factor of a compute module let's get this into production at ISA and then assemble [Music] it thanks to ISA for the pcbs for this project and many other projects they delivered really fast and now we can go to assembly during assembly I had a bit of trouble with aligning the cm4 headers turns out if you look in the actual data sheet of those headers they do not recommend putting two in parallel so that usage is actually a bit off speec and the reason is just it's really hard to perfectly align them so they fit on the board every time at least by hand if you get those assembled as a Serv it like with Isa then I don't think that's an issue but if you're doing it by hand be aware that it's really hard to perfectly align them a big difference between these two is that my variant has has a USB C port on there and that is because the compute module 4 can't really be used without embedding it even to flash it you have to put it on some sort of carrier but this thing here has its own USBC Port it also has a header for USB to uart converter so I can Flash it directly on here and don't have to embed it yet and I could also use this Standalone for projects that just need the barebones thing like stuff that only uses Wi-Fi and doesn't really need the gpio but I could always add them later on now that we have working Hardware I just proved that by flashing on a blink sketch that just outputs via serial with the Arduino ID so I know the chip is flashable and all the electronics work as intended now it's about flashing Linux onto this system hello I'm James from workbench Wednesdays a show about the stuff found on your electronics workbench look for new episodes on well Wednesdays you can connect with me over on the element 14 Community I look forward to seeing you for now it is time to get back to watching this week's project video I tried to compile the Linux kernel and this port myself but my computer every time locks up or outright shuts off during compilation I think I have a GCC compiler uh dependency error so I won't try that again because I need the PC to uh edit this video but thankfully the creators of the original Port have sent me a pre-compiled file for that or basically a series of files that we have to flash onto the esp32s fre to make it boot Linux this is the next project that we're going to tackle flashing Linux on this microcontroller is a multi-step process first we have to flash a boot loader then we have to flash a partition table then fill out this partition with even more files and in the end we should have a bootable system so I want to make that easier so I wrote a little script for that flashing Linux on the ESP 32 S3 is a bit complicated you have to remember a lot of commands and have to keep your ESP IDF up to date so I made a little script that makes that easier it is basically dependent on all these files that I got uh from the original creators of the port uh to flash them onto there and expects those files but you can during the script just enter uh different files if they are called differently because you can decide that while compiling but this makes that into a much more beable process it still takes around 8 to 10 minutes to flash all that stuff onto the little board now that we have a bootable system we connect to it via the serial terminal over our USB port I have to connect to the actual running system via uart because the cons console is actually put out to the art connection if I would compile that colel myself I could also change that I think hopefully let's see if the native USB will work in time currently USB host and stuff is not implemented so we can change directory and stuff but we can't actually do very much in terms of a compute module with it yet but we can uh change gpio States for example at the moment usually we stop at one iteration prove that it works and then we run out of time but this time I've pumped double shifts and there's a second PCB here that one has two USB ports integrates the USB U converter and even has another microcontoller on there what could that mean let's hop on over to Kat huh once again we're in Kad on my computer so we still have the same template but I've actually drawn up a new schematic it looks kind of like the old one but there are some changes especially for example I have changed the little header pins to a freeh headed pin because I can now solar in a switch which will make flashing and stuff a bit more comfortable and also if you look in the video section we have a whole new thing on here this is an rp240 the chip that is on the Raspberry Pi Pico and I've chosen that for one specific thing the Pio the programmable input output stuff because you can actually make this thing output DVI which is a subset of HDMI so I could have basically a little pseudo GPU I haven't done anything on the code yet but this is basically putting it out on HDMI Zer and here would be the pins for HDMI 1 haven't connected them yet because routing would be an absolute Nightmare and I get have to get this thing into production as fast as possible so if it's in this video you know that I did uh make it fast enough so we basically have a whole second microcontroller on here that gets commands via uart and then puts it on there and the goal is to have this accept the same commands as the Adafruit Graphics Library so you could basically wrap that into the same thing use the same library and when you output the commands in a program that you run on Linux it will draw graph graic on screen and not just output text h isn't that's an idea I have no idea how to pull that off in code yet but we'll see so anyway uh important if you use a rp240 you have to give it external flash that is not included into the chip so be aware that when you calculate for cost and space on the board speaking of space on the board oh boy do we have little space it's a four layer Board of course again but yeah the routing got pretty complicated still wanted to match up all the pins whenever possible uh this one here is even more complicated oh boy there's a lot of stuff to R here uh basically this section here that is all GPU stuff and this is basically mpu or yeah CPU stuff like main processor and graphics processor but I also have this super tiny IC here which is a USB switch and that allows me to give that uh Native USB functionality either to that chip or to that chip which means that it can effectively switch places so if you use that thing stand alone or embedded into something you don't have to run Linux you can also run circuit Python and arino or whatever and you can use DSP as the main controller and use the other one uh the rp240 as auxiliary stuff or you you can change it around use the rp240 as your main controller and use that as your Wi-Fi Bridge or your Bluetooth thing however you like and you can use it Standalone or embedded or on Linux if you want so let's get this into production ASAP with fast shipping and stuff to ISA so it makes it still into this video and uh I have an easier time flashing stuff on here because now the U to USB converter is integrated into the board the assembly went okayish I had a lot of cleanup to do there were a lot of bridges and stuff really tiny components also there are some experimental features like this switch that switches between the two microcontrollers to be able to program them and as you see I have removed the rp240 because it shorted the system which led to a brown out on here it was not so easy to detect but my finger sensed heat and usually a chip that gets very hot but doesn't do anything usually means it's broken so I removed it and now this thing boots and we can demo [Music] it after booting into Linux which actually takes about 15 seconds we can now change folders change directories look at all the stuff that is there we can see a lot of the usual Linux operating system functions are present we can change into the/ Etc directory which is the only one that we can actually Rite to all the other stuff is read only and in this directory we find a config file for the Wi-Fi settings if we use VI the built-in text editor we can change those settings to our credentials for the local Wi-Fi reboot the system log in again and then we have actual internet connection and we can ping a server if we can ping a server we should also be able to use W get to get files and for that purpose on zud doom.com I've made an FTP server that now holds test files which are basically just text files that I can download onto this thing and with cat I can read that and be sure that download happened correctly and I can basically get files onto the system currently that's the only way because the USB host functionality is not active so I can't put a USB stick on there or somewhere so that is the way I currently get files onto that or I type them in something really cool is also that I don't have to connect via the serial terminal if I don't want to I can also connect via SSH and that even works at the same time so I'm now connected both ways once via USB with the serial terminal and once via SSH over a normal terminal this is really cool I can even do stuff on both ends so so it's actually two users on one computer like with the the the old uh main frames but it's actually just a single ESP 32 crazy obviously this version has a lot of things to be desired and left to do especially for the HDMI output and there's a lot of software that we have to do for that there's a dedicated repo for all the software stuff called The esp32 Playground that is linked in the show notes there's also a dedicated repo and all the files on the element 14 Community for this handy little board and it's uh development there is a repo for pseudo Flash the tool to get it on there so we' have done already a lot of stuff to turn this into a thing that might go out there and could be built into a lot of projects but I want to hear from you your ideas on what needs to be added to this board what kind of software support does it take to make make this into a viable alternative what are the projects that you would do that are not just just not microcontroller territory just not single board computer there might be something in between or just this little project where it would be just overkilled to use a Raspberry Pi but you still want to have something like an operating system let me know I got to go there's another project waiting for me and I'm pretty sure it involves this in one way or [Music] another
Info
Channel: element14 presents
Views: 100,305
Rating: undefined out of 5
Keywords: electronics, hardware, hacking, mods, element14, maker, engineering, element14presents, linux, esp32, esp32project, esp32projects, raspberrypi, raspberrypicomputemodule
Id: pj0a91vlcGo
Channel Id: undefined
Length: 18min 53sec (1133 seconds)
Published: Fri Oct 06 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.