
Linux on an 8-Bit Micro? (2012) - WoodenChair
http://dmitry.gr/?r=05.Projects&proj=07.%20Linux%20on%208bit
======
dang
For the curious—2017:
[https://news.ycombinator.com/item?id=15841241](https://news.ycombinator.com/item?id=15841241)

2016:
[https://news.ycombinator.com/item?id=12537653](https://news.ycombinator.com/item?id=12537653)

2014:
[https://news.ycombinator.com/item?id=8791812](https://news.ycombinator.com/item?id=8791812)

2013:
[https://news.ycombinator.com/item?id=5581851](https://news.ycombinator.com/item?id=5581851)

2012:
[https://news.ycombinator.com/item?id=3767410](https://news.ycombinator.com/item?id=3767410)

------
johnklos
It's a good example of a minimal system, but it's more academic than an
example of something that illustrates a useful system. It's arguable whether
much could be done with it in real time. There's no TCP/IP stack, and even if
networking did exist, most connection types would time out.

I'm interested in the minimal computing resource needed to run a full network
stack and recent software. So far, I've run an m68030 with 10 megs of memory
and a 16 bit memory bus (Mac LC II) multiuser with networking. 24 megs in a
VAXstation VLC is enough to compile plenty of real software. Even a real
11/780 from 1977 can still run sshd and negotiate a connection before a
timeout.

~~~
Ezhik
I have this bucket list idea of getting the lowest-powered chip I can find
that's still fast enough to give me a nice little *nix environment in which I
can use Vim, Tmux, and also SSH into things, then sticking it into a laptop
shell and filling the rest of the space with batteries.

I wonder if one could achieve like a month of battery life for such a
glorified typewriter/thin client.

~~~
IgorPartola
Just curious, what would you use vim for on a device like that? Presumably it
won’t be able to do much beyond what you outlined so unless you plan on using
it as just a not taking device/typewriter, why not just have an embedded ssh
client with tmux?

~~~
Ezhik
Pretty much just what you said - when offline, it's just a fancy typewriter
that I can also run a simple shell script or two on.

------
neilv
For people interested in this, another thing to be aware of is uClinux:
[https://en.wikipedia.org/wiki/%CE%9CClinux](https://en.wikipedia.org/wiki/%CE%9CClinux)

Another easy way to play around with Linux fit onto very modest hardware (but
not 8-bit microcontrollers), which is very popular and very useful, is OpenWrt
on a cheap old home WiFi router:
[https://en.wikipedia.org/wiki/OpenWrt](https://en.wikipedia.org/wiki/OpenWrt)

(If you want to pick up an old router for $20, WNDR3700v2, WNDR3700v4,
WNDR3800, and select later ones in that family are a good starting point. The
OpenWrt wiki pages for them will give specs and suggest what hardware revs are
better.)

------
hermitdev
This is impressive.

Myself and several project mates used an Atmel AVR in early 2003 to build an
mp3 player. We didnt bother with the storage integration instead to just opt
to stream the mp3 file from a host PC over a UART. IIRC, we only had 32k RAM &
32k ROM to work with (we werent using a Mega chip, I'd have to dig through
notes to find the model).

Knowing what we went through to get that mp3 player working (which we
delegated the actual decoding to a dedicated chip) with just the AVR, what
Dmitry accomplished with this is amazing. Many props.

Edit: this was a senior level college project for a BSEE, not work related.

------
deathanatos
_Very_ impressive.

Kinda reminds me of Linux running on JavaScript:
[https://bellard.org/jslinux/vm.html?url=https://bellard.org/...](https://bellard.org/jslinux/vm.html?url=https://bellard.org/jslinux/buildroot-x86-xwin.cfg&graphic=1)

~~~
snazz
They’re both hacks for running Linux in ways it was not intended to run, by
exploiting other technology, so there’s certainly some connection.

~~~
johnhenry
How was linux intended to run?

~~~
mr_toad
It’s in the article:

“The common answer is that it requires a 32-bit architecture and an MMU and at
least a megabyte of ram to fit the kernel.”

He gets around the 32 bit + MMU requirement by emulation. It’s a cool hack,
but it really is a hack.

~~~
lisk1
According to him it takes about 5 hours to get to the command prompt which is
kinda funny but interesting project nevertheless

~~~
0815test
I'd imagine that a modern kernel has a lot of pointless fat in it and that the
5-hours figure _could_ be reduced if perhaps only slightly, with appropriate
optimization effort. It might even be useful to deliberately have such a
super-slow (but reliable, since it runs on highly deterministic
microcontroller-class HW) benchmark in the mix, as you would be able to make
very precise and fine-grained measurements about how even seemingly-unrelated
changes might impact performance within the kernel, whether for the better or
worse.

~~~
silly-silly
I believe that the idea would not be relevant in "general purpose benchmarking
improvements" due to the vast differences in micro architecture between this
CPU and modern CPU's.

The pipelining and internal optimizations differ greatly.

------
poizan42
I have probably commented this before, but the nommu support was merged all
the way back in 2.5.46, so a mmu is certainly not a requirement for running
Linux.

A 32-bit architecture is not really a requirement either, you just need a
compiler that can be told to use 32-integer types and pointers. You probably
also have to modify the compiler to generate accesses to your external ram for
loads and stores.

The real thing preventing you from running Linux on 8-bit micros is the
requirement of a von Neumann architecture (or something that looks like it).
These small MCUs usually don't even have a way of loading code at runtime
which makes it impossible to run any sort multitasking without interpretation.

------
ilaksh
Maybe CP/M would be an easier type of operating system for that type of
computer..if a bit dated.

[https://spritesmods.com/?art=avrcpm](https://spritesmods.com/?art=avrcpm)

[https://hackaday.com/2017/03/25/cpm-8266/](https://hackaday.com/2017/03/25/cpm-8266/)

[https://github.com/toyoshim/cp-mega88](https://github.com/toyoshim/cp-mega88)

~~~
aquabeagle
Or FUZIX

[https://github.com/EtchedPixels/FUZIX](https://github.com/EtchedPixels/FUZIX)

~~~
wazoox
Yep, definitely [http://www.fuzix.org/](http://www.fuzix.org/) . It works on a
whole lot of 8 bit machines.

------
GeorgeKangas
I had an 8-bit micro, the Tandy (i.e. Radio Shack) Color Computer ("CoCo"),
made in the mid 80s.

I got an optional OS for it, called "OS9" but unrelated to Apple's OS9 (which
came later).

OS9 had capabilities very similar to (and modeled on)Unix. Clearly, Linux or
something a lot like it could also have run on the CoCo.

~~~
orionblastar
Trs80 Coco series used the 6809 CPU that is 16 bits. The article talks about
Linux on 8 bit systems.

I'd say the Mega65 might be a good 8 bit machine to port Linux to.
[http://mega65.com](http://mega65.com)

~~~
GeorgeKangas
The 6809 was 8 bits, in the same way Z80 and 6502 and 6800 were: 8 bit data
bus, 16 bit address bus.

It had a few 16 bit instructions: arithmetic on data in registers, or
loading/storing a 16 bit register (8 bits at a time). I think the Z80 did as
well.

Here's Wikipedia:
[https://en.wikipedia.org/wiki/Motorola_6809](https://en.wikipedia.org/wiki/Motorola_6809)

~~~
jacquesm
It also had an 8x8 mul with 16 bit result.

~~~
timbit42
One 16-bit feature doesn't make a CPU where every other feature is 8-bit a
16-bit CPU.

~~~
jacquesm
I don't think I claimed it was a 16 bit CPU.

------
iammer
Needs (2012)

------
tlrobinson
Spoiler: they wrote an ARM emulator.

Very impressive project, but if you were hoping to run Linux on an 8-bit
microcontroller for anything real you'll be disappointed.

~~~
dmitrygr
Well, it will run Linux on an 8-bit microcenter for real, just sloooowly :)

~~~
FPGAhacker
All they have to do fix that is set LS_COLORS appropriately.

~~~
taneq
I dunno if a factor of 40 is going to cut it.

------
fulafel
I wonder what would be the ideal Linux compile target for running on
interpreter style emulators (as contrasted to binary translation style).

I guess the machine instructions should be as high level as possible, to
reduce the interperter dispatch overhead. Of course then you'd need to port
Linux and gcc to your hyper-CISC...

------
0815test
Interesting. Making it run RISC-V rather than ARM would provide slightly
quicker emulation, I believe. (And indeed, more generally, running a RISC-V VM
provides a quick way of enabling modern 64-bit code to run even on hardware
that's restricted to a 32-bit address space. Given that there's a lot of such
hardware around, even of quite recent vintage, this _can_ be practically
helpful.)

~~~
dmitrygr
Riscv didn't exist when I wrote this. Even now it doesn't exist (it will
"exist" when someone ships a billion somethings with it in it)

~~~
sitkack
I absolutely love your 8-bit Linux and plan on building one after I finish my
relay computer.

The billion cores mark for RISC-V will be somewhere around the middle of 2020
thanks to Western Digital and Microsemi.

[https://www.forbes.com/sites/tiriasresearch/2017/12/06/weste...](https://www.forbes.com/sites/tiriasresearch/2017/12/06/western-
digital-gives-a-billion-unit-boost-to-open-source-risc-v-cpu/#23a62b782266)

> What many do not realize is that the company ships over 1 billion processor
> cores within its products each year and is moving toward 2 billion per year.

[https://hackaday.com/2019/02/13/western-digital-releases-
the...](https://hackaday.com/2019/02/13/western-digital-releases-their-risc-v-
cores-to-the-world/)

> Last year, Western Digital made the amazing claim that they will transition
> their consumption of silicon over to RISC-V, putting one Billion RISC-V
> cores per year into the marketplace.

[https://www.microsemi.com/product-directory/mi-v-embedded-
ec...](https://www.microsemi.com/product-directory/mi-v-embedded-
ecosystem/4406-risc-v-cpus)

~~~
dmitrygr
Oh, I do realize it. But it is 2019 so my statement holds as true :)

------
phkahler
Reminded me of this XKCD:

[https://xkcd.com/505/](https://xkcd.com/505/)

------
rcdwealth
Sadly the software is proprietary. Indicating for "commercial use" means it is
proprietary.

When already doing something for Linux kernel, it would be advisable to
promote the same license as the Linux kernel, such as GNU General Public
License 2.

Promote free software and advance of free software.

~~~
geezerjay
Give it a rest. The project is really impressive and quite a feat. Leave the
militant piggy-backing out of it.

