29
Module-4 Introduction Embedded Linux Tushar B Kute [email protected] http://snashlug.org [email protected]

Module 4 Embedded Linux

Embed Size (px)

DESCRIPTION

Introduction to Embedded Linux. http://tusharkute.com http://snashlug.org

Citation preview

Page 1: Module 4 Embedded Linux

Module-4 Introduction Embedded Linux

Tushar B [email protected]

http://snashlug.org [email protected]

Page 2: Module 4 Embedded Linux

What is Embedded Linux?

● porting the Linux kernel to run on a particular CPU and board which will be put into an embedded device.

● There are many companies that sell embedded Linux solutions.

● These usually include a ported Linux kernel with cross-development tools, and sometimes with real time extensions.

● the APIs and kernel codebase are the same for embedded Linux as desktop Linux

2

Page 3: Module 4 Embedded Linux

Why Embedded Linux?

● Royalty-free● Strong networking support● Has already been ported to many different CPU

architectures● Relatively small for its feature set● Easy to configure● Huge application base● Modern OS (eg. memory management, kernel

modules, etc.)

3

Page 4: Module 4 Embedded Linux

Distributions

● Commercial: – MontaVista – BlueCat Linux– …

● MMU less– uCLinux

● Hard Real-time support– RTLinux

4

Page 5: Module 4 Embedded Linux

Embedded Linux System

● Boot loader– U-boot– GRUB– …

● Kernel● File system

– Many types

5

Page 6: Module 4 Embedded Linux

Building system

● Configure and compile Toolchain– Better idea: use already made

● Configure and make the boot-loader● Install the boot loader on the target

– Use special hardware or older board boot loader● Configure and compile the kernel● Build file system

6

Page 7: Module 4 Embedded Linux

Development

● Choose C library● Use the toolchain to create

– User space applications– Kernel modules (drivers)

● Many free tools

7

Page 8: Module 4 Embedded Linux

Free tools

● C library● Toolchains● Emulators● Root file systems● Graphical toolkits● ….

8

Page 9: Module 4 Embedded Linux

C library

http://www.gnu.org/software/libc/● 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)

Page 10: Module 4 Embedded Linux

uClibchttp://www.uclibc.org/ for CodePoet Consulting

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 and TimeSys.

Page 11: Module 4 Embedded Linux

newlib

http://sources.redhat.com/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.

Page 12: Module 4 Embedded Linux

klibc

http://www.kernel.org/pub/linux/libs/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.Not elaborate enough to support BusyBox applications.

Page 13: Module 4 Embedded Linux

uClibc toolchains

Free Electrons uClibc toolchainshttp://free-electrons.com/community/tools/uclibcRun on i386 GNU/LinuxSupported platformsarm, armeb, i386, m68k, ppc, mips, mipsel, sh

Page 14: Module 4 Embedded Linux

Platform specific toolchains

ARM● Code Sourcery (glibc only, used by many):

http://www.codesourcery.com/gnu_toolchains/arm/Also available for Solaris and Windows workstations.

● ftp://ftp.handhelds.org/projects/toolchain/ (glibc only)

MIPS● http://www.linux-mips.org/wiki/Toolchains (useful links)

Page 15: Module 4 Embedded Linux

Toolchain building utilitiesBuildroot: http://buildroot.uclibc.org/

● Dedicated Makefile to build uClibc based toolchainsand even entire root filesystems.

● Downloads sources and applies patches.

Crosstool: http://www.kegel.com/crosstool/● Dedicated script to build glibc based toolchains

Doesn’t support uClibc yet.● Downloads sources and applies patches.

Page 16: Module 4 Embedded Linux

Scratchboxhttp://scratchbox.org/ - A cross-compiling toolkit project

Makes it easier to cross-compilea 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, x86Uses the qemu emulator to transparently run built arm binaries.Experimental support for ppc, mips and cris.

Page 17: Module 4 Embedded Linux

qemu

http://qemu.orgFast processor emulatorusing a portable dynamic translator.

Full system emulation

Emulates the processor and various peripheralsSupported: x86, x86_64, ppc, arm, sparc, mips

