Linux ported to Atmel's ATmega microcontrollers

March 30, 2012 // 12:10 p.m.

Tags: #arduino #arm #armv5te #atmega #atmel #dmitry-grinberg #eight-bit #emulator #linux #linux-kernel #microcontroller #ubuntu

The Ubuntu Linux distribution has been ported to the cheapest and most portable platform yet: An Atmel ATmega microcontroller.

Boasting a 20MHz 8-bit AVR processor, 128KB of flash storage and a massive 16KB of SRAM, the ATmega1284P isn't the most logical choice for building a microcomputer. It's the same basic design found in the Arduino prototyping platform: a microcontroller, designed to use its 32 pins to interface with external hardware like sensors, motors and LEDs.

That didn't stop Russian-born and California-based programmer Dmitry Grinberg from taking on the challenge of porting the Linux kernel and a full desktop operating system to the device, though.

'It is common to see newbies asking in microcontroller forums if they can run Linux on their puny little eight-bit micro,' Grinberg explains of his inspiration in a blog post. 'The results are usually laughter. It is also common to see, in Linux forums, asked what the minimum specs for Linux are. 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.'

Grinberg decided that such a limitation could likely be avoided by emulating hardware the ATmega chips don't have in software. Designing his own ARM emulator - 'porting someone else's code is no fun, plus none of the emulators I saw out there were written in a way that would make them easy to port to an eight-bit device,' he explains - Grinberg was able to convince the ATmega1284P chip to pretend that it was a PXA255 ARMv5TE processor.

Overclocking the chip to 24MHz from the stock 20MHz, and adding a 16MB SIMM module for RAM and a 1GB SD card for the operating system itself, Grinberg was able to successfully load an older copy of Ubuntu Linux onto the device, complete with a graphical user interface.

While it works, the result isn't exactly a speed demon: Grinberg has timed the boot process at around two hours to reach the BASH shell - something an average netbook can achieve in around two seconds - and a further four hours to load the rest of the operating system. 'Starting X [the graphical user interface] takes a lot longer,' Grinberg adds.

'Curiously enough, once booted, the system is somewhat usable,' Grinberg claims in defence of the design. 'You can type a command and get a reply within a minute. That is to say that you can, in fact, use it. I used it today to format an SD card, for example. This is definitely not the fastest, but I think it may be the cheapest, slowest, simplest to hand assemble, lowest part count, and lowest-end Linux PC. The board is hand-soldered using wires, there is not even a requirement for a printed circuit board.'

Grinberg's design, which he's releasing under a non-commercial open source licence, is portable to other microcontrollers such as the cheaper ATmega644. When you're talking about a chip that costs just £8, however, it's probably worth just plumping for the more powerful ATmega1284P.

Full details of the build, which is the equivalent of an ARMv5TE processor running at around 6.5KHz (yes, we meant to type kilohertz and not megahertz) can be found on Grinberg's website.