Title: Topics in Embedded Systems
1COM609 Topics in Embedded Systems
Lecture 1. Embedded Systems vs General-Purpose
Systems
Prof. Taeweon Suh Computer Science
Education Korea University
2Embedded Systems
- Embedded System is a special-purpose computer
system designed to perform one or a few dedicated
functions -- Wikipedia - In general, it does not provide programmability
to users, as opposed to general purpose computer
systems like PC - Embedded systems are virtually everywhere in your
daily life
3Embedded Systems (Cont)
- Even though embedded systems cover a wide range
of special-purpose systems, there are common
characteristics - Low cost
- Should be cheap to be competitive
- Memory is typically very small compared to a
general purpose computer system - Lightweight processors are used in embedded
systems - Low power
- Should consume low power especially in case of
portable devices - Low-power processors are used in embedded systems
4Embedded Systems (Cont)
- High performance
- Should meet the computing requirements of
applications - Users want to watch video on portable devices
- Audio should be in sync with video
- Gaming gadgets like playstation should provide
high performance - Real-time property
- Job should be done within a time limit
- Aerospace applications, Car control systems,
Medical gadgets are critical in terms of time
constraint Otherwise, it could lead to
catastrophe such as loss of life - Will talk more about this
5Embedded Systems (Cont)
- It is challenging to satisfy the characteristics
- You may not be able to achieve high performance
while maintaining low power consumption and
making use of cheap components - So, you got to do your best in a given
circumstance to be competitive in the market
6HW/SW Stack of Embedded Systems
- Identical to the general-computer systems
7Components of Embedded Systems
- Hardware
- It is mainly composed of processor (1 or more),
memory, I/O devices including network devices,
timers, sensors etc.
8Components of Embedded Systems
- Software
- System software
- Operating systems
- Many times, a multitasking (multithreaded) OS is
required, as embedded applications become
complicated - Networking, GUI, Audio, Video
- Processor is context-switched to process multiple
jobs - Operating system footprint should be small enough
to fit into memory of an embedded system - In the past and even now, real-time operating
systems (RTOS) such as VxWorks or uC/OS-II have
been used because they are light-weighted in
terms of memory requirement - Nowadays, little heavy-weighted OSs such as
Windows-CE or embedded Linux (uClinux) are used,
as embedded processors support computing power
and advanced capabilities such as MMU (Memory
Management Unit) - Device drivers for I/O devices
9Components of Embedded Systems (Cont)
- Software (cont.)
- Application software
- Run on top of operating system
- Execute tasks that users wish to perform
- Web surfing, Audio, Video playback
10Real-Time System
- Real-time operating system (RTOS)
- Multitasking operating system intended for
real-time applications - RTOS facilitates the creation of real-time
systems - RTOS does not necessarily have a high throughput
- RTOS is valued more for how quickly and/or
predictably it can respond to a particular event - Hard real-time systems are required to complete a
critical task within a guaranteed amount of time - Soft real-time systems are less restrictive
- Implementing real-time system requires a careful
design of scheduler - System must have the priority-based scheduling
- Real-time processes must have the highest
priority - Priority inheritance (next slide)
- Solve the priority inversion problem
- Process dispatch latency must be small
11Priority Inversion Problem
- Pathfinder mission on Mars in 1997
- Used VxWorks, an RTOS kernel, from WindRiver
- Software problems caused the total system resets
of the Pathfinder spacecraft in mission - Watchdog timer goes off, informing that something
has gone dramatically wrong and initiating the
system reset
12Priority Inversion Problem
- VxWorks provides preemptive priority scheduling
of threads - Tasks on the Pathfinder spacecraft were executed
as threads with priorities that were assigned in
the usual manner reflecting the relative urgency
of these tasks.
Task 1 tries to get the semaphore
Task 1 gets the semaphore and execute
Task 1 preempts Task3
Priority Inversion
Task 1 (highest priority)
Task 2 (medium priority)
Task 2 preempts task 3
Task 3 (lowest priority)
Task 3 is resumed
Time
Task 3 gets semaphore
Task 3 is resumed
Task 3 releases the semaphore
13Priority Inheritance
- A chain of processes could all be accessing
resources that the high-priority process needs - All these processes inherit the high priority
until they are done with the resource - When they are finished, their priority reverts to
its original value
Task 1 tries to get the semaphore (Priority of
Task 3 is raised to Task 1s)
Task 1 preempts Task3
Task 1 completes
Priority Inversion
Task 1 (highest priority)
Task 2 (medium priority)
Task 3 (lowest priority)
Time
Task 3 gets semaphore
Task 3 is resumed with the highest priority
Task 3 releases the semaphore
14Operating Systems for Embedded Systems
- RTOSs
- pSOS
- VxWorks
- VRTX (Versatile Real-Time Executive)
- uC/OS-II
- Palm OS (source Wikipedia)
- Embedded operating system initially developed by
U.S. Robotics-owned Palm Computing, Inc. for
personal digital assistants (PDAs) in 1996 - Symbian OS (source Wikipedia)
- Proprietary operating system designed for mobile
devices by Symbian Ltd. - A descendant of Psion's EPOC and runs exclusively
on ARM processors - Android
- Open Handset Alliance Project
- Based on Linux 2.6 kernel
- http//code.google.com/android/
15Operating Systems for Embedded Systems
- Windows CE (WinCE) (source Wikipedia)
- Microsoft's operating system for minimalistic
computers and embedded systems - WinCE is a distinctly different operating system
and kernel, rather than a trimmed-down version of
desktop Windows - Embedded Linux (uClinux, ELKS, ThinLinux)
(source Wikipedia) - The use of a Linux operating system in embedded
computer systems - According to survey conducted by Venture
Development Corporation, Linux was used by 18 of
embedded engineers - Embedded versions of Linux are designed for
devices with relatively limited resources, such
as cell phones and set-top boxes - Due to concerns such as cost and size, embedded
devices usually have much less RAM and secondary
storage than desktop computers, and are likely to
use flash memory instead of a hard drive - Since embedded devices are used for specific
purposes rather than general purposes, developers
optimize their embedded Linux distributions to
target specific hardware configurations and usage
situations - These optimizations can include reducing the
number of device drivers and software
applications, and modifying the Linux kernel to
be a real-time operating system - Instead of a full suite of desktop software
applications, embedded Linux systems often use a
small set of free software utilities such as
busybox, and replace the glibc C standard library
with a more compact alternative such as dietlibc,
uClibc, or Newlib.
16Embedded System Design Flow
- ASIC Application-Specific Integrated Circuit
- SoC System-on-Chip
17A General-Purpose Computer System (till 2008)
CPU
Main Memory (DDR2)
FSB (Front-Side Bus)
North Bridge
Graphics card
DMI (Direct Media I/F)
Peripheral devices
South Bridge
Hard disk
USB
PCIe card
But, dont forget the big picture!
18Present, Near Future and More
Keep in mind that CPU and computer systems are
evolving at a fast pace
19x86 History (as of 2008)
20x86 History (Cont.)
32-bit (i386)
8-bit
16-bit
4-bit
32-bit (i586)
64-bit (x86_64)
32-bit (i686)
2009
Core i7
21x86?
- What is x86?
- Generic term referring to processors from Intel,
AMD and VIA - Derived from the model numbers of the first few
generations of processors - 8086, 80286, 80386, 80486 ? x86
- Now it generally refers to processors from Intel,
AMD, and VIA - x86-16 16-bit processor
- x86-32 (aka IA32) 32-bit processor IA
Intel Architecture - x86-64 64-bit processor
- Intel takes about 80 of the PC market and AMD
takes about 20 - Apple also have been introducing Intel-based Mac
from Nov. 2006
22Chipset
- We call North and South Bridges as Chipset
- Chipset has many PCIe devices inside
- North Bridge
- Memory controller
- PCI express ports to connect Graphics card
- http//www.intel.com/Assets/PDF/datasheet/316966.p
df - South Bridge
- HDD (Hard-disk) controller
- USB controller
- Various peripherals connected
- Keyboard, mouse, timer etc
- PCI express ports
- http//www.intel.com/Assets/PDF/datasheet/316972.p
df - Note that the landscape is being changed!
- For example, memory controller is integrated into
CPU
23PCI, PCI Express Devices
- PCI (Peripheral Component Interconnect)
- Computer bus connecting all the peripheral
devices to the computer motherboard - PCIe (PCI Express)
- Replaced PCI in 2004
- Point-to-point connection
PCI express slot x16
PCI express slots
PCI slot
http//www.pcisig.com/specifications/pciexpress/
24An Old GP Computer System Example
25PCI Express Slots in GP Systems
PCI express slot
26GP Computer System in terms of PCIe
North Bridge
South Bridge
27Core i7-based Systems
- Core i7 860 (Lynnfield) based system
- Core i7 920 (Bloomfield) based system
28Software Stack
Applications (MS-office, Google Earth)
API (Application Program I/F)
Operating System (Linux, Vista, Mac OS )
BIOS provides common I/Fs
BIOS (AMI, Phoenix Technologies )
Computer Hardware (CPU, Chipset, PCIe cards ...)
29How the GP Computer System Works?
- x86-based system starts to execute from the reset
address 0xFFFF_FFF0 - The first instruction is jmp xxx off from BIOS
ROM - BIOS (Basic Input/Output System)
- Detect and initialize all the devices (including
PCI devices via PCI enumeration) on the system - Provide common interfaces to OS
- Hand over the control to OS
- OS
- Manage the system resources including main memory
- Control and coordinate the use of the hardware
among various application programs for the
various users - Provide APIs for system and application
programming
30So What?
- How is it different from embedded systems?
- General-purpose computer systems provide
programmability to end-users - You can do any kinds of programming on your PC
- C, C, C, Java etc
- General-purpose systems should provide backward
compatibility - A new system should be able to run legacy
software, which could be in the form of binaries
with no source codes written 30 years ago - So, general purpose computer system becomes messy
and complicated, still containing all legacy
hardware functionalities
31x86 Operation Modes
- Real Mode ( real address mode)
- Programming environment of the 8086 processor
- 8086 is a 16-bit processor from Intel
- Protected Mode
- Native state of the 32-bit Intel processor
- For example, Windows is running in protected mode
- 32-bit mode
- IA-32e mode (64-bit mode)
- There are 2 sub modes
- Compatibility mode
- 64-bit mode
32Registers in 8086
- Registers inside the 8086
- 16-bit segment registers
- CS, DS, SS, ES
- General-purpose registers
- all 16-bits
- AX, BX, CX, DX, SP, BP, SI, DI
- Registers in x86-32
33Real Mode Addressing
- In real mode (8086), general purpose registers
are all 16-bit wide - Real model
- Segment registers specify the base address of
each segment - Segment registers
- CS Code Segment -gt used to store instructions
- DS Data Segment -gt used to store data
- SS Stack Segment -gt stack
- ES Extra Segment -gt could be used to store more
data - Addressing method
- Segment ltlt 4 offset physical address
- Example
- mov ax, 2000h
- mov ds, ax
- ? Data segment starts from 20000h (2000h ltlt 4)
34Data Segment in Real Mode
- Memory addressing in real mode (8086)
0xFFFFF
Main Memory (1MB)
mov ax, 2000h mov ds, ax mov al, 100h
20100h
100h
offset
2000h
DS
20000h 2000h ltlt 4
0x0
35A20M
- 8088/8086 allowed only 1MB memory access since
they have only 20-bit physical address lines - 220 1MB
- Memory is accessed with segmentoffset in
8086/8088 (still the same though) - What if CS0xFFFF, IP0x0020?
- CS ltlt 4 IP 0x100010
- But, we have only 20 address lines. So, 8088 ends
up accessing 0x00010 ignoring the 1 in A21 - Some (weird?) programmers took advantage of this
mechanism
36A20M (Cont)
- How about now?
- Your Core 2 Duo has 48-bit physical address lines
- What happens if there is no protection in the
previous case - Processor will access 0x100010, breaking the
legacy code - So, x86 provides a mechanism called A20M (A20
Mask) to make it compatible with the old
generations
37A20M (Cont)
38Another Example
- Protected mode addressing (32-bit)
- As application programs become larger, 1MB main
memory is too small - Intel introduced protected mode to address a
larger memory (up to 4GB) - But, Intel still wants to use 16-bit segment
registers for the backward compatability - How to access a 4GB space with a 16-bit register?
39Protected Mode Addressing
Hardware Inside the CPU (Registers)
Main memory
GDT
LDT
Segment Descriptor
Segment Descriptor
Segment Descriptor
Segment Descriptor
Segment Descriptor
Segment Descriptor
Segment Descriptor
Segment Descriptor
Segment Descriptor
Segment Descriptor
40Segment Descriptor Format
- Software (OS) creates descriptor tables (GDT, LDT)
41Address Translation in Protected Mode
42One More Example
- 8259 Interrupt Controller
Still in South Bridge