SlideShare una empresa de Scribd logo
1 de 129
Descargar para leer sin conexión
12/07/13 - Marc Leeman
Company Confidential - 1
Basic Introduction to
Embedded Linux
Barco Seminar
11/07/2013
Marc Leeman
12/07/13 - Marc Leeman
Company Confidential - 2
Patches Accepted
● 11th time we do this training
● 5th time based on SheevaPlug
● Bear with us
● Developed over time
● Inconsistencies in course text/slides(?)
● Feedback welcome!
12/07/13 - Marc Leeman
Company Confidential - 3
Goals
● Huge topic, so only introduction
● Hands on, examples, share experience
● Become acquainted with typical small
footprint embedded Linux
● Where to look for setting up or obtaining
a cross compile toolchain environment
● Get to know the typical bootloaders
● Lots-of-examples
12/07/13 - Marc Leeman
Company Confidential - 4
Hardware
● SheevaPlug
● Marvell Arm Kirkwood processor
● 1.2 GHz
● 512 MB RAM
● U-Boot bootloader
● 512 MB NAND Flash
● Gb Ethernet, Serial, SD Card, USB, ...
12/07/13 - Marc Leeman
Company Confidential - 5
SheevaPlug
12/07/13 - Marc Leeman
Company Confidential - 6
Contents
● The GNU/Linux System
● System Overview
● System Design
● Cross Compilation Toolchain
● The Linux Boot Process
● Boot Loaders
● The Linux Kernel
● File Systems
● Userspace
12/07/13 - Marc Leeman
Company Confidential - 7
The GNU/Linux System
12/07/13 - Marc Leeman
Company Confidential - 8
● Computer operating system and its
kernel -> GNU/Linux, GNU+Linux, ...
● The GNU Project (1983)
● Hurd kernel 1990
● Linux kernel: 1991
● Estimated cost typical linux distribution is
10.8 billion; the kernel alone an extra 1.4
billion (2008, Fedora 9)
● All the underlying source code is
available
Linux
12/07/13 - Marc Leeman
Company Confidential - 9
Applications
● LAMP
● Linux, Apache, MySQL, Perl/PHP/Python
● Gaming (PS3)
● Embedded
● Set top boxes, mobile phones, routers &
switches, dreambox, TiVo, …
● Handhelds
● Supercomputers
● 34 fastest running Linux, 92% of top 500
12/07/13 - Marc Leeman
Company Confidential - 10
Linux & Super computing
12/07/13 - Marc Leeman
Company Confidential - 11
Usability
● KDE/Gnome
● Office, Calenders, ...
● plethora of programs/utilities
● Eye candy: 3D Desktop accelleration
● usability in par with commercial OSes.
12/07/13 - Marc Leeman
Company Confidential - 12
Installation
● Easy installation
● Powerful development environment
● Wide architecture support
● Live-CDs, Dual Boot, ...
12/07/13 - Marc Leeman
Company Confidential - 13
System Overview
12/07/13 - Marc Leeman
Company Confidential - 14
System on Chip
● Hardware varies a lot
● Linux kernel and OS abstracts HW from software
● CPU
● PowerPC (was?) popular in Barco
● ARM seems to be picking up
● Focus on ARM, but techniques can be applied
to other archs.
● X86 systems
12/07/13 - Marc Leeman
Company Confidential - 15
System on Chip
● RAM
● Storage
● Used to be typically NOR flash, sometimes
NAND
● Currently NAND due to cost (eMMC)
● I/O
● Lot of variation
● Serial and Ethernet
12/07/13 - Marc Leeman
Company Confidential - 16
Embedded Linux Components
● Bootloader
● Linux kernel
● 1 (or more) file systems with userspace
● Kernel sometimes inside rootfs as well
12/07/13 - Marc Leeman
Company Confidential - 17
Layering
● Boot loader only active during powerup
● Only kernel talks to hardware
● Same for ALL Linux systems
12/07/13 - Marc Leeman
Company Confidential - 18
System Design
12/07/13 - Marc Leeman
Company Confidential - 19
Considerations
● Redundancy
● Hardware (network interfaces)
● Software (factory/upgrade)
● Configuration (redundant flash with CRC)
● Predictability
● Uncertainty => fall back to factory settings
● Stability
● Linux :-)
● Monitoring
● Quis custodiet ipsos custodes
12/07/13 - Marc Leeman
Company Confidential - 20
Basic choice
● Small and minimalistic
● Focus on minimal footprint
● Reduce component cost (large volumes)
● Minimal functionality
● Often one indivisible deliverable
● Platform approach
● Focus on software design
● Reduce software development cost (a lot of
low volume platforms)
● Pluggable functionality
● Easy functionality extension and system
configuration.
● Trend seems is to focus on software
12/07/13 - Marc Leeman
Company Confidential - 21
Small is Beautiful
Speed increase RAM reduction Power reduction Cost reduction
More speed ­ CPU can run slower or stay
longer in power saving mode
­ Slower, cheaper
CPU
Less RAM ­ Faster allocations
­ Less swapping
­ Sometimes less
cache flushing
­ Fewer / smaller RAM chips:
less dynamic and standby
power.
­ CPU with less cache: less power
­ Fewer / cheaper
RAM chips
­ CPU with less
cache: cheaper
Less space ­ Faster application
loading from
storage and in
RAM.
­ Sometimes,
simpler, faster
code.
­ Less RAM usage ­ Fewer / smaller storage chips:
less power
­ Fewer / cheaper
storage
Less power ­ Cheaper batteries
­ or cheaper
AC/DC converter
●No black and white choice
●Storage is cheap
●Small does have a cost:
● Focus on software that adds value
12/07/13 - Marc Leeman
Company Confidential - 22
Components
● File systems
● Rw: Jffs2, ubifs
● Ro: cramfs, squashfs
● Ext2, FAT
● Glibc or uclibc
● Glibc: localisation (l10n), internationalisation support
(I18n), threading
● Uclibc: replace (configurable) parts of libc allows
optimisation for size
● Scales up to 33% wrt original libc reference
● System utils or busybox
● all-in-one, GNU utils optimised for size
12/07/13 - Marc Leeman
Company Confidential - 23
The bootloader
● Das U-Boot
● Extracts kernel image to RAM and sets
Program Counter
● But is much more!
● executes scripts
● can get kernel over network
● can be used to upgrade the flash sections
● debugging over network
● ...
12/07/13 - Marc Leeman
Company Confidential - 24
The Linux Kernel
● Basic hardware detection and
initialisation
● In the kernel image is needed:
● minimal configuration to allow recognition of root
FS
● hardware access for root partition
● SCSI, IDE, LIBATA, FLASH, MAC/PHY, ...
● File system
● ext2, ext3, jfs, ubifs, xfs, nfs, reiserfs, ...
● What is not needed:
● Firewall (iptables), keyboard, mouse, ...
(peripherals)
● Can be postponed to the final stages of booting
● Good Practice
● only include needed functionality
12/07/13 - Marc Leeman
Company Confidential - 25
Static or Dynamic Linking (1)
Static linking
● All shared library code duplicated in the
executables
● Allows not to copy the C library in the file
system.
Simpler and smaller when very few
executables (busybox)
● Library code duplication: bad for systems with
more executables (code size and RAM)
Best for small systems (< 1-2 MB) with few
executables!
Not used that much anymore
12/07/13 - Marc Leeman
Company Confidential - 26
Static or Dynamic Linking (2)
Dynamic linking
● Shared library code not duplicated in
the executables
● Makes much smaller executables
● Saves space in RAM (bigger executable
take more RAM)
● Requires the library to the copied to the
file system
Best for medium to big systems (> 500 KB
- 1 MB)
12/07/13 - Marc Leeman
Company Confidential - 27
Libc
● glibc (GNU C library):
http://www.gnu.org/software/libc/
Found on most computer type GNU/Linux machines
Size on arm: approx 1.7 MB
● uClibc: http://www.uclibc.org/
Found in more and more embedded Linux systems!
Size on arm: approx 400 KB (you save 1.2 MB!)
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
12/07/13 - Marc Leeman
Company Confidential - 28
Stripping
● Compiled executables contain extra information which
can be used to investigate problems in a debugger.
● This was useful for the tool developer, but not for the
final user.
● To remove debugging information, use the strip
command.
This can save a very significant amount of space!
gcc ­o hello hello.c (output size: 4635 bytes)
strip hello (output size: 2852 bytes, -38.5%)
12/07/13 - Marc Leeman
Company Confidential - 29
Setting up our Cross
Compilation Toolchain
12/07/13 - Marc Leeman
Company Confidential - 30
Terminology
● build platform: where the code is
compiled
● host platform: where the compiled code
will be executed
● target platform: for compilers,
represents what type of object code the
package itself will produce
● preferred compiler for code that runs on
different archs
12/07/13 - Marc Leeman
Company Confidential - 31
Terminology (2)
● gcc: GNU Compiler Collection
● 1987...
● glibc: GNU C standard library
● Unix98, POSIX, C99, +extensions
● x86, m68k, Alpha, PPC, ARM, CRIS, MIPS,
s390, SPARC
● Linux +Hurd kernels, also FreeBSD and
NetBSD
● glibc 2 = libc6; (older glibc -> libc5)
● uclibc
● cf. Supra
12/07/13 - Marc Leeman
Company Confidential - 32
Top Down Approach
Top-down approach to building an embedded system
● Starting from a complete desktop GNU/Linux
distribution (Debian, Fedora...) and removing
unneeded stuff.
● Very tedious job: need to go through a huge number
of files and packages. Need to understand what each
file and package is about before removing it.
● Keeping unnecessarily complex scripts and
configuration files.
● The end result is still quite big, as standard desktop
tool sets and libraries are used. Lots of shared
libraries still needed too.
12/07/13 - Marc Leeman
Company Confidential - 33
Bottom Up Approach
Bottom-up approach to building embedded systems
● Starting with an empty or minimalistic root file
system, adding only things that you need.
● Much easier to do! You just spend time on things you
need.
● Much easier to control and maintain: you build an
understanding about the tools you use.
● You only need very simple configuration scripts.
● The end result can be extremely small, all the more
as you use lightweight tool sets instead.
12/07/13 - Marc Leeman
Company Confidential - 34
Toolchain
● gcc:
● cross-compiling: compile for a target
configuration other than the build host.
● $(arch)-$(os){-$(lib)}-gcc
● powerpc-linux-uclibc-gcc,
arm-linux-newlib-gcc
● typical gcc toolchain links against libc
● When uclibc is used, a compiler is needed
that matches that exact uclibc configuration
● automated with buildroot
12/07/13 - Marc Leeman
Company Confidential - 35
Toolchain selection
● Depends on your environment
● Native build (x86, emulation, arm, ...)
● Cross compilation build
● Glibc cross compilations toolchains are often
available
● Native complation toolchains are ALWAYS
available (e.g. qemu)
● With uClibc, a exactly matched toolchain is
required
12/07/13 - Marc Leeman
Company Confidential - 36
Native and emulation
● The target hardware is very performant
● Target instruction set is emulated
● Both use a 'native' compiler
● Typical easier to use for complex
software environments
12/07/13 - Marc Leeman
Company Confidential - 37
Buildroot
● Classic cross compilation
● Set of Makefiles and patches
● Generates:
● cross-compilation toolchain
● gcc, binutils, gdb, ...
● (root filesystem for target, kernel,
bootloader, ..)
12/07/13 - Marc Leeman
Company Confidential - 38
Buildroot configuration
● Kconfig interface
● make menuconfig
● Select compiler, binutils and gdb
version.
● http://buildroot.net
12/07/13 - Marc Leeman
Company Confidential - 39
Exercise
● Retrieve buildroot 2012.08 from
● http://www.buildroot.org/download.html
● $ make sheevaplug_defconfig
● $ make
●
● Note: you will need to set your http_proxy environment variable
to http://neo.barco.com:3128/ and/or use
http://sleipner.barco.com/downloads/ as primary download site
(Build Options → Mirrors and Download locations)
12/07/13 - Marc Leeman
Company Confidential - 40
The Linux Boot Process
12/07/13 - Marc Leeman
Company Confidential - 41
High Level View
12/07/13 - Marc Leeman
Company Confidential - 42
System startup
● CPU executes code at a predefined
address (e.g. CS0, address 0x100)
● for a PC: BIOS in flash on motherboard
● embedded e.g. U-Boot, Redboot or similar
● PC:
● if valid boot device is found, the 1st
stage
bootloader is loaded
12/07/13 - Marc Leeman
Company Confidential - 43
Stage 1 Bootloader (x86)
● <512 bytes, fits in 1 sector
● binary itself < 446 bytes
● 64 byte partition table
● 2 byte signature
● loaded from MBR boot device
● Task is to load second stage bootloader
12/07/13 - Marc Leeman
Company Confidential - 44
Boot device signature
12/07/13 - Marc Leeman
Company Confidential - 45
Stage 2 bootloader
● LILO/GRUB
● load and select kernel
● optionally selects initrd
● pass control to the kernel
12/07/13 - Marc Leeman
Company Confidential - 46
Kernel
● zImage (zlib, lzo or lzma compressed)
● without initrd, kernel should contain just
the functionality to detect & mount root
filesystem
12/07/13 - Marc Leeman
Company Confidential - 47
Kernel startup
12/07/13 - Marc Leeman
Company Confidential - 48
kernel startup (2)
● Assembly, arch specific
● head.S
● hardware initialisation and setup basic
environment
● decompress kernel in memory
● Uncompressing Linux... Ok, booting the kernel
● startup_32:
● initialise page tables and enable memory
paging
● CPU detection
12/07/13 - Marc Leeman
Company Confidential - 49
kernel startup (3)
● C, non arch specific
● start_kernel in init/main.c
● init interrupts
● (init ramdisk)
● initial root fs in memory/detect hardware
● embedded: can be final root filesystem
● memory initialisation
● thread_kernel starts /sbin/init
● first user-level application
● Can be modified to another application
12/07/13 - Marc Leeman
Company Confidential - 50
init
● First user-level application
● compiled/linked with libc
● uses /etc/inittab
● Spawn services
● sshd, apache, ...
● /bin/sh can also be used to start a
single shell instead of init
12/07/13 - Marc Leeman
Company Confidential - 51
Runlevels (sysv)
● startup behaviour of init is divided in
“runlevels”
● 0: Halt
● 1: Single User Mode
● 2: Basic Multi-User mode without NFS
● 3: Full Multi-User mode
● 4: Not used
● 5: Full Multi User Mode with X11 Login
● 6: Reboot
● Not so fixed, some distros use fewer
levels (e.g. Slackware, Debian, ...)
12/07/13 - Marc Leeman
Company Confidential - 52
init scripts
● Most start scripts can be found in
● /etc/init.d/
● /etc/rcX.d contains symbolic links to the
scripts
● X: 1,2,3,4,5,6,S
● K20autofs
● S: start
● K: stop
● number for ordering: e.g. start network
daemons after network devices.
12/07/13 - Marc Leeman
Company Confidential - 53
inittab entry
● 1:2345:respawn/sbin/getty 38400 tty1
● id
● runlevels
● action
● process to be executed
● id:3:initdefault:
● default runlevel
● /etc/init.d/networking
● {start|stop|restart|force-reload}
12/07/13 - Marc Leeman
Company Confidential - 54
Boot Loaders
12/07/13 - Marc Leeman
Company Confidential - 55
Overview
● First thing to run after power on
● Tasks:
● Initialize (some of) hardware
● Load a kernel
● Execute it
● Boot loaders often have extra
functionality:
● Access memory and registers
● Program flash
● ..
12/07/13 - Marc Leeman
Company Confidential - 56
Boot Loaders
● Lots of Linux compatible boot loaders
● LILO & GRUB well known
● PC specific
● Often platform specific
● Portable:
● RedBoot
● Das U-Boot
12/07/13 - Marc Leeman
Company Confidential - 57
Das U-Boot
● The universal boot loader
● Probably most feature full, flexible and
most actively developed boot loader
● Very much focused on Linux
● Started as PPCBoot, but now portable
● Licensed under the GPL
● Has a alternative implementation
barebox (u-boot-v2).
12/07/13 - Marc Leeman
Company Confidential - 58
U-Boot Features
● Flash support
● NOR, NAND, Dataflash, ..
● Compression
● GZIP, BZIP2
● Interactive command line interface
● Boot scripting
● TCP/IP stack with BOOTP and DHCP,
TFTP and NFS
● LOTS of drivers:
● Often ported from Linux
● IDE, SCSI, MMC, PCMCIA, USB, LCD, I2C,
SPI, ..
12/07/13 - Marc Leeman
Company Confidential - 59
U-Boot Features (2)
● x86 emulation
● Graphics card POST on non-x86
● File Systems
● JFFS2, Cramfs, squashfs EXT2, FAT,
Reiserfs, ..
● Boot splash images
● FPGA configuration
● ...
12/07/13 - Marc Leeman
Company Confidential - 60
Exercise
● Bootup SheevaPlug in U-Boot and
explore commands (type help) and
environment variables (type printenv)
12/07/13 - Marc Leeman
Company Confidential - 61
U-Boot operation
● Once a working U-Boot (flash) is installed,
upgrading can be done with
serial/tftp/u-boot
tftp 100000 /home/services/tftpboot/u-boot.bin
protect off fe000000 fe03ffff
era fe000000 fe03ffff
cp.b 100000 fe000000 ${filesize}
protect on fe000000 fe03ffff
● scripting helps :-)
run burnfact
12/07/13 - Marc Leeman
Company Confidential - 62
Exercise
● Download u-boot 2010.06 and build for
SheevaPlug. Update through JTAG or
TFTP
● Check section 4.6 in manual
● Needed .deb's at
http//neo.barco.com/~mleeman/downloads/SheevaPlugCourse
12/07/13 - Marc Leeman
Company Confidential - 63
The Linux Kernel
12/07/13 - Marc Leeman
Company Confidential - 64
History
● 1991: post in comp.os.minix
● Linux 0.1
● 1994: Linux 1.0.0
● 1996: Linux 2.0.0
● 1999: Linux 2.2.0
● 2001: Linux 2.4.0
● 2003: Linux 2.6.0
● 2011: Linux 3.0
● 2012: Linux 3.5
12/07/13 - Marc Leeman
Company Confidential - 65
Architecture
● monolithic kernel
● drivers run in ring 0
● X11 is in userspace
● contrary to Windows
● Supports
● preemption
● virtual memory
● memory management
● threading
● TCP/IP
● ...
● Mostly in C (97%), 3% ASM
12/07/13 - Marc Leeman
Company Confidential - 66
Modules
● kernel code that can access hardware
directly
● modules can be loaded/unloaded and
re-configured at run-time
● e.g.
sudo modprobe xfs
lsmod
sudo insmod /path/to/xfs.ko
sudo modprobe module param=1
● Also in configuration file
/etc/modprobe.d/module.conf
12/07/13 - Marc Leeman
Company Confidential - 67
Source Tree
● BIG! (~525 MB, 10M lines)
● A lot is drivers
● Core kernel ~5MB
12/07/13 - Marc Leeman
Company Confidential - 68
Source Tree (2)
Kernel 2.6.36
● 216M drivers
● 114M arch
● 32M fs
● 21M sound
● 19M include
● 19M net
● 17M Documentation
● 4.6M kernel
● 2.2M scripts
● 2.2M mm
● 1.7M crypto
● 1.4M lib
● 1.4M security
● 544K block
● 244K ipc
● 144K init
● 108K samples
● 56K usr
12/07/13 - Marc Leeman
Company Confidential - 69
Architecture Specific code
● arch/<cpu>
● arch/<cpu>/include/asm
● A few MB per arch
● Depending on no. supported boards
12/07/13 - Marc Leeman
Company Confidential - 70
Release Schedule
● New release every 2-3 months
● 2.6.39 19/05/2011
● 3.0 22/07/2011
● 3.1 24/10/2011
● 3.2 05/01/2012
● 3.3 22/03/2012
● 3.4 21/05/2012
● 3.5 21/07/2012
● 3.6 01/10/2012
● 3.7 11/12/2012
● 3.8 19/02/2013
● 3.9 29/04/2013
● 3.10 30/06/2013
12/07/13 - Marc Leeman
Company Confidential - 71
Release Schedule (2)
● Tree is open for 2 weeks after release
● LOTS of activity – rc1 diff ~1M lines
● After that only bugfixes
● New -rcX release every 1-2 weeks
● 3.x.y stable releases for serious bugs
found after release
12/07/13 - Marc Leeman
Company Confidential - 72
Tracking Development
● Linux kernel mailing list (2-300 mails/day)
● lwn.net Kernel - http://lwn.net/Kernel
● http://www.kernelnewbies.org/LinuxChan
ges
● kernel.org gitweb:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=summary
12/07/13 - Marc Leeman
Company Confidential - 73
Device Tree
● Introduced in the PowerPC processor
ports, moving to other archs (ARM,
Microblaze)
● The Device Tree describes the
hardware to the kernel
● Includes e.g. Flash map, PCI
addresses, MAC addresses, ...
● U-Boot has support for modifying the
dts/dtb
12/07/13 - Marc Leeman
Company Confidential - 74
User Space Interface
● Basically 3 types of interfaces:
● Character Devices
● Block Devices
● Network Devices
● (procfs, sysfs, netlink)
● Rarely needs to be implemented
directly
● Kernel provides frameworks
12/07/13 - Marc Leeman
Company Confidential - 75
Character Devices
● Most common type
● Anything that can be viewed as a stream of
bytes (serial ports, input devices,
framebuffers, sound devices, ..)
● Accessed like normal files
● open/close/read/write/lseek/..
● Additional settings through ioctl
● Added in kernel by
● Registering a cdev and implement
file_operations
12/07/13 - Marc Leeman
Company Confidential - 76
Block Devices
● For Storage Devices
● Harddisks, MMC, USB keys, ..
● Accessed like Character Devices
● Kernel Interface More Complicated
● Added in kernel by
● Registering a gendisk and implement
block_device_operations
12/07/13 - Marc Leeman
Company Confidential - 77
Network Devices
● For Network Devices
● Ethernet, Wireless, PPP, ..
● Accessed using socket API
● socket/accept/listen/recv/send/..
● Configuration typically through
programs/scripts
● ip/ifconfig/vconfig/ethtool/..
● Added in kernel by
● Registering a net_device and implement
net_device_ops
12/07/13 - Marc Leeman
Company Confidential - 78
Hardware Access
● Memory mapped registers
● Linux uses virtual memory (MMU)
● ioremap(physical address)
logical
● read{b,w,l}(logical)
● write{b,w,l}(value, logical)
● iounmap(logical)
12/07/13 - Marc Leeman
Company Confidential - 79
Device Model
● Object Oriented, Tree Structured
● Busses (struct bus_type)
● Devices (struct device)
● Drivers (struct driver)
● Visible in sysfs
● Take a look on your PC!
● Saves code, Tree hierarchy important
for E.G. power management
12/07/13 - Marc Leeman
Company Confidential - 80
Busses
● Devices connect to CPU through
busses
● USB, PCI, I2C, SPI, Platform, ..
● Each corresponds to a specific bus_type
● Bus-specific interface for drivers
● Tree Based
● E.G. a USB controller on a PCI bus
12/07/13 - Marc Leeman
Company Confidential - 81
Devices and Drivers
● Object Oriented
● Drivers (Classes)
● Devices (Instances)
● Common interface
● Probe (Constructor)
● Remove (Destructor)
● Bus connects (binds) both together
12/07/13 - Marc Leeman
Company Confidential - 82
Platform Bus
● “Dummy” bus for simple memory
mapped devices on SoCs
● Plug-n-play binding emulated through
string matching (driver/device name
member)
12/07/13 - Marc Leeman
Company Confidential - 83
Platform Bus Binding
struct platform_device {
const char * name;
…
};
struct platform_driver {
struct device_driver driver {
const char *name;
};
...
};
● Platform_device in platform code
● Platform_driver in device driver
12/07/13 - Marc Leeman
Company Confidential - 84
Resources
static struct resource smc911x_resources[] = {
[0] = {
.start = 0x8e000000,
.end = 0x8e0000ff,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = 4,
.end = 4,
.flags = IORESOURCE_IRQ,
},
};
● Generic way of providing platform
details such as base address and IRQ:
●Platform data pointer for special stuff
12/07/13 - Marc Leeman
Company Confidential - 85
PCI Bus
● Device/Driver binding using PCI
Vendor/Product ID (PnP)
● lspci
● USB is very similar
00:1f.3 SMBus: Intel Corporation N10/ICH 7 Family SMBus Controller (rev 02)
01:00.0 Ethernet controller: Marvell Technology Group Ltd. 88E8053 PCI-E
Gigabit Ethernet Controller (rev 22)
02:00.0 Network controller: Atheros Communications Inc. AR5008 Wireless
Network Adapter (rev 01)
03:03.0 FireWire (IEEE 1394): Agere Systems FW322/323 (rev 61)
..
12/07/13 - Marc Leeman
Company Confidential - 86
Character Interface
● Make communication available to
userspace via device files
# ls -l /dev |grep dsp
crw-rw-rw- 1 0 0 252, 4 Jul 20 2006 dspa
crw-r----- 1 0 0 252, 0 Jul 20 2006 dspa0
crw-r----- 1 0 0 252, 1 Jul 20 2006 dspa1
crw-r----- 1 0 0 252, 2 Jul 20 2006 dspa2
crw-r----- 1 0 0 252, 3 Jul 20 2006 dspa3
# ls -l /dev |grep fpga
crw-r----- 1 0 0 253, 0 Jul 20 2006 fpgaa
crw-r----- 1 0 0 251, 0 Jul 20 2006 nwwfpgaa
12/07/13 - Marc Leeman
Company Confidential - 87
read/write
● read/write on file handles
● copy data from the kernel to application
code
● copy_to_user(...)
● copy data from application code to the
kernel
● copy_from_user(...)
● If user reads
● kernel writes from userspace
● If user writes
● kernel reads from userspace
12/07/13 - Marc Leeman
Company Confidential - 88
Device Files
● ioctl is often used in code to send
commands and data to the kernel/device
● For register access, read/write/lseek is
better.
● bad example:
static inline uint32_t ppc2dsp_getregister(const DSP
*dsphandle,uint32_t address){
TSBarcoMemEntry entry;
entry.addr = address;
ioctl(*dsphandle,PPC2DSP_GET_REG,&entry);
return entry.value;
}
dsp = open ("/dev/dspa", O_RDWR);
12/07/13 - Marc Leeman
Company Confidential - 89
ioctl
● fine tuned and often specialised
hardware control
● allows to pass arbitrary data from user
to kernel and vice versa
● int(*ioctl)(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
● switch(cmd)
● number 0..N cmd X-(
12/07/13 - Marc Leeman
Company Confidential - 90
Interrupts
● Kernel needs to act on a “hardware
event”
● polling?
● slow and CPU intensive!
● An interrupt is a signal that the
hardware can send when it wants the
processor's attention.
12/07/13 - Marc Leeman
Company Confidential - 91
Flash Map
● Add partitions to the flash
● different functionality
● select between
● kernels
● root filesystems
● redundant configuration spaces
● file systems (jffs2, squashfs, ...)
● Create one logical area from multiple
flash chips
12/07/13 - Marc Leeman
Company Confidential - 92
LED Class
● Kernel already has a framework for this
● See:
● drivers/leds
● Documentation/leds-class.txt
● /sys/class/leds
● gpio_led driver makes this very easy
● Various led-triggers can be hooked up
12/07/13 - Marc Leeman
Company Confidential - 93
File Systems
12/07/13 - Marc Leeman
Company Confidential - 94
Introduction
● More than 50 file systems supported
● More than any other OS
● What to choose?
12/07/13 - Marc Leeman
Company Confidential - 95
File System Types
● Disk based
● Flash based
● Network file systems
● “Virtual” file systems
12/07/13 - Marc Leeman
Company Confidential - 96
Disk Based
● Biggest group
● Native
● Supports all POSIX features
● EXT2/3/4, Reiserfs3/4, XFS, JFS, Btrfs, ..
● Recommended
● Compatibility
● Might not support all POSIX features
● Less performance
● FAT, NTFS, HPFS, BEFS, AFFS, ISO9660,
UDF, ..
12/07/13 - Marc Leeman
Company Confidential - 97
Disk Based (2)
● Disks are not common in embedded
systems
● PC-Like
● Flash with disk interface (USB, CF, MMC,..)
● Limit writes for flash!
● No journalling file systems
● noatime mount option
● EXT2 or FAT
12/07/13 - Marc Leeman
Company Confidential - 98
Flash Based
● Disk based can be used
● Kernel MTD layer can emulate block device
● Only realistic for read only
● Optimized for flash
● Cramfs (old)
● Squashfs
● Journalling file system 2 (JFFS2) (old)
● UBIFS
12/07/13 - Marc Leeman
Company Confidential - 99
Cramfs / Squashfs
● Read only
● Compression
● Squashfs finally in mainline
● Squashfs newer
● More features, better compression, faster
● Can also be used on disks
● Often combined with RAM disk for /tmp
● OpenWRT uses squashfs-lmza
● Squashfs + better compression
● Complex to implement: lmza non standard
12/07/13 - Marc Leeman
Company Confidential - 100
JFFS2
● Read/write
● Compression, but less effective
● Journalling, so no fsck
● Long mount time on big partitions
● Complex
● Consider raw flash partition or
EEPROM if data limited
12/07/13 - Marc Leeman
Company Confidential - 101
UBIFS
● Similar to JFFS2 but newer
● Uses UBI (Unsorted Block Images)
● More Scalable, faster mount time
● Better fit for (big) NAND flash
12/07/13 - Marc Leeman
Company Confidential - 102
Network File Systems
● NFS, SMBFS/CIFS
● AFS, CODA, 9FS, ..
● Not commonly used in production
● NFS very handy for development
● Kernel can boot on NFS
● NFS supports normal POSIX features
12/07/13 - Marc Leeman
Company Confidential - 103
“Virtual” File Systems
● No underlying media to store data
● Sysfs, procfs: Interface to kernel
● TMPFS: Dynamic RAM disks
● Devtmpfs: Dynamic /dev
12/07/13 - Marc Leeman
Company Confidential - 104
Conclusion
● Lots to choose from
● Most systems use more than one
12/07/13 - Marc Leeman
Company Confidential - 105
Userspace
12/07/13 - Marc Leeman
Company Confidential - 106
busybox
http://www.busybox.net/
● Most Unix command line utilities within a
single executable!
● includes a web server!
● Sizes less than 1 MB (statically compiled
with glibc)
less than 500 KB (statically compiled with
uClibc)
● Easy to configure
● The best choice for
● Initrds with complex scripts
12/07/13 - Marc Leeman
Company Confidential - 107
busybox
● combine unix utilities in one single small
executable
● share startup code
● configurable commands
● configurable functionality of the
commands
● applets easy to add
12/07/13 - Marc Leeman
Company Confidential - 108
● Best way to describe:
root@OpenWrt:~# busybox
BusyBox v1.4.2 (2007-09-29 07:21:40 CEST) multi-call binary
Copyright (C) 1998-2006 Erik Andersen, Rob Landley, and others.
Licensed under GPLv2. See source distribution for full notice.
Usage: busybox [function] [arguments]...
or: [function] [arguments]...
BusyBox is a multi-call binary that combines many common Unix
utilities into a single executable. Most people will create a
link to busybox for each function they wish to use and BusyBox
will act like whatever it was invoked as!
Currently defined functions:
[, [[, arping, ash, awk, awx, basename, bunzip2, bzcat, cat, chgrp, chmod, chown, chroot,
clear,
cp, crond, crontab, cut, date, dd, df, dirname, dmesg, du, echo, egrep, env, expr, false,
fgrep,
find, free, grep, gunzip, gzip, halt, head, hexdump, hostid, httpd, id, ifconfig, init,
insmod,
ipkg, kill, killall, killall5, klogd, length, less, ln, lock, logger, logread, ls, lsmod,
md5sum,
mesg, mkdir, mkfifo, mknod, mktemp, mount, mv, nc, netmsg, netstat, nslookup, passwd, pidof,
ping, ping6, pivot_root, poweroff, printf, ps, pwd, rdate, reboot, reset, rm, rmdir, rmmod,
route, sed, seq, sh, sleep, sort, strings, switch_root, sync, sysctl, syslogd, tail, tar,
tee,
telnet, telnetd, test, time, top, touch, tr, traceroute, true, udhcpc, umount, uname, uniq,
uptime, vconfig, vi, watchdog, wc, wget, which, xargs, yes, zcat
12/07/13 - Marc Leeman
Company Confidential - 109
Configuration
● Again, Kconfig based
12/07/13 - Marc Leeman
Company Confidential - 110
CGI
`
12/07/13 - Marc Leeman
Company Confidential - 111
dropbear
● replaces telnetd
● obsolete since mid '90s
● secure communication
● no need for
● telnetd, ftpd, samba, ...
● tunnelling :-)
● Typical W32 clients
● PuTTy, WinSSH
● jcterm, mindterm
● GNU/Linux
● default
12/07/13 - Marc Leeman
Company Confidential - 112
Buildroot
● Not just for toolchains
● Can build entire Linux systems
● Make files, downloads over net
● No root permissions required
● Used in D&A and Medical
● Used in several Open Source projects:
● OpenWrt, Gumstix, ...
12/07/13 - Marc Leeman
Company Confidential - 113
Full blown Distributions
● Interesting option
● If disk(-like) storage available
● Little difference between SoC target and
desktop/server
● Functionality is can easily be expanded
● Debugging tools
● Verification
● GNU/Debian supports 11 archs
● Lots of precompiled packages
● ~20.000
● No need to cross compile
12/07/13 - Marc Leeman
Company Confidential - 114
First stage bootstrap
● Nice for development together with NFS
● Debootstrap –verbose –variant=minbase 
–keyring=/home/me/pubring.gpg –include=apt 
–arch=armhf –foreign vclub /home/me/chroot­2013 
ftp://cypher.barco.com/nvslinux 
/usr/share/debootstrap/scripts/wheezy
● Result is a armhf target on an x86-64
machine
● Installation requires a 'second-stage'
installation
● Does not run natively (<==> x86 (i386))
12/07/13 - Marc Leeman
Company Confidential - 115
Second Stage bootstrap
● Qemu is needed
● QEMU can launch Linux processes compiled for one CPU on
another CPU
● Fully system emulation
● Copy /usr/bin/qemu-static into
$TARGET/usr/bin/qemu-static
● Why 'static'?
● Debootstrap /home/me/chroot­2013/ 
/debootstrap/debootstrap –second­stage
12/07/13 - Marc Leeman
Company Confidential - 116
Qemu
● Spot the difference
● marc@drd1812:~/Development$ uname ­a
● Linux drd1812 3.9.4 #1 SMP PREEMPT Thu May 30 12:53:13 CEST 2013 x86_64 GNU/Linux
● marc@drd1812:~/Development$ sudo chroot dolphin­dev­env­2013­03­11/
● root@drd1812:/ dolphin­dev$ uname ­a
● Linux drd1812 3.9.4 #1 SMP PREEMPT Thu May 30 12:53:13 CEST 2013 armv7l GNU/Linux
12/07/13 - Marc Leeman
Company Confidential - 117
Packages
● a “package” refers to a compressed file
archive containing all of the files that
come with a particular application.
● Typical binary in nature
● Can install new functionality
● Can expand current functionality
● Can modify existing functionality
● Most common forms
● Debian package: file.deb
● Debian, Ubuntu, ...
● Redhat package: file.rpm
● Redhat, SuSE, Fedora, …
12/07/13 - Marc Leeman
Company Confidential - 118
Packages
● Selective upgrade
● Once deployed, typical bugfixes, security
fixes
12/07/13 - Marc Leeman
Company Confidential - 119
Packages 101
● Concept of a 'repo'
● Can be networked, on disk, on CD, USB, …
● deb
● deb­src
● Can be networked, on disk, on CD, USB, …
● In /etc/apt/sources.list.d/file.list
● deb ftp://cypher.barco.com/nvslinux/ vclub 
main contrib non­free
● File, cdrom, http, ftp, copy, rsh, ssh, …
● Lots of command line, console and GUI
front-ends
12/07/13 - Marc Leeman
Company Confidential - 120
Packages 101
● Update the package descriptions
● $ sudo apt­get update
● Install a single package
● $ sudo dpkg barco­mna240_123­1.deb
● Install a single package with
dependencies from the network
● $ sudo apt­get install barco­mna240
● $ sudo apt­get remove barco­mna280
● $ sudo apt­get purge barco­mna280
● Upgrade the system without installing
extra packages
● $ sudo apt­get upgrade
12/07/13 - Marc Leeman
Company Confidential - 121
Packages 101
● Upgrade the system
● $ sudo apt­get dist­upgrade
● Search the package descriptions
● $ sudo apt­get search barco
● Show detailed package description
● $ sudo apt­get show barco­c12
● Housekeeping
● Clear package cache
● $ sudo apt­get cache clear
● Remove unused packages
● $ sudo apt­get autoremove
12/07/13 - Marc Leeman
Company Confidential - 122
Privilege separation
● Services run as a separate
(unprivileged) user: e.g. webserver, ftp,
ssh, …
● Security concerns
12/07/13 - Marc Leeman
Company Confidential - 123
Setting up a Server
12/07/13 - Marc Leeman
Company Confidential - 124
General
● Platform of choice: GNU/Debian
● the developers' platform
● powerful, handy package management
● Check with IT:
● we will need DHCP (conflicts with corporate)
● Alternate: 2 network cards, external (Barco),
internal (my.net.local).
12/07/13 - Marc Leeman
Company Confidential - 125
Needed & (Useful)
● NFS
● mount root filesystem without re-burning it
to flash: much faster
● use larger filesystem than can be stored on
flash for development
● DHCP/BOOTP
● cf. supra
● kernel send BOOTP package to get
kernel/filesystem location over the network
12/07/13 - Marc Leeman
Company Confidential - 126
Needed & (Useful)
● atftpd
● Trivial ftp protocol
● used by U-Boot to obtain files over the
network
● used by BDI2000 to get files over the
network
● (bind)
● DNS server
● e.g. bdi02.smd.localnet is handier than 10.2.0.17
12/07/13 - Marc Leeman
Company Confidential - 127
Needed & (Useful)
● SSH
● Secure Shell
ssh-keygen -t dsa -b 4096
scp ~/.ssh/id_dsa.pub me@remote:
ssh me@remote 'mkdir -p ~/.ssh'
ssh me@remote 'cat id_dsa.pub > ~/.ssh/authorized_keys'
● (Samba)
● Windows Share access
● (LDAP)
● Centralised account and rights and service
management
● sudo & fakeroot
● selective super user root rights assignment
12/07/13 - Marc Leeman
Company Confidential - 128
Conclusions
● improvements to upstream sources
● communicate upstream
● e.g. Das U-Boot
● e.g. buildroot
● Kernel changes
● minimise them ASAP
● reduces maintenance to a minimum
● focus on the important code
● Montavista, MetroWerx
12/07/13 - Marc Leeman
Company Confidential - 129
References
● Update version of the examples, course text and slides:
● http://neo.barco.com/~mleeman/embedded_linux/
● D&A info:
● http://ccwiki/EmbeddedLinuxTraining

Más contenido relacionado

La actualidad más candente

Linux Kernel Startup Code In Embedded Linux
Linux    Kernel    Startup  Code In  Embedded  LinuxLinux    Kernel    Startup  Code In  Embedded  Linux
Linux Kernel Startup Code In Embedded LinuxEmanuele Bonanni
 
U boot porting guide for SoC
U boot porting guide for SoCU boot porting guide for SoC
U boot porting guide for SoCMacpaul Lin
 
Embedded_Linux_Booting
Embedded_Linux_BootingEmbedded_Linux_Booting
Embedded_Linux_BootingRashila Rr
 
Kernel Recipes 2015: Representing device-tree peripherals in ACPI
Kernel Recipes 2015: Representing device-tree peripherals in ACPIKernel Recipes 2015: Representing device-tree peripherals in ACPI
Kernel Recipes 2015: Representing device-tree peripherals in ACPIAnne Nicolas
 
Understanding a kernel oops and a kernel panic
Understanding a kernel oops and a kernel panicUnderstanding a kernel oops and a kernel panic
Understanding a kernel oops and a kernel panicJoseph Lu
 
Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBshimosawa
 
linux device driver
linux device driverlinux device driver
linux device driverRahul Batra
 
Uboot startup sequence
Uboot startup sequenceUboot startup sequence
Uboot startup sequenceHoucheng Lin
 
Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)RuggedBoardGroup
 
Building Embedded Linux Systems Introduction
Building Embedded Linux Systems IntroductionBuilding Embedded Linux Systems Introduction
Building Embedded Linux Systems IntroductionSherif Mousa
 
U Boot or Universal Bootloader
U Boot or Universal BootloaderU Boot or Universal Bootloader
U Boot or Universal BootloaderSatpal Parmar
 

La actualidad más candente (20)

Embedded Linux Kernel - Build your custom kernel
Embedded Linux Kernel - Build your custom kernelEmbedded Linux Kernel - Build your custom kernel
Embedded Linux Kernel - Build your custom kernel
 
Embedded Linux - Building toolchain
Embedded Linux - Building toolchainEmbedded Linux - Building toolchain
Embedded Linux - Building toolchain
 
Embedded Linux on ARM
Embedded Linux on ARMEmbedded Linux on ARM
Embedded Linux on ARM
 
Linux Kernel Startup Code In Embedded Linux
Linux    Kernel    Startup  Code In  Embedded  LinuxLinux    Kernel    Startup  Code In  Embedded  Linux
Linux Kernel Startup Code In Embedded Linux
 
U boot porting guide for SoC
U boot porting guide for SoCU boot porting guide for SoC
U boot porting guide for SoC
 
Embedded_Linux_Booting
Embedded_Linux_BootingEmbedded_Linux_Booting
Embedded_Linux_Booting
 
Kernel Recipes 2015: Representing device-tree peripherals in ACPI
Kernel Recipes 2015: Representing device-tree peripherals in ACPIKernel Recipes 2015: Representing device-tree peripherals in ACPI
Kernel Recipes 2015: Representing device-tree peripherals in ACPI
 
Understanding a kernel oops and a kernel panic
Understanding a kernel oops and a kernel panicUnderstanding a kernel oops and a kernel panic
Understanding a kernel oops and a kernel panic
 
Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKB
 
linux device driver
linux device driverlinux device driver
linux device driver
 
Uboot startup sequence
Uboot startup sequenceUboot startup sequence
Uboot startup sequence
 
Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)
 
Embedded Operating System - Linux
Embedded Operating System - LinuxEmbedded Operating System - Linux
Embedded Operating System - Linux
 
Linux Porting
Linux PortingLinux Porting
Linux Porting
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 
Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)
 
Toolchain
ToolchainToolchain
Toolchain
 
Understanding the Dalvik Virtual Machine
Understanding the Dalvik Virtual MachineUnderstanding the Dalvik Virtual Machine
Understanding the Dalvik Virtual Machine
 
Building Embedded Linux Systems Introduction
Building Embedded Linux Systems IntroductionBuilding Embedded Linux Systems Introduction
Building Embedded Linux Systems Introduction
 
U Boot or Universal Bootloader
U Boot or Universal BootloaderU Boot or Universal Bootloader
U Boot or Universal Bootloader
 

Destacado

Embedded Linux from Scratch to Yocto
Embedded Linux from Scratch to YoctoEmbedded Linux from Scratch to Yocto
Embedded Linux from Scratch to YoctoSherif Mousa
 
Building Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARMBuilding Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARMSherif Mousa
 
Embedded linux system development (slides)
Embedded linux system development (slides)Embedded linux system development (slides)
Embedded linux system development (slides)Jaime Barragan
 
Embedded linux barco-20121001
Embedded linux barco-20121001Embedded linux barco-20121001
Embedded linux barco-20121001Marc Leeman
 
Yocto - Embedded Linux Distribution Maker
Yocto - Embedded Linux Distribution MakerYocto - Embedded Linux Distribution Maker
Yocto - Embedded Linux Distribution MakerSherif Mousa
 
Embedded Linux Talk Uni Forum
Embedded Linux Talk Uni ForumEmbedded Linux Talk Uni Forum
Embedded Linux Talk Uni ForumSumant Diwakar
 
Module 4 Embedded Linux
Module 4 Embedded LinuxModule 4 Embedded Linux
Module 4 Embedded LinuxTushar B Kute
 
Assistencia geologica
Assistencia geologicaAssistencia geologica
Assistencia geologicacrom68
 
The move from a hardware centric design to a software centric design: GStream...
The move from a hardware centric design to a software centric design: GStream...The move from a hardware centric design to a software centric design: GStream...
The move from a hardware centric design to a software centric design: GStream...Marc Leeman
 
Ensoft dvb 1
Ensoft dvb 1Ensoft dvb 1
Ensoft dvb 1sarge
 
sasikumarj_resume
sasikumarj_resumesasikumarj_resume
sasikumarj_resumeSasi Kumar
 
OTT in Azerbaijan - Project Brief
OTT in Azerbaijan - Project BriefOTT in Azerbaijan - Project Brief
OTT in Azerbaijan - Project BriefFarhad Shahrivar
 
Capria no_video_ship_detection_with_dvbt_software_defined_passive_radar
 Capria no_video_ship_detection_with_dvbt_software_defined_passive_radar Capria no_video_ship_detection_with_dvbt_software_defined_passive_radar
Capria no_video_ship_detection_with_dvbt_software_defined_passive_radargrssieee
 

Destacado (20)

Embedded Linux
Embedded LinuxEmbedded Linux
Embedded Linux
 
Embedded Linux from Scratch to Yocto
Embedded Linux from Scratch to YoctoEmbedded Linux from Scratch to Yocto
Embedded Linux from Scratch to Yocto
 
Building Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARMBuilding Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARM
 
Embedded linux system development (slides)
Embedded linux system development (slides)Embedded linux system development (slides)
Embedded linux system development (slides)
 
Embedded linux barco-20121001
Embedded linux barco-20121001Embedded linux barco-20121001
Embedded linux barco-20121001
 
Yocto - Embedded Linux Distribution Maker
Yocto - Embedded Linux Distribution MakerYocto - Embedded Linux Distribution Maker
Yocto - Embedded Linux Distribution Maker
 
Building
BuildingBuilding
Building
 
Paper5
Paper5Paper5
Paper5
 
Embedded Linux Talk Uni Forum
Embedded Linux Talk Uni ForumEmbedded Linux Talk Uni Forum
Embedded Linux Talk Uni Forum
 
Linux Mint
Linux MintLinux Mint
Linux Mint
 
Module 4 Embedded Linux
Module 4 Embedded LinuxModule 4 Embedded Linux
Module 4 Embedded Linux
 
Assistencia geologica
Assistencia geologicaAssistencia geologica
Assistencia geologica
 
Linux Workshop , Day 3
Linux Workshop , Day 3Linux Workshop , Day 3
Linux Workshop , Day 3
 
How To Handle An IRD Audit - Atainz
How To Handle An IRD Audit - AtainzHow To Handle An IRD Audit - Atainz
How To Handle An IRD Audit - Atainz
 
The move from a hardware centric design to a software centric design: GStream...
The move from a hardware centric design to a software centric design: GStream...The move from a hardware centric design to a software centric design: GStream...
The move from a hardware centric design to a software centric design: GStream...
 
Ensoft dvb 1
Ensoft dvb 1Ensoft dvb 1
Ensoft dvb 1
 
sasikumarj_resume
sasikumarj_resumesasikumarj_resume
sasikumarj_resume
 
OTT in Azerbaijan - Project Brief
OTT in Azerbaijan - Project BriefOTT in Azerbaijan - Project Brief
OTT in Azerbaijan - Project Brief
 
DVB-T/H Solution
DVB-T/H  SolutionDVB-T/H  Solution
DVB-T/H Solution
 
Capria no_video_ship_detection_with_dvbt_software_defined_passive_radar
 Capria no_video_ship_detection_with_dvbt_software_defined_passive_radar Capria no_video_ship_detection_with_dvbt_software_defined_passive_radar
Capria no_video_ship_detection_with_dvbt_software_defined_passive_radar
 

Similar a Embedded Linux Introduction

Installing Postgres on Linux
Installing Postgres on LinuxInstalling Postgres on Linux
Installing Postgres on LinuxEDB
 
Developping drivers on small machines
Developping drivers on small machinesDevelopping drivers on small machines
Developping drivers on small machinesAnne Nicolas
 
The ABC of Linux (Linux for Beginners)
The ABC of Linux (Linux for Beginners)The ABC of Linux (Linux for Beginners)
The ABC of Linux (Linux for Beginners)plarsen67
 
Porting the drm/kms graphic drivers to DragonFlyBSD by Francois Tigeot
Porting the drm/kms graphic drivers to DragonFlyBSD by Francois TigeotPorting the drm/kms graphic drivers to DragonFlyBSD by Francois Tigeot
Porting the drm/kms graphic drivers to DragonFlyBSD by Francois Tigeoteurobsdcon
 
Linux Memory Basics for SysAdmins - ChinaNetCloud Training
Linux Memory Basics for SysAdmins - ChinaNetCloud TrainingLinux Memory Basics for SysAdmins - ChinaNetCloud Training
Linux Memory Basics for SysAdmins - ChinaNetCloud TrainingChinaNetCloud
 
Is Android the New Embedded Linux? at AnDevCon VI
Is Android the New Embedded Linux? at AnDevCon VIIs Android the New Embedded Linux? at AnDevCon VI
Is Android the New Embedded Linux? at AnDevCon VIOpersys inc.
 
LAS16-209: Finished and Upcoming Projects in LMG
LAS16-209: Finished and Upcoming Projects in LMGLAS16-209: Finished and Upcoming Projects in LMG
LAS16-209: Finished and Upcoming Projects in LMGLinaro
 
What's New in OpenLDAP
What's New in OpenLDAPWhat's New in OpenLDAP
What's New in OpenLDAPLDAPCon
 
BDM37: Hadoop in production – the war stories by Nikolaï Grigoriev, Principal...
BDM37: Hadoop in production – the war stories by Nikolaï Grigoriev, Principal...BDM37: Hadoop in production – the war stories by Nikolaï Grigoriev, Principal...
BDM37: Hadoop in production – the war stories by Nikolaï Grigoriev, Principal...Big Data Montreal
 
The Forefront of the Development for NVDIMM on Linux Kernel
The Forefront of the Development for NVDIMM on Linux KernelThe Forefront of the Development for NVDIMM on Linux Kernel
The Forefront of the Development for NVDIMM on Linux KernelYasunori Goto
 
The RULE project: efficient computing for all GNU/Linux users
The RULE project: efficient computing for all GNU/Linux usersThe RULE project: efficient computing for all GNU/Linux users
The RULE project: efficient computing for all GNU/Linux usersMarco Fioretti
 
How Can OpenNebula Fit Your Needs: A European Project Feedback
How Can OpenNebula Fit Your Needs: A European Project FeedbackHow Can OpenNebula Fit Your Needs: A European Project Feedback
How Can OpenNebula Fit Your Needs: A European Project FeedbackNETWAYS
 
OpenNebulaConf 2013 - How Can OpenNebula Fit Your Needs: A European Project F...
OpenNebulaConf 2013 - How Can OpenNebula Fit Your Needs: A European Project F...OpenNebulaConf 2013 - How Can OpenNebula Fit Your Needs: A European Project F...
OpenNebulaConf 2013 - How Can OpenNebula Fit Your Needs: A European Project F...OpenNebula Project
 
Is Android the New Embedded Linux? at AnDevCon V
Is Android the New Embedded Linux? at AnDevCon VIs Android the New Embedded Linux? at AnDevCon V
Is Android the New Embedded Linux? at AnDevCon VOpersys inc.
 
RNUG 2020: HCL Notes 11.0.1 FP2 - Performance Boost Re-Reloaded
RNUG 2020: HCL Notes 11.0.1 FP2 - Performance Boost Re-ReloadedRNUG 2020: HCL Notes 11.0.1 FP2 - Performance Boost Re-Reloaded
RNUG 2020: HCL Notes 11.0.1 FP2 - Performance Boost Re-Reloadedpanagenda
 
RNUG - HCL Notes 11.0.1 FP2 — Performance Boost Re-Reloaded
RNUG - HCL Notes 11.0.1 FP2 — Performance Boost Re-ReloadedRNUG - HCL Notes 11.0.1 FP2 — Performance Boost Re-Reloaded
RNUG - HCL Notes 11.0.1 FP2 — Performance Boost Re-ReloadedChristoph Adler
 
Challenges with Gluster and Persistent Memory with Dan Lambright
Challenges with Gluster and Persistent Memory with Dan LambrightChallenges with Gluster and Persistent Memory with Dan Lambright
Challenges with Gluster and Persistent Memory with Dan LambrightGluster.org
 
The Deck by Phil Polstra GrrCON2012
The Deck by Phil Polstra GrrCON2012The Deck by Phil Polstra GrrCON2012
The Deck by Phil Polstra GrrCON2012Philip Polstra
 
Redis Developers Day 2014 - Redis Labs Talks
Redis Developers Day 2014 - Redis Labs TalksRedis Developers Day 2014 - Redis Labs Talks
Redis Developers Day 2014 - Redis Labs TalksRedis Labs
 
Optimizing Servers for High-Throughput and Low-Latency at Dropbox
Optimizing Servers for High-Throughput and Low-Latency at DropboxOptimizing Servers for High-Throughput and Low-Latency at Dropbox
Optimizing Servers for High-Throughput and Low-Latency at DropboxScyllaDB
 

Similar a Embedded Linux Introduction (20)

Installing Postgres on Linux
Installing Postgres on LinuxInstalling Postgres on Linux
Installing Postgres on Linux
 
Developping drivers on small machines
Developping drivers on small machinesDevelopping drivers on small machines
Developping drivers on small machines
 
The ABC of Linux (Linux for Beginners)
The ABC of Linux (Linux for Beginners)The ABC of Linux (Linux for Beginners)
The ABC of Linux (Linux for Beginners)
 
Porting the drm/kms graphic drivers to DragonFlyBSD by Francois Tigeot
Porting the drm/kms graphic drivers to DragonFlyBSD by Francois TigeotPorting the drm/kms graphic drivers to DragonFlyBSD by Francois Tigeot
Porting the drm/kms graphic drivers to DragonFlyBSD by Francois Tigeot
 
Linux Memory Basics for SysAdmins - ChinaNetCloud Training
Linux Memory Basics for SysAdmins - ChinaNetCloud TrainingLinux Memory Basics for SysAdmins - ChinaNetCloud Training
Linux Memory Basics for SysAdmins - ChinaNetCloud Training
 
Is Android the New Embedded Linux? at AnDevCon VI
Is Android the New Embedded Linux? at AnDevCon VIIs Android the New Embedded Linux? at AnDevCon VI
Is Android the New Embedded Linux? at AnDevCon VI
 
LAS16-209: Finished and Upcoming Projects in LMG
LAS16-209: Finished and Upcoming Projects in LMGLAS16-209: Finished and Upcoming Projects in LMG
LAS16-209: Finished and Upcoming Projects in LMG
 
What's New in OpenLDAP
What's New in OpenLDAPWhat's New in OpenLDAP
What's New in OpenLDAP
 
BDM37: Hadoop in production – the war stories by Nikolaï Grigoriev, Principal...
BDM37: Hadoop in production – the war stories by Nikolaï Grigoriev, Principal...BDM37: Hadoop in production – the war stories by Nikolaï Grigoriev, Principal...
BDM37: Hadoop in production – the war stories by Nikolaï Grigoriev, Principal...
 
The Forefront of the Development for NVDIMM on Linux Kernel
The Forefront of the Development for NVDIMM on Linux KernelThe Forefront of the Development for NVDIMM on Linux Kernel
The Forefront of the Development for NVDIMM on Linux Kernel
 
The RULE project: efficient computing for all GNU/Linux users
The RULE project: efficient computing for all GNU/Linux usersThe RULE project: efficient computing for all GNU/Linux users
The RULE project: efficient computing for all GNU/Linux users
 
How Can OpenNebula Fit Your Needs: A European Project Feedback
How Can OpenNebula Fit Your Needs: A European Project FeedbackHow Can OpenNebula Fit Your Needs: A European Project Feedback
How Can OpenNebula Fit Your Needs: A European Project Feedback
 
OpenNebulaConf 2013 - How Can OpenNebula Fit Your Needs: A European Project F...
OpenNebulaConf 2013 - How Can OpenNebula Fit Your Needs: A European Project F...OpenNebulaConf 2013 - How Can OpenNebula Fit Your Needs: A European Project F...
OpenNebulaConf 2013 - How Can OpenNebula Fit Your Needs: A European Project F...
 
Is Android the New Embedded Linux? at AnDevCon V
Is Android the New Embedded Linux? at AnDevCon VIs Android the New Embedded Linux? at AnDevCon V
Is Android the New Embedded Linux? at AnDevCon V
 
RNUG 2020: HCL Notes 11.0.1 FP2 - Performance Boost Re-Reloaded
RNUG 2020: HCL Notes 11.0.1 FP2 - Performance Boost Re-ReloadedRNUG 2020: HCL Notes 11.0.1 FP2 - Performance Boost Re-Reloaded
RNUG 2020: HCL Notes 11.0.1 FP2 - Performance Boost Re-Reloaded
 
RNUG - HCL Notes 11.0.1 FP2 — Performance Boost Re-Reloaded
RNUG - HCL Notes 11.0.1 FP2 — Performance Boost Re-ReloadedRNUG - HCL Notes 11.0.1 FP2 — Performance Boost Re-Reloaded
RNUG - HCL Notes 11.0.1 FP2 — Performance Boost Re-Reloaded
 
Challenges with Gluster and Persistent Memory with Dan Lambright
Challenges with Gluster and Persistent Memory with Dan LambrightChallenges with Gluster and Persistent Memory with Dan Lambright
Challenges with Gluster and Persistent Memory with Dan Lambright
 
The Deck by Phil Polstra GrrCON2012
The Deck by Phil Polstra GrrCON2012The Deck by Phil Polstra GrrCON2012
The Deck by Phil Polstra GrrCON2012
 
Redis Developers Day 2014 - Redis Labs Talks
Redis Developers Day 2014 - Redis Labs TalksRedis Developers Day 2014 - Redis Labs Talks
Redis Developers Day 2014 - Redis Labs Talks
 
Optimizing Servers for High-Throughput and Low-Latency at Dropbox
Optimizing Servers for High-Throughput and Low-Latency at DropboxOptimizing Servers for High-Throughput and Low-Latency at Dropbox
Optimizing Servers for High-Throughput and Low-Latency at Dropbox
 

Último

Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operationalssuser3e220a
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptxmary850239
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxMichelleTuguinay1
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxkarenfajardo43
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17Celine George
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataBabyAnnMotar
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptxmary850239
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
week 1 cookery 8 fourth - quarter .pptx
week 1 cookery 8  fourth  -  quarter .pptxweek 1 cookery 8  fourth  -  quarter .pptx
week 1 cookery 8 fourth - quarter .pptxJonalynLegaspi2
 
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxMan or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxDhatriParmar
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...DhatriParmar
 
Multi Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleMulti Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleCeline George
 
Mental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsMental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsPooky Knightsmith
 

Último (20)

Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operational
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped data
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
week 1 cookery 8 fourth - quarter .pptx
week 1 cookery 8  fourth  -  quarter .pptxweek 1 cookery 8  fourth  -  quarter .pptx
week 1 cookery 8 fourth - quarter .pptx
 
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxMan or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
prashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Professionprashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Profession
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
 
Multi Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleMulti Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP Module
 
Mental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsMental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young minds
 

Embedded Linux Introduction

  • 1. 12/07/13 - Marc Leeman Company Confidential - 1 Basic Introduction to Embedded Linux Barco Seminar 11/07/2013 Marc Leeman
  • 2. 12/07/13 - Marc Leeman Company Confidential - 2 Patches Accepted ● 11th time we do this training ● 5th time based on SheevaPlug ● Bear with us ● Developed over time ● Inconsistencies in course text/slides(?) ● Feedback welcome!
  • 3. 12/07/13 - Marc Leeman Company Confidential - 3 Goals ● Huge topic, so only introduction ● Hands on, examples, share experience ● Become acquainted with typical small footprint embedded Linux ● Where to look for setting up or obtaining a cross compile toolchain environment ● Get to know the typical bootloaders ● Lots-of-examples
  • 4. 12/07/13 - Marc Leeman Company Confidential - 4 Hardware ● SheevaPlug ● Marvell Arm Kirkwood processor ● 1.2 GHz ● 512 MB RAM ● U-Boot bootloader ● 512 MB NAND Flash ● Gb Ethernet, Serial, SD Card, USB, ...
  • 5. 12/07/13 - Marc Leeman Company Confidential - 5 SheevaPlug
  • 6. 12/07/13 - Marc Leeman Company Confidential - 6 Contents ● The GNU/Linux System ● System Overview ● System Design ● Cross Compilation Toolchain ● The Linux Boot Process ● Boot Loaders ● The Linux Kernel ● File Systems ● Userspace
  • 7. 12/07/13 - Marc Leeman Company Confidential - 7 The GNU/Linux System
  • 8. 12/07/13 - Marc Leeman Company Confidential - 8 ● Computer operating system and its kernel -> GNU/Linux, GNU+Linux, ... ● The GNU Project (1983) ● Hurd kernel 1990 ● Linux kernel: 1991 ● Estimated cost typical linux distribution is 10.8 billion; the kernel alone an extra 1.4 billion (2008, Fedora 9) ● All the underlying source code is available Linux
  • 9. 12/07/13 - Marc Leeman Company Confidential - 9 Applications ● LAMP ● Linux, Apache, MySQL, Perl/PHP/Python ● Gaming (PS3) ● Embedded ● Set top boxes, mobile phones, routers & switches, dreambox, TiVo, … ● Handhelds ● Supercomputers ● 34 fastest running Linux, 92% of top 500
  • 10. 12/07/13 - Marc Leeman Company Confidential - 10 Linux & Super computing
  • 11. 12/07/13 - Marc Leeman Company Confidential - 11 Usability ● KDE/Gnome ● Office, Calenders, ... ● plethora of programs/utilities ● Eye candy: 3D Desktop accelleration ● usability in par with commercial OSes.
  • 12. 12/07/13 - Marc Leeman Company Confidential - 12 Installation ● Easy installation ● Powerful development environment ● Wide architecture support ● Live-CDs, Dual Boot, ...
  • 13. 12/07/13 - Marc Leeman Company Confidential - 13 System Overview
  • 14. 12/07/13 - Marc Leeman Company Confidential - 14 System on Chip ● Hardware varies a lot ● Linux kernel and OS abstracts HW from software ● CPU ● PowerPC (was?) popular in Barco ● ARM seems to be picking up ● Focus on ARM, but techniques can be applied to other archs. ● X86 systems
  • 15. 12/07/13 - Marc Leeman Company Confidential - 15 System on Chip ● RAM ● Storage ● Used to be typically NOR flash, sometimes NAND ● Currently NAND due to cost (eMMC) ● I/O ● Lot of variation ● Serial and Ethernet
  • 16. 12/07/13 - Marc Leeman Company Confidential - 16 Embedded Linux Components ● Bootloader ● Linux kernel ● 1 (or more) file systems with userspace ● Kernel sometimes inside rootfs as well
  • 17. 12/07/13 - Marc Leeman Company Confidential - 17 Layering ● Boot loader only active during powerup ● Only kernel talks to hardware ● Same for ALL Linux systems
  • 18. 12/07/13 - Marc Leeman Company Confidential - 18 System Design
  • 19. 12/07/13 - Marc Leeman Company Confidential - 19 Considerations ● Redundancy ● Hardware (network interfaces) ● Software (factory/upgrade) ● Configuration (redundant flash with CRC) ● Predictability ● Uncertainty => fall back to factory settings ● Stability ● Linux :-) ● Monitoring ● Quis custodiet ipsos custodes
  • 20. 12/07/13 - Marc Leeman Company Confidential - 20 Basic choice ● Small and minimalistic ● Focus on minimal footprint ● Reduce component cost (large volumes) ● Minimal functionality ● Often one indivisible deliverable ● Platform approach ● Focus on software design ● Reduce software development cost (a lot of low volume platforms) ● Pluggable functionality ● Easy functionality extension and system configuration. ● Trend seems is to focus on software
  • 21. 12/07/13 - Marc Leeman Company Confidential - 21 Small is Beautiful Speed increase RAM reduction Power reduction Cost reduction More speed ­ CPU can run slower or stay longer in power saving mode ­ Slower, cheaper CPU Less RAM ­ Faster allocations ­ Less swapping ­ Sometimes less cache flushing ­ Fewer / smaller RAM chips: less dynamic and standby power. ­ CPU with less cache: less power ­ Fewer / cheaper RAM chips ­ CPU with less cache: cheaper Less space ­ Faster application loading from storage and in RAM. ­ Sometimes, simpler, faster code. ­ Less RAM usage ­ Fewer / smaller storage chips: less power ­ Fewer / cheaper storage Less power ­ Cheaper batteries ­ or cheaper AC/DC converter ●No black and white choice ●Storage is cheap ●Small does have a cost: ● Focus on software that adds value
  • 22. 12/07/13 - Marc Leeman Company Confidential - 22 Components ● File systems ● Rw: Jffs2, ubifs ● Ro: cramfs, squashfs ● Ext2, FAT ● Glibc or uclibc ● Glibc: localisation (l10n), internationalisation support (I18n), threading ● Uclibc: replace (configurable) parts of libc allows optimisation for size ● Scales up to 33% wrt original libc reference ● System utils or busybox ● all-in-one, GNU utils optimised for size
  • 23. 12/07/13 - Marc Leeman Company Confidential - 23 The bootloader ● Das U-Boot ● Extracts kernel image to RAM and sets Program Counter ● But is much more! ● executes scripts ● can get kernel over network ● can be used to upgrade the flash sections ● debugging over network ● ...
  • 24. 12/07/13 - Marc Leeman Company Confidential - 24 The Linux Kernel ● Basic hardware detection and initialisation ● In the kernel image is needed: ● minimal configuration to allow recognition of root FS ● hardware access for root partition ● SCSI, IDE, LIBATA, FLASH, MAC/PHY, ... ● File system ● ext2, ext3, jfs, ubifs, xfs, nfs, reiserfs, ... ● What is not needed: ● Firewall (iptables), keyboard, mouse, ... (peripherals) ● Can be postponed to the final stages of booting ● Good Practice ● only include needed functionality
  • 25. 12/07/13 - Marc Leeman Company Confidential - 25 Static or Dynamic Linking (1) Static linking ● All shared library code duplicated in the executables ● Allows not to copy the C library in the file system. Simpler and smaller when very few executables (busybox) ● Library code duplication: bad for systems with more executables (code size and RAM) Best for small systems (< 1-2 MB) with few executables! Not used that much anymore
  • 26. 12/07/13 - Marc Leeman Company Confidential - 26 Static or Dynamic Linking (2) Dynamic linking ● Shared library code not duplicated in the executables ● Makes much smaller executables ● Saves space in RAM (bigger executable take more RAM) ● Requires the library to the copied to the file system Best for medium to big systems (> 500 KB - 1 MB)
  • 27. 12/07/13 - Marc Leeman Company Confidential - 27 Libc ● glibc (GNU C library): http://www.gnu.org/software/libc/ Found on most computer type GNU/Linux machines Size on arm: approx 1.7 MB ● uClibc: http://www.uclibc.org/ Found in more and more embedded Linux systems! Size on arm: approx 400 KB (you save 1.2 MB!) 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
  • 28. 12/07/13 - Marc Leeman Company Confidential - 28 Stripping ● Compiled executables contain extra information which can be used to investigate problems in a debugger. ● This was useful for the tool developer, but not for the final user. ● To remove debugging information, use the strip command. This can save a very significant amount of space! gcc ­o hello hello.c (output size: 4635 bytes) strip hello (output size: 2852 bytes, -38.5%)
  • 29. 12/07/13 - Marc Leeman Company Confidential - 29 Setting up our Cross Compilation Toolchain
  • 30. 12/07/13 - Marc Leeman Company Confidential - 30 Terminology ● build platform: where the code is compiled ● host platform: where the compiled code will be executed ● target platform: for compilers, represents what type of object code the package itself will produce ● preferred compiler for code that runs on different archs
  • 31. 12/07/13 - Marc Leeman Company Confidential - 31 Terminology (2) ● gcc: GNU Compiler Collection ● 1987... ● glibc: GNU C standard library ● Unix98, POSIX, C99, +extensions ● x86, m68k, Alpha, PPC, ARM, CRIS, MIPS, s390, SPARC ● Linux +Hurd kernels, also FreeBSD and NetBSD ● glibc 2 = libc6; (older glibc -> libc5) ● uclibc ● cf. Supra
  • 32. 12/07/13 - Marc Leeman Company Confidential - 32 Top Down Approach Top-down approach to building an embedded system ● Starting from a complete desktop GNU/Linux distribution (Debian, Fedora...) and removing unneeded stuff. ● Very tedious job: need to go through a huge number of files and packages. Need to understand what each file and package is about before removing it. ● Keeping unnecessarily complex scripts and configuration files. ● The end result is still quite big, as standard desktop tool sets and libraries are used. Lots of shared libraries still needed too.
  • 33. 12/07/13 - Marc Leeman Company Confidential - 33 Bottom Up Approach Bottom-up approach to building embedded systems ● Starting with an empty or minimalistic root file system, adding only things that you need. ● Much easier to do! You just spend time on things you need. ● Much easier to control and maintain: you build an understanding about the tools you use. ● You only need very simple configuration scripts. ● The end result can be extremely small, all the more as you use lightweight tool sets instead.
  • 34. 12/07/13 - Marc Leeman Company Confidential - 34 Toolchain ● gcc: ● cross-compiling: compile for a target configuration other than the build host. ● $(arch)-$(os){-$(lib)}-gcc ● powerpc-linux-uclibc-gcc, arm-linux-newlib-gcc ● typical gcc toolchain links against libc ● When uclibc is used, a compiler is needed that matches that exact uclibc configuration ● automated with buildroot
  • 35. 12/07/13 - Marc Leeman Company Confidential - 35 Toolchain selection ● Depends on your environment ● Native build (x86, emulation, arm, ...) ● Cross compilation build ● Glibc cross compilations toolchains are often available ● Native complation toolchains are ALWAYS available (e.g. qemu) ● With uClibc, a exactly matched toolchain is required
  • 36. 12/07/13 - Marc Leeman Company Confidential - 36 Native and emulation ● The target hardware is very performant ● Target instruction set is emulated ● Both use a 'native' compiler ● Typical easier to use for complex software environments
  • 37. 12/07/13 - Marc Leeman Company Confidential - 37 Buildroot ● Classic cross compilation ● Set of Makefiles and patches ● Generates: ● cross-compilation toolchain ● gcc, binutils, gdb, ... ● (root filesystem for target, kernel, bootloader, ..)
  • 38. 12/07/13 - Marc Leeman Company Confidential - 38 Buildroot configuration ● Kconfig interface ● make menuconfig ● Select compiler, binutils and gdb version. ● http://buildroot.net
  • 39. 12/07/13 - Marc Leeman Company Confidential - 39 Exercise ● Retrieve buildroot 2012.08 from ● http://www.buildroot.org/download.html ● $ make sheevaplug_defconfig ● $ make ● ● Note: you will need to set your http_proxy environment variable to http://neo.barco.com:3128/ and/or use http://sleipner.barco.com/downloads/ as primary download site (Build Options → Mirrors and Download locations)
  • 40. 12/07/13 - Marc Leeman Company Confidential - 40 The Linux Boot Process
  • 41. 12/07/13 - Marc Leeman Company Confidential - 41 High Level View
  • 42. 12/07/13 - Marc Leeman Company Confidential - 42 System startup ● CPU executes code at a predefined address (e.g. CS0, address 0x100) ● for a PC: BIOS in flash on motherboard ● embedded e.g. U-Boot, Redboot or similar ● PC: ● if valid boot device is found, the 1st stage bootloader is loaded
  • 43. 12/07/13 - Marc Leeman Company Confidential - 43 Stage 1 Bootloader (x86) ● <512 bytes, fits in 1 sector ● binary itself < 446 bytes ● 64 byte partition table ● 2 byte signature ● loaded from MBR boot device ● Task is to load second stage bootloader
  • 44. 12/07/13 - Marc Leeman Company Confidential - 44 Boot device signature
  • 45. 12/07/13 - Marc Leeman Company Confidential - 45 Stage 2 bootloader ● LILO/GRUB ● load and select kernel ● optionally selects initrd ● pass control to the kernel
  • 46. 12/07/13 - Marc Leeman Company Confidential - 46 Kernel ● zImage (zlib, lzo or lzma compressed) ● without initrd, kernel should contain just the functionality to detect & mount root filesystem
  • 47. 12/07/13 - Marc Leeman Company Confidential - 47 Kernel startup
  • 48. 12/07/13 - Marc Leeman Company Confidential - 48 kernel startup (2) ● Assembly, arch specific ● head.S ● hardware initialisation and setup basic environment ● decompress kernel in memory ● Uncompressing Linux... Ok, booting the kernel ● startup_32: ● initialise page tables and enable memory paging ● CPU detection
  • 49. 12/07/13 - Marc Leeman Company Confidential - 49 kernel startup (3) ● C, non arch specific ● start_kernel in init/main.c ● init interrupts ● (init ramdisk) ● initial root fs in memory/detect hardware ● embedded: can be final root filesystem ● memory initialisation ● thread_kernel starts /sbin/init ● first user-level application ● Can be modified to another application
  • 50. 12/07/13 - Marc Leeman Company Confidential - 50 init ● First user-level application ● compiled/linked with libc ● uses /etc/inittab ● Spawn services ● sshd, apache, ... ● /bin/sh can also be used to start a single shell instead of init
  • 51. 12/07/13 - Marc Leeman Company Confidential - 51 Runlevels (sysv) ● startup behaviour of init is divided in “runlevels” ● 0: Halt ● 1: Single User Mode ● 2: Basic Multi-User mode without NFS ● 3: Full Multi-User mode ● 4: Not used ● 5: Full Multi User Mode with X11 Login ● 6: Reboot ● Not so fixed, some distros use fewer levels (e.g. Slackware, Debian, ...)
  • 52. 12/07/13 - Marc Leeman Company Confidential - 52 init scripts ● Most start scripts can be found in ● /etc/init.d/ ● /etc/rcX.d contains symbolic links to the scripts ● X: 1,2,3,4,5,6,S ● K20autofs ● S: start ● K: stop ● number for ordering: e.g. start network daemons after network devices.
  • 53. 12/07/13 - Marc Leeman Company Confidential - 53 inittab entry ● 1:2345:respawn/sbin/getty 38400 tty1 ● id ● runlevels ● action ● process to be executed ● id:3:initdefault: ● default runlevel ● /etc/init.d/networking ● {start|stop|restart|force-reload}
  • 54. 12/07/13 - Marc Leeman Company Confidential - 54 Boot Loaders
  • 55. 12/07/13 - Marc Leeman Company Confidential - 55 Overview ● First thing to run after power on ● Tasks: ● Initialize (some of) hardware ● Load a kernel ● Execute it ● Boot loaders often have extra functionality: ● Access memory and registers ● Program flash ● ..
  • 56. 12/07/13 - Marc Leeman Company Confidential - 56 Boot Loaders ● Lots of Linux compatible boot loaders ● LILO & GRUB well known ● PC specific ● Often platform specific ● Portable: ● RedBoot ● Das U-Boot
  • 57. 12/07/13 - Marc Leeman Company Confidential - 57 Das U-Boot ● The universal boot loader ● Probably most feature full, flexible and most actively developed boot loader ● Very much focused on Linux ● Started as PPCBoot, but now portable ● Licensed under the GPL ● Has a alternative implementation barebox (u-boot-v2).
  • 58. 12/07/13 - Marc Leeman Company Confidential - 58 U-Boot Features ● Flash support ● NOR, NAND, Dataflash, .. ● Compression ● GZIP, BZIP2 ● Interactive command line interface ● Boot scripting ● TCP/IP stack with BOOTP and DHCP, TFTP and NFS ● LOTS of drivers: ● Often ported from Linux ● IDE, SCSI, MMC, PCMCIA, USB, LCD, I2C, SPI, ..
  • 59. 12/07/13 - Marc Leeman Company Confidential - 59 U-Boot Features (2) ● x86 emulation ● Graphics card POST on non-x86 ● File Systems ● JFFS2, Cramfs, squashfs EXT2, FAT, Reiserfs, .. ● Boot splash images ● FPGA configuration ● ...
  • 60. 12/07/13 - Marc Leeman Company Confidential - 60 Exercise ● Bootup SheevaPlug in U-Boot and explore commands (type help) and environment variables (type printenv)
  • 61. 12/07/13 - Marc Leeman Company Confidential - 61 U-Boot operation ● Once a working U-Boot (flash) is installed, upgrading can be done with serial/tftp/u-boot tftp 100000 /home/services/tftpboot/u-boot.bin protect off fe000000 fe03ffff era fe000000 fe03ffff cp.b 100000 fe000000 ${filesize} protect on fe000000 fe03ffff ● scripting helps :-) run burnfact
  • 62. 12/07/13 - Marc Leeman Company Confidential - 62 Exercise ● Download u-boot 2010.06 and build for SheevaPlug. Update through JTAG or TFTP ● Check section 4.6 in manual ● Needed .deb's at http//neo.barco.com/~mleeman/downloads/SheevaPlugCourse
  • 63. 12/07/13 - Marc Leeman Company Confidential - 63 The Linux Kernel
  • 64. 12/07/13 - Marc Leeman Company Confidential - 64 History ● 1991: post in comp.os.minix ● Linux 0.1 ● 1994: Linux 1.0.0 ● 1996: Linux 2.0.0 ● 1999: Linux 2.2.0 ● 2001: Linux 2.4.0 ● 2003: Linux 2.6.0 ● 2011: Linux 3.0 ● 2012: Linux 3.5
  • 65. 12/07/13 - Marc Leeman Company Confidential - 65 Architecture ● monolithic kernel ● drivers run in ring 0 ● X11 is in userspace ● contrary to Windows ● Supports ● preemption ● virtual memory ● memory management ● threading ● TCP/IP ● ... ● Mostly in C (97%), 3% ASM
  • 66. 12/07/13 - Marc Leeman Company Confidential - 66 Modules ● kernel code that can access hardware directly ● modules can be loaded/unloaded and re-configured at run-time ● e.g. sudo modprobe xfs lsmod sudo insmod /path/to/xfs.ko sudo modprobe module param=1 ● Also in configuration file /etc/modprobe.d/module.conf
  • 67. 12/07/13 - Marc Leeman Company Confidential - 67 Source Tree ● BIG! (~525 MB, 10M lines) ● A lot is drivers ● Core kernel ~5MB
  • 68. 12/07/13 - Marc Leeman Company Confidential - 68 Source Tree (2) Kernel 2.6.36 ● 216M drivers ● 114M arch ● 32M fs ● 21M sound ● 19M include ● 19M net ● 17M Documentation ● 4.6M kernel ● 2.2M scripts ● 2.2M mm ● 1.7M crypto ● 1.4M lib ● 1.4M security ● 544K block ● 244K ipc ● 144K init ● 108K samples ● 56K usr
  • 69. 12/07/13 - Marc Leeman Company Confidential - 69 Architecture Specific code ● arch/<cpu> ● arch/<cpu>/include/asm ● A few MB per arch ● Depending on no. supported boards
  • 70. 12/07/13 - Marc Leeman Company Confidential - 70 Release Schedule ● New release every 2-3 months ● 2.6.39 19/05/2011 ● 3.0 22/07/2011 ● 3.1 24/10/2011 ● 3.2 05/01/2012 ● 3.3 22/03/2012 ● 3.4 21/05/2012 ● 3.5 21/07/2012 ● 3.6 01/10/2012 ● 3.7 11/12/2012 ● 3.8 19/02/2013 ● 3.9 29/04/2013 ● 3.10 30/06/2013
  • 71. 12/07/13 - Marc Leeman Company Confidential - 71 Release Schedule (2) ● Tree is open for 2 weeks after release ● LOTS of activity – rc1 diff ~1M lines ● After that only bugfixes ● New -rcX release every 1-2 weeks ● 3.x.y stable releases for serious bugs found after release
  • 72. 12/07/13 - Marc Leeman Company Confidential - 72 Tracking Development ● Linux kernel mailing list (2-300 mails/day) ● lwn.net Kernel - http://lwn.net/Kernel ● http://www.kernelnewbies.org/LinuxChan ges ● kernel.org gitweb: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=summary
  • 73. 12/07/13 - Marc Leeman Company Confidential - 73 Device Tree ● Introduced in the PowerPC processor ports, moving to other archs (ARM, Microblaze) ● The Device Tree describes the hardware to the kernel ● Includes e.g. Flash map, PCI addresses, MAC addresses, ... ● U-Boot has support for modifying the dts/dtb
  • 74. 12/07/13 - Marc Leeman Company Confidential - 74 User Space Interface ● Basically 3 types of interfaces: ● Character Devices ● Block Devices ● Network Devices ● (procfs, sysfs, netlink) ● Rarely needs to be implemented directly ● Kernel provides frameworks
  • 75. 12/07/13 - Marc Leeman Company Confidential - 75 Character Devices ● Most common type ● Anything that can be viewed as a stream of bytes (serial ports, input devices, framebuffers, sound devices, ..) ● Accessed like normal files ● open/close/read/write/lseek/.. ● Additional settings through ioctl ● Added in kernel by ● Registering a cdev and implement file_operations
  • 76. 12/07/13 - Marc Leeman Company Confidential - 76 Block Devices ● For Storage Devices ● Harddisks, MMC, USB keys, .. ● Accessed like Character Devices ● Kernel Interface More Complicated ● Added in kernel by ● Registering a gendisk and implement block_device_operations
  • 77. 12/07/13 - Marc Leeman Company Confidential - 77 Network Devices ● For Network Devices ● Ethernet, Wireless, PPP, .. ● Accessed using socket API ● socket/accept/listen/recv/send/.. ● Configuration typically through programs/scripts ● ip/ifconfig/vconfig/ethtool/.. ● Added in kernel by ● Registering a net_device and implement net_device_ops
  • 78. 12/07/13 - Marc Leeman Company Confidential - 78 Hardware Access ● Memory mapped registers ● Linux uses virtual memory (MMU) ● ioremap(physical address) logical ● read{b,w,l}(logical) ● write{b,w,l}(value, logical) ● iounmap(logical)
  • 79. 12/07/13 - Marc Leeman Company Confidential - 79 Device Model ● Object Oriented, Tree Structured ● Busses (struct bus_type) ● Devices (struct device) ● Drivers (struct driver) ● Visible in sysfs ● Take a look on your PC! ● Saves code, Tree hierarchy important for E.G. power management
  • 80. 12/07/13 - Marc Leeman Company Confidential - 80 Busses ● Devices connect to CPU through busses ● USB, PCI, I2C, SPI, Platform, .. ● Each corresponds to a specific bus_type ● Bus-specific interface for drivers ● Tree Based ● E.G. a USB controller on a PCI bus
  • 81. 12/07/13 - Marc Leeman Company Confidential - 81 Devices and Drivers ● Object Oriented ● Drivers (Classes) ● Devices (Instances) ● Common interface ● Probe (Constructor) ● Remove (Destructor) ● Bus connects (binds) both together
  • 82. 12/07/13 - Marc Leeman Company Confidential - 82 Platform Bus ● “Dummy” bus for simple memory mapped devices on SoCs ● Plug-n-play binding emulated through string matching (driver/device name member)
  • 83. 12/07/13 - Marc Leeman Company Confidential - 83 Platform Bus Binding struct platform_device { const char * name; … }; struct platform_driver { struct device_driver driver { const char *name; }; ... }; ● Platform_device in platform code ● Platform_driver in device driver
  • 84. 12/07/13 - Marc Leeman Company Confidential - 84 Resources static struct resource smc911x_resources[] = { [0] = { .start = 0x8e000000, .end = 0x8e0000ff, .flags = IORESOURCE_MEM, }, [1] = { .start = 4, .end = 4, .flags = IORESOURCE_IRQ, }, }; ● Generic way of providing platform details such as base address and IRQ: ●Platform data pointer for special stuff
  • 85. 12/07/13 - Marc Leeman Company Confidential - 85 PCI Bus ● Device/Driver binding using PCI Vendor/Product ID (PnP) ● lspci ● USB is very similar 00:1f.3 SMBus: Intel Corporation N10/ICH 7 Family SMBus Controller (rev 02) 01:00.0 Ethernet controller: Marvell Technology Group Ltd. 88E8053 PCI-E Gigabit Ethernet Controller (rev 22) 02:00.0 Network controller: Atheros Communications Inc. AR5008 Wireless Network Adapter (rev 01) 03:03.0 FireWire (IEEE 1394): Agere Systems FW322/323 (rev 61) ..
  • 86. 12/07/13 - Marc Leeman Company Confidential - 86 Character Interface ● Make communication available to userspace via device files # ls -l /dev |grep dsp crw-rw-rw- 1 0 0 252, 4 Jul 20 2006 dspa crw-r----- 1 0 0 252, 0 Jul 20 2006 dspa0 crw-r----- 1 0 0 252, 1 Jul 20 2006 dspa1 crw-r----- 1 0 0 252, 2 Jul 20 2006 dspa2 crw-r----- 1 0 0 252, 3 Jul 20 2006 dspa3 # ls -l /dev |grep fpga crw-r----- 1 0 0 253, 0 Jul 20 2006 fpgaa crw-r----- 1 0 0 251, 0 Jul 20 2006 nwwfpgaa
  • 87. 12/07/13 - Marc Leeman Company Confidential - 87 read/write ● read/write on file handles ● copy data from the kernel to application code ● copy_to_user(...) ● copy data from application code to the kernel ● copy_from_user(...) ● If user reads ● kernel writes from userspace ● If user writes ● kernel reads from userspace
  • 88. 12/07/13 - Marc Leeman Company Confidential - 88 Device Files ● ioctl is often used in code to send commands and data to the kernel/device ● For register access, read/write/lseek is better. ● bad example: static inline uint32_t ppc2dsp_getregister(const DSP *dsphandle,uint32_t address){ TSBarcoMemEntry entry; entry.addr = address; ioctl(*dsphandle,PPC2DSP_GET_REG,&entry); return entry.value; } dsp = open ("/dev/dspa", O_RDWR);
  • 89. 12/07/13 - Marc Leeman Company Confidential - 89 ioctl ● fine tuned and often specialised hardware control ● allows to pass arbitrary data from user to kernel and vice versa ● int(*ioctl)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); ● switch(cmd) ● number 0..N cmd X-(
  • 90. 12/07/13 - Marc Leeman Company Confidential - 90 Interrupts ● Kernel needs to act on a “hardware event” ● polling? ● slow and CPU intensive! ● An interrupt is a signal that the hardware can send when it wants the processor's attention.
  • 91. 12/07/13 - Marc Leeman Company Confidential - 91 Flash Map ● Add partitions to the flash ● different functionality ● select between ● kernels ● root filesystems ● redundant configuration spaces ● file systems (jffs2, squashfs, ...) ● Create one logical area from multiple flash chips
  • 92. 12/07/13 - Marc Leeman Company Confidential - 92 LED Class ● Kernel already has a framework for this ● See: ● drivers/leds ● Documentation/leds-class.txt ● /sys/class/leds ● gpio_led driver makes this very easy ● Various led-triggers can be hooked up
  • 93. 12/07/13 - Marc Leeman Company Confidential - 93 File Systems
  • 94. 12/07/13 - Marc Leeman Company Confidential - 94 Introduction ● More than 50 file systems supported ● More than any other OS ● What to choose?
  • 95. 12/07/13 - Marc Leeman Company Confidential - 95 File System Types ● Disk based ● Flash based ● Network file systems ● “Virtual” file systems
  • 96. 12/07/13 - Marc Leeman Company Confidential - 96 Disk Based ● Biggest group ● Native ● Supports all POSIX features ● EXT2/3/4, Reiserfs3/4, XFS, JFS, Btrfs, .. ● Recommended ● Compatibility ● Might not support all POSIX features ● Less performance ● FAT, NTFS, HPFS, BEFS, AFFS, ISO9660, UDF, ..
  • 97. 12/07/13 - Marc Leeman Company Confidential - 97 Disk Based (2) ● Disks are not common in embedded systems ● PC-Like ● Flash with disk interface (USB, CF, MMC,..) ● Limit writes for flash! ● No journalling file systems ● noatime mount option ● EXT2 or FAT
  • 98. 12/07/13 - Marc Leeman Company Confidential - 98 Flash Based ● Disk based can be used ● Kernel MTD layer can emulate block device ● Only realistic for read only ● Optimized for flash ● Cramfs (old) ● Squashfs ● Journalling file system 2 (JFFS2) (old) ● UBIFS
  • 99. 12/07/13 - Marc Leeman Company Confidential - 99 Cramfs / Squashfs ● Read only ● Compression ● Squashfs finally in mainline ● Squashfs newer ● More features, better compression, faster ● Can also be used on disks ● Often combined with RAM disk for /tmp ● OpenWRT uses squashfs-lmza ● Squashfs + better compression ● Complex to implement: lmza non standard
  • 100. 12/07/13 - Marc Leeman Company Confidential - 100 JFFS2 ● Read/write ● Compression, but less effective ● Journalling, so no fsck ● Long mount time on big partitions ● Complex ● Consider raw flash partition or EEPROM if data limited
  • 101. 12/07/13 - Marc Leeman Company Confidential - 101 UBIFS ● Similar to JFFS2 but newer ● Uses UBI (Unsorted Block Images) ● More Scalable, faster mount time ● Better fit for (big) NAND flash
  • 102. 12/07/13 - Marc Leeman Company Confidential - 102 Network File Systems ● NFS, SMBFS/CIFS ● AFS, CODA, 9FS, .. ● Not commonly used in production ● NFS very handy for development ● Kernel can boot on NFS ● NFS supports normal POSIX features
  • 103. 12/07/13 - Marc Leeman Company Confidential - 103 “Virtual” File Systems ● No underlying media to store data ● Sysfs, procfs: Interface to kernel ● TMPFS: Dynamic RAM disks ● Devtmpfs: Dynamic /dev
  • 104. 12/07/13 - Marc Leeman Company Confidential - 104 Conclusion ● Lots to choose from ● Most systems use more than one
  • 105. 12/07/13 - Marc Leeman Company Confidential - 105 Userspace
  • 106. 12/07/13 - Marc Leeman Company Confidential - 106 busybox http://www.busybox.net/ ● Most Unix command line utilities within a single executable! ● includes a web server! ● Sizes less than 1 MB (statically compiled with glibc) less than 500 KB (statically compiled with uClibc) ● Easy to configure ● The best choice for ● Initrds with complex scripts
  • 107. 12/07/13 - Marc Leeman Company Confidential - 107 busybox ● combine unix utilities in one single small executable ● share startup code ● configurable commands ● configurable functionality of the commands ● applets easy to add
  • 108. 12/07/13 - Marc Leeman Company Confidential - 108 ● Best way to describe: root@OpenWrt:~# busybox BusyBox v1.4.2 (2007-09-29 07:21:40 CEST) multi-call binary Copyright (C) 1998-2006 Erik Andersen, Rob Landley, and others. Licensed under GPLv2. See source distribution for full notice. Usage: busybox [function] [arguments]... or: [function] [arguments]... BusyBox is a multi-call binary that combines many common Unix utilities into a single executable. Most people will create a link to busybox for each function they wish to use and BusyBox will act like whatever it was invoked as! Currently defined functions: [, [[, arping, ash, awk, awx, basename, bunzip2, bzcat, cat, chgrp, chmod, chown, chroot, clear, cp, crond, crontab, cut, date, dd, df, dirname, dmesg, du, echo, egrep, env, expr, false, fgrep, find, free, grep, gunzip, gzip, halt, head, hexdump, hostid, httpd, id, ifconfig, init, insmod, ipkg, kill, killall, killall5, klogd, length, less, ln, lock, logger, logread, ls, lsmod, md5sum, mesg, mkdir, mkfifo, mknod, mktemp, mount, mv, nc, netmsg, netstat, nslookup, passwd, pidof, ping, ping6, pivot_root, poweroff, printf, ps, pwd, rdate, reboot, reset, rm, rmdir, rmmod, route, sed, seq, sh, sleep, sort, strings, switch_root, sync, sysctl, syslogd, tail, tar, tee, telnet, telnetd, test, time, top, touch, tr, traceroute, true, udhcpc, umount, uname, uniq, uptime, vconfig, vi, watchdog, wc, wget, which, xargs, yes, zcat
  • 109. 12/07/13 - Marc Leeman Company Confidential - 109 Configuration ● Again, Kconfig based
  • 110. 12/07/13 - Marc Leeman Company Confidential - 110 CGI `
  • 111. 12/07/13 - Marc Leeman Company Confidential - 111 dropbear ● replaces telnetd ● obsolete since mid '90s ● secure communication ● no need for ● telnetd, ftpd, samba, ... ● tunnelling :-) ● Typical W32 clients ● PuTTy, WinSSH ● jcterm, mindterm ● GNU/Linux ● default
  • 112. 12/07/13 - Marc Leeman Company Confidential - 112 Buildroot ● Not just for toolchains ● Can build entire Linux systems ● Make files, downloads over net ● No root permissions required ● Used in D&A and Medical ● Used in several Open Source projects: ● OpenWrt, Gumstix, ...
  • 113. 12/07/13 - Marc Leeman Company Confidential - 113 Full blown Distributions ● Interesting option ● If disk(-like) storage available ● Little difference between SoC target and desktop/server ● Functionality is can easily be expanded ● Debugging tools ● Verification ● GNU/Debian supports 11 archs ● Lots of precompiled packages ● ~20.000 ● No need to cross compile
  • 114. 12/07/13 - Marc Leeman Company Confidential - 114 First stage bootstrap ● Nice for development together with NFS ● Debootstrap –verbose –variant=minbase  –keyring=/home/me/pubring.gpg –include=apt  –arch=armhf –foreign vclub /home/me/chroot­2013  ftp://cypher.barco.com/nvslinux  /usr/share/debootstrap/scripts/wheezy ● Result is a armhf target on an x86-64 machine ● Installation requires a 'second-stage' installation ● Does not run natively (<==> x86 (i386))
  • 115. 12/07/13 - Marc Leeman Company Confidential - 115 Second Stage bootstrap ● Qemu is needed ● QEMU can launch Linux processes compiled for one CPU on another CPU ● Fully system emulation ● Copy /usr/bin/qemu-static into $TARGET/usr/bin/qemu-static ● Why 'static'? ● Debootstrap /home/me/chroot­2013/  /debootstrap/debootstrap –second­stage
  • 116. 12/07/13 - Marc Leeman Company Confidential - 116 Qemu ● Spot the difference ● marc@drd1812:~/Development$ uname ­a ● Linux drd1812 3.9.4 #1 SMP PREEMPT Thu May 30 12:53:13 CEST 2013 x86_64 GNU/Linux ● marc@drd1812:~/Development$ sudo chroot dolphin­dev­env­2013­03­11/ ● root@drd1812:/ dolphin­dev$ uname ­a ● Linux drd1812 3.9.4 #1 SMP PREEMPT Thu May 30 12:53:13 CEST 2013 armv7l GNU/Linux
  • 117. 12/07/13 - Marc Leeman Company Confidential - 117 Packages ● a “package” refers to a compressed file archive containing all of the files that come with a particular application. ● Typical binary in nature ● Can install new functionality ● Can expand current functionality ● Can modify existing functionality ● Most common forms ● Debian package: file.deb ● Debian, Ubuntu, ... ● Redhat package: file.rpm ● Redhat, SuSE, Fedora, …
  • 118. 12/07/13 - Marc Leeman Company Confidential - 118 Packages ● Selective upgrade ● Once deployed, typical bugfixes, security fixes
  • 119. 12/07/13 - Marc Leeman Company Confidential - 119 Packages 101 ● Concept of a 'repo' ● Can be networked, on disk, on CD, USB, … ● deb ● deb­src ● Can be networked, on disk, on CD, USB, … ● In /etc/apt/sources.list.d/file.list ● deb ftp://cypher.barco.com/nvslinux/ vclub  main contrib non­free ● File, cdrom, http, ftp, copy, rsh, ssh, … ● Lots of command line, console and GUI front-ends
  • 120. 12/07/13 - Marc Leeman Company Confidential - 120 Packages 101 ● Update the package descriptions ● $ sudo apt­get update ● Install a single package ● $ sudo dpkg barco­mna240_123­1.deb ● Install a single package with dependencies from the network ● $ sudo apt­get install barco­mna240 ● $ sudo apt­get remove barco­mna280 ● $ sudo apt­get purge barco­mna280 ● Upgrade the system without installing extra packages ● $ sudo apt­get upgrade
  • 121. 12/07/13 - Marc Leeman Company Confidential - 121 Packages 101 ● Upgrade the system ● $ sudo apt­get dist­upgrade ● Search the package descriptions ● $ sudo apt­get search barco ● Show detailed package description ● $ sudo apt­get show barco­c12 ● Housekeeping ● Clear package cache ● $ sudo apt­get cache clear ● Remove unused packages ● $ sudo apt­get autoremove
  • 122. 12/07/13 - Marc Leeman Company Confidential - 122 Privilege separation ● Services run as a separate (unprivileged) user: e.g. webserver, ftp, ssh, … ● Security concerns
  • 123. 12/07/13 - Marc Leeman Company Confidential - 123 Setting up a Server
  • 124. 12/07/13 - Marc Leeman Company Confidential - 124 General ● Platform of choice: GNU/Debian ● the developers' platform ● powerful, handy package management ● Check with IT: ● we will need DHCP (conflicts with corporate) ● Alternate: 2 network cards, external (Barco), internal (my.net.local).
  • 125. 12/07/13 - Marc Leeman Company Confidential - 125 Needed & (Useful) ● NFS ● mount root filesystem without re-burning it to flash: much faster ● use larger filesystem than can be stored on flash for development ● DHCP/BOOTP ● cf. supra ● kernel send BOOTP package to get kernel/filesystem location over the network
  • 126. 12/07/13 - Marc Leeman Company Confidential - 126 Needed & (Useful) ● atftpd ● Trivial ftp protocol ● used by U-Boot to obtain files over the network ● used by BDI2000 to get files over the network ● (bind) ● DNS server ● e.g. bdi02.smd.localnet is handier than 10.2.0.17
  • 127. 12/07/13 - Marc Leeman Company Confidential - 127 Needed & (Useful) ● SSH ● Secure Shell ssh-keygen -t dsa -b 4096 scp ~/.ssh/id_dsa.pub me@remote: ssh me@remote 'mkdir -p ~/.ssh' ssh me@remote 'cat id_dsa.pub > ~/.ssh/authorized_keys' ● (Samba) ● Windows Share access ● (LDAP) ● Centralised account and rights and service management ● sudo & fakeroot ● selective super user root rights assignment
  • 128. 12/07/13 - Marc Leeman Company Confidential - 128 Conclusions ● improvements to upstream sources ● communicate upstream ● e.g. Das U-Boot ● e.g. buildroot ● Kernel changes ● minimise them ASAP ● reduces maintenance to a minimum ● focus on the important code ● Montavista, MetroWerx
  • 129. 12/07/13 - Marc Leeman Company Confidential - 129 References ● Update version of the examples, course text and slides: ● http://neo.barco.com/~mleeman/embedded_linux/ ● D&A info: ● http://ccwiki/EmbeddedLinuxTraining