25

Is it possible to run Linux on Arduino? If yes, what steps and limitations need to be considered? If not, what are the limitations that prevent this?

18

Linux is a very complex operating system, but it may be able to fit on an Arduino. Things to consider:

  • There is no current AVR port of the source code.
  • You would have no graphics, instead access the terminal over UART.
  • The filesystem driver would have to be rewritten to access internal flash or an external SD card.
  • It would be extremely slow! The ATmega328 would run at 16 MHz, or about 20 MHz max (overclocked). Most Linux machines run at a minimum of 400 MHz, and more with graphics.
  • You would probably need some extra RAM, probably a good idea to use an ATmega2650 (the one in the Mega), which has 16 times the RAM of the Uno. You could also use a Due (6x as fast as the Uno, more RAM).
  • You may have to write special USB drivers for OTG (on the Due) or MAX3421EE (Mega ADK, USB host shield).

In short, it would take a lot of time and effort, and probably would be too slow for everyday use. If you really want Arduino Linux, check out the Yún.

  • 2
    You would not "probably" need extra ram, you do need extra ram. Linux requires 1 MB+ ram. Also, the lack of a MMU would mean you'd have to figure out how to emulate one (or run ucLinux). Realistically, at best, you'd wind up emulating a more capable processor in the atmega, which would be an order of magnitude slower then native code. Even the arduino due doesn't have anywhere near the required ram. – Connor Wolf Mar 27 '14 at 3:09
  • Also, the ATmega328P has 2 KB SRAM, and the ATmega2560P only has 8 KB. That is only 4X the ram, not 16x. – Connor Wolf Mar 27 '14 at 3:09
16

It just doesn't have enough RAM. You'd also need to teach it to boot from flash memory, which would involve rewriting the bootloader.

You can instead use an Arduino Yun or a PCDuino; while not "standard" Arduinos these support Arduino shields and run Linux.

Or there's always the Raspberry Pi.

  • Why do you say Yun is not "standard" Arduino? I agree it may not be the most common, but it is an Arduino indeed. – jfpoilpret Feb 12 '14 at 6:02
  • @jfpoilpret Most Arduinos are atmega boards which run compiled C++ via avr-gcc and have a USB handling chip. They come in various shapes/sizes/powers, but they're essentially the same (Mega aside). It seemed pretty obvious that the OP was talking about these and not the Yun/etc, hence the distinction. – Manishearth Feb 12 '14 at 6:07
  • There's also the soon-to-be-released Arduino Tre, at least I'm hoping it's soon ;-) – Chris O Feb 12 '14 at 14:03
6

The short answer is no.

Basically, you would need LOTS more ram then even the biggest ATmega has natively.

It is theoretically possible to add external hardware, and program the ATmega to emulate a more powerful CPU, and run linux on that. However, on a plain arduino, it is not possible.

It would be much more realistic to run linux on a Arduino Due, which is basically a AT91SAM3X8E CPU. However, you'd still need to add some additional SRAM and storage.

There are things like the Arduino Yun, but that is really a entirely separate linux module on the same PCB as a ATmega32U4, so I don't know if you can really count it as an arduino.


Possibly relevant: What does it take to run embedded linux?

1

There is a board called the pcDuino that can run multiple variants of Linux such as Debian, Ubuntu, Open WRT, LEDE, Raspian PIXEL (just to mention a few). This board is not a native Arduino, rather Arduino AtHeart, and is made by LinkSprite.
pcDuino

Arduino have a couple of boards that support running a variant of Linux called Linino:

  • The Arduino Yún is a microcontroller board based on the ATmega32u4 and the Atheros AR9331. The Atheros processor supports a Linux distribution based on OpenWrt named Linino OS. The board has built-in Ethernet and WiFi support, a USB-A port, micro-SD card slot, 20 digital input/output pins (7 of them can be used as PWM outputs and 12 as analog inputs), a 16 MHz crystal oscillator, a micro USB connection, an ICSP header, and 3 reset buttons.
  • The new Arduino Tian board is powered by Atmel’s SAMD21 MCU, featuring a 32-bit ARM Cortex® M0+ core and a Qualcomm Atheros AR9342, which is an highly integrated MIPS processor operating at up to 533MHz and feature-rich IEEE802.11n 2x2 2.4/5 GHz dual-band WiFi module. Qualcomm Atheros MIPS supports a Linux distribution, based on OpenWRT named Linino. The Arduino Tian has also a build in 4GB eMMC memory that will can be helpful to build your projects. It is possible to Switch ON/OFF the Linux port from the MCU to reduce the power consumption.
  • Arduino Industrial 101 is an Evaluation board for Arduino 101 LGA module. The ATmega32u4 microcontroller is integrated in the baseboard. The module supports a Linux distribution based on OpenWRT named LininoOS. The board has built-in WiFi (IEEE 802.11b/g/n operations up to 150Mbps 1x1 2.4 GHz), 3 GPIOs (of which 2 can be used as PWM Outputs), 4 Analog Inputs, 1 USB, 1 Ethernet signal on pin headers and a built-in DC/DC converter. Check out the assembling guide and simply connect your board to a computer with a micro USB cable to get started.
-2

It is possible, however it would be a pain because you would have to write it in C. (not to mention the extra hardware needed like an sd card shield and extra memory chip(s)) Something like Ontas, a kernel I wrote in C for the arduino, would help as It has support to add drivers, at the expense of making the void loop function repeat slower. (This is not as big of a deal as you might think it is) (Ontas is still under development and new features are added all the time)

Click here for the link to the .ino and accompanying .h files

-2

This is several years old, but maybe more pertinent as Arduinos get more RAM and 32 bit ATMega AVRs, etc. There's an obvious problem notably not in the most popular answer here. The Arduino uses an AVR MICROCONTROLLER, not a MICROPROCESSOR. This is a major reason why there is no port of linux. Microcontrollers are designed to perform a specific task, applications where the relationship of input and output is well defined. Microprocessors are designed to run a variety of apps on operating systems. Remember, from the beginning, Linux needed a memory management unit and could not run on 8088 or 286 PCs. Then there was μClinux, which originally targeted the Motorola DragonBall family of embedded 68k processors, for Palm Pilots. It was never particularly successful. You might have more success porting FreeDOS or even Minix than Linux, maybe something in assembler, but compiling an OS on a microcontroller is very impractical. Perhaps it's a challenging academic problem, but specifically counter to the purpose of using a microcontroller instead of a microprocessor.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.