To know which machine types are supported:qemu­system­arm ­M ?i386, x86_64 system emulation: now close to native speedsthanks to the kqemu kernel module (now GPL v2!).

Page 18: Module 4 Embedded Linux

ARM emulatorsOnly Free Software, of course!

● SkyEye: http://skyeye.sourceforge.netEmulates several ARM platforms (AT91, Xscale...) and can boot several operating systems (Linux, uClinux, and others)

● Softgun: http://softgun.sourceforge.netVirtual ARM system with many virtual on-board peripherals. Boots Linux.

● SWARM - Software ARM - arm7 emulatorhttp://www.cl.cam.ac.uk/~mwd24/phd/swarm.htmlCan run uClinux

Page 19: Module 4 Embedded Linux

Other emulators

● ColdFire emulatorhttp://www.slicer.ca/coldfire/Can boot uClinux

Page 20: Module 4 Embedded Linux

Minicom

● Definition: serial communication program● Available in all GNU / Linux distributions● Capabilities (all through a serial link):

– Serial console to a remote Unix system– File transfer– Modem control and dial-up– Serial port configuration

Page 21: Module 4 Embedded Linux

General purpose toolbox: BusyBox

http://www.busybox.net/

Most Unix command line utilities within a single executable!It even includes a web server!

Sizes less than < 500 KB (statically compiled with uClibc) or less than 1 MB (statically compiled with glibc).

Easy to configure which features to include.

The best choice for

Initramfs / initrd with complex scripts

Small and medium size embedded systems

See http://www-128.ibm.com/developerworks/linux/library/l-busybox/for a nice introduction.

Page 22: Module 4 Embedded Linux

ssh server and client: dropbear

http://matt.ucc.asn.au/dropbear/dropbear.html

Very small memory footprint ssh server for embedded systems

Satisfies most needs. Both client and server!

Size: 110 KB, statically compiled with uClibc on i386.(OpenSSH client and server: approx 1200 KB,dynamically compiled with glibc on i386)

Useful to:– Get a remote console on the target device– Copy files to and from the target device (scp or rsync ­e ssh).

Page 23: Module 4 Embedded Linux

Benefits of a web server interface

Many network enabled devices can just have a network interface

Examples: modems / routers, IP cameras, printers...

No need to develop drivers and applications for computers connected to the device. No need to support multiple operating systems!

Just need to develop static or dynamic HTML pages(possibly with powerful client-side JavaScript).Easy way of providing access to device information and parameters.

Reduced hardware costs (no LCD, very little storage space needed)

Page 24: Module 4 Embedded Linux

Linux porting projects

Useful to find patches, binaries, documentation, toolchains...Only ports for embedded systems are listedarm: http://www.arm.linux.org.uk/See also http://www.linux-arm.org/ (from ARM Limited)m68k: http://www.linux-m68k.org/mips: http://www.linux-mips.org/ppc: http://penguinppc.org/embedded/sh: http://linuxsh.sourceforge.net/xtensa: http://xtensa.sourceforge.net/

Page 25: Module 4 Embedded Linux

Useful web sites

LinuxDevices.com: http://linuxdevices.com● Weekly newsletter with news and announcements

about embedded devices running Linux.● Articles, whitepapers, and Linux embedded devices

catalog.● An excellent site to follow industry news!

Page 26: Module 4 Embedded Linux

Example:

● Download CodeSourcery's toolchain installer for GNU/Linux target for IA32 host

● Install it: sh arm-2008q3-72-arm-none-linux-gnueabi.bin● The toolchain provides the cross compiler

arm-none-linux-gnueabi-gcc. You need to put it's directory in your $PATH. Once you have the toolchain, you can easily compile your hello world program: arm-none-linux-gnueabi-gcc -o hello -static hello.c

● Copy the binary to your phone and run it from an adb shell prompt: ./hello

Page 27: Module 4 Embedded Linux

Installation

●sudo apt-get install gcc-arm-linux-gnueabi

●sudo apt-get install android-tools-adb

Page 28: Module 4 Embedded Linux

Engineers are not users, they are creators!

Page 29: Module 4 Embedded Linux

This presentation is created using LibreOffice Writer 4.1.0.4 available freely under GNU public license.

Thank you