Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded...

42
Free Software for Embedded Systems Mail: [email protected] Web: http://stephane.lavirotte.com/ University of Nice - Sophia Antipolis

Transcript of Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded...

Page 1: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

Free Software for Embedded Systems

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

Page 2: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

We must start with something…

Introduction

Free Electrons - Stéphane Lavirotte 23/31/2010

Page 3: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

Linux for embedded systems– Is used more and more

– In use in many devicesMobile 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 systemsuClinux, uClibc, dietlib, …

Easy to include free software inside that products– sqlite, samba, thttpd, …

Linux for Embedded Systems

Free Electrons - Stéphane Lavirotte 33/31/2010

Page 4: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

Development Phases

Configuration– First, choose which features to include in the system

Kernel configuration

Choose the tools and applications to include

Build– Need to recompile the entire system for the target:

Kernel

Libraries

Applications

Deployment– Installation of files in a filesystem

– Transfer on the target and start the new system

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

Page 5: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

System Components

Component– Boot Loader

– Kernel

– Kernel Modules

– File Systems

– Libraries

– Applications

Boot Loader

Kernel

File System

Kernel Modules

Libraries

Applications

Free Electrons - Stéphane Lavirotte 53/31/2010

Page 6: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

About Free Software

Linux is and Open Source Free SoftwareFree 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).

See– http://www.gnu.org/philosophy/

Free Electrons - Stéphane Lavirotte 63/31/2010

Page 7: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

The GNU General Public License (GPL)

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

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 detailsFAQ GPL: http://www.gnu.org/licenses/gpl-faq.html

Free Electrons - Stéphane Lavirotte 73/31/2010

Page 8: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

A collection of Software Tools

Free Applications and Embedded Systems

Free Electrons - Stéphane Lavirotte 83/31/2010

Page 9: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

glibc

C Library made by GNU project– http://www.gnu.org/software/libc/

– LGPL License

Designed for– Performances

– Respect standards

– Portability

Necessary for all GNU/Linux systems

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

Free Electrons - Stéphane Lavirotte 93/31/2010

Page 10: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

uClibc

C Library made by CodePoet Consulting– http://www.uclibc.org/

– LGPL License

– Now supported by MontaVista, TimeSys, Wind River

Designed– For small and tiny embedded systems

– With a maximum of functionalities

Provides most needs– Debian Woody completely ported using uClibc

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)

Free Electrons - Stéphane Lavirotte 103/31/2010

Page 11: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

Comparison

glibc (GNU C Library)– Done for its performance and the respect of standards

– The best for workstation machines and servers

uClibc– Highly compatible

– Made for embedded systems with a small storage capacity and memory

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

Free Electrons - Stéphane Lavirotte 143/31/2010

Page 12: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

THE Toolbox

A Toolbox for the Target

Free Electrons - Stéphane Lavirotte 263/31/2010

Page 13: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

BusyBox

http://www.busybox.net/

BusyBox– Consolidates most Unix utilities into a single executable

– A web server if also included !

– Small sizeStatically compiled with uClibC: less the 500KB

Statically compiled with glibc: less than 1MB

An excellent choice for:– Initramfs or initrd with complexes scripts

– Embedded systems with small and medium-sized storage

Easy to configure the wanted functionalities

Free Electrons - Stéphane Lavirotte 273/31/2010

Page 14: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

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, devfsd, 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

Free Electrons - Stéphane Lavirotte 283/31/2010

Page 15: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

Configuring BusyBox

Get the latest stable version– http://busybox.net/

Configuring BusyBox (create a .config file):– make defconfig

To begin with BusyBoxConfigure Busybox with all the options (produce a huge system)

– make allnoconfigUnselect all the optionsAllow to include only wanted features (produce a small system)

Same interface as the kernel configuration tool– make menuconfig (texte) make xconfig (graphique)

Possibility to configure the wanted commands and all the options and functionalities wanted for these commands

Free Electrons - Stéphane Lavirotte 293/31/2010

Page 16: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

Compiling BusyBox

When Cross-Compiling– Choose the microprocessor architecture and the right cross-

compiler in the Makefile (as for kernel)ARCH ?= armCROSS_COMPILE ?= arm-linux-gnueabi-

– Add path to the cross-compiler in our PATHexport PATH=/usr/local/arm/3.3.2/bin:$PATH

BusyBox Compiling– Make

BusyBox Installing– make install

