for Embedded Systems

Mail: [email protected] Web: http://stephane.lavirotte.com/ University of Nice - Sophia Antipolis Introduction

We must start with something…

3/31/2010 Free Electrons - Stéphane Lavirotte 2 for Embedded Systems

9 Linux for embedded systems – Is used more and more – In use in many devices ƒ Mobile Phones ƒ PDA (Personal Digital Equipment) ƒ Network Equipments ƒ … ƒ Have a look to: – http://www.linuxfordevices.com/c/a/Linux-For-Devices-Articles/The-Linux-Devices-Showcase/ – Used in limited resources systems ƒ uClinux, uClibc, dietlib, … 9 Easy to include free software inside that products – , samba, thttpd, …

3/31/2010 Free Electrons - Stéphane Lavirotte 3 Development Phases

9 Configuration – First, choose which features to include in the system ƒ Kernel configuration ƒ Choose the tools and applications to include 9 Build – Need to recompile the entire system for the target: ƒ Kernel ƒ Libraries ƒ Applications

9 Deployment – Installation of files in a filesystem – Transfer on the target and start the new system

3/31/2010 Free Electrons - Stéphane Lavirotte 4 System Components

9 Component – Boot Loader Boot Loader – Kernel Kernel – Kernel Modules

– File Systems Kernel Modules – Libraries Libraries – Applications

Applications

File System

3/31/2010 Free Electrons - Stéphane Lavirotte 5 About Free Software

9 Linux is and Open Source Free Software 9 Free Software provides 4 freedom to the user: – The freedom to use the program as it sees fit – The freedom to study how the program works and adapt it to its own needs (Get the source code is a precondition). – The freedom to redistribute copies to help others – The freedom to improve the program, and distribute the improvements to the public so that the community can benefit from advanced (Get the source code is a precondition). 9 See – http://www.gnu.org/philosophy/

3/31/2010 Free Electrons - Stéphane Lavirotte 6 The GNU General Public License (GPL) 9 Copyleft licenses rely on copyright law to require that any modified version remains free software. – For more details ƒ Copyleft: http://www.gnu.org/copyleft/copyleft.html 9 The GNU GPL requires that modifications and derivative works are also under GPL: – Applies only to software distributed – Any program using GPL code (statically or dynamically linked) is regarded as an extension of this code and therefore under the GPL – For more details ƒ FAQ GPL: http://www.gnu.org/licenses/gpl-faq.html

3/31/2010 Free Electrons - Stéphane Lavirotte 7 Free Applications and Embedded Systems

A collection of Software Tools

3/31/2010 Free Electrons - Stéphane Lavirotte 8 glibc

9 Library made by GNU project – http://www.gnu.org/software/libc/ – LGPL License 9 Designed for – Performances – Respect standards – Portability 9 Necessary for all GNU/Linux systems 9 But too big for embedded systems – About 1,5 - 2MB are necessary ƒ Sur IPaQ: 1,2MB pour la libc et 500KB pour la libm ƒ Sur i386: 1,3MB pour la libc et 150KB pour la libm – Possible alternatives

3/31/2010 Free Electrons - Stéphane Lavirotte 9 uClibc

9 C Library made by CodePoet Consulting – http://www.uclibc.org/ – LGPL License – Now supported by MontaVista, TimeSys, Wind River 9 Designed – For small and tiny embedded systems – With a maximum of functionalities 9 Provides most needs – Woody completely ported using uClibc 9 Small: about 4 times smaller than glibc arm – glibc: 1700 KB (libc: 1.2 MB, libm: 500 KB) – uClibc:. 400 KB (libuClibc: 300 KB, libm: 55KB)

3/31/2010 Free Electrons - Stéphane Lavirotte 10 Comparison

9 glibc (GNU C Library) – Done for its performance and the respect of standards – The best for workstation machines and servers

9 uClibc – Highly compatible – Made for embedded systems with a small storage capacity and memory

9 The others: diet libc, newlib, – Most suitable for all small systems, or initramfs and init ramdisk

3/31/2010 Free Electrons - Stéphane Lavirotte 14 A Toolbox for the Target

THE Toolbox

3/31/2010 Free Electrons - Stéphane Lavirotte 26 BusyBox

9 http://www.busybox.net/ 9 BusyBox – Consolidates most Unix utilities into a single executable – A web server if also included ! – Small size ƒ Statically compiled with uClibC: less the 500KB ƒ Statically compiled with glibc: less than 1MB 9 An excellent choice for: – Initramfs or initrd with complexes scripts – Embedded systems with small and medium-sized storage 9 Easy to configure the wanted functionalities

3/31/2010 Free Electrons - Stéphane Lavirotte 27 BusyBox Commands

addgroup, adduser, adjtimex, ar, arping, ash, awk, basename, bunzip2, bzcat, cal, cat, chgrp, chmod, chown, chroot, chvt, clear, cmp, cp, cpio, crond, crontab, cut, date, dc, dd, deallocvt, delgroup, deluser, , df, dirname, dmesg, dos2unix, dpkg, dpkgdeb, du, dumpkmap, dumpleases, echo, egrep, env, expr, false, fbset, fdflush, fdformat, fdisk, fgrep, find, fold, free, freeramdisk, fsck.minix, ftpget, ftpput, getopt, getty, grep, gunzip, gzip, halt, hdparm, head, hexdump, hostid, hostname, httpd, hush, hwclock, id, ifconfig, ifdown, ifup, inetd, init, insmod, install, ip, ipaddr, ipcalc, iplink, iproute, iptunnel, kill, killall, klogd, lash, last, length, linuxrc, ln, loadfont, loadkmap, logger, login, logname, logread, losetup, ls, lsmod, makedevs, md5sum, mesg, mkdir, mkfifo, mkfs.minix, mknod, mkswap, mktemp, modprobe, more, mount, msh, mt, mv, nameif, nc, netstat, nslookup, od, openvt, passwd, patch, pidof, ping, ping6, pipe_progress, pivot_root, poweroff, printf, ps, pwd, rdate, readlink, realpath, reboot, renice, reset, rm, rmdir, rmmod, route, rpm, rpm2cpio, runparts, rx, sed, seq, setkeycodes, sha1sum, sleep, sort, startstopdaemon, strings, stty, su, sulogin, swapoff, swapon, sync, sysctl, yslogd, tail, tar, tee, telnet, telnetd, test, tftp, time, top, touch, tr, traceroute, true, tty, udhcpc, udhcpd, umount, uname, uncompress, uniq, unix2dos, unzip, uptime, usleep, uudecode, uuencode, vconfig, vi, vlock, watch, watchdog, wc, wget, which, who, whoami, xargs, yes, zcat

3/31/2010 Free Electrons - Stéphane Lavirotte 28 Configuring BusyBox

9 Get the latest stable version – http://busybox.net/ 9 Configuring BusyBox (create a .config file): – make defconfig ƒ To begin with BusyBox ƒ Configure Busybox with all the options (produce a huge system) – make allnoconfig ƒ Unselect all the options ƒ Allow to include only wanted features (produce a small system) 9 Same interface as the kernel configuration tool – make (texte) make xconfig (graphique) 9 Possibility to configure the wanted commands and all the options and functionalities wanted for these commands

3/31/2010 Free Electrons - Stéphane Lavirotte 29 Compiling BusyBox

