
Linux on an 8-bit micro (2012) - pant
http://dmitry.gr/index.php?r=05.Projects&proj=07.+Linux+on+8bit
======
lifthrasiir
This is from 2012. Previous discussion:
[https://news.ycombinator.com/item?id=5581851](https://news.ycombinator.com/item?id=5581851)

While this is amazing, this does prove that it is probably impossible to run
Linux in 8-bit micro without such contortion. Any Turing-complete machine with
enough storage and memory can simulate ARM, and also ARM Linux. So don't use
this as an argument for using a normal Linux in such platforms :)

~~~
Narishma
And here's the previous previous discussion:
[https://news.ycombinator.com/item?id=3767410](https://news.ycombinator.com/item?id=3767410)

------
SwellJoe
That's amazing. I wouldn't even know where to start on something like this:

"As you can see, there is an antique 30-pin SIMM memory module on the board.
These were in use for 80286-based PCs. It is interfaced to the ATmega, and I
wrote the code to access it as well as refresh it within spec (SDRAM requires
constant refreshing to avoid losing data)."

Though 300kb/s is (much) slower than a hard disk, which is hard to
imagine...and the result: "It takes about 2 hours to boot to bash prompt"

~~~
hcarvalhoalves
It's been a while since I last saw a boot take longer than a split second on
"Uncompressing Linux..." :)

------
duaneb
This is probably one of the crazier projects I've ever seen. I've often
contemplated what running a "true os" on an 8 bit CPU would entail, and TBH
the idea of an emulator never struck me.

On top of that, a hand-wired linux computer with hand-written arm emulator?
Ridiculous.

~~~
pjc50
Well, you could run CP/M on an 8-bit system, which would have been called a
"true OS" at the time it was written and sold ...

~~~
dalke
Or if that's not "true" enough, Xenix was a Unix for 8-bit systems.

~~~
justin66
Xenix ran on 16-bit systems.

~~~
dalke
Oops! Yes. 16 bit. I was thinking of the 8 bit data bus of the 16 bit 8088.