Just need to copy all files to the target filesystem– cp -a _install/* /mnt/rootfs/

Free Electrons - Stéphane Lavirotte 303/31/2010

Page 17: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

ssh, http, …

Servers for the Target

Free Electrons - Stéphane Lavirotte 333/31/2010

Page 18: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

Advantages of an Embedded Web Server

Several devices need something to be able to configure it (for example, the network address)– Gateway/ Modems, IP Camera, Printer, …

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, …)

Free Electrons - Stéphane Lavirotte 353/31/2010

Page 19: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

thttpd

Tiny/Turbo/Throttling HTTP server:– http://acme.com/software/thttpd/

Simple– Only implement the minimum of HTTP 1.1 protocol

Small at all points of view– 88KB for 2.25b version against 264KB for Apache– Very low memory consumption (no fork)

Portable Code– Can compile on almost all Unix systems

Very quick to answer– Almost as fast as the complete servers

Security– Designed to protect Web servers from attacks

Free Electrons - Stéphane Lavirotte 363/31/2010

Page 20: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

Other Embedded Web Servers

BusyBox (http://busybox.net/) – 9KB (BusyBox 1.5): includes CGI, authentication, and support

for scripts (like php)

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)

Boa (http://www.boa.org/)– Designed to be simple, fast and secured

Lighthttpd (http://lighttpd.net/)

– Designed to manage high number of requests

Free Electrons - Stéphane Lavirotte 373/31/2010

Page 21: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

Graphical Toolboxes

Graphic Libraries for the Target

Free Electrons - Stéphane Lavirotte 383/31/2010

Page 22: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

NanoX / Microwindows

NanoX / Microwindows– http://www.microwindows.org/– Graphical library running under Linux

Framebuffer, X / Windows, SVGAlib, and some other graphical systems

Advantages:– Lisence: Mozilla Public License, allowing proprietary

applications– Very light (< 100KB)– 2 APIs (C language)

API Win32: allows Windows et Windows CENaon-X API: small X server with an API of Xlib type

– Documentation of API, FAQs and Tutorials available

Limitations– Lack some support for themes

Free Electrons - Stéphane Lavirotte 393/31/2010

Page 23: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

NanoX / Microwindows

Free Electrons - Stéphane Lavirotte 403/31/2010

Page 24: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

MiniGUI

MiniGUI– http://www.minigui.org/

– Mature graphical toolbox

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

Limitations– Needs a commercial license to create a product with

Free Electrons - Stéphane Lavirotte 413/31/2010

Page 25: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

MiniGUI

Terminals

Set‐Top  Box

Industrial Tools

Free Electrons - Stéphane Lavirotte 423/31/2010

Page 26: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

FLTK

Fast Light ToolKit (pronounce « fulltick »)– http://fltk.org/

– Pronunciation: « fulltick »

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)

Free Electrons - Stéphane Lavirotte 433/31/2010

Page 27: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

FLTK

Free Electrons - Stéphane Lavirotte 443/31/2010

Page 28: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

Simple Direct media Layer– http://libsdl.org/

– Cross-platform multimedia library

– At the origin, created for video games programming

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

Free Electrons - Stéphane Lavirotte 453/31/2010

Page 29: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

SDL

Free Electrons - Stéphane Lavirotte 463/31/2010

Page 30: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

DirectFB– http://www.directfb.org/

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

– Windowing system with transparency management

– Many applications and demos available

Free Electrons - Stéphane Lavirotte 473/31/2010

Page 31: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

DirectFB

Free Electrons - Stéphane Lavirotte 483/31/2010

Page 32: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

Qt

Qt Embedded– http://trolltech.com/products/qt/features/platforms/embedded/

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

Limitations– Need a commercial license to create new products

Free Electrons - Stéphane Lavirotte 493/31/2010

Page 33: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

Qt

Free Electrons - Stéphane Lavirotte 503/31/2010

Page 34: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

GTK

Projet GTK+– http://www.gtk.org/

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 Cairo for vector graphics

Solutions for system without any FPU

Limitations– Important size with all libraries

4.4MB with DirectFB13.4MB with X

To see an application example:– http://www.directfb.org/docs/GTK_Embedded/

Free Electrons - Stéphane Lavirotte 513/31/2010

Page 35: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

GTK

Free Electrons - Stéphane Lavirotte 523/31/2010

Page 36: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

A suite of standard applications

Environments for Target

Free Electrons - Stéphane Lavirotte 533/31/2010

Page 37: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

Opie .

Open Palmtop Integrated Environment– http://opie.handhelds.org/

– Based on Qt Embedded

Advantages– Based on framebuffer (rather than on X)

– Include an application suite for PDAContacts, Calendar, … (Personal Information Management)

Multimedia applications for video and music playing

Device configuration

Misc: games, email, …

– Include beautiful icons and interfaces (themes)

Limitations– Lack a goo Web client (old Konqueror version)

Free Electrons - Stéphane Lavirotte 543/31/2010

Page 38: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

Opie

Free Electrons - Stéphane Lavirotte 553/31/2010

Page 39: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

Gnome Mobile .

Gnome Mobile– http://www.gnome.org/mobile/

Advantages– Huge community

Free Electrons - Stéphane Lavirotte 563/31/2010

Page 40: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

Gnome Mobile

Free Electrons - Stéphane Lavirotte 573/31/2010

Page 41: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

GPE .

GPE Palmtop Environment– http://gpe.linuxtogo.org/

– Based on the GTK+ toolkit

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

Free Electrons - Stéphane Lavirotte 583/31/2010

Page 42: Free Software for Embedded Systems - unice.frtrolen.polytech.unice.fr/cours/esa/04-Embedded Apps-en.pdf · – At the origin, created for video games programming. 9Advantages –

GPE

Free Electrons - Stéphane Lavirotte 593/31/2010