Can you run Linux on an ESP32? Yes! While a normal ESP32 can’t run Linux (yet), one specific variant can. The ESP32-S3-N8R8 is now able to boot a Linux port for Xtensa Cores, and doesn’t do a poor job! On the contrary, the port is quite usable, comes with the classic vi editor, and even connects to the internet. Also in this video, Clem explores the use of the Raspberry Pi Compute Module 4 along with some of its limitations. He points out that, for some projects, a microcontroller is more suitable and power-efficient choice than a single-board computer like the Raspberry Pi. However, he acknowledges that in many cases, a more capable system running an operating system like Linux is required.
Jump to Downloads & Bonus Content | Jump to Discussions
DOWNLOADS: Code, CAD Files, and Schematics
Clem introduces the idea of running Linux on an ESP32 microcontroller, specifically the ESP32-S3 variant. There is a Linux port available for this ESP32 variant, allowing for a more versatile and power-efficient option for projects requiring an operating system. Clem delves into the hardware design process of his SUDOSOM-S3 module, showing a PCB layout that accommodates the ESP32-S3 in a form factor compatible with the Raspberry Pi Compute Module 4. He highlights the importance of maintaining GPIO compatibility to make transitioning projects from the Raspberry Pi to this custom board easier. He also discusses the challenges of aligning the headers when putting everything together.
To design and build his SUDOSOM-S3, he uses a KiCad template for CM4-style boards. Keeping this template in mind, he designs a simple initial iteration based on the principle communicated in the USB-Card Reader Prototype Episode. This included the core MCU module, power regulation, a USB port, and pins for debugging and flashing, as well as GPIOs routed to corresponding pins on the Mezzanine connectors. Speaking of Hirose Mezzanine connectors, aligning them when doing hand assembly is very tricky and solder bridges can easily form. Inspection with a microscope is needed, and cleaning up the pins with a generous amount of flux and deliberate soldering iron touches is almost always advisable.
A key difference between the SUDOSOM module compared to a real CM4 is not just a different processor, but a USB-C port. The SUDOSOM has an onboard USB-C port, which allows it to be used as a standalone and not just embedded into a device. This makes developing software and Wi-Fi applications much easier. With his first iteration assembled, Clem proceeded to compile the needed files; however, a big hurdle in the form of missing knowledge about kernel development and toolchains emerged.
A key difference between the SUDOSOM module compared to a real CM4 is not just a different processor, but a USB-C port. The SUDOSOM has an onboard USB-C port, which allows it to be used as a standalone and not just embedded into a device. This makes developing software and Wi-Fi applications much easier. With his first iteration assembled, Clem proceeded to compile the needed files; however, a big hurdle in the form of missing knowledge about kernel development and toolchains emerged.
After installing the missing dependencies, with multiple attempts at compiling, Clem is forced to abandon his initial plan. His editing PC crashed violently on every attempt, most likely due to overheating during compilation or configuration errors. To save his PC from certain death, he asked the developers of the Linux port for pre-compiled firmware. Two names of note are doing the bulk of work on the overall project:
The current state is documented on Github: https://github.com/ESP32DE/Boot-Linux-ESP32S3-Playground
Next, he shares his script to simplify the process of flashing Linux onto the ESP32-S3, emphasizing the multi-step nature of the process, including bootloader and partition table flashing. It turns out this is not as straightforward as just uploading an Arduino sketch or flashing CircuitPython via ESP-IDF. By referencing the build scripts of jcmvbkbc & Adafruit’s Docker version, Clem finds all the required commands for the multi-step flashing process and successfully flashes Linux on his SUDOSOM module. This process was a daunting experience that he couldn´t fathom doing every time, even by just copying and pasting lines from a text document. To make things easier, the flashing process was completed using precompiled files that he received from the creators of the Linux port: https://github.com/mayermakes/Sudoflash
This tool asks for the port the SUDOSOM module is connected to, the names of specific files (as those could be named differently when compiled from scratch), and executes the needed commands, including updating ESP-IDF to support the right target MCU. While this process is now much simpler, it still takes 8-10 minutes to flash the board. Clem shows the bootable system and demonstrates connecting to it via a serial terminal over a USB port. He mentions the possibility of using SSH for remote access and demonstrates downloading files using Wget. After exploring the file system, he builds a quick second iteration to push his SUDOSOM project along faster. Version 2 integrates the USB-to-UART converter on board, adds a second USB-C port for the native USB capabilities that are hopefully coming soon to the Linux port, and employs an RP2040 MCU to act as a pseudo-GPU.
The RP2040 is the MCU used on the Raspberry Pi Pico and is known for its PIO capabilities, which allow it to produce DVI video (a subset of HDMI). To make the SUDOSOM module more versatile, Clem integrates an RP2040 microcontroller for additional functionality, such as graphics capabilities via HDMI/DVI. This, in turn, should give the SUDOSOM graphical capabilities.
Clem also discusses his experience with compiling the Linux kernel, noting a potential issue with GCC compiler dependencies. The flashing process was completed using precompiled files that he received from the creators of the Linux port. Clem shows the bootable system and demonstrates connecting to it via a serial terminal over a USB port. He mentions the possibility of using SSH for remote access and demonstrates downloading files using Wget.
To make the SUDOSOM module more versatile, Clem integrates an RP2040 microcontroller (the type found in the Raspberry Pi Pico) for additional functionality, such as graphics capabilities via HDMI/DVI. Clem acknowledges that there is still work to be done, particularly regarding HDMI output, and encourages viewers to share their ideas for improving the board and software support.
The plan is to eventually program a driver that allows the use of Adafruit’s GFX library commands with SUDOSOM, so the RP2040 would not only render the UART-console to a screen, but also draw graphics (like it already does on TFTs and OLEDs in numerous projects). Clem rushes through the KiCad process to get the PCB into production at Aisler as soon as possible. Thanks to quick turnaround and express shipping, he receives the board just in time for the release of the video. After cleaning up some solder bridges under the microscope, the new Sudosom Beta is flashable. However, it browns out on boot. Another hurdle to overcome.
Overall, Clem provides a comprehensive overview of the project, its challenges, and its potential applications, making it clear that this custom board could serve as a valuable tool for makers seeking a balance between microcontroller and single-board computer capabilities in their projects.
Linux on ESP32 is in a very young state, but has the potential to be a cost-effective solution for projects that might benefit from an operating system other than RTOS, and avoid overengineering when using proper CM4 modules. During development of the SUDOSOM Beta variant, Clem came up with configurations that are already possible with the current version of his SBC that make it a nice candidate for non-Linux projects. The ESP32-S3 can be used as both host and auxiliary processor. Both the ESP32-S3 and the RP2040 can be used with Arduino , C/C++ , RUST and MicroPython. You can freely choose if you want to run your main code on the RP2040, and use the ESP32-S3 as a Wifi and BLE bridge (similar to the Pico W), or go the other way and run the main code on ESP32-S3, using the RP204)’s PIO capabilities for the I/O. A mix of languages might also come in handy for many projects, with a simple CircuitPython file handling and faster executing C code on a dedicated real-time processor. The future looks full of intense development for this little module on the software side. And it seems that Clem already has plans to integrate it into an upcoming project.
Files and Bonus Content Links:
- Community Discussion on Linux on ESp32S3
- DOWNLOADS: Code, CAD Files, and Schematics
- Creators of the linux port to ESP32-S3: https://twitter.com/jcmvbkbc and https://twitter.com/ESP32DE
- Repo for the Linux port https://github.com/ESP32DE/Boot-Linux-ESP32S3-Playground
- Repo for Flashing tool https://github.com/mayermakes/Sudoflash
Bill of Material:
Product Name | Manufacturer | Quantity | Buy Kit |
---|---|---|---|
HIROSE(HRS) DF40C-100DP-0.4V(51) | HIROSE | 2 | Buy Now |
HIROSE(HRS) DF40C-100DS-0.4V(51) | HIROSE | 2 | Buy Now |
MICROCHIP MCP1825S-3302E/DB | Microchip | 2 | Buy Now |
MOLEX 105450-0101 | Molex | 3 | Buy Now |
FTDI FT230XS-R | FTDI | 1 | Buy Now |
RASPBERRY-PI RP2040CT | Raspberry pi | 1 | Buy Now |
Additional Parts:
ESP32-S3-N8R8 module (it needs a minimum of 8MB PSRAM to run Linux) can be sourced over www.mayermakes.at |
You can use code "thanks_mayermakes_23" at checkout on Aisler.net if you want to try the PCBs out. |