Presentation is loading. Please wait.

Presentation is loading. Please wait.

Bina Software Development © 1 Introduction to Embedded Linux.

Similar presentations


Presentation on theme: "Bina Software Development © 1 Introduction to Embedded Linux."— Presentation transcript:

1 Bina Software Development © http://www.bna.co.il 1 Introduction to Embedded Linux

2 What is Linux A fully-networked 32/64-Bit Unix-like Operating System Unix Tools Compilers Network Tools Multi-user, Multitasking, Multiprocessor Has the X Windows GUI Runs on multiple platforms Includes the Source Code

3 Where did it come from? Linus Torvalds created it with assistance from programmers around the world first posted on Internet in 1991 Linux 1.0 in 1994; 2.6 in 2003 Open Source: When programmers on the Internet can read, redistribute, and modify the source for a piece of software, it evolves People improve it, people adapt it, people fix bugs. And this can happen at a speed that, compared to conventional software development, seems astonishing

4 How do you get it? Download it from the Internet From a “Distribution” (e.g. RedHat)RedHat Linux kernel X Windows system and GUI Web, e-mail, FTP servers Installation & configuration support 3rd party apps Hardware support

5 Why is it significant? Growing popularity Powerful Runs on multiple hardware platforms Users like its speed and stability No requirement for latest hardware It’s “free” Licensed under GPL Vendors are distributors who package Linux

6 The Linux System User commands includes executable programs and scripts The shell interprets user commands. It is responsible for finding the commands and starting their execution. Several different shells are available. Bash is popular, The kernel manages the hardware resources for the rest of the system.

7 Shells An interface between the Linux system and the user Used to call commands and programs An interpreter Powerful programming language “Shell scripts” =.bat.cmd EXEC REXX Many available (bsh; ksh; csh; bash; tcsh) Character Based and Graphics Based

8 Portability and hardware support Runs on most architectures. Scalability Can run on super computers as well as on tiny devices (4 MB of RAM is enough). Compliance to standards and interoperability. Exhaustive networking support. Security It can't hide its flaws. Its code is reviewed by many experts. Stability and reliability. Modularity Can include only what a system needs even at run time. Easy to program You can learn from existing code. Many useful resources on the net. Linux Kernel

9 Supported hardware architectures See the arch/ directory in the kernel sources Minimum: 32 bit processors, with or without MMU 32 bit architectures ( arch/ subdirectories) alpha, arm, cris, frv, h8300, i386, m32r, m68k, m68knommu, mips, parisc, ppc, s390, sh, sparc, um, v850, xtensa 64 bit architectures: ia64, mips64, ppc64, sh64, sparc64, x86_64

10 Kernel architecture System call interface Process management Memory management Filesystem support Device control Networking CPU support code Filesystem types Storage drivers Character device drivers Network device drivers CPU / MMU support code C library App1App2... User space Kernel space Hardware CPU RAM Storage

11 Linux Device Handling Devices are the way linux talks to the world Devices are special files in the /dev directory (try ls /dev ) /dev/ttyxTTY devices /dev/hdbIDE hard drive /dev/hdb1Partition 1-IDE hard drive /dev/nullThe null device /dev/zeroAn endless stream of zeroes /dev/mouseLink to mouse

12 Devices and Drivers Each /dev file has a major and minor number Major defines the device type Minor defines device within that type Drivers register a device type brw-r--r-- 1 root root 64, 0 Jun 1 1999 /dev/mnda crw-r--r-- 1 root root 5, 0 Jan 5 09:18 /dev/tty Major no. Minor no. Device Type: b - block c - character

13 Special Files - /proc Information about internal Linux processes are accessible to users via the /proc file system (in memory) cat /proc/cpuinfo vendor_id : IBM/S390 # processors : 1 bogomips per cpu: 86.83 processor 0: version = FF, identification = 045226, machine = 9672

14 File Systems Linux supports many different types Most commonly, ext2fs Filenames of 255 characters File sizes up to 2GB Theoretical limit 4TB Derived from extfs Highly reliable and high performer

15 File Systems Other file systems: sysv - SCO/Xenix ufs- SunOS/BSD vfat- Win9x msdos- MS-DOS/Win umsdos- Linux/DOS ntfs- WinNT (r/o) hpfs- OS/2 (r/o) Other File systems: iso9660 (CD-ROM) nfs- NFS coda- NFS-like ncp- Novell smb- LANManager etc

16 Processes Processes are created in a hierarchical structure whose depth is limited only by the virtual memory available to the virtual machine A process may control the execution of any of its descendants by suspending or resuming it, altering its relative priority, or even terminating it Termination of a process by default causes termination of all its descendants; termination of the root process causes termination of the session Linux assigns a process ID (PID) to the process

17 Bina Software Development © http://www.bna.co.il 17 Embedded Linux

18 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 © Bina Software Development http://www.bna.co.il 18

19 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.) © Bina Software Development http://www.bna.co.il 19

20 Distributions Commercial: MontaVista BlueCat Linux … MMU less uCLinux Hard Real-time support RTLinux © Bina Software Development http://www.bna.co.il 20

21 Embedded Linux System Boot loader U-boot GRUB … Kernel File system Many types © Bina Software Development http://www.bna.co.il 21

22 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 © Bina Software Development http://www.bna.co.il 22

23 Development Choose C library Use the toolchain to create User space applications Kernel modules (drivers) Many free tools © Bina Software Development http://www.bna.co.il 23

