Tải bản đầy đủ (.pdf) (132 trang)

Free Software tools for embedded systems

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (2 MB, 132 trang )

1
Free Software tools for embedded systems
© Copyright 2004­2008, Free Electrons
Creative Commons Attribution­ShareAlike 2.5 license
http://free­electrons.com
Jan 24, 2008
Free Software tools for embedded systems
Free Software tools for embedded systems
Thomas Petazzoni / Michael Opdenacker
Free Electrons
http://free­electrons.com/
Created with OpenOffice.org 2.x
2
Free Software tools for embedded systems
© Copyright 2004­2008, Free Electrons
Creative Commons Attribution­ShareAlike 2.5 license
http://free­electrons.com
Jan 24, 2008
Rights to copy
Attribution – ShareAlike 2.5
You are free
to copy, distribute, display, and perform the work
to make derivative works
to make commercial use of the work
Under the following conditions
Attribution. You must give the original author credit.
Share Alike. If you alter, transform, or build upon this work, 
you may distribute the resulting work only under a license 
identical to this one.
For any reuse or distribution, you must make clear to others the 
license terms of this work.


Any of these conditions can be waived if you get permission from 
the copyright holder.
Your fair use and other rights are in no way affected by the above.
License text:  />© Copyright 2004­2008
Free Electrons
feedback@free­electrons.com
Document sources, updates and translations: 
http://free­electrons.com/training/devtools
Corrections, suggestions, contributions and 
translations are welcome!
3
Free Software tools for embedded systems
© Copyright 2004­2008, Free Electrons
Creative Commons Attribution­ShareAlike 2.5 license
http://free­electrons.com
Jan 24, 2008
Best viewed with...
This document is best viewed with a recent PDF reader
or with OpenOffice.org itself!
Take advantage of internal or external hyperlinks.
So, don’t hesitate to click on them!
Find pages quickly thanks to automatic search
Use thumbnails to navigate in the document in a quick way
If you’re reading a paper or HTML copy, you should get your 
copy in PDF or OpenOffice.org format on 
http://free­electrons.com/training/devtools!
4
Free Software tools for embedded systems
© Copyright 2004­2008, Free Electrons
Creative Commons Attribution­ShareAlike 2.5 license

http://free­electrons.com
Jan 24, 2008
Training contents (1)
C library for the target device
C library options
GNU / Linux workstation
Cross­compiling toolchains
Emulators
Various tools
How to find Free Software for your needs
Commercial toolsets and distributions
5
Free Software tools for embedded systems
© Copyright 2004­2008, Free Electrons
Creative Commons Attribution­ShareAlike 2.5 license
http://free­electrons.com
Jan 24, 2008
Training contents (2)
Target device
Busybox
http and ssh servers
Graphical toolkits
Web browsers
Text editors
Precompiled packages, distributions
6
Free Software tools for embedded systems
© Copyright 2004­2008, Free Electrons
Creative Commons Attribution­ShareAlike 2.5 license
http://free­electrons.com

Jan 24, 2008
Training contents (3)
Annexes
Automatic system generation with BitBake / OpenEmbedded
7
Free Software tools for embedded systems
© Copyright 2004­2008, Free Electrons
Creative Commons Attribution­ShareAlike 2.5 license
http://free­electrons.com
Jan 24, 2008
Free Software tools for embedded systems
C library for the target device
C library options
8
Free Software tools for embedded systems
© Copyright 2004­2008, Free Electrons
Creative Commons Attribution­ShareAlike 2.5 license
http://free­electrons.com
Jan 24, 2008
glibc
/>License: LGPL
C library from the GNU project
Designed for performance, standards compliance and 
portability
Found on all GNU / Linux host systems
Quite big for small embedded systems: about 1.7 MB on 
Familiar Linux iPAQs (libc: 1.2 MB, libm: 500 KB)
9
Free Software tools for embedded systems
© Copyright 2004­2008, Free Electrons

Creative Commons Attribution­ShareAlike 2.5 license
http://free­electrons.com
Jan 24, 2008
uClibc
/>License: LGPL
Lightweight C library for small embedded systems, with most features 
though.
The whole Debian Woody was ported to it...
You can assume it satisfied most needs!
Size (arm): 4 times smaller than glibc!
uClibc: approx. 400 KB (libuClibc: 300 KB, libm: 55KB)
glibc: approx 1700 KB (libc: 1.2 MB, libm: 500 KB)
Now supported by MontaVista, TimeSys and Wind River.
10
Free Software tools for embedded systems
© Copyright 2004­2008, Free Electrons
Creative Commons Attribution­ShareAlike 2.5 license
http://free­electrons.com
Jan 24, 2008
Honey, I shrunk the programs!
C program Compiled with shared libraries Compiled statically
glibc uClibc glibc uClibc
Plain “hello world” 4.6 K 4.4 K 475 K 25 K
Busybox 245 K 231 K 843 K 311 K
11
Free Software tools for embedded systems
© Copyright 2004­2008, Free Electrons
Creative Commons Attribution­ShareAlike 2.5 license
http://free­electrons.com
Jan 24, 2008

diet libc
/>A C library optimized for small size
Designed to compile small statically linked programs, 
resulting in executables with a fraction of the size
of those using glibc.
diet libc compiled code size: approximately 70 KB 
12
Free Software tools for embedded systems
© Copyright 2004­2008, Free Electrons
Creative Commons Attribution­ShareAlike 2.5 license
http://free­electrons.com
Jan 24, 2008
newlib
/>Minimal C library for very small embedded systems
Lets you remove floating point support wherever you don't need it. 
Also provides an integer only iprintf() function. Much 
smaller!
Provides single precision math library functions. Much faster than 
the standard IEEE compliant ones.
Extremely portable. Supports most processor architectures.
See  />for a very good overview.
13
Free Software tools for embedded systems
© Copyright 2004­2008, Free Electrons
Creative Commons Attribution­ShareAlike 2.5 license
http://free­electrons.com
Jan 24, 2008
klibc
/>“Kernel C library”
Tiny and minimalistic C library designed for use in an initramfs at 

boot time (alternative to initrds).
Fine for the creation of simple shell scripts.
Ships with small executables for use in shells, built with klibc,
and a klcc compiler to compile your own applications.
Not elaborate enough to support BusyBox applications.
Useful details in   />14
Free Software tools for embedded systems
© Copyright 2004­2008, Free Electrons
Creative Commons Attribution­ShareAlike 2.5 license
http://free­electrons.com
Jan 24, 2008
C library options ­ Summary
GNU C library (glibc)
Designed for performance compliance with standards.
Best for servers and desktops.
uClibc
Highly compatible, but implemented for small embedded 
systems with little storage space and RAM
Others: diet libc, newlib, klibc
Best suited for tiny systems, or init ramdisks or initramfs.
15
Free Software tools for embedded systems
© Copyright 2004­2008, Free Electrons
Creative Commons Attribution­ShareAlike 2.5 license
http://free­electrons.com
Jan 24, 2008
Free Software tools for embedded systems
GNU / Linux workstation
Cross­compiling toolchains
16

Free Software tools for embedded systems
© Copyright 2004­2008, Free Electrons
Creative Commons Attribution­ShareAlike 2.5 license
http://free­electrons.com
Jan 24, 2008
Standalone toolchain build
Building a cross­compiling toolchain by yourself is a difficult and painful task! 
Can take days or weeks!
Lots of details to learn. Several components to build
(building gcc twice: once for gcc + once for compilers that need the C library).
Lots of decisions to make
(such as C library version and configuration for your platform)
Need kernel headers and C library sources
Need to be familiar with current gcc issues and patches on your platform
Useful to be familiar with building and configuring tools
/>can show you how fun it can be!
17
Free Software tools for embedded systems
© Copyright 2004­2008, Free Electrons
Creative Commons Attribution­ShareAlike 2.5 license
http://free­electrons.com
Jan 24, 2008
Get a precompiled toolchain
Can get one from several locations... Just need to know where!
Caution
Toolchains are not relocatable! Install them in
/usr/local/<arch> if they were built for this location.
Note: no longer true with gcc 4.x versions.
Make sure the toolchain you pick suits your needs:
CPU, endianism, C library and compiler versions...

18
Free Software tools for embedded systems
© Copyright 2004­2008, Free Electrons
Creative Commons Attribution­ShareAlike 2.5 license
http://free­electrons.com
Jan 24, 2008
uClibc toolchains
Free Electrons uClibc toolchains
http://free­electrons.com/community/tools/uclibc
Run on i386 GNU/Linux
Supported platforms
arm, armeb, i386, m68k, ppc, mips, mipsel, sh
19
Free Software tools for embedded systems
© Copyright 2004­2008, Free Electrons
Creative Commons Attribution­ShareAlike 2.5 license
http://free­electrons.com
Jan 24, 2008
Platform specific toolchains (1)
ARM
Code Sourcery (supports GNU/Linux, EABI and uClinux):
/>Also available for Windows workstations.
MIPS
ux­mips.org/wiki/Toolchains (useful links)
20
Free Software tools for embedded systems
© Copyright 2004­2008, Free Electrons
Creative Commons Attribution­ShareAlike 2.5 license
http://free­electrons.com
Jan 24, 2008

Platform specific toolchains (2)
Coldfire
Code Sourcery (supports ELF, GNU/Linux and uClinux):
/>PowerPC
Code Sourcery (supports GNU/Linux and EABI)
/>21
Free Software tools for embedded systems
© Copyright 2004­2008, Free Electrons
Creative Commons Attribution­ShareAlike 2.5 license
http://free­electrons.com
Jan 24, 2008
Toolchain building utilities
Buildroot:  />Dedicated Makefile to build uClibc based toolchains
and even entire root filesystems.
Downloads sources and applies patches.
Crosstool:   />Dedicated script to build glibc based toolchains
Doesn’t support uClibc yet.
Downloads sources and applies patches.
22
Free Software tools for embedded systems
© Copyright 2004­2008, Free Electrons
Creative Commons Attribution­ShareAlike 2.5 license
http://free­electrons.com
Jan 24, 2008
gcc / glibc / binutils / kernel versions
Crosstool build reports:  />Can help you 
to find a 
working 
combination 
of gcc, 

glibc, 
binutils 
and kernel 
headers 
versions!
23
Free Software tools for embedded systems
© Copyright 2004­2008, Free Electrons
Creative Commons Attribution­ShareAlike 2.5 license
http://free­electrons.com
Jan 24, 2008
Build your rootfs with buildroot
Buildroot supports most architectures
It automatically downloads tool sources and applies patches.
Except your custom applications, it can build most apps you 
will need (194 supported in May 2007). Examples:
BusyBox, bzip2, Cairo, dbus, Dillo, DirectFB, Dropbear, 
lighthttpd, Python, Qtopia4, sqlite, thttpd, tinyX, xorg...
Very easy to use. Just run:
make menuconfig
make 
24
Free Software tools for embedded systems
© Copyright 2004­2008, Free Electrons
Creative Commons Attribution­ShareAlike 2.5 license
http://free­electrons.com
Jan 24, 2008
Scratchbox
/>Makes it easier to cross­compile
a complete embedded Linux system.

Works by allowing tools to be cross­compiled in a transparent 
way, making building tools believe they are doing a native 
compile job.
Supported platforms: arm, x86
Uses the qemu emulator to transparently run built arm binaries.
Experimental support for ppc, mips and cris.
25
Free Software tools for embedded systems
© Copyright 2004­2008, Free Electrons
Creative Commons Attribution­ShareAlike 2.5 license
http://free­electrons.com
Jan 24, 2008
Scratchbox features
Main benefits
Chrooted environment:
you are still on the host, but you only see the target files.
Transparent cross­compiling: the cross­compiler looks like a native one.
Transparent execution: either through remote execution on the target. Or through 
CPU code emulation (qemu).
Other features
Ships with cross­compiling toolchains
and software to create Debian packages.
Supports both uClibc and glibc.
Very basic root filesystems available.

×