Hacker News new | past | comments | ask | show | jobs | submit login
Linux 5.0 shown to boot on ESP32 processor (cnx-software.com)
290 points by MrBuddyCasino on July 19, 2021 | hide | past | favorite | 79 comments



This is pretty amazing. I remember the first computer I installed Linux 1.x on had 12 megs of ram in around 1992 or 1993? The smallest system I built/ran it on even back then was probably a 386 with 4MB of ram and it was so slow. Kind of amazing that after so much work, even torn down to the bare minimum it can run the modern kernel on such minimal hardware!

Edit: probably worth noting that esp32 cores are an order of magnitude higher frequency than those 90s computers.


You could run a serviceable Linux console on 4MB RAM back then. X11 was also doable though it would be swapping heavily with less than 8MB.

Nowadays it would be more practical to add ESP32 support to uClinux and skip the unnecessary performance hit of the VM.


> swapping heavily with less than 8MB.

No kidding! My intro to X was seeing it load bare-bones on my enthusiast friend's 2M (could have been 4) 386.

I think he brought xfontsel up or something and you could see the scanlines being drawn one at a time :)

A couple of years later, I was running fvwm2 and a very serviceable desktop at work in 8M though. (AFAIR, anyhow.)


FVWM2 it's even lighter and faster than TWM. Test it if you don't believe me.

With the wireframe mode, it's even faster on moving and resizing.


Moving and resizing wireframe boxes seems like to me like an ergonomic and technical win - it’s a bit baffling to me why it’s not the default everywhere, no matter what the compute/gfx capabilities.


Yeah, it's crazy how CWM it's crazy fast on my AMD Turion 2 but windows lag a bit upon moving/resizing them.

Implementing a wireframe mode on CWM should be dumb easy and a lot of older machines would profit from that.


Back in the day you had plenty of SVGAlib games, PDF readers and even video players. You didn't need X at all, mp3blaster/mpg123 worked crazy fast on a Pentium and with Screen you had the perfect multitasking environment for the TTY.


Elinks could render to SVGAlib well enough to browse sites that weren’t loaded with JS, no X11 needed


Elinks? I think it's links+, which support{s,ed} SVGALIB and Framebuffer.

But back in the day you could browse without images perfectly fine, as the important ones where under galleries with custom links and downloading them was really slow.


> "You could run a serviceable Linux console on 4MB RAM back then. X11 was also doable [..]"

This was my setup for a considerable amount of time. Even though it is hard to believe in our fast paced times it must have been for several years.

The 386DX with 4 MiB was my first Linux machine and my first PC for that matter. 4 MiB was not enough to even run the Slackware installer, so you had to partition and mkswap manually from the command line before you could run it.

Apart from that it was a pretty workable machine for those days standards. I used it from the console most of the time, but X11 worked, even if it was slow as molasses, as you said. I remember running GNU chess. While you could play from the command line it was one of the apps where the GUI was really helpful.

Good times!


True. I ran a whole university’s DNS service on a 4MB 486dx2/66 running Linux 1.2.13.


We probably hung out on the same IRC channels :)


back in the day we've had 64KB to run our GUI and it ran fine (GEOS on c64). 4MB RAM would have been jaw dropping.


I’ve come to appreciate how economical folks who experience the 8-bit era are, and it seems to be having a resurgence and I love it.


As long as you don’t expect it to do much. GEOS barely manages to run one application at a time while swapping continuously. It’s an impressive achievement but really not comparable to a general purpose multitasking operating system.


It was definatelly not "barely". The word processor became my workhorse for all my school assignments for a while...

Also, when writing, it's probably better not to have a multitasking OS - no distractions ;-)


You're kidding, right? GEOS was terrible. Absolutely horrible. Unusable.


Is uCLinux even still alive? Last time I checked the main website was gone.


It's merged with the mainline kernel.


Is there any actual information for building it? I really am having a hard time finding anything that doesn't just link to a SourceForge repo last updated in 2016.


So is extensa support although probably not for this one specifically.


People forget (if they were even there) what was reasonable at the time. My first Linux was a 386sx with 5MB of RAM in the late 80s. It ran pretty well.


assuming either linux or 80 was a typo here hehe


