Linux on ESP32

Posted by boveyking 5 days ago

Counter129Comment49OpenOriginal

Comments

Comment by tyingq 1 day ago

The responses all seem a little harsh. If you poke through the user's history, this kind of thing isn't new for them, going back to pre-LLM-could-do-this days.

I think the docs are light because the primary goal for them is not to provide everyone with a well documented linux on esp-32-s31 guide, but rather this that they shared:

"I'm currently working on a hackable music player and I used to prototype with the OG esp32, and tbh if I wasn't for Bluetooth audio I'd move on to S3 already" ( from the links in this comment https://news.ycombinator.com/item?id=49134987 )

Comment by Aurornis 1 day ago

> If you poke through the user's history, this kind of thing isn't new for them, going back to pre-LLM-could-do-this days.

Is there another set of comments or history I should be looking at? The only pre-LLM comment is about doing a prototype for something with the old ESP32. That was a common hobby microcontroller introductory project, but there’s a world of difference between playing with an OG ESP32 and porting MMU Linux to a new platform.

I think we should be honest about what this is: Someone spent their tokens letting an agent attempt bring up of Linux on the platform and it got something to work. I’m appreciative that it was shared. However, given the lack of useful documentation (the key MMU doc is basically empty) and the lack of other explanations, I don’t think we should be reading more into this than as a pure LLM agent proof of concept.

Comment by sparse-Matrix 1 day ago

Honestly, why do you care so much if AI was used?

Assuming he did use AI, it didn't spontaneously generate the project and foist it upon the user and the world; the user used the AI to generate the project at his direction.

It's like the old friend when I decided I didn't care for wearing a full beard in July and got really angry with me about it when I shaved -- not my friend anymore.

Dont like the project? move along.

Otherwise, why are you wasting your energy to put down this hardwork?

Comment by Aurornis 1 day ago

[dead]

Comment by numpad0 1 day ago

There isn't much interesting about a rocket engine other than it's rocket science and it's awesome if it works. A basic mockup of one is in PrusaSlicer sample files.

Comment by ofalkaed 1 day ago

It takes no effort to play LLM or not, you don't need to know anything about the topic or put anytime into reading and understanding the submission, just find that em-dash and you can turn every discussion into meta slop.

Comment by tyingq 1 day ago

I also think an LLM isn't going to just spit this all out and viola, it boots. I imagine there were many rounds of jtag debug, copy/paste into the LLM prompt, with enough human knowledge/context to say the right thing, suggest some existing implementation snippet, etc.

Comment by Aurornis 1 day ago

> I imagine there were many rounds of jtag debug, copy/paste into the LLM prompt

You may not be familiar with modern LLM tools.

You don’t need to copy/paste anything. You can easily instruct your agent to access the serial port and JTAG debugger and it will easily handle it through subsessions.

The tools have moved rapidly this year. Something like this is entirely doable by attaching the right cables, telling the agent where to access everything, and then keeping it fed with enough tokens to keep going.

There are some amazing projects doing reverse engineering or porting to micros fully automated. The results are still full of typical LLM output problems, but it’s amazing what can be brute forced with enough tokens in an LLM loop.

When I’m evaluating MCU platforms for new projects I’ll some times set an LLM loose on each to get a proof of concept running so I can do benchmarks or testing. It can save a lot of time finding showstoppers or roadblocks before I waste a lot of time on doing the problem correctly.

Comment by nunobrito 7 hours ago

I've been writing code by hand for 30 years and nowadays use LLM too for embedded and Android development among other stuff. It saves a lot of time and is amazing that it can debug multiple embedded devices connected to the computer far better than my doing it by myself.

There is certainly slop but it was always like this in software engineering, just that now is far easier for anyone to write code that runs on ESP32 which in my opinion was already quite easy in the past but frankly bothersome to get any complex project running.

I'm old enough to remember when other developers criticized heavily the usage of Turbo Pascal in the 90s because "it wasn't a real compiler" but reality is that it made software writing far easier and fun for a whole new generation of kids. It seems we are going through a similar wave, it will take time until this settles as a new tool.

Comment by sparse-Matrix 1 day ago

This is a common misconception among those who nothing about AI

Comment by grieferpig 1 day ago

Author here, few things to clarify:

- Yes it is vibe coded. It do work on real S31 dev boards (there's console output and binary releases to prove that.) I understand the esp32 microcontroller architecture to some extent, but I barely know how to port Linux to other RISC-V platforms; what I did is to tell the agent something like "Go implement an IPC transport that uses a shared SRAM buffer and an IPC interrupt doorbell" or "sdmmc uses designware ip; search esp-idf usage and port the existing Linux driver over." An AI agent on its own would never discover S31's bespoke hardware behavior without my guidance, for example, that the register `mcliccfg` has writable bits, despite esp-idf saying otherwise. However I admit that AI assistance is the direct reason why I am able to progress this fast, and I did learn a lot about kernel development during the process. If you're bothered by AI code, move on.

- Untested is a bit misleading: per the README, means "seems working; not thoroughly tested." They do seem to work at the time when their drivers are being built. Three weeks into this project I can't have everything stress-tested already.

- I built this more as a proof of concept intending for my own use; I did not expect it to gain popularity anytime soon, so the docs are very bad for now.

Comment by Aurornis 1 day ago

Obviously vibecoded but interesting nevertheless. The agent left everything marked as untested in the README but the output snippets toward the bottom imply that it got something working enough to log in and run some commands.

Nobody is going to mistake this for a carefully crafted port of Linux but it at least serves as a proof of concept.

The real downside of the vibecoding is that we don’t get any helpful information about what it took to get it done with thoughtful analysis from a human. Just a chunk of code in a GitHub repo with some half-coherent README. There’s a docs folder, but the documentation about the MMU part just says that there are two MMUs across a couple lines of notes. Okay, great.

Comment by voakbasda 1 day ago

Given the context of a vibe-coded project, would it be reasonable to assume the example outputs are outright hallucinations, without seeing indisputable evidence to the contrary?

Sad that’s where my mind goes, but this is what the world has been training me to believe. And these doubts now eclipse the skepticism that I developed toward things that humans posted on the internet.

Lies, damn lies, and LLMs.

Comment by Aurornis 1 day ago

I don’t think so. I think this is a real result confirmed by a real person.

I also think it’s pretty cool.

We do need to keep it in context though.

Comment by IgorPartola 1 day ago

On the other hand this shows that it is possible and gives a floor for performance.

Comment by Izmaki 1 day ago

Everything is untested or WIP. What is the news here, sorry?

Comment by jubilanti 1 day ago

The news is: vibe coder vibe coded this and got their agents to upvote it.

Comment by genericacct 1 day ago

For a worthy goal .. linux on esp would be a game changer for iot imho

Comment by 0x20cowboy 1 day ago

Why would it be a game changer? It seems a heavy hammer for what is actually needed. FreeRTOS itself is already really incredibly fat.

(Worthy goal though I agree there. Fun at the minimum.)

Comment by pjmlp 1 day ago

For whom? There are already plenty of POSIX options, and with business friendly licenses.

Comment by NooneAtAll3 1 day ago

[flagged]

Comment by jagged-chisel 1 day ago

Is that a critical correction? Is a gender neutral pronoun somehow unacceptable?

Comment by NooneAtAll3 1 day ago

it's plural

Comment by jagged-chisel 13 hours ago

their, pronoun

2) a form of the possessive case of singular they used as an attributive adjective, before a noun.

a) (used to refer to a generic or unspecified person previously mentioned, about to be mentioned, or present in the immediate context): A parent should read to their child.

