Make Your Linux Embedded System Small

A large size of an embedded system might be a problem that bedevils embedded system developers the most. Developers, as return, are always seeking for ways to downsize their embedded systems, so as to leave more RAM and Flash memory resources for applications and reduce the hardware cost of the device. In this article some methods for downsizing the embedded system are to be introduced.


     Since the software platform of an embedded system consists of two parts: a kernel and root filesystem, we divide the methods into two parts, the first part is about getting a small kernel and the second is about downsizing the components in the root filesystem.
Downsizing the kernel:


1. Select a hardware compatible kernel. Selecting an appropriate kernel brings not only small size but also efficient use of processor power. For example, for a MMU-less microcontroller based development baord, you should select a kernel that does not require MMU function such as uCLinux rather than a standard Linux kernel.


2. Remove the useless modules in the kernel by correct configuration. As a matter of fact, the default configuration of Linux kernel includes many unused modules, which occupies the system resources while doing nothing. Remove them all and we will get a concise kernel as well as more free space.


3. Use optimization parameters when compiling the kernel. Parameters -O1, -O2 or -O3 improves performance of the kernel but increases the size, parameter -Os reduce the size but cramps the performance. However it is impossible to optimize both the size and performance simultaneously. Generally we can select -O2 to achieve a balance between size and performance.


4. Decrease the size of static buffer and array. You can use the command nm. to find out which buffer or array occupies large memory space and then change the initial size of the buffer or array. Or you can modify the options in the menuconfig of the kernel to decrease the maximum number of supported peripherals.


Downsizing the root filesystem
    Four methods can be employed to downsize the root filesystem.


1. We can use BusyBox. As so called ‟The Swiss Army Knife of Embedded Linux‟, BusyBox combines tiny versions of many common UNIX utilities into a single small executable. It provides replacements for most of the utilities that you usually find in GNU fileutils, shellutils, etc. The utilities in BusyBox generally have fewer options than their full-featured GNU cousins; however, the included options provide the expected functionality and behave very much like their GNU counterparts. The space used for BusyBox is 7.04% of that of the original tools, by using it we can greatly reduce the size of the filesystem.


2. Optimize the libraries.
     Some of the libraries are useless for your system, removing them will get you a lot of free space. You can use the command ldd to list the required shared libraries that are being used by the programs and other shared libraries, and then with this information, you can identify the unused libraries and remove them.