Ug...yes, meant 90s. Must proofread...


12 megs in 92? Fancy.


Haha, tell me about it. I think the 4MB upgrade cost around $300 or $400 at the time? Similar to my first 1GB hard disk which came a few years later that cost $500.

I was a little spoiled since my dad worked for a telco, so we tended to have decently modern computers and modems for that reason. I was REALLY fancy when I got 128k ISDN in 1996.


I had 1.1 up /2.2 down mbit Adsl in 1997, was pretty awesome!


I worked for an ISP so that my day job was 1mpbs, this was enough to serve 50 concurrent dialup customers back then!


Slashdot would fly under Netscape/Opera :p. Under Lynx, it would be like switching off from a bike to an F16.


my 1st HDD (1992) was a 20MB one ... 20 - MEGA-BYTES (about $300) and quess that I totally screwed it using the debug -mistyped some params- in order to Low-Level format it, luckily I ve managed to return it back.


I worked in a lab once with a five megabyte hard drive from the 80s being used as a door stop, it was huuge, like the size of a large shoebox. They also had a WORM drive from the 80s that I dug up an ad for and it cost $25k for the writer and it could store 4Gb!!! On what looked like a laser disc in a tray. It’s wild the range of available technology at any given time, depending on how much money you have.

I do remember being very cautions when I first setup linux because things actually cared about the number of blocks, cylinders, etc, and if you got it wrong things broke in confusing ways.


> 12 megs in 92? Fancy.

Absolute luxury! I had 4MB three years later in '95... and in '96 I got the Linux Kernel Internals book which came with a slackware CD, forcing me to purchase my first CDROM drive.


The computer I was using at work in 92 had a whopping 16mb! It was amazing. It might have been a 386 20MHz (before the cache was added to the systems so was very slow compared to a 25Mhz that came out soon afterwards).


Lucky you! In 1991, I moved from a Timex 2068 to PC, while the technical school was still using 8086 and 286 systems.

A 386SX with 20MHz, 40 MB and 2MB, running Windows 3.0.

16MB was indeed another level!


The repo link: https://github.com/juiceRv/JuiceVm

It seems to be booting a riscv vm, which is capable of running linux. The hardware capabilities of ESP32 is not very important(except being fast enough).


"Fast" is relative here. According to the youtube link OP posted in CNX comments, it takes 6 minutes to boot to shell. Still, better than two hours @dmitrygr's ARMv5-on-AVR emulator took.


yeah, 240MHz 32-bit cpu does help compared to the 20-mhz 8-bitter :)

Although, Xtensa can execute out of RAM, so here a JIT could be used for a larger speedup. Maybe i'll build a RiscV-to-xtensa jit some day when i'm bored


The video description states 30x speed so I suspect three hours is a more realistic expectation.

https://youtu.be/w9UlZIYZtwI



> it takes two hours to boot up to a bash prompt, and four more to load up Ubuntu and login. If you want a Megahertz rating, good luck; the effective clock speed is about 6.5 kilohertz. While the worst Linux PC ever won’t win any races, its simple construction puts it within the reach of even the klutziest of hardware builders; the entire device is just a microcontroller, RAM, SD card, a few resistors, and some wire.

I don't know why, but this little kludge greatly pleases my sense of aesthetics.


I remember when I first learned of MySQL’s triggers I immediately thought that it might be fun to use them to implement a microcontroller or even a full computer emulator. A table with registers, a table for RAM, etc. If it was x86 or ARM or some such then I could compile Linux on it and then run MySQL inside of that!


That is an amazing idea. Then run SAP on top of that and turn it into an art installation.


Should have run Oberon, though.


Sort of equivalent to this (installing Linux on a dead badger): http://strangehorizons.com/non-fiction/articles/installing-l...


Not even close. 8MB of RAM with a 32bit processor will run Linux perfecly well on minimal builds.

A 230MHZ 32bit CPU it's far more powerful than a 8bit processor emulating a 32bit one.

You could use cli apps and even X perfecly well with 16MB and 80MHZ in 1996.

EDIT: Ok, this is emulating too. Sorry, then.


Linux doesn’t target the xtensa nor does it have a proper mmu so this is emulating a risc-v. It is still very much in the novelty “hack” realm.


