Minimal Image

From Yocto Project
Revision as of 07:00, 22 June 2011 by Kai.kang (talk | contribs) (first half initialize)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Introduction

A core run-time component of any Linux-based system is the C standard library. The C standard library (otherwise referred to as "libc" in this wiki page) contains a collection of headers and library routines used to implement operations (I/O and string handling, for example) in the C programming language. There are numerous implementations of libc. GNU libc (glibc) is ubiquitous while other libcs, in particular embedded glibc (eglibc) is designed for embedded systems.

eglibc strives to be source and binary compatible with glibc. eglibc's goals include reduced footprint, configurable components, better support for cross-compilation and cross-testing. In particular, eglibc's component configuration system allows embedded developers to build customized versions of the library that include only the features their application uses, reducing its space requirements.

Yocto provides eglibc's component configuration system by commit fbc60cc5ba2284bfcaea8c82001a49b7795cc2a2

This wiki page try to describe how to use eglibc component configuration system to create a really minimal image based on Yocto core-image-minimal.

eglibc component configuration system

eglibc's component configuration system categorizes the library's functions into "option groups", and allows you to include or exclude option groups individually. Some option groups depend on others; eglibc tracks these relationships, and ensures that the selected configuration yields a functioning library.

eglibc currently provides 38 option groups, documented in the file 'option-groups.def' in eglibc source code. Yocto support eglibc component configuration system in meta/recipes-core/eglibc/eglibc-options.inc, and provides distro features corresponding to eglibc configurable options there. It checks DISTRO_FEATURES whether contain the option then set it to Y or N in the ${B}/option-groups.config.

meta-yocto/conf/local.conf.sample.extended has a sample to enable all the eglibc configurable options. You should define DISTRO_FEATURES_LIBC and DISTRO_FEATURES in your own conf/local.conf, and set the options what you want to enable in DISTRO_FEATURES_LIBC.

For example, write the following line to your conf/local.conf to only enable OPTION_EGLIBC_LIBM,

DISTRO_FEATURES_LIBC = "libc-libm"

DISTRO_FEATURES = "alsa bluetooth ext2 irda pcmcia usbgadget usbhost wifi nfs zeroconf pci ${DISTRO_FEATURES_LIBC}"

Then you can build eglibc.

Dependencies

Current build core-image-minimal image need enable the following 15 options list in the following table. And the table show the dependecies between these eglibc component configuration system and Yocto core-image-minimal installed packages.

eglibc configuration option Required by
libc-libm gcc-runtime busybox
libc-crypt busybox tinylogin perl sysvinit
libc-posix-clang-wchar libc-posix-wchar-io libc-locale-code
libc-posix-wchar-io ncurses util-linux
libc-locale-code gettext
libc-posix-regexp module-init-tools-depmod update-alternatives-cworth linux-yocto(perf)
libc-nsswitch libc-inet
libc-inet pciutils sysvinit openssl util-linux perl busybox libc-sunrpc libc-nis
libc-sunrpc libc-nis sysvinit
libc-nis perl
libc-utmp tinylogin busybox perl libc-getlogin
libc-getlogin gettext tinylogin
libc-fcvt perl
libc-spawn gettext
libc-ftraverse elfutils