Systèmes Et Applications Embarquées
Total Page:16
File Type:pdf, Size:1020Kb
Free Software 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 Linux 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 – sqlite, 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 C 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 – Debian 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, klibc – 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, 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 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 menuconfig (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 Xlib 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