There does seem to be a Xtensa Linux port, but you need a Xtensa chip that has some more features than the ESP32 does. http://wiki.linux-xtensa.org/index.php/Supported_Processors


Ah, then that's different, because I've run Linux under an Armv5 device with 32+16mb of RAM with zram just fine.


Similar in the sense that both approaches essentially run Linux in a VM, virtualizing the typical hardware required such as the MMU. In essence, it's the esp32 version isn't much different, just faster as the core is faster.

Would be cool to get no-MMU Linux running on it. I've seen that run on STM32F7's natively..


Loading was super slow for me. Archived copy: https://archive.is/kx3o9


Wow, I always though this was unfeasible due to how limited the ESP32 MMU is.


The MMU is not really a requirement in this situation, a processor with a real MMU is emulated in software[1] on the ESP32 (this is the virtual machine referred to in the article and comments)

1: https://github.com/juiceRv/JuiceVm


He said infeasible, not impossible. You can run Linux with no MMU by compiling binaries with static offset into main memory but it's not amazingly practical.


Uh, so that's the trick, very neat.


Video of the boot was linked in comments https://www.youtube.com/watch?v=w9UlZIYZtwI

Note the description: video is sped up 30x


Weird. It shouldn't be that slow. I've run Linux on a 486 16mhz which was definitely slower than an esp32 and it was performing just fine.


It probably wasn't Linux 5.0 though, was it?

There likely were also some nasty, performance-sacrificing hacks involved. A comment above mentions "booting a riscv vm".


It's running on a RISC-V emulator that's running on the ESP32 Xtensa. That would slow it down quite a lot.


Note: It uses a virtual machine


Does this processor support privilege levels? And threads?


No to privilege levels, yes to threads.

But to answer your question more completely, it's running a RISC-V emulator which is then running the Linux kernel.


That's cool. Even CircuitPython doesn't support threads.


MicroPython (CircuitPython's upstream) does:

  MicroPython v1.16; ESP32 module with ESP32
  Type "help()" for more information.

  >>> import _thread
  >>> _thread.start_new_thread
  <function>


What does it mean for processor to support threads? I thought that threads are OS-level abstraction.


Well, the processor needs to be able to do the context-switching (switch all registers, i.e. the visible state of the cpu, with those of another thread). You can obviously do this in software (emulate it) but that would be too slow for most practical purposes. Hence the question.


Most context switching code happens in software. It's only occasionally that cores have hardware task switch support.


Interestingly, Intel has hardware context switching support, but apparently Linux and Windows don't use it.

https://en.wikipedia.org/wiki/Context_switch#Hardware_vs._so...


Yeah, that was it's own system that had a lot of mismatches with how different OSes wanted to conceive of task switching.

Where Intel ended up was the xsave/xrestor family of instructions to save and restore processor state according to a bit flag argument of high level functional units. And that's really only because of how complex all of the extensions to x86 have been over the years; a fresh arch is probably just better off manually writing everything with normal loads and stores until right around the iret equivalent. Dumps between the register file and memory show up on perf traces anyway so it's generally a very optimized path in the CPU for general uses anyway.


You need a programmable timer interrupt to be able to preempt running code, but in general you're right


Note: this is for the new RISC-V ESP32 (not the older xtensa based one)


Nope.

> (...) one developer apparently managed to boot Linux 5.0.0 on a board with an ESP32 dual-core Xtensa processor (...)

> The shortened boot log above shown the bootloader output with ESP32-D0WD dual-core Xtensa processor eventually booting Linux 5.0.0.

It's booting to a RISC-V virtual machine which then boots Linux, which may have confused you.


OK - that makes sense - it was OpenSBI which is a RISCV only thing that confused me


The article says that it's not, and according to the reddit post, it seems to be using a JuiceVM port to ESP-IDF, allowing it to run on the Xtensa version.


I read that as ESPN2


i should finally start my esp32 project

actually i work 9h a day i dont think i have time ;_;


Pardon my question. Why is this significant?


E.g. I did not know it was possible. (And, being able to run Linux is significant.)


It's not. It's a fun hack.


Life would be boring, if we cared only about significant productive stuff. This is a fun project to spark our minds. Nothing wrong with that.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: