News for hackers. Stuff that matters.
Re:Linux on an 8-bit micro (2012) by lifthrasiir on Wednesday December 24, 2014 @05:17AM (#8792342)
This is from 2012. Previous discussion: 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 :)

Re:Linux on an 8-bit micro (2012) by Narishma on Wednesday December 24, 2014 @06:23AM (#8792455)
And here's the previous previous discussion: https://news.ycombinator.com/item?id=3767410
Re:Linux on an 8-bit micro (2012) by SwellJoe on Wednesday December 24, 2014 @02:12AM (#8791926)
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"

Re:Linux on an 8-bit micro (2012) by hcarvalhoalves on Wednesday December 24, 2014 @03:06PM (#8794338)
It's been a while since I last saw a boot take longer than a split second on "Uncompressing Linux..." :)
Re:Linux on an 8-bit micro (2012) by duaneb on Wednesday December 24, 2014 @03:03AM (#8792057)
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.

Re:Linux on an 8-bit micro (2012) by reidrac on Wednesday December 24, 2014 @04:48PM (#8794649)
I'm not an expert but AFAIK it makes sense: he's using an AVR and that's Harvard architecture, meaning code and data use different buses so all you can run must be in the flash of the microprocessor.

So emulation is a way to workaround that "limitation".

Edit: on mobile, typos

Re:Linux on an 8-bit micro (2012) by pantalaimon on Wednesday December 24, 2014 @12:07PM (#8793518)
What about RIOT [1], Contiki [2] or TinyOS [3]?

[1] http://riot-os.de/ [2] http://www.contiki-os.org/ [3] http://www.tinyos.net/

Re:Linux on an 8-bit micro (2012) by duaneb on Wednesday December 24, 2014 @01:48PM (#8794009)
Of those, it seems like only TinyOS would qualify (a full userland stack that you can develop from) under the same qualifications that netbsd might qualify....

To be clear, by "true os", I mean a posix runtime, preemptive multitasking with threads and processes, memory protection.

Still, cool links (I'll save that TinyOS for later this week), and I like the username.

Re:Linux on an 8-bit micro (2012) by revelation on Wednesday December 24, 2014 @01:52PM (#8794030)
Most 8 bit micros don't have an MMU, so you can't have memory protection or virtual memory. That's a hardware limitation.
Re:Linux on an 8-bit micro (2012) by duaneb on Wednesday December 24, 2014 @02:48PM (#8794261)
> so you can't have memory protection

You can if you emulate all memory.... I had never considered that solution before, that was my original point :)

Re:Linux on an 8-bit micro (2012) by pantalaimon on Friday December 26, 2014 @10:49AM (#8799102)
I think you will like NuttX [1] even more :)

[1] http://www.nuttx.org/

Re:Linux on an 8-bit micro (2012) by pjc50 on Wednesday December 24, 2014 @06:46AM (#8792502)
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 ...
Re:Linux on an 8-bit micro (2012) by duaneb on Wednesday December 24, 2014 @01:49PM (#8794014)
Hah, I've actually run CP/M on a DEC Robin! I wouldn't call that a "true os" by my (own, flawed, unspecified) definition because it doesn't have memory protection or preemptive multitasking.
Re:Linux on an 8-bit micro (2012) by dalke on Wednesday December 24, 2014 @07:03AM (#8792537)
Or if that's not "true" enough, Xenix was a Unix for 8-bit systems.
Re:Linux on an 8-bit micro (2012) by justin66 on Wednesday December 24, 2014 @08:26AM (#8792755)
Xenix ran on 16-bit systems.
Re:Linux on an 8-bit micro (2012) by dalke on Wednesday December 24, 2014 @09:13AM (#8792882)
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... - "As far as I know, Micronix was the only Unix-like multiuser system ever to run on an 8 bit processor."

Re:Linux on an 8-bit micro (2012) by Zardoz84 on Wednesday December 24, 2014 @10:43AM (#8793183)
FUZIX and UZIX runs on an Z80
Re:Linux on an 8-bit micro (2012) by dalke on Wednesday December 24, 2014 @11:30AM (#8793378)
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 .
Re:Linux on an 8-bit micro (2012) by duaneb on Wednesday December 24, 2014 @01:49PM (#8794017)
Wow, great find! Thanks!
Re:Linux on an 8-bit micro (2012) by reidrac on Wednesday December 24, 2014 @04:33AM (#8792246)
This guy is amazing, look at his projects! Really inspiring.

Related (you may know it already): 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.

Re:Linux on an 8-bit micro (2012) by davidw on Wednesday December 24, 2014 @05:17AM (#8792343)
> 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.

Re:Linux on an 8-bit micro (2012) by myrandomcomment on Wednesday December 24, 2014 @04:23AM (#8792223)
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.

Re:Linux on an 8-bit micro (2012) by cnvogel on Wednesday December 24, 2014 @06:25AM (#8792456)
Contiki already runs natively on AVR. https://github.com/contiki-os/contiki/wiki/Avr-platforms
Re:Linux on an 8-bit micro (2012) by myrandomcomment on Wednesday December 24, 2014 @01:17PM (#8793854)
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.
Re:Linux on an 8-bit micro (2012) by duaneb on Wednesday December 24, 2014 @01:55PM (#8794045)
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.
Re:Linux on an 8-bit micro (2012) by myrandomcomment on Wednesday December 24, 2014 @11:15PM (#8795384)
That also worked just fine on Amiga OS 3.1 without and MMU :)
Re:Linux on an 8-bit micro (2012) by keitmo on Wednesday December 24, 2014 @03:36AM (#8792117)
I haven't seen software-based DRAM refresh in a long time. Well done!
Re:Linux on an 8-bit micro (2012) by pant on Wednesday December 24, 2014 @03:43AM (#8792132)
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?
Re:Linux on an 8-bit micro (2012) by cnvogel on Wednesday December 24, 2014 @06:38AM (#8792485)
> 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.

Re:Linux on an 8-bit micro (2012) by nly on Wednesday December 24, 2014 @09:17AM (#8792898)
> 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.

Re:Linux on an 8-bit micro (2012) by jacquesm on Wednesday December 24, 2014 @05:40AM (#8792377)
For something like this with fewer layers:

http://en.wikipedia.org/wiki/OS-9

Re:Linux on an 8-bit micro (2012) by jhallenworld on Thursday December 25, 2014 @02:55AM (#8795773)
Yes, it's nice, but I only tried it on the Co-Co ver 1 which I thought was pretty terrible hardware.
Re:Linux on an 8-bit micro (2012) by sliverstorm on Wednesday December 24, 2014 @03:48AM (#8792145)
ucLinux gets you around the MMU problem... Was Linux ever built on 16-bit? The PDP-11 (the origin of Unix) was 16..
Re:Linux on an 8-bit micro (2012) by ksherlock on Wednesday December 24, 2014 @08:20AM (#8792738)
ELKS, the Embeddable Linux Kernel Subset, targeted the 16-bit 8086 without an mmu.
Re:Linux on an 8-bit micro (2012) by vishnuharidas on Wednesday December 24, 2014 @01:34AM (#8791838)
That one was one of the best myth buster in tech (not considering the time taken to boot the system!)
Re:Linux on an 8-bit micro (2012) by logicallee on Wednesday December 24, 2014 @06:09AM (#8792425)
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...

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

Re:Linux on an 8-bit micro (2012) by listic on Wednesday December 24, 2014 @06:36AM (#8792479)
Looks like 8-bit microcontrollers are actually in the same price range as SOC's that run Linux natively. They have something going for them: easier to understand and use for hobbyists and lower-tech projects, probably easier to interface electrically (are those $6 chips 5V tolerant? Oops, they are not released yet), but otherwise that's another example of an older tech that was left behind. Keep in mind that those Atmel chips were released a while ago, and Allwinner has been the leader of low prices and this is the newest, unreleased chip; also I'm not sure that you and I will be able to buy it, in quantities of 1 (or even 100), when it will be released.

NB: ODROID is been selling a $35 Raspberry Pi-beating board with an Amlogic Cortex-A5 1.5Ghz quad core CPU (Amlogic M805, http://www.amlogic.com/product02.htm, apparently) but I can't find it on Octopart.

Re:Linux on an 8-bit micro (2012) by cnvogel on Wednesday December 24, 2014 @06:52AM (#8792514)
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...

Re:Linux on an 8-bit micro (2012) by duskwuff on Wednesday December 24, 2014 @05:18PM (#8794723)
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.
Re:Linux on an 8-bit micro (2012) by pjc50 on Wednesday December 24, 2014 @06:49AM (#8792510)
They're nice parts; 8-bit micros with a lot of Flash. ATtiny20 is the cheap end with hardly any Flash.
Re:Linux on an 8-bit micro (2012) by logicallee on Wednesday December 24, 2014 @07:33AM (#8792607)
sure, but he didn't get it working on attiny20 :) ($0.57 @ qty 5k) which is what the project kind of looks/sounds like...
Re:Linux on an 8-bit micro (2012) by frozenport on Wednesday December 24, 2014 @02:09AM (#8791918)
>>To conquer this obstacle, I wrote an ARM emulator.

So, its still running on an ARM!

Re:Linux on an 8-bit micro (2012) by dtech on Wednesday December 24, 2014 @02:41AM (#8791990)
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.
Re:Linux on an 8-bit micro (2012) by frozenport on Wednesday December 24, 2014 @03:00AM (#8792052)
Tell that to the emulated system :-)