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.

There are two separate "footprint" metrics that need to be considered:

Size of the bootable Linux image.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.5 MBytes ballpark.

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 LPC4357 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)) {
while (fgets(buff, sizeof(buff), fp)) {
fputs(buff, stdout);

while(1) {
return -1;

The bootable Linux image ready for running on the LPC4357 (hello.uImage) is about 500 KBytes in size.

Here is a snapshot of the boot session for that configuration, as run on the Embedded Artists LPC4357 Dev Kit. Notice the 31548 KBytes of unused memory:

U-Boot 2010.03-00073-1.14.0 (May 14 2015 - 12:51:52)

CPU : LPC43xx series (Cortex-M4/M0)
Freqs: SYSTICK=144MHz,CCLK=144MHz
Board: Embedded Artists LPC4357 Dev Kit Rev A1
Starting kernel ...
Freeing init memory: 64K
Mounting /proc..
Reading /proc/meminfo:
MemTotal:          31976 kB
MemFree:           31548 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:       15988 kB
Committed_AS:          0 kB
VmallocTotal:          0 kB
VmallocUsed:           0 kB
VmallocChunk:          0 kB

Hello, A2F-Linux!
Hello, A2F-Linux!
Hello, A2F-Linux!