What about Micronix?
[http://www.retrotechnology.com/herbs_stuff/mnix_micronix.htm...](http://www.retrotechnology.com/herbs_stuff/mnix_micronix.html)
\- "As far as I know, Micronix was the only Unix-like multiuser system ever to
run on an 8 bit processor."

~~~
Zardoz84
FUZIX and UZIX runs on an Z80

~~~
dalke
Cool! And it meets the 'multiuser' qualifier too: "UZI180 is a multi-tasking,
multi-user operating for the Zilog Z180 family of microprocessors.", from
[https://github.com/EtchedPixels/FUZIX/tree/master/Kernel](https://github.com/EtchedPixels/FUZIX/tree/master/Kernel)
.

~~~
duaneb
Wow, great find! Thanks!

------
reidrac
This guy is amazing, look at his projects! Really inspiring.

Related (you may know it already):
[https://github.com/EtchedPixels/FUZIX](https://github.com/EtchedPixels/FUZIX)

Implementing a VM is an interesting way to workaround some Harvard
architecture's limitations as long as speed is not a factor.

------
davidw
> uARM is certainly no speed demon. It takes about 2 hours to boot to bash
> prompt

Because he's emulating a 32 bit system on an 8 bit system, which certainly
takes some brilliant hacking skills, but takes it completely out of the realm
of something practical.

------
myrandomcomment
[https://en.m.wikipedia.org/wiki/Contiki](https://en.m.wikipedia.org/wiki/Contiki)

Runs on 6510(6502) with 64kb on a Commodore 64. While is is cool it would be
more interesting to have it run native and not via an ARM emulation layer.

~~~
cnvogel
Contiki already runs natively on AVR. [https://github.com/contiki-
os/contiki/wiki/Avr-platforms](https://github.com/contiki-os/contiki/wiki/Avr-
platforms)

~~~
myrandomcomment
I am not talking about Contiki running on this platform. If your read the
story you will see the author wrote an ARM emulator to run on the CPU to the.
Run the code. I was staying it would be more interesting if it was native and
using Contiki as an example that you can run on an 8 bit Cpu without and MMU.

~~~
duaneb
Well, you can run many things without an MMU, the question is whether it will
be at all pleasant to use without an MMU. What makes linux nice is not the
fact that it allows you to run code, but it allows you to run thousands of
pieces of code at once, stably.

~~~
myrandomcomment
That also worked just fine on Amiga OS 3.1 without and MMU :)

------
keitmo
I haven't seen software-based DRAM refresh in a long time. Well done!

------
pant
Unbelievable proof of concept. It is just genius that this guy made this. But
what do you think that we can get out of this? Are there any practical reasons
to run Linux on Micro-controller?

~~~
cnvogel
> But what do you think that we can get out of this?

One can learn that sometimes it's worthwhile, or even the prudent thing to do,
to emulate the hardware instead of porting code. Emulating a 32bit CPU on a
8bit µC is certainly a little over the edge, but it's not unheard of to
emulate a legacy/antique CPU on a newer one to make use of proven code.

See for example the ancient HP48 calculators, where the obsolete original
device (HP48) is emulated on the contemporary ARM CPU (HP50) to be able to
reuse the proven old codebase.

Or you might invent your own bytecode that isn't as intricate as implementing
a full ARM computer, but maybe give you amenities like high precision math, or
better sting handling, or portability between different microcontrollers (if
you are a company supporting several generations of platforms)...

> Are there any practical reasons to run Linux on Micro-controller?

If you don't restrict yourself to 8-bit microcontrollers, you can run Linux on
MMU-less Cortex-M3/M4: You loose all the convenience of memory-protection
(apps can crash each other by writing in foreign memory space), have severe
restrictions in your API (no mmap, restrictions on fork(), memory
fragmentation issues, ...), but you gain a very powerful networking stack,
filesystems, a LOAD of existing device drivers, ... that you would otherwise
have to rewrite for yourself.

~~~
nly
> it's not unheard of to emulate a legacy/antique CPU on a newer one to make
> use of proven code.

It's probably less to do with using proven code and more to do with
maintaining perfect bug-for-bug compatibility. You can't even reimplement the
bugs you haven't discovered yet. Also, writing an interpreter for most
microcode is fairly methodical. Depending on what level of detail you need to
emulate (clock timings, interrupts etc) it could be quicker and simpler than
digging up an old fossil of a developer who knows enough about the original
software to port it for you.

------
jacquesm
For something like this with fewer layers:

[http://en.wikipedia.org/wiki/OS-9](http://en.wikipedia.org/wiki/OS-9)

~~~
jhallenworld
Yes, it's nice, but I only tried it on the Co-Co ver 1 which I thought was
pretty terrible hardware.

------
sliverstorm
ucLinux gets you around the MMU problem... Was Linux ever built on 16-bit? The
PDP-11 (the origin of Unix) was 16..

~~~
ksherlock
ELKS, the Embeddable Linux Kernel Subset, targeted the 16-bit 8086 without an
mmu.

------
vishnuharidas
That one was one of the best myth buster in tech (not considering the time
taken to boot the system!)

------
logicallee
Does anyone know why these 8-bit processors are so expensive? The two he
listed ATmega1284p and ATmega644a cost like $9.07 (qty 1) to $4.88 (qty 2.5k),
and $7.08 (qty 1) to $3.79 (qty 2.5k) on Mouser.

I would have thought we're talking like a $1.30 chip.

Meanwhile look at what you get for $6 - [http://linuxgizmos.com/quad-core-
allwinner-soc-targets-low-c...](http://linuxgizmos.com/quad-core-allwinner-
soc-targets-low-cost-4k-ott-set-top-boxes/)

Am I missing something? Or are his 8-bit microcontrollers actually in the
exact same price range as an SOC that runs Linux natively?

~~~
cnvogel
The ATMega128... parts are the second-to-largest 8-bit micro that Atmel sells,
I think they already have a strange combination of a lot of flash & RAM (for a
8-bit CPU), but not that many, or that complex, peripherals. So they might
only be used in (comparatively) low volume in fringe applications.

As an example for "embedded, non Linux" microcontrollers, the lpc1227 (32bit
Cortex-M0 @ 45MHz, 128k Flash) is only half the cost (~$2 @ 10k units) at much
more CPU power and more versatile peripherals. Probably a much more balanced
(and maybe more popular) choice for applications of a comparable complexity...

~~~
duskwuff
The part the author is using here is especially odd: it's on the large side
for AVR microcontrollers (128 KB flash, 16 KB SRAM), and comes in a DIP
package. That's an unusual combination; most microcontrollers that size
nowadays are ARM, and are often only available as surface-mount parts.

------
frozenport
>>To conquer this obstacle, I wrote an ARM emulator.

So, its still running on an ARM!

~~~
dtech
No, it's running on a 8-bit microcontroller. Just as a SNES emulator that
plays SNES games doesn't magically transform your computer into a SNES.

~~~
frozenport
Tell that to the emulated system :-)