9 When Cross-Compiling – Choose the microprocessor architecture and the right cross- compiler in the Makefile (as for kernel) ƒ ARCH ?= arm ƒ CROSS_COMPILE ?= arm-linux-gnueabi- – Add path to the cross-compiler in our PATH ƒ export PATH=/usr/local/arm/3.3.2/bin:$PATH 9 BusyBox Compiling – Make 9 BusyBox Installing – make install 9 Just need to copy all files to the target filesystem – cp -a _install/* /mnt/rootfs/

3/31/2010 Free Electrons - Stéphane Lavirotte 30 Servers for the Target

ssh, http, …

3/31/2010 Free Electrons - Stéphane Lavirotte 33 Advantages of an Embedded Web Server 9 Several devices need something to be able to configure it (for example, the network address) – Gateway/ Modems, IP Camera, Printer, … 9 Advantages of an embedded Web Server – No need to develop some specific drivers – No need to develop a specific configuration application – No need to support different OS – Just need to develop some HTML pages (static or dynamic ones) to allow the configuration (with the power of java-script on client side) – Reduce the hardware costs (no LCD screen, no need to have a lot of storage capabilities on device, …)

3/31/2010 Free Electrons - Stéphane Lavirotte 35 thttpd

9 Tiny/Turbo/Throttling HTTP server: – http://acme.com/software/thttpd/ 9 Simple – Only implement the minimum of HTTP 1.1 protocol 9 Small at all points of view – 88KB for 2.25b version against 264KB for Apache – Very low memory consumption (no fork) 9 Portable Code – Can compile on almost all Unix systems 9 Very quick to answer – Almost as fast as the complete servers 9 Security – Designed to protect Web servers from attacks

3/31/2010 Free Electrons - Stéphane Lavirotte 36 Other Embedded Web Servers

9 BusyBox (http://busybox.net/) – 9KB (BusyBox 1.5): includes CGI, authentication, and support for scripts (like php) 9 Klone (http://koanlogic.com/kl/cont/gb/html/klone.html) – Can include dynamic page (in C/C++ <% code %> ) and compressed – Only one executable (about 150KB) 9 Boa (http://www.boa.org/) – Designed to be simple, fast and secured 9 Lighthttpd (http://lighttpd.net/) – Designed to manage high number of requests

3/31/2010 Free Electrons - Stéphane Lavirotte 37 Graphic Libraries for the Target

Graphical Toolboxes

3/31/2010 Free Electrons - Stéphane Lavirotte 38 NanoX / Microwindows

9 NanoX / Microwindows – http://www.microwindows.org/ – Graphical library running under Linux ƒ Framebuffer, X / Windows, SVGAlib, and some other graphical systems 9 Advantages: – Lisence: Mozilla Public License, allowing proprietary applications – Very light (< 100KB) – 2 APIs (C language) ƒ API Win32: allows Windows et Windows CE ƒ Naon-X API: small X server with an API of type – Documentation of API, FAQs and Tutorials available 9 Limitations – Lack some support for themes

3/31/2010 Free Electrons - Stéphane Lavirotte 39 NanoX / Microwindows

3/31/2010 Free Electrons - Stéphane Lavirotte 40 MiniGUI

9 MiniGUI – http://www.minigui.org/ – Mature graphical toolbox 9 Advantages – Supported architectures: x86, arm, ppc, m68k, mips – Support Linux / uClinux, eCos, some proprietary RT OS and Win32 – Seams popular and used in many Asian devices – Programming language: C – About 700KB 9 Limitations – Needs a commercial license to create a product with

3/31/2010 Free Electrons - Stéphane Lavirotte 41 MiniGUI

Terminals Industrial Tools

Set‐Top Box

3/31/2010 Free Electrons - Stéphane Lavirotte 42 FLTK

9 Fast Light ToolKit (pronounce « fulltick ») – http://fltk.org/ – Pronunciation: « fulltick » 9 Advantages – LGPL License – Cross-platform: Unix X11, Windows et Max OS X – Can create new applications in few minutes with the help of FLUID builder – C++ Libraries – Support for 3D graphical (OpenGL)

3/31/2010 Free Electrons - Stéphane Lavirotte 43 FLTK

3/31/2010 Free Electrons - Stéphane Lavirotte 44 9 Simple Direct media Layer – http://libsdl.org/ – Cross-platform multimedia library – At the origin, created for video games programming 9 Advantages – Allow a very low level access: keyboard, mouse, joystick, sound, 3D display (via OpenGL) and 2D (via framebuffer) – Now used for embedded systems – Native C interface – Several wrappers for many languages – Many applications and demos available

3/31/2010 Free Electrons - Stéphane Lavirotte 45 SDL

3/31/2010 Free Electrons - Stéphane Lavirotte 46 9 DirectFB – http://www.directfb.org/ 9 Advantages – C library in user mode – Designed for embedded systems – Compact, powerful, flexible et easy to use – Support for hardware acceleration (with fallback software for actions non hardware supported) – Abstraction layer to entry possibilities – with transparency management – Many applications and demos available

3/31/2010 Free Electrons - Stéphane Lavirotte 47 DirectFB

3/31/2010 Free Electrons - Stéphane Lavirotte 48

9 Qt Embedded – http://trolltech.com/products/qt/features/platforms/embedded/ 9 Advantages – Same API as the desktop (easy to develop applications) – Based on framebuffer (rather than X) with its own windowing system – Can easily change Look and Feel – Completely modular: so that, you can limit the size: ƒ Entre 1.7 et 4.1 MB compressed (3.6 et 9.0MB non compressed) – Support for: arm, x86, mips, powerpc, windows ce – Integrated with several Java VM 9 Limitations – Need a commercial license to create new products

3/31/2010 Free Electrons - Stéphane Lavirotte 49 Qt

3/31/2010 Free Electrons - Stéphane Lavirotte 50 GTK

9 Projet GTK+ – http://www.gtk.org/ 9 Advantages – Exactly the same version as the desktop one – C Library that we can include in several language – Usable with X and DirectFB – Based on for vector graphics ƒ Solutions for system without any FPU 9 Limitations – Important size with all libraries ƒ 4.4MB with DirectFB ƒ 13.4MB with X 9 To see an application example: – http://www.directfb.org/docs/GTK_Embedded/

3/31/2010 Free Electrons - Stéphane Lavirotte 51 GTK

3/31/2010 Free Electrons - Stéphane Lavirotte 52 Environments for Target

A suite of standard applications

3/31/2010 Free Electrons - Stéphane Lavirotte 53 Opie .

9 Open Palmtop Integrated Environment – http://opie.handhelds.org/ – Based on Qt Embedded 9 Advantages – Based on framebuffer (rather than on X) – Include an application suite for PDA ƒ Contacts, Calendar, … (Personal Information Management) ƒ Multimedia applications for video and music playing ƒ Device configuration ƒ Misc: games, email, … – Include beautiful icons and interfaces (themes) 9 Limitations – Lack a goo Web client (old Konqueror version)

3/31/2010 Free Electrons - Stéphane Lavirotte 54 Opie

3/31/2010 Free Electrons - Stéphane Lavirotte 55 Gnome Mobile .

9 Gnome Mobile – http://www.gnome.org/mobile/ 9 Advantages – Huge community

3/31/2010 Free Electrons - Stéphane Lavirotte 56 Gnome Mobile

3/31/2010 Free Electrons - Stéphane Lavirotte 57 GPE .

9 GPE Palmtop Environment – http://gpe.linuxtogo.org/ – Based on the GTK+ toolkit 9 Advantages – Based on X framebuffer X – Easy to remotely display the screen of a PC – Set of applications for PDA with LinPhone – Standard GTK+ application can run with no or not much modifications – Recognize handwriting on screen display

3/31/2010 Free Electrons - Stéphane Lavirotte 58 GPE

3/31/2010 Free Electrons - Stéphane Lavirotte 59