EETH - Blog

Linux on a Microcontroller the ESP32 S3 Does the Impossible

· hkcfs

You know, we spend a lot of time drooling over the latest CPUs with hundreds of gigabytes of RAM, or fat, hungry Nvidia GPUs with terabytes of VRAM. We talk about “edge computing” on Raspberry Pis or even fancy mini-PCs. But what if I told you that developers are now cramming a full Linux kernel onto a microcontroller? Yes, a microcontroller. The tiny chips typically found in smart light bulbs or simple sensors.

For a long time, the idea of running Linux on something like an ESP32 was considered impossible, or at best, a crazy hack with no practical purpose. These chips have a few megabytes of RAM, not gigabytes. They are designed for simple, real-time tasks, not running a full operating system with all its bells and whistles. But sometimes, “impossible” is just a dare to the open-source community.

I’m here to tell you that the impossible has become a reality. People are running Linux on the ESP32-S3, and it’s not just a boot screen; it’s a functional, networked Linux system. This is a feat of engineering that makes my 16MB OpenWrt router look like a server rack (I think it’s a bit too much).

The Hardware Hero: The ESP32-S3 (and its tiny brain)

Before we get into the Linux wizardry, let’s appreciate the hardware: the Espressif ESP32-S3. This is a fantastic chip, primarily designed for IoT devices.

The ESP32-S3 is like a highly efficient, specialized drone. It’s built for specific, fast-response tasks, not for carrying a payload the size of a jumbo jet. The idea of loading Linux onto it is like asking that drone to carry a full-sized human.

The Unbelievable Feat: Linux Booting!

The breakthrough came from dedicated developers pushing the limits. One prominent figure, “rudi ;-)” on the ESP32 Forum, has been a key driver. Just check out his thread, aptly titled “Boot Linux on ESP32-S3”.

The initial success was met with excitement, but also a healthy dose of skepticism. As one forum user, “username,” put it:

“Lastly, though it boots, what can we really do with such limited ram?”

And that’s the million-dollar question. What can you do with so little?

Looking at the terminal output from rudi’s work (you can see similar outputs in the YouTube videos as well):

Linux buildroot 6.5.0-rc1 #2 PREEMPT Tue Aug 8 08:11:59 CEST 2023 xtensa GNU/Linux
Mem: 7.2M total, 4.1M used, 2.3M free, 884.0K buff/cache
CPU: 37% usr, 27% sys, 0% nic, 34% idle, 0% io, 0% irq, 0% sirq
Load average: 0.08 0.05 0.01 1/37 900

(As seen in the image on the ESP32 forum)

Let that sink in: 7.2MB total RAM detected, with 2.3MB free. A full Linux kernel, running on literally a 4.9MB megabytes of RAM. Most “minimal” Linux distributions for desktop PCs would consume 10-5x that just for the kernel. This is not just minimal; this is microscopic.

Initial clockspeeds often start around 160MHz, but developers quickly pushed it to the chip’s limit. As rudi stated:

“i heard you, - here you are 240 MHz,” … “sched_clock: 32 bits at 240MHz, resolution 4ns, wraps every 8947848189ns”

What Can You Actually Do? (The “Limited RAM” Question, Answered Ingeniously)

So, with only a few megabytes of RAM, what’s the point? You can’t compile a big program locally. You can’t run a web server hosting hundreds of pages. You can barely run top without it eating half your RAM.

This is where the true ingenuity comes in: remote file systems and SSH.

The ESP32 Linux port isn’t meant to be a standalone powerhouse. It’s designed to be a thin client to a more powerful server. As demonstrated in one of the YouTube videos (see “Remote Build by ESP32-S3 SSH Client which runs #jcmvbkbc #esp32s3 #linux #esp32 S3 port”) and the forum post, the system can:

This setup allows for:

The Linux kernel on ESP32-S3 is still very much an experimental, bleeding-edge project. It’s not for the uninitiated yet.

#linux #esp32 #microcontroller #embedded #minimalism #iot #buildroot #open-source #hardware hacking

Reply to this post by email ↪