TeamStation AI System Report LATAM IT Salaries 2024
Embedded Linux Odp
1. Embedded Linux Crash Course
Eric Gustafson
http://embedded.gustafson-consulting.com
ericg@gustafson-consulting.com
2. Agenda
● What is “Embedded”?
● Example Walk Through
● Why Linux as an embedded platform?
● References
– Convention: colored names have a reference in the references.
3. What is Embedded?
● Embedded is a very nebulous term.
● My Definition: NOT a General Purpose Computer
● Some Linux Examples:
● TiVo ● PrismIQ
● Google Phone (Android) ● RioReceiver
● Home Routers ● Soekris
– ActionTec (Qwest DSL) ● An Old PC
4. Target System
“Application”
BusyBox
C Library (uClibc) (system programs)
Linux Kernel Boot syslinux (on disk)
BIOS (firmware)
Hardware – Intel x86 / PC Architecture
5. System Boot
1. Hardware Reset → Bootloader
● BIOS Executes → syslinux (i.e. DOS format floppy/CF)
● syslinux → loads the Linux Kernel
2. Linux Kernel initializes
● Kernel mounts initrd.gz, the “root” filesystem.
3. Kernel → /sbin/init (from BusyBox)
4. init → /etc/rc (sh script – developer provided)
5. rc script → “Application”
6. The Build Artifacts
– What makes up our system –
● Hardware – provided
● BIOS – provided
● syslinux – {download, precompiled}
● Linux Kernel – BUILD
● µclibc (C Library) - BUILD
● BusyBox (core programs) – BUILD
● “Application” – BUILD
7. Cross Compiler Tool Chain
– How to build the Artifacts –
● Cross Compilation
– Gnu Binutils
● Assembler, linker, etc.
– Gnu C Compiler
– C Library – uClibc
● Others: Newlib, Gnu C Library
– Linux Kernel – just the headers
● Packaging
– initrd.gz – cramfs tools
● Alternatives: ext2fs, jffs2, many others
8. End to End Build
– Getting our hands a little dirty –
● Buildroot
● http://buildroot.uclibc.org
– Menu based configuration
– Many options for configuration and architecture
– Does everything
● builds cross compiler tool chain
● compiles kernel, C library (μClibc), BusyBox
● packages root filesystem image
– Leaves all artifacts, and configuration, in place.
– Buildroot is an excellent place to start.
9. From Scratch
– Getting our hands really dirty –
● Build Cross Development Tools
– Build Binutils
– Install Linux Kernel Headers
– Build gcc-initial (no C Library dependencies)
– Build C library (μClibc)
– Build gcc-final (which uses the C library)
● X-Compile Target Artifacts
– Configure & Compile Linux Kernel → bzImage (the Kernel)
– Configure & Compile BusyBox
– Compile “Application”
10. From Scratch (2)
– Getting our hands really dirty –
● Package Root Filesystem
– Make a temp directory to act as “/”, call it “root_dir”
– Place BusyBox, μClibc, and “Application” in directory “root_dir” using a typical root layout.
– mkfs -t cramfs root_dir initrd
– gzip -9 initrd → “initrd.gz”, the initrd image
● Place Artifacts on boot media.
– Create a DOS format floppy (or CF card)
– syslinux /dev/fd0 # only needed the first time
– Mount /dev/fd0
● Create and copy syslinux.cfg to /dev/fd0
– This is a small config file w/ kernel boot arguments
● Copy kernel, bzImage, to /dev/fd0
● Copy the root filesystem, initrd.gz, to /dev/fd0
11. Why Linux?
● Open Source
● Modifications are common, and easy.
● Entire tool chain is freely available – low cost to entry.
● The Kernel has LOTS of configurable
drivers.
– Common embedded chipset support.
– Theres more than just chipset support though.
● File systems, network protocols, and lots more.
● Momentum – Linux's success is feeding on itself.
12. References
● Compiler Tools ● C Libraries
– GNU Binutils - – μClibc - http://uclibc.org/
http://www.gnu.org/software/binutils – Newlib -
– GNU C Compiler - http://sourceware.org/newlib/
http://gcc.gnu.org – Gnu C Library -
● GCC requires GMP and MPFR http://www.gnu.org/software/libc/
– GMP - http://gmplib.org/
– MPFR - http://www.mpfr.org/
● Linux Kernel
– http://www.kernel.org/
– http://www.linuxdocs.org/
HOWTOs/Kernel-HOWTO.html