24 Kernel modules © Bina Software Development http://www.bna.co.il 24 /* hello.c */ #include #include #include static int __init hello_init(void) { printk(KERN_ALERT "Good morrow"); printk(KERN_ALERT "to this fair assembly.\n"); return 0; } static void __exit hello_exit(void) { printk(KERN_ALERT "Alas, poor world, what treasure"); printk(KERN_ALERT "hast thou lost!\n"); } module_init(hello_init); module_exit(hello_exit); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Greeting module"); MODULE_AUTHOR("William Shakespeare");

25 Free tools C library Toolchains Emulators Root file systems Graphical toolkits …. © Bina Software Development http://www.bna.co.il 25

26 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)

27 uClibc http://www.uclibc.org/http://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.

28 Honey, I shrunk the programs!

29 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.

30 klibc http://www.kernel.org/pub/linux/libs/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.

31 uClibc toolchains Free Electrons uClibc toolchains http://free-electrons.com/community/tools/uclibc http://free-electrons.com/community/tools/uclibc Run on i386 GNU/Linux Supported platforms arm, armeb, i386, m68k, ppc, mips, mipsel, sh

32 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. http://www.codesourcery.com/gnu_toolchains/arm/ ftp://ftp.handhelds.org/projects/toolchain/ (glibc only) ftp://ftp.handhelds.org/projects/toolchain/ MIPS http://www.linux-mips.org/wiki/Toolchains (useful links) http://www.linux-mips.org/wiki/Toolchains

33 Toolchain building utilities Buildroot: http://buildroot.uclibc.org/http://buildroot.uclibc.org/ Dedicated Makefile to build uClibc based toolchains and even entire root filesystems. Downloads sources and applies patches. Crosstool: http://www.kegel.com/crosstool/http://www.kegel.com/crosstool/ Dedicated script to build glibc based toolchains Doesn’t support uClibc yet. Downloads sources and applies patches.

34 Scratchbox http://scratchbox.org/http://scratchbox.org/ - A cross-compiling toolkit project 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.

35 qemu http://qemu.org http://qemu.org Fast processor emulator using a portable dynamic translator. Full system emulation Emulates the processor and various peripherals Supported: 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 speeds thanks to the kqemu kernel module (now GPL v2!).

36 ARM emulators Only Free Software, of course! SkyEye: http://skyeye.sourceforge.net Emulates several ARM platforms (AT91, Xscale...) and can boot several operating systems (Linux, uClinux, and others)http://skyeye.sourceforge.net Softgun: http://softgun.sourceforge.net Virtual ARM system with many virtual on-board peripherals. Boots Linux.http://softgun.sourceforge.net SWARM - Software ARM - arm7 emulator http://www.cl.cam.ac.uk/~mwd24/phd/swarm.html Can run uClinux http://www.cl.cam.ac.uk/~mwd24/phd/swarm.html

37 Other emulators ColdFire emulator http://www.slicer.ca/coldfire/ Can boot uClinux http://www.slicer.ca/coldfire/

38 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

39 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.http://www-128.ibm.com/developerworks/linux/library/l-busybox/

40 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 ).

41 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)

42 thttpd Tiny/Turbo/Throttling HTTP server http://acme.com/software/thttpd/ http://acme.com/software/thttpd/ Simple Implements the HTTP/1.1 minimum (or just a little more) Simple to configure and run. Small Executable size: 88K (version 2.25b), Apache 2.0.52: 264K Very low memory consumption: does not fork and very careful about memory consumption. Portable Compiles cleanly on most Unix-like operating systems Fast About as fast as full-featured servers. Much faster on very high loads (because reduces the server load for the same amount of work) Secure Designed to protect the webserver machine from attacks.

43 Other web servers (1) BusyBox http server: http://busybox.net Tiny: only adds 9 K to BusyBox 1.5 (dynamically linked with glibc on i386, with all features enabled.)! Sufficient features for many devices with a web interface, including CGI, http authentication and script support (like PHP). License: GPLhttp://busybox.net KLone: http://koanlogic.com/kl/cont/gb/html/klone.html Lightweight but full featured web server for embedded systems. Can enclose dynamic (written in C/C++ ) and compressed content all in an executable of an approximate size of 150 KB. License: Dual GPL / Commercial. See also http://linuxdevices.com/news/NS8234701895.htmlhttp://koanlogic.com/kl/cont/gb/html/klone.htmlhttp://linuxdevices.com/news/NS8234701895.html

44 Other web servers (2) Boa: http://www.boa.org/ Designed to be simple, fast and secure. Unlike thttpd, no particular care for memory or disk footprint though. Embedded systems: pretty popular, though not targeted by developers.http://www.boa.org/ lighthttpd: http://lighttpd.net Low footprint server good at managing high loads. May be useful in embedded systems too.http://lighttpd.net

45 Graphical toolkits Licenses matter here! Toolkits allowing proprietary applications Nano-X / Microwindows, FLTK, SDL, DirectFB, GTK GPL toolkits (commercial license required for proprietary apps) MiniGUI, Qt Embedded Graphical environments and applications Qtopia, Opie, GPE Web browser based interfaces

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

47 Useful web sites LinuxDevices.com: http://linuxdevices.comhttp://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!

48 More info http://free-electrons.com Best site: many resources http://bina-soft.blogspot.com/ Our blog and source repository © Bina Software Development http://www.bna.co.il 48


Download ppt "Bina Software Development © 1 Introduction to Embedded Linux."

Similar presentations


Ads by Google