# Linux on ARM Cortex-M3 series

I'm new to ARM and a bit confused with all the diferent series.

I need to build a low power gateway (ethernet, wifi...), so I guess a cortex-M or cortex-R will be the good starting point. But it didn't find any dev board with say a cortex-m3 (wich seems to be quite popular) supporting linux.

It seems possible linuxM3, so I wonder why there is no linux project around an mbed or a LPCXpresso for example ?

Can anyone point me to the dev board I seek, or explain me why "cortex m"+linux doesn't comme with more answers ?

• NXP has some linux support for other processors not sure about that specific one. – kenny Sep 8 '11 at 17:51
• How low power does it need to be? I managed to build a 1/2 watt full Linux system based on the Freescale iMX283. 1/2W during normal load w/no Ethernet, 1W with Ethernet, <1.5W Ethernet with full load... The Ethernet PHY is half the system power at normal load. – darron Sep 9 '11 at 0:34

Regarding the ARM Cortex-M3:

Linux requires an MMU (Memory Management Unit). The ARM Cortex-M3 does not have one. It is impossible to run the mainline Linux kernel on the ARM Cortex-M3.

However, there is a variant of the Linux kernel for MMUless processors called uCLinux.

Linux on M3 Guide

ST's Application Note on uCLinux

However, as others have noted, Linux is unlikely to be practical on the M3. It won't run without external RAM. I believe that even the largest Cortex-M3 parts only have 1MB flash, so you'll likely need extra storage too.

## Cortex-M isn't up to the job, you need the ARM926EJ-S