Comment by biosboiii 1 day ago

>Espressif's radio firmware blobs are closed source, and must run within ESP-IDF's FreeRTOS framework. It's near impossible to reverse-engineer them (not to mention legal risks.)

It's not nearly impossible, it has already been done :)

Slides: https://fahrplan.events.ccc.de/congress/2024/fahrplan/media/...

Video: https://www.youtube.com/watch?v=r8IqkUTGjlA

Comment by grieferpig 1 day ago

It is for the older original esp32, not for this port which is esp32-s31. Their radio are drastically different. Also their reverse engineered firmware are incomplete so esp-hosted remains the best choice for now.

Comment by yjftsjthsd-h 2 days ago

> In mainline linux, XIP support on RISC-V was removed, so 6.12 was used instead which has proper XIP support.

Doesn't that put it in an awkward position relying on a dead end feature?

Comment by grieferpig 1 day ago

There are other ports that uses newer kernels (iirc annoyedmilk/esp32-s31-linux used 7.1). XIP saves me RAM, and on a device with 16mib ram I need to squeeze as much ram as possible. Besides I couldn't think of any use cases where you really need a newer kernel

Comment by yjftsjthsd-h 17 hours ago

I absolutely see the appeal for XIP here! I just have been sufficiently traumatized by Android devices that anything that breaks the ability to follow upstream makes me nervous. I'm sure it's workable here, both because this is a recent enough version that it'll be supported for a long time and because I expect it can be ported forward if really needed. (And of course, at this point it's not like this is a real production thing so as an experiment who cares.)

Comment by Neywiny 1 day ago

What I remember was they said it could come back if people needed it but it was broken for looking (months, years) at a time. So even if they didn't remove it, 6.12 might be the last working version with it anyway

