Professional Documents
Culture Documents
~ Kiran Divekar
Agenda
Basic Embedded systems
Embedded Linux
Tools, Development
Points to optimize
Embedded Linux
Run on Limited Resource
Real Time
Dedicated Device Drivers
Sixnet VersaTRAK IPm
Embedded Linux
PowerPC CPU
16MB DRAM 16MB Flash
Serial & Ethernet Ports
Linux and IEC1131 Programming/Modbus
Sharp Zaurus
Lineo Embedix
206 MHz StrongARM
64 MB DRAM 16MB Flash
3.5 display (320x240) 64K
colors
Opera browser & Qtopia
QT/Embedded GUI
Cell and Web Phones
Telepong Mobile
Phone
GITWiT Mobile
Aplio/PRO IP Phone
Phone
TiVO Set Top Box
uCLinux
Built-in Ethernet port
100 MHz ETRAX CPU
16 MB RAM
Humanoid Robots
Univ. of
Tokyo/Kawanda
Ind.
Dual Pentium CPU
RT-Linux
Height: 53 inches
Weight: 121 lbs.
Isamu
Humanoid Robots
HOAP
Fujitsu
RT-Linux
Height: 48 cm
Weight: 6 kg
100 units/yr
What is an Embedded OS?
- Donald Gillies
What is Real Time?
Hard
guaranteed worst-case response times
absolutely, positively, first time every time
Soft
Kinda, sorta, usually
What makes a good RTOS?
Embedded NT/XP
Real-time control
Windows CE (CE.NET)
Internet devices
Pocket PC 2002
Handheld PCs and PDAs
Commercial Embedded Linux
Neoware NeoLinux
Red Hat derived for information appliances
PalmPalm Tynux
Internet appliuance and multimedia
Red Hat Embedded Linux
general purpose embedded solution
RedSonic Red-Ice Linux
runs from DiskonChip or CompactFlash
Commercial Embedded Linux
Bluecat Linux
TimeSys Linux GPL
low latency enhanced kernel
Tuxia TASTE
distro targets Internet appliances
Open Source Embedded Linux
Embedded Debian Project
convert Debian to an embedded OS
ETLinux
for PC104 SBCs
uCLinux
for microprocessors that dont have MM
uLinux (muLinux)
distro fits on a single floppy
Commercial Linux RTOS
GUI Applications
Applications
GUI
Kernel
Device Driver
Hardware
Linux on PC
Memory
#
#
#hello world :-( PC User Apps
#
#
Keybo Kernel
ard
IO
Devices
Disk File File System
System
File system on disk
Linux on Embedded System
Memory
User Apps
CPU IO
Kernel
RAM ROM
File System
Kernel Kernel
Device
Driver Display Adaptor Keyboard Driver
#
# Keybo
#hello world :-( ard
#
#
UI on Embedded System
Printf Scanf
Kernel Kernel
Device
Driver Display Adaptor Keyboard Driver
LCD Button
Touch
UART
Replacing Replacing screen
Displayer Keyboard
LED UART
Network Network
UI on UART
Printf Scanf
Kernel
Kernel
Device
Driver UART Driver
Txd Rxd
Layout
System Bootloader
Kernel
Memory ROM
Rootdisk
Usage
(Static)
RAM
System Bootloader
Kernel
Memory ROM
Rootdisk
Usage
(Running) Kernel
Rootdisk
RAM
User
Memory
Debugging Using The Ethernet
Ethernet
RS232
Linux
Local kernel
Booting
RAM
RAM Disk
0x0xffe00000
u-boot
Zipped Linux
ROM kernel
Zipped root
image
Remote Booting (U-Boot on MPC860)
Zipped Linux
Linux
kernel 192.168.0.3
kernel
DHCP server
NFS server
0x0xffe00000
Bootloader ROM
Kernel
Rootdisk
Init Board
Also support some basic
debugging function
Loading Kernel
From ROM or From
Remote Server RAM
Load Root Image
Starting Kernel
Root Disk
Host Target Development environment
Arm targets : Linux supports 10 distinct ARM
Advanced RISC Machine
http://www.arm.linux.org.uk
SCSI, USB, I2C buses
Parallel, Serial ports
MTD storage
Host Target
Host: Development machine
Target: Embedded target system
PC
With NFS Server
Development
Ethernet Board
1111011 Cable
1110101 (Running
1101010 Linux)
uclibc
C Compiled with Compiled statically
program shared libraries
ls Busybox
/dev/console Device files
myapp cross-compiled application
Kernel XIP
Kernel code is not copied into RAM, thus
saving the size of the uncompressed
kernel executable (at least 1 MB, often 2
or 3 MB).
Static or dynamic linking? (1)
Static linking
All shared library code duplicated in the
executables
Allows not to copy the C library in the
filesystem.
Simpler and smaller when very few
executables (busybox)
Library code duplication: bad for systems
with more executables, best for small
systems with few executables!
Static or dynamic linking? (2)
Dynamic linking
Shared library code not duplicated in the
executables
Makes much smaller executables
Saves space in RAM (bigger executables
take more RAM)
How to use uClibc?
Need to compile all your executables with
a uClibc toolchain.
Ready-to-use toolchains
You also have to copy the uClibc files
from the toolchain to the /lib directory in
the target root filesystem.
Need for stripping
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%)
Don't forget to strip libraries too!
Are my executables stripped?
You can use the file command to get the answer
file hello
hello: ELF 32-bit LSB executable,
Intel 80386, version 1 (SYSV), for
GNU/Linux 2.2.5, dynamically linked
(uses shared libs), not stripped
strip hello
hello: ELF 32-bit LSB executable,
Intel 80386, version 1 (SYSV), for
GNU/Linux 2.2.5, dynamically linked
(uses shared libs), stripped
How to strip
Some lightweight tools, like busybox, are
automatically stripped when you build them.
Makefiles for many standard tools offer a
special command:
make install-strip
Caution: stripping is architecture
dependent.
Use the strip command from your cross-
compiling toolchain:
arm-linux-strip potato
sstrip: super strip
Goes beyond strip and can strip out a few
more bits that are not used by Linux to start
an executable.
Library Optimizer
http://libraryopt.sourceforge.net/
Examines the complete target file system,
resolves all shared library symbol
references, and rebuilds the shared
libraries with only the object files required
to satisfy the symbol references.
Can also take care of stripping executables
and libraries.
Compiler space optimizations
Regular compiler optimizations simplifying
code also reduce size
You can also reduce the size of
executables by asking gcc to optimize
generated code size:
gcc -Os -o husband husband.c
-Os corresponds to -O2 optimizations
except the ones increasing size, plus extra
size-specific ones.
Restartable applications
http://www.suspend2.net/
Lots of great features for notebook users,
such as RAM suspend or hibernate to disk.
Unfortunately, restricted on some Intel
compatible processors and targeting only
machines with APM or ACPI
Not addressing the requirements of
embedded systems
Reducing power consumption -
Summary
Tickless operation
CPU frequency control
Suspend hidden GUIs
Software suspend (for PC embedded
systems)
Kernel and application XIP
Power management in device drivers
Kernel Function Trace
Kernel Function Trace (KFT)
Kernel function tracing system, to answer
questions such as:
What functions are called?
How long to the functions take?
How many times are the functions called?
In which functions is most time spent?
Many details and a very good presentation:
http://elinux.org/Kernel_Function_Trace
Use a swap partition
For embedded systems with a hard disk
Even if your system never gets out of RAM, and swapping
is not used much in embedded systems, it could make
sense!
With a swap partition, the system can swap out memory
pages which haven't been used recently, making more
RAM available for caching frequently accessed files.
This should improve overall throughput, but may also
reduce system responsiveness. Bad for real-time
systems!
Caution: do not use flash storage as a swap partition!
Use mlockall()
Parts of the address space of a process may be
swapped out or not loaded yet (on-demand paging:
the kernel only loads process pages with are
actually accessed, and loads other ones when
actually accessed). This causes unpredictable
delays in process execution.
The mlockall() system call can be used to make
sure that the entire address space of a running
process is loaded in RAM.
Useful for real-time applications needing
predictable response time.
Debugging
Gdb server on Target
Target remote over serial/network
Unstripped binaries at host
Mechanisms to export cores.
Accidental reboots.
Remote
Debugging Remote PC
Running Linux
Ethernet
GDB
Cable
GBD Server
Debugging Using RS232 Port
Ethernet
RS232
Unified tools
Metroworks
Further info
Home page:
http://handhelds.org/
Mailing lists:
http://www.handhelds.org/email_lists.html
For Further Info
Web Sites
LinuxDevices.com
http://www.linuxdevices.com/
Embedded Linux Consortium
http://www.embedded-linux.org/index.php3
All Linux Devices
http://alllinuxdevices.com/
Embedded Linux StarGate
http://linux-embedded.com/
For Further Info
Web Sites/Magazines
Dr. Dobbs Embedded Systems
http://www.ddjembedded.com/about/