Why register?

  • Download software and technical materials
  • Purchase products at our on-line shop
  • Receive design news to stay up-to-date with Emcraft's new solutions



What is the Minimal Footprint of uClinux? Print


This is perhaps one of the most frequently asked questions about uClinux on Cortex-M.

First thing to say is that external RAM is a must for uClinux. However small a Linux configuration, it still requires at least several MBytes of RAM to run from. All Cortex-M devices Emcraft is aware of limit they internal SRAM to hundreds KBytes at best. There is no way uClinux can be run from a single-chip Cortex-M design, as of this writing.

A two-chip design (Cortex-M + external RAM) is a possibility, however. There are actually two separate "footprint" metrics that need to be considered:

Size of the bootable Linux image. Given the two-chip design goal (i.e. no external device to mount the root file system from), the root file system is embedded in the bootable image as initramfs. More specifically, the bootable image is comprised of two major pieces:

  • Linux kernel itself;
  • cpio representation of the root file system, which gets expanded into a RAM-based initramfs and mounted as rootfs when Linux is booting up.

The size of such a bootable image starts at maybe 0.5 MBytes for truly minimal configurations and ranges to whatever, depending on what you have put into your root file system and, to a lesser extent, what configuration options you have enabled in your kernel. For instance, enabling the TCP/IP stack in the kernel increases the image size somewhat substantially.

The size of a practical bootable image, with Ethernet, TCP/IP and a reasonable set of user-space tools and applications confugured, would be in a 1.5 - 2 MBytes ballpark. With the "two-chips Linux design" concept in mind, a 1.5 MBytes image could possibly fit into internal Flash of today's Cortex-M microcontrollers. One example of a device that can hold an image of the size is the STM32F429 Cortex-M4 microcontroller.

Size of external RAM required for run-time Linux operation. The answer we give to our customers when asked how much RAM is needed is the more the better, but no less than 8 MBytes. Admittedly, it may be possible to run some very basic configurations with rootfs mounted from NFS or some external device even out of 2 MBytes but frankly this is more of a joke than a configuration one can build a practical uClinux design on.

As the rule of thumb, consider at least 32 MB RAM if your intention is to use uClinux in a serious product. When you approach deployment and it becomes clear that you can fit into less RAM, you might want to downsize to a compatible 16 MB or even 8 MB RAM device, however the safe advice is to start with more RAM rather than less. Requirements for embedded applications grow at an incredibly fast rate and it is a sure bet that in a 1-year's time you will be wanting to add new software features to your design. Seeing that you are already considering uClinux for your microcontroller application, you are probably fed up with the "if only I had another 512 MB of RAM" kind of situation MCU developers are used to. If you want Linux and "features", plan for reasonable amounts of RAM.

On a practical side of things, and given the specific context of SDRAM memory used with the advanced STM32F4 microcontrollers, the BOM differences between compatible 8 MB, 16 MB and 32 MB devices are often times quite tolerable. Again, the advice we can give is to play safely and plan for more RAM rather than less.

With that background in mind, here are some footprint numbers for a sample Linux configuration that Emcraft includes in the software distribution. The project is called hello (for "Hello, world") and can be found in the projects/hello directory, relative to the top of the distribution directory.

The kernel configuration of this project is minimalistic, for instance, the TCP/IP stack is disabled. At the application level, this is really a single-process configuration. Specifically, instead of the standard Linux init, the project runs a custom application called hello. The following are relevant snippets from the hello.intramfs specification file that illustrate how the custom application is installed on the target instead of init.

file /bin/hello ${INSTALL_ROOT}/projects/${SAMPLE}/hello/hello 755 0 0
slink /bin/init hello 777 0 0

The application itself is a simple endless-loop Hello, world C program, except that before entering the loop it prints the content of /proc/meminfo to stdout (which is the Linux serial console in this specific configuration). The meminfo printout gives information on how much memory is available when the application is running.

The application source can be found in projects/hello/hello/hello.c. For the sake of completeness, here is the full source of that program:

#include <stdio.h>
#include <unistd.h>
#include "hello.h"
#include <sys/mount.h>

int main(int argc, char **argv)
char buff[4096];
int rc;
FILE *fp;

printf("Mounting /proc..\n");

if (mount("proc", "/proc", "proc", MS_MGC_VAL, NULL)) {
perror("Unable to mount /proc");
goto xit;
if (!(fp = fopen("/proc/meminfo", "r"))) {
goto xit;
printf("Reading /proc/meminfo:\n");
while (fgets(buff, sizeof(buff), fp)) {
fputs(buff, stdout);

while(1) {
return -1;

The bootable Linux image ready for installation to embedded Flash of the STM32F429 (hello.uImage) is 594 KBytes in size. That easily fits into the 2 MBytes Flash of the STM32F429 with room to go.

Here is a snapshot of the boot session for that configuration, as run on the STM32F429 Discovery. The kernel runs from the internal Flash and is quite fast (note the 167 BogoMIPS metrics in the kernel output). Boot time to the application is less than a second (we didn't measure specifically, but it is probably around 600 msecs from the power-on). Notice the 7564 KBytes of unused memory:

U-Boot 2010.03-00016-ge284a31-dirty (Jan 16 2014 - 18:50:55)

CPU : STM32F4 (Cortex-M4)
Freqs: SYSCLK=180MHz,HCLK=180MHz,PCLK1=45MHz,PCLK2=90MHz
Board: STM32F429-DISCOVERY Rev 1.A

Starting kernel ...

Linux version 2.6.33-arm1 (vlad@ ocean.emcraft.com) (gcc version 4.4.1 (Sourcery G++ Lite 2010q1-189) ) #378 Fri Jan 17 14:15:00 MSK 2014
Memory: 8MB = 8MB total
Memory: 7984k/7984k available, 208k reserved, 0K highmem
Calibrating delay loop... 167.52 BogoMIPS (lpj=837632)
Freeing init memory: 8K
Mounting /proc..
Reading /proc/meminfo:
MemTotal: 7992 kB
MemFree: 7564 kB
Buffers: 0 kB
Cached: 32 kB
SwapCached: 0 kB
Active: 0 kB
Inactive: 0 kB
Active(anon): 0 kB
Inactive(anon): 0 kB
Active(file): 0 kB
Inactive(file): 0 kB
Unevictable: 0 kB
Mlocked: 0 kB
MmapCopy: 72 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 0 kB
Mapped: 0 kB
Shmem: 0 kB
Slab: 244 kB
SReclaimable: 24 kB
SUnreclaim: 220 kB
KernelStack: 72 kB
PageTables: 0 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 3996 kB
Committed_AS: 0 kB
VmallocTotal: 0 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
Hello, A2F-Linux!
Hello, A2F-Linux!