Comment by iririririr 1 day ago

it's common to move "unused" code to patches

Comment by fitsumbelay 1 day ago

The responses to agent-aided dev seem a little over the top to me.

The derisive "vibe-coded" label is one thing, but the least compelling argument or complaint of them all is the truly worn out one about barriers to entry that you and I and so many others worked soooo hard to climb over are now being obliterated, allowing any casual Moe to stroll into your domain. How many professionals -- djs, photographers ... hell, SEO experts -- pretty much anyone technical and possibly creative have watched technology make work and the accumulation of competitors almost too easy.

If you just remember that no one in this time-space or anyother AFAICT is forcing you to consume or even read about projects like this, you'll find life goes on and you're actually still an expert who people who need experts will value materially (which should be your thing, otherwise wth are you complaining about?)

In fact, if you keep your mind open you might -- not definitely but _just_ _might_ -- find a piece of something useful amidst the slop. One fellow's trash ...

Comment by kogasa240p 1 day ago

Looks interesting but wouldn't something like netBSD be a better fit?

Comment by Joel_Mckay 1 day ago

Most ESP chips use FreeRTOS, and flash page caching support in hardware.

Unlike Multi-core Application processors which are a better fit for OS like BSD or Linux. =3

Comment by kogasa240p 22 hours ago

Good to know.

Comment by Rochus 5 days ago

How can it run when there is no MMU? Isn't this like rewriting a large part of the kernel?

Comment by peterus 2 days ago

This is for the recently released ESP32-S31 which does have a MMU, unlike the ESP32-S3.

The author has more details in this reddit post: https://eddrit.com/r/esp32/comments/1vait52/mmu_linux_on_the... And the docs section of the repo: https://github.com/GrieferPig/esp32-s31-linux/tree/main/docs...

Comment by Rochus 1 day ago

Thanks for the links. This doesn't seem to be a true RISC-V MMU (according to the Sv32 specification) integrated into the CPU core itself, but just a peripheral designed for memory mapped SPI flash and PSRAM. So as far as I understand there is no true process isolation with page faults and dynamic paging.

Comment by Rohansi 1 day ago

Sv32 is what every 32-bit RISC-V CPU with an MMU uses. It is a full MMU. You can run Linux on it.

Comment by Rochus 1 day ago

Sure, but what the S31 calls "MMU" is not an Sv32 MMU; therefore my comment.

Comment by Rohansi 1 day ago

The documentation states:

> Compliant with RISC-V Sv32 virtual memory scheme

https://documentation.espressif.com/esp32-s31_datasheet_en.p...

Comment by Rochus 1 day ago

Ok, I see. The S3’s "MMU" is just an external-memory mapper, not a virtual-memory MMU. The S31 apparently has both, that mapper plus an architectural CPU-side Sv32 MMU; that offers indeed a lot of interesting possibilities. Even sel4 would run on this machine as it seems. The ARM world has no microcontroller with a true MMU as far as I know. Risc-V now has at least two (here is the other one: https://www.bunniestudios.com/blog/2026/baochip-1x-a-mostly-...).

Comment by andylinpersonal 23 hours ago

Cortex-R82 may be the only microcontroller-class ARM core with MMU, but there are few chance for a random dev to develop on them.

Comment by 1 day ago

Comment by chrsw 1 day ago

The Microchip PIC32MZ MCU has an MMU as well. But not with wireless options in a 8x8 QFN80 package like this ESP32-S31. That's pretty small. No flash though.

Comment by yjftsjthsd-h 2 days ago

There is actually precedent for nommu Linux, though it obviously has tradeoffs.

Comment by stevefan1999 1 day ago

Yeah, nommu Linux basically cannot run normal ELF since there is no virtual memory which is needed for relative addressing and relocations. You are mostly left with classical formats like AT&T a.out only

Comment by derefr 1 day ago

You wouldn’t be able to guarantee execution of arbitrary ELF, but couldn’t you intentionally build non-PIC-compiled ELF executables where the section base addresses as defined in the header must match the MMU region “slots” the host provides?

Comment by extraduder_ire 1 day ago

I can't find it now, but someone ported nommu linux to those cortex-m3 "bluepill" development boards that could be bought for ~$2 (they were built wrong and liquidated for a massive discount).

Seeing the title of this submission reminded me of it because I messed around with it a bit a few years ago.

Comment by piterrro 1 day ago

When can we run doom on it?

Comment by extraduder_ire 1 day ago

On linux on an esp32? Doubtful that would even work.

There have been esp32 ports of doom for a decade though. Here's a current one: https://github.com/AmirhoseinMasoumi/ESP32-DOOM

Comment by boveyking 5 days ago

Have a try.