A search for "Cortex-M + Linux" doesn't come up with a lot of answers because the Cortex-M isn't designed for Linux. The least-powerful ARM generally considered able to run a full OS like Linux is the ARM926EJ-S series, which uses the ARMv5 architecture. This is a classic processor, with wide adoption (it's found in many NAS boxes, older smartphones, and the Chumby Classic) and lots of support, but it's a little less efficient than its successors. It has an ARMv5 architecture, and runs at a couple hundred MHz.

## This is what you really want, but you can't have it

The processor you really want, I think, is the Cortex-A5: Designed to replace (and be just a little more powerful than) the ARM11, but much more power efficient and on a more modern process. (Note: Nothing to do with Apple's A5, that's a special Cortex-A9) It was announced in 2009, and we're waiting to see silicon "any day now". No one has yet produced a general-purpose SoC for this processor, because smartphones drive the market and the market between a more powerful A9 and an older ARM11 just isn't compelling. See this discussion for more details: http://forum.beyond3d.com/archive/index.php/t-60145.html

## More powerful options

The ARMv6 in the ARM11 is a little more efficient, but also more powerful (so you may not see any savings in your power budget). It powers less old smartphones like the iPhone 3G, as well as the iPod Touch, Kindle and Zune and runs at 500-800 MHz. The latest architecture, ARMv7, is the Cortex series. The Cortex-A8 and -A9 are powering the latest smartphones and tablets at 800MHz - 1.2GHz, you'll likely want to stick with the smaller, slower processors if you're aiming for a minimalist design. The performance-per-watt numbers of these processors are fantastic, but it might be safer (and will certainly be less complex) to just use the ARMv5 parts.

• Note: the Cortex-A5 is now shipping, and Atmel claim to provide Linux support for their version: atmel.com/Microsite/sama5d3/… – pjc50 Nov 9 '13 at 9:47

Please check this site for some Cortex-M3 platforms that support Linux (uClinux):

http://www.emcraft.com/

We successfully run uClinux on the following Cortex-M3 MCUs: NXP's LPC1788, STmicro's STM32F2, Actel's SmartFusion, and are in process of adding support for a couple more: Freescale Kinetis, STM32F4 (these two are Cortex-M4 rather than Cortex-M3).

True, Linux (uClinux included) requires external RAM to run - the integrated SRAM of Cortex-M is not nearly large enough even for an ultra-tiny Linux configuration; you need at least 4MB of external RAM for practical configurations. The more the better, in fact - if you application needs "features", Linux has support for about anything and you will not be sorry that you have added more RAM rather than less.

In respect to particular devices to use for external RAM, it all is defined by the external memory interface provided by a particular MCU. STM32F and SmartFusion support only SRAM; you would be able to get a 16MB 70ns PSRAM (with a Page Mode for faster operation) for $6-7; LPC1788 support faster SDRAM memories; Kinetis K70 supports DDR2 ($5 for a 64MB device), etc. All those memories draw power at just uA levels at static times.

You need something to load a bootable Linux from, but this can be about anything - network, SDcard, SPI EEPROM, NOR or NAND Flash, etc.

Overall, I daresay that Linux is a totally practical option for a Cortex-M3 design.

## Update

There are plenty of power-sensitive applications where your device is idle most of the time, however, when running, it needs to be able to do many things that are not going to be easy to achieve using a smaller RTOS. Secure connections, VLAN, TCP/IP tunneling, SNMP, SD Card, USB device / host, WiFI, etc and the list of requirements goes on and on.

With a smaller RTOS some of those features will be available, some not, however it is only part of the story. What we are seeing with our customers more and more is that embedded designs using Cortex-M3 need not just 1 or 2 of those advanced features, they need many of them from a single device. Even if an RTOS provides all features a design needs off-the-shelf, cramming it all into the on-the-chip memory is going to be a challenge. uClinux or not, my guess is that the trend is going to be that more and more Cortex-M-based designs will use external memory. Of course, once you get external RAM in your design, uClinux starts making more sense.

Regarding low processing power provided by Cortex-M (as measured against the requirements of the Linux kernel), as a recent experience, we have just enabled uClinux on the Freescale K70 MCU. This is a Cortex-M4 (which is the same as Cortex-M3 plus hardware FP and DSP units); on-chip interfaces to high-density RAM (DDR2) and Flash (NAND), with 2x8KB on-chip caches. 120Mhz Cortex-M core, with 150Mhz parts coming out soon.

Linux (uClinux) runs just beatifully on this device. Using 'dhrystone', we get about 50% performance we get on a 250Mhz Freescale PowerPC box. Fast boot-up, lots of RAM (the TWR-K70 module provides 128MB of RAM and 256MB of NAND Flash), networking, JFFS2, framebuffer, SSH, HTTPD, Qt/E - all this runs just fine on K70. Overall user experience is your regular "embedded Linux" on an MMU-full microprocessor.

Here is a pointer to the video of a live uClinux session running on the Freescale Kinetis K70 Cortex-M4 MCU:

Without some kind of support for external memory (both RAM and Flash) it is impossible that you can fit even the smallest linux distribution (say, uclinux) on to the mentioned devices' built in resources.

This typically means a 32-bit bus is exposed in order to hook up additional chips. This is why it's more common to see linux single-board-computers (SBC) with additional RAM and flash chips in the megabytes-range used to run linux. The microcontrollers you've listed don't offer this. The way I see it, the cortex-m0/m3 is meant more for applications where an 8-bit micro would not (or barely) suffice - thus all the resources you need are built into the chip.

To better answer this question, it would be wise to analyse the requirements for embedded linux. This typically means being able to fit a bootloader, kernel, and file system - and of course the actual user application and libraries required to run it. Total this up and you'll soon see that you may need a couple megabytes of RAM and Flash to do anything useful.

There is not MMU on the stm32 so you have to use ucLinux.

A quick google for ucLinux will send you in the right direction. https://www.google.com/search?q=stm32+uclinux

But on the other hand, Linux is not really that useful on this kind of small mcu and most of he time you need external ram and a SD-card to get it running. And then the pricetag is closing up on projects like the Rasperry PI, so you need to think about what your needs are.

Maybe another smaller OS is a better choice? Even thou it is nice to have Linux everywhere...

There are some low power applications like smart meetering where it is indeed usefull to use a Cortex-M3 with external Memory running Linux. Think not in terms of total cost (The boards will cost nearly as much as with a faster Core) but in terms of energy consumption.

If you live off a battery, and are idle mode most of the time, taking a measurement maybe each minute or so and then sending that off over a network it might be nice to be able to use the infrastructure brought to you by linux for TCP/IP, encryption etc.

On the embedded World Exhibition this year Pengutronix showed a linux on a prototyping-board from EnergyMicro running uCLinux on a Cortex-M3 with external RAM and a powerconsumption of 1.6mW when in idle Mode. Energy Micro has some incredible low power Cortex-M3 and M4 MCUs in their portfolio specifically optimized for low power applications which need aprox 16mW of Power when running at 32MHz while executing Code from RAM. This can enable Linux on a variety of battery powered devices where bigger and faster processors just don't fit your energy budget. On the other hand you won't get a lot of processing power from these either...

So basically if you're living of a battery and don't need much processing power this might be a solution for you, if not you might opt for a bigger ARM Core with MMU.

I believe there are a couple Cortex-M3 vendors that offer application notes about using stripped-down flavors of Linux (uCLinux) running on their product-offerings. Anecdotally, I believe ST Micro had some offerings. I'm currently working with an Actel/Microsemi SmartFusion (Cortex-M3 + FPGA Fabric) that has a PDF application note pointing to an Emcraft offering.