Introduction to Embedded Systems
Copyright Copyright © 2011 to author(s). All rights reserved All content in this presentation, including charts, data, artwork and logos (from here on, "the Content"), is the property of  Amr Ali  or the corresponding owners, depending on the circumstances of publication, and is protected by national and international copyright laws. Authors are not personally liable for your usage of the Content that entailed casual or indirect destruction of anything or actions entailed to information profit loss or other losses. Users are granted to access, display, download and print portions of this presentation, solely for their own personal non-commercial use, provided that all proprietary notices are kept intact.  Product names and trademarks mentioned in this presentation belong to their respective owners. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Course Objective After completing this course, you will answer: What is an embedded systems? What is an embedded hardware? What is embedded software? What are the embedded systems development tools? Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Course Notes Set your cell phone to vibrate. I assume you know computer architecture. Ask any time. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Course References Embedded Systems Architecture 2 nd  Edition, Tammy Noergaard Introduction to Real-Time Operating Systems, by David Kalinsky http://en.wikipedia.org/ Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Course Outline Introduction Embedded Hardware Embedded Software Embedded Development Tools Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Course Outline Introduction Embedded Hardware Embedded Software Embedded Development Tools Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
What is a Computer System? A programmable machine that executes a sequence of operations to perform certain functions. A computer system consists of: Hardware Software Examples include: Servers PCs Embedded systems Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems Software Hardware
Hardware The physical component of a computer system. HW is:  Harder to develop Customized to a specific application Of better performance  in high-speed systems Examples include: Processor Memories IOs  Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Software The non-physical part of a computer system. SW is: Highly configurable Faster to develop Easier to update Cheaper to develop Of limited performance by the HW it runs on Examples include: Applications Operating systems Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
What is a General Purpose System? A computer system that can do many functionalities depending on: Available hardware Installed programs Examples include: PCs Servers Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
What is an Embedded System? A special purpose computer system that can perform a single or few functionalities. Functionalities are done by dedicated HW and SW with limited resources. On average, a person interacts with 100s of embedded systems on daily basis. Embedded systems are of high diversity. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Embedded Systems Examples Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Characteristics of Embedded Systems - Dependability Reliability Maintainability Availability Safety Security Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Characteristics of Embedded Systems - Efficiency Energy Code size Run-time Weight Cost Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Characteristics of Embedded Systems - Dedication Dedicated user interface No mouse, no screen, no keyboard… Dedicated towards an application Knowledge at design time can be used to minimize resources and maximize robustness Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Characteristics of Embedded Systems – Meeting Real-Time Constraints React to stimuli within a time interval dictated by the system specs Right answers arriving too early or too late are wrong. An embedded system can be a: Hard real-time system Firm real-time system Soft real-time system Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Characteristics of Embedded Systems – Connection to a Physical Environment Through sensors and actuators Hybrid systems Analog, digital, mechanical… Typically, embedded systems are reactive. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Embedded Versus General Purpose Systems Embedded Few applications A part of a bigger system Not programmed by end users Harder to develop General Purpose Board class of application Standalone or integrated in parallel with other systems End users programmable Easier to develop Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Embedded Systems Architecture Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems Device Drivers  Operating Systems Middleware Application SoC Memories Peripherals
Exercise 1: Characterize an Embedded System Goal: Identify embedded systems characteristics Each group of 2 persons should:  Pick an embedded system Identify its characteristics Time: 15 minutes Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Course Outline Introduction Embedded Hardware Embedded Software Embedded Development Tools Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
CPU, Processor, and SoC Amr Ali Abdel-Naby@2011 Introduction to STM32 STM32 SoC
Central Processing Unit AKA CPU Core of most of digital systems Performs arithmetic, control, data, and IO operations Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
CPU Structure Registers Internal bus Address Data Control  CU: Control Unit ALU: Arithmetic and Logic Unit Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems CU Registers ALU Internal Bus
Registers Temporal storage inside the CPU Flip-flops and latches A register can be: A general purpose register Carry out program or data processing A control register Controls the program or the CPU A status/flag register Shows the current state of the CPU Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
ALU Carries on: Arithmetic operations +, -, … Logic operations AND, OR, SHIFT… Operates and stores results in general registers Stores operation status in flag/status registers Carry occurrence, overflow occurrence… Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
CU Controls the internal flow to fetch, decode, and execute an instruction Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems Instruction Program Counter Memory Device Instruction Register Instruction Decoder Control Signal Generator
Pipelining Continuous and parallel streaming of instruction to the CPU A method of achieving higher execution speed at same clock speed Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems With pipelining, same number of instructions executes in less time. F D E F D E F D E F D E F D E F D E
Types of CPUs CISC Complex Instruction Set Introduced in 1960s Memory referencing operations 100s of assembly instructions Complex in design Simple compilers Targets code size RISC Reduced Instruction Set Introduced in 1950s Load/store architecture Around 40 assembly instructions per CPU Simple in design Complex compilers Targets performance Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Processor  In addition to the CPU, it may have: Cache memories Memory management unit Memory protection unit System Bus Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Cache Memories System performance is lowered  due to slow bus and memory  regardless of the CPU speed. Improved performance by using  a high speed memory to store  frequently accessed instructions/data. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems Bus  (66 MHz) Bus  (66 MHz) CPU (400 MHz) Memory Device (10 MHz) CPU + Cache (400 MHz) Memory Device (10 MHz)
Read Operation with a Cache Cache hit A requested instruction/data is in cache Cache performance is high when cache hit rate is high Cache miss A requested instruction/data is not in cache Cache performance is low when cache miss rate is high Line fill Retrieving instruction/data from external memory to cache incase of cache miss Cache retrieves a group of instructions/data Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Write Operation with a Cache Write through A CPU writing to a certain address writes to both external memory and caches. Write back A CPU writing to a certain address writes to caches only and postpones writing to external memories to a later time. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Memory Management Unit AKA MMU It is used for address translation from virtual address to physical address. It provides memory protection functions as well. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems VA PA CPU Memory Device MMU
System Bus Connects the processor to the external memories. There are 2 famous bus architectures: Von-Neumann Harvard Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems CPU Instruction/Data Memories CPU Instruction Memory Data Memory
System on Chip Due to advancements in silicon technologies, it is possible to add more functionalities to the processor on chip. A processor tends to be a complete system on chip. In addition to the processor, it may have: Co-processors Memories Direct Memory Access Internal IO devices IO controllers Interrupt controller Peripherals Bus Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Co-Processor A processor that supplements the functions of the primary processor. Extensions include: Floating point operations Graphics Digital signal processors Encryption processors Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Memories They are used to store instructions and data. They can be divided into: Volatile memory When power is off, contents are lost. Non-volatile memory When power is off, consents are preserved. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Volatile Memories Versus Non-Volatile Memories Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Direct Memory Access A coprocessor that allows data transfers without the interference of the processor. A key player in for HW concurrency. It can move data between: Memories A memory and IO device The speed is limited by the speed of the slowest device in the transfer. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems CPU DMA Memory IO Device
IO Devices They exchange information with the processor. They include digital and non-digital signals. Only digital signals are interfaced directly to the CPU.  Not all IO devices can be integrated on the chip. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Internal IO Devices They can be integrated on chip because they Are physically silicon devices Have small size Examples include: Memories ADCs RTCs IO controllers Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
External IO Devices Devices can’t be integrated on chip because they: Are physically non silicon devices Have large size that is not easily integrated on chip Have a bus interface that is different from that is used internally Examples include: LCD Keypad Speakers Mic Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
IO Controllers They are used to interface the off-chip IO devices to the chip. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems CPU Signals Device Signals CPU IO Device IO Control
IO Address Allocation This is necessary to control the IO devices. There are 2 types: IO mapped IO Exclusive address space for the IO devices Widely used in PC world Memory mapped IO IO devices and memories share same address space Widely used in embedded systems Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Memory Mapped IOs versus IO Mapped IOs IO Mapped x86… Exclusive IO region Different instructions to access IO  Processor has a single pin that separates the IO from memory. Memory Mapped ARM, PPC, MIPS, x86.. A memory region Same instruction to access memory and IO  External address decoder decodes the address and decides whether to select a memory or a device. IO region must be non-cacheable and all IO variables must be declared as volatile. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
IO Management Polling A program continuously checks the IO device Interrupt If an IO device needs processor attention, it interrupts the processor. A key player for multi-tasking and real-time DMA Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Interrupt Controller Extends interrupt signals of the processors Offloads the CPU by doing some of interrupt processing  Extra level of interrupt control Maps the interrupt signal to the processor interrupt signal Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems CPU IO Device Interrupt Control
Interrupt Processing Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems Interrupt Control
On Chip Bus Connects the components of the SoC Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Types of the SoC Application specific integrated circuit (ASIC) Programmable HW FGPAs CPLDs Application specific instruction set processors (ASIPs) DSPs Media processors Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Implementation Tradeoff Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Embedded Boards PCBs that can be used to run an embedded SW on top of it.  It has: SoC’s Memories IOs A development board can be an evaluation board or a solution board. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Embedded Boards  cont’d Evaluation boards Boards that has a controller and all possible IOs that the controller can connect to. Used by controller manufacturers to test their own chip. Design houses use them to develop their products’ prototypes. Solutions boards Used in actual product Subset or a tuned version of the evaluation board Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Exercise 2: Identify Your Embedded System Hardware Goal: Identify embedded systems hardware Each group of 2 persons should:  Identify the embedded hardware for the example in exercise 1 Time: 15 minutes Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Course Outline Introduction Embedded Hardware Embedded Software Embedded Development Tools Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Program A SW that the hardware understands and runs to achieve a specific result. A program is written in 1 or more programming languages. A program may compose or can be a mix of: Application Middleware Operating system Device Driver Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems Device Drivers  Operating Systems Middleware Application
Programming Languages in Embedded Systems They can be: Low level Assembly Machine code High level C/C++ Java  Ada Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Machine Code and Assembly Programming Machine code is 1’s and 0’s only Understood by processor only Inconvenient to write a program with Mnemonic code Machine code converted to symbols understood by programmers Assembly language mnemonic code + pseudo instructions to improve programs readability Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Assembly Instructions Instruction consists of mnemonic (opcode) and operands Opcode is an action taken by a processor Operands is the target the opcode should take an action for/on ADD A, B, C Opcode: ADD Operands: A, B, and C Symantec: register A = register B + register C Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Pros and Cons of Assembly Language Pros Readable and understandable compared to machine code Easier to debug and maintain compared to machine code Cons Knowledge of HW and processor internals is necessary Processor specific Limited capabilities Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
C/C++ Programming Processor independent Flexible Easier to write Assembly can be inlined in C/C++ Greater productivity Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Bootloader  The first program that should run when the system starts. Initial code written in assembly and then switches to C/C++. Initializes the HW for proper SW operation and jumps to the first program to run on the system. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Device Drivers Pieces of SW that interface directly to/abstracts the HW devices. A device driver is divided into 2 layers: Low level: HW dependent High level: OS dependent Device drivers are installed during bootloading or when a device is used for the 1 st  time in the system or whenever the device is plugged. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems HLD Operating Systems Middleware Application LLD
Operating System A SW that manages HW and SW system resources. It provide HW abstraction as well. Windows and Unix can be used in embedded systems. Another class of OSs called RTOS fits more in embedded systems. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Middleware AKA libraries Pieces of SW that solve a generic problem are gathered to form a middleware. Examples: GUI libraries Video/Audio Decoders USB stack TCP/IP stacks Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Application Pieces of SW that: Interface to the user Tunes the middleware Uses the OS and device drivers To solve a specific problem Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Embedded SW Application Form There are several different types of SW architecture in use: Endless loop Cyclic execution Interrupt controlled system Cooperative multi-tasking Preemptive multitasking Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
The Endless Loop No tasks Polled device I/O only Often, performance too slow Amr Ali Abdel-Naby@ 2009 Real-Time Operating Systems DO FOREVER Request Input Device make a Measurement Wait for the Measurement to be ready Fetch the Value of the Measurement Process the Value of the Measurement IF Value is Reasonable THEN Prepare new Result using Value  ELSE Result will be an Error Report Request Output Device deliver the Result Wait for the Result to be output Confirm that output is OK END DO
Basic Cyclic Executive Endless loop of tasks Tasks as independent as possible Separate application issues. Little interaction Tasks share information easily. Write/Read shared data Polled device I/O only Time of complete loop determines real-time. Amr Ali Abdel-Naby@ 2009 Real-Time Operating Systems
Time-Driven Cyclic Executive More precise timing Timer interrupt determines real-time. Sharing data OK Polled device I/O only (except timer) Amr Ali Abdel-Naby@ 2009 Real-Time Operating Systems
Multi-Rate Cyclic Executive Some tasks need higher rate. Integer multiple of base rate Major cycle/Minor cycle(s) Sharing data OK Polled device I/O only (except timer) Amr Ali Abdel-Naby@ 2009 Real-Time Operating Systems
Limitation of Cyclic Executives Polled device I/O only Too low rate: Miss transient occurrences Too high rate: Waste CPU power Prefer interrupt-driven I/O Timing of task executions imprecise Data-dependent loops SW maintenance nightmare Amr Ali Abdel-Naby@ 2009 Real-Time Operating Systems
Caution Adding Interrupts  Interrupt service routine (ISR) May need to pass data to task it is interrupting Possible result: Inconsistent data Amr Ali Abdel-Naby@ 2009 Real-Time Operating Systems HW I/P Device ISR Shared Data Area SW using Data  from ISR Old New
Multi-Rate Executive with Interrupts ISRs write to one set of buffers. Tasks use data from another set of buffers. At each clock tick, data are copied. Not a weekend “Garage” project Sharing data among tasks, OK Polled and interrupt-driven device I/O Amr Ali Abdel-Naby@ 2009 Real-Time Operating Systems HW I/P Device ISR Shared Data Area Task Data Buffers DI Copy data from ISR buffers  to task buffers EI
Faster Response: Preemptive Scheduling All previous schedulers: Non-Preemptive Preemptive Scheduling == Task switches can take place at any point/time Tasks can be switched in mid-execution. Preemptive scheduler is very complex. Polled and interrupt-driven device I/O are OK. ISR data not delayed by a tick    Task can respond at once Amr Ali Abdel-Naby@ 2009 Real-Time Operating Systems Task 1 Task 2 Task 3 HW I/P Device ISR Task 3
Preemptive Scheduling Issues Which task can preempt which task? Answer is in priority. Sharing data, Not OK OS provide safe mechanism for passing data between ISRs/Tasks. Amr Ali Abdel-Naby@ 2009 Real-Time Operating Systems Shared Data Area Task 1 Task 1 cont’d Task 2 with higher priority
An Intertask Communication Catalog Data Transfer: Destructive reading, non-destructive writing Message queues Direct message passing Indirect message passing  Mailboxes Pipes Data Transfer: Destructive writing, non-destructive reading RTOS-protected globals: notepad registers, environment variables, … Shared data area protected by a mutual exclusion mechanism. Amr Ali Abdel-Naby@ 2009 Real-Time Operating Systems
An Intertask Communication Catalog  cont’d -ve synchronization == mutual exclusion Semaphores Mutexes +ve synchronization Event flags Condition variables Signals  Amr Ali Abdel-Naby@ 2009 Real-Time Operating Systems
Exercise 3: Identify Your Embedded System Software Goal: Identify embedded systems hardware Each group of 2 persons should:  Identify the embedded software for the example in exercise 1 Time: 15 minutes Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Course Outline Introduction Embedded Hardware Embedded Software Embedded Development Tools Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Embedded Development Tools Depending on your business, you may need different set of tools. Integrated Device Manufacturer (IDM) Original Equipment Manufacturer (OEM) Embedded SW design house I will try to focus on the most commonly used tools. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Assembler A SW program that converts source code written in assembly language into machine language. Examples include: GNU assembler Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Compiler A SW program that converts source code written in a high level programming language into another programming language. C/C++    Assembly or Machine language Compilation can be: Native: Compiler and generated executables run on the same processor.  Cross: Compiler runs on a processor and the generated executables runs on a different processor. Examples include: ARMCC GCC Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Linker and Locator A linker is a SW program that links the compilation and assemble operations’ outputs into a single executable. A locator is a SW program that can change the memory map of the linker output. It is common these days to see a combined linker-locator tool. Examples include: GCC Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Simulator A SW program that imitates a real thing, state of affairs, or processes. Simulation is an approximation of the real time system. A simulator is used when: The real platform is not available. It is dangerous to test on real system directly. Examples include: Proteus Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Debugger A SW program + HW device that interfaces my PC to my embedded HW. It can be used to: Set breakpoints Dump memories Trace execution Watch variables The HW can be  In circuit debugger Debug agent SW on bard Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Flash Loader A SW program + HW device that interfaces my PC to my embedded HW. It can be used to: Erase ROM/Flash Read ROM/Flash Program ROM/Flash Watch variables Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Profiler A SW program that gathers information about a program during execution. Profiler is used to know which areas of code to optimize speed and memory. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Integrated Development Environment A SW program that provides a comprehensive facilities for programmers. It includes: Assemblers Compilers Linkers Debuggers Simulators Profilers Text editors Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Schematic Capture/Circuit Design Tool A SW program that allows the circuit designer to enter his circuit design into CAD tools. It is used for: Design simulation Design sketching Examples include: OrCAD KiCAD Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
PCB Layout Design Tool A SW program that allows the transformation of the circuit schematic capture into PCB layout that cab printed on a circuit board. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Oscilloscope A HW Device that allows observation of constantly varying voltages. It observes the exact wave shape across time. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
Exercise 4: Identify Your Embedded System Development Tools Goal: Identify embedded systems development tools Each group of 2 persons should:  Identify the embedded system development tools for the example in exercise 1 Time: 15 minutes Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems

Introduction to embedded systems

  • 1.
  • 2.
    Copyright Copyright ©2011 to author(s). All rights reserved All content in this presentation, including charts, data, artwork and logos (from here on, "the Content"), is the property of Amr Ali or the corresponding owners, depending on the circumstances of publication, and is protected by national and international copyright laws. Authors are not personally liable for your usage of the Content that entailed casual or indirect destruction of anything or actions entailed to information profit loss or other losses. Users are granted to access, display, download and print portions of this presentation, solely for their own personal non-commercial use, provided that all proprietary notices are kept intact. Product names and trademarks mentioned in this presentation belong to their respective owners. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 3.
    Course Objective Aftercompleting this course, you will answer: What is an embedded systems? What is an embedded hardware? What is embedded software? What are the embedded systems development tools? Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 4.
    Course Notes Setyour cell phone to vibrate. I assume you know computer architecture. Ask any time. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 5.
    Course References EmbeddedSystems Architecture 2 nd Edition, Tammy Noergaard Introduction to Real-Time Operating Systems, by David Kalinsky http://en.wikipedia.org/ Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 6.
    Course Outline IntroductionEmbedded Hardware Embedded Software Embedded Development Tools Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 7.
    Course Outline IntroductionEmbedded Hardware Embedded Software Embedded Development Tools Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 8.
    What is aComputer System? A programmable machine that executes a sequence of operations to perform certain functions. A computer system consists of: Hardware Software Examples include: Servers PCs Embedded systems Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems Software Hardware
  • 9.
    Hardware The physicalcomponent of a computer system. HW is: Harder to develop Customized to a specific application Of better performance in high-speed systems Examples include: Processor Memories IOs Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 10.
    Software The non-physicalpart of a computer system. SW is: Highly configurable Faster to develop Easier to update Cheaper to develop Of limited performance by the HW it runs on Examples include: Applications Operating systems Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 11.
    What is aGeneral Purpose System? A computer system that can do many functionalities depending on: Available hardware Installed programs Examples include: PCs Servers Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 12.
    What is anEmbedded System? A special purpose computer system that can perform a single or few functionalities. Functionalities are done by dedicated HW and SW with limited resources. On average, a person interacts with 100s of embedded systems on daily basis. Embedded systems are of high diversity. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 13.
    Embedded Systems ExamplesAmr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 14.
    Characteristics of EmbeddedSystems - Dependability Reliability Maintainability Availability Safety Security Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 15.
    Characteristics of EmbeddedSystems - Efficiency Energy Code size Run-time Weight Cost Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 16.
    Characteristics of EmbeddedSystems - Dedication Dedicated user interface No mouse, no screen, no keyboard… Dedicated towards an application Knowledge at design time can be used to minimize resources and maximize robustness Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 17.
    Characteristics of EmbeddedSystems – Meeting Real-Time Constraints React to stimuli within a time interval dictated by the system specs Right answers arriving too early or too late are wrong. An embedded system can be a: Hard real-time system Firm real-time system Soft real-time system Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 18.
    Characteristics of EmbeddedSystems – Connection to a Physical Environment Through sensors and actuators Hybrid systems Analog, digital, mechanical… Typically, embedded systems are reactive. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 19.
    Embedded Versus GeneralPurpose Systems Embedded Few applications A part of a bigger system Not programmed by end users Harder to develop General Purpose Board class of application Standalone or integrated in parallel with other systems End users programmable Easier to develop Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 20.
    Embedded Systems ArchitectureAmr Ali Abdel-Naby@2011 Introduction to Embedded Systems Device Drivers Operating Systems Middleware Application SoC Memories Peripherals
  • 21.
    Exercise 1: Characterizean Embedded System Goal: Identify embedded systems characteristics Each group of 2 persons should: Pick an embedded system Identify its characteristics Time: 15 minutes Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 22.
    Course Outline IntroductionEmbedded Hardware Embedded Software Embedded Development Tools Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 23.
    CPU, Processor, andSoC Amr Ali Abdel-Naby@2011 Introduction to STM32 STM32 SoC
  • 24.
    Central Processing UnitAKA CPU Core of most of digital systems Performs arithmetic, control, data, and IO operations Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 25.
    CPU Structure RegistersInternal bus Address Data Control CU: Control Unit ALU: Arithmetic and Logic Unit Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems CU Registers ALU Internal Bus
  • 26.
    Registers Temporal storageinside the CPU Flip-flops and latches A register can be: A general purpose register Carry out program or data processing A control register Controls the program or the CPU A status/flag register Shows the current state of the CPU Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 27.
    ALU Carries on:Arithmetic operations +, -, … Logic operations AND, OR, SHIFT… Operates and stores results in general registers Stores operation status in flag/status registers Carry occurrence, overflow occurrence… Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 28.
    CU Controls theinternal flow to fetch, decode, and execute an instruction Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems Instruction Program Counter Memory Device Instruction Register Instruction Decoder Control Signal Generator
  • 29.
    Pipelining Continuous andparallel streaming of instruction to the CPU A method of achieving higher execution speed at same clock speed Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems With pipelining, same number of instructions executes in less time. F D E F D E F D E F D E F D E F D E
  • 30.
    Types of CPUsCISC Complex Instruction Set Introduced in 1960s Memory referencing operations 100s of assembly instructions Complex in design Simple compilers Targets code size RISC Reduced Instruction Set Introduced in 1950s Load/store architecture Around 40 assembly instructions per CPU Simple in design Complex compilers Targets performance Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 31.
    Processor Inaddition to the CPU, it may have: Cache memories Memory management unit Memory protection unit System Bus Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 32.
    Cache Memories Systemperformance is lowered due to slow bus and memory regardless of the CPU speed. Improved performance by using a high speed memory to store frequently accessed instructions/data. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems Bus (66 MHz) Bus (66 MHz) CPU (400 MHz) Memory Device (10 MHz) CPU + Cache (400 MHz) Memory Device (10 MHz)
  • 33.
    Read Operation witha Cache Cache hit A requested instruction/data is in cache Cache performance is high when cache hit rate is high Cache miss A requested instruction/data is not in cache Cache performance is low when cache miss rate is high Line fill Retrieving instruction/data from external memory to cache incase of cache miss Cache retrieves a group of instructions/data Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 34.
    Write Operation witha Cache Write through A CPU writing to a certain address writes to both external memory and caches. Write back A CPU writing to a certain address writes to caches only and postpones writing to external memories to a later time. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 35.
    Memory Management UnitAKA MMU It is used for address translation from virtual address to physical address. It provides memory protection functions as well. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems VA PA CPU Memory Device MMU
  • 36.
    System Bus Connectsthe processor to the external memories. There are 2 famous bus architectures: Von-Neumann Harvard Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems CPU Instruction/Data Memories CPU Instruction Memory Data Memory
  • 37.
    System on ChipDue to advancements in silicon technologies, it is possible to add more functionalities to the processor on chip. A processor tends to be a complete system on chip. In addition to the processor, it may have: Co-processors Memories Direct Memory Access Internal IO devices IO controllers Interrupt controller Peripherals Bus Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 38.
    Co-Processor A processorthat supplements the functions of the primary processor. Extensions include: Floating point operations Graphics Digital signal processors Encryption processors Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 39.
    Memories They areused to store instructions and data. They can be divided into: Volatile memory When power is off, contents are lost. Non-volatile memory When power is off, consents are preserved. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 40.
    Volatile Memories VersusNon-Volatile Memories Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 41.
    Direct Memory AccessA coprocessor that allows data transfers without the interference of the processor. A key player in for HW concurrency. It can move data between: Memories A memory and IO device The speed is limited by the speed of the slowest device in the transfer. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems CPU DMA Memory IO Device
  • 42.
    IO Devices Theyexchange information with the processor. They include digital and non-digital signals. Only digital signals are interfaced directly to the CPU. Not all IO devices can be integrated on the chip. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 43.
    Internal IO DevicesThey can be integrated on chip because they Are physically silicon devices Have small size Examples include: Memories ADCs RTCs IO controllers Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 44.
    External IO DevicesDevices can’t be integrated on chip because they: Are physically non silicon devices Have large size that is not easily integrated on chip Have a bus interface that is different from that is used internally Examples include: LCD Keypad Speakers Mic Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 45.
    IO Controllers Theyare used to interface the off-chip IO devices to the chip. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems CPU Signals Device Signals CPU IO Device IO Control
  • 46.
    IO Address AllocationThis is necessary to control the IO devices. There are 2 types: IO mapped IO Exclusive address space for the IO devices Widely used in PC world Memory mapped IO IO devices and memories share same address space Widely used in embedded systems Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 47.
    Memory Mapped IOsversus IO Mapped IOs IO Mapped x86… Exclusive IO region Different instructions to access IO Processor has a single pin that separates the IO from memory. Memory Mapped ARM, PPC, MIPS, x86.. A memory region Same instruction to access memory and IO External address decoder decodes the address and decides whether to select a memory or a device. IO region must be non-cacheable and all IO variables must be declared as volatile. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 48.
    IO Management PollingA program continuously checks the IO device Interrupt If an IO device needs processor attention, it interrupts the processor. A key player for multi-tasking and real-time DMA Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 49.
    Interrupt Controller Extendsinterrupt signals of the processors Offloads the CPU by doing some of interrupt processing Extra level of interrupt control Maps the interrupt signal to the processor interrupt signal Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems CPU IO Device Interrupt Control
  • 50.
    Interrupt Processing AmrAli Abdel-Naby@2011 Introduction to Embedded Systems Interrupt Control
  • 51.
    On Chip BusConnects the components of the SoC Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 52.
    Types of theSoC Application specific integrated circuit (ASIC) Programmable HW FGPAs CPLDs Application specific instruction set processors (ASIPs) DSPs Media processors Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 53.
    Implementation Tradeoff AmrAli Abdel-Naby@2011 Introduction to Embedded Systems
  • 54.
    Embedded Boards PCBsthat can be used to run an embedded SW on top of it. It has: SoC’s Memories IOs A development board can be an evaluation board or a solution board. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 55.
    Embedded Boards cont’d Evaluation boards Boards that has a controller and all possible IOs that the controller can connect to. Used by controller manufacturers to test their own chip. Design houses use them to develop their products’ prototypes. Solutions boards Used in actual product Subset or a tuned version of the evaluation board Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 56.
    Exercise 2: IdentifyYour Embedded System Hardware Goal: Identify embedded systems hardware Each group of 2 persons should: Identify the embedded hardware for the example in exercise 1 Time: 15 minutes Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 57.
    Course Outline IntroductionEmbedded Hardware Embedded Software Embedded Development Tools Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 58.
    Program A SWthat the hardware understands and runs to achieve a specific result. A program is written in 1 or more programming languages. A program may compose or can be a mix of: Application Middleware Operating system Device Driver Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems Device Drivers Operating Systems Middleware Application
  • 59.
    Programming Languages inEmbedded Systems They can be: Low level Assembly Machine code High level C/C++ Java Ada Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 60.
    Machine Code andAssembly Programming Machine code is 1’s and 0’s only Understood by processor only Inconvenient to write a program with Mnemonic code Machine code converted to symbols understood by programmers Assembly language mnemonic code + pseudo instructions to improve programs readability Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 61.
    Assembly Instructions Instructionconsists of mnemonic (opcode) and operands Opcode is an action taken by a processor Operands is the target the opcode should take an action for/on ADD A, B, C Opcode: ADD Operands: A, B, and C Symantec: register A = register B + register C Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 62.
    Pros and Consof Assembly Language Pros Readable and understandable compared to machine code Easier to debug and maintain compared to machine code Cons Knowledge of HW and processor internals is necessary Processor specific Limited capabilities Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 63.
    C/C++ Programming Processorindependent Flexible Easier to write Assembly can be inlined in C/C++ Greater productivity Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 64.
    Bootloader Thefirst program that should run when the system starts. Initial code written in assembly and then switches to C/C++. Initializes the HW for proper SW operation and jumps to the first program to run on the system. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 65.
    Device Drivers Piecesof SW that interface directly to/abstracts the HW devices. A device driver is divided into 2 layers: Low level: HW dependent High level: OS dependent Device drivers are installed during bootloading or when a device is used for the 1 st time in the system or whenever the device is plugged. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems HLD Operating Systems Middleware Application LLD
  • 66.
    Operating System ASW that manages HW and SW system resources. It provide HW abstraction as well. Windows and Unix can be used in embedded systems. Another class of OSs called RTOS fits more in embedded systems. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 67.
    Middleware AKA librariesPieces of SW that solve a generic problem are gathered to form a middleware. Examples: GUI libraries Video/Audio Decoders USB stack TCP/IP stacks Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 68.
    Application Pieces ofSW that: Interface to the user Tunes the middleware Uses the OS and device drivers To solve a specific problem Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 69.
    Embedded SW ApplicationForm There are several different types of SW architecture in use: Endless loop Cyclic execution Interrupt controlled system Cooperative multi-tasking Preemptive multitasking Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 70.
    The Endless LoopNo tasks Polled device I/O only Often, performance too slow Amr Ali Abdel-Naby@ 2009 Real-Time Operating Systems DO FOREVER Request Input Device make a Measurement Wait for the Measurement to be ready Fetch the Value of the Measurement Process the Value of the Measurement IF Value is Reasonable THEN Prepare new Result using Value ELSE Result will be an Error Report Request Output Device deliver the Result Wait for the Result to be output Confirm that output is OK END DO
  • 71.
    Basic Cyclic ExecutiveEndless loop of tasks Tasks as independent as possible Separate application issues. Little interaction Tasks share information easily. Write/Read shared data Polled device I/O only Time of complete loop determines real-time. Amr Ali Abdel-Naby@ 2009 Real-Time Operating Systems
  • 72.
    Time-Driven Cyclic ExecutiveMore precise timing Timer interrupt determines real-time. Sharing data OK Polled device I/O only (except timer) Amr Ali Abdel-Naby@ 2009 Real-Time Operating Systems
  • 73.
    Multi-Rate Cyclic ExecutiveSome tasks need higher rate. Integer multiple of base rate Major cycle/Minor cycle(s) Sharing data OK Polled device I/O only (except timer) Amr Ali Abdel-Naby@ 2009 Real-Time Operating Systems
  • 74.
    Limitation of CyclicExecutives Polled device I/O only Too low rate: Miss transient occurrences Too high rate: Waste CPU power Prefer interrupt-driven I/O Timing of task executions imprecise Data-dependent loops SW maintenance nightmare Amr Ali Abdel-Naby@ 2009 Real-Time Operating Systems
  • 75.
    Caution Adding Interrupts Interrupt service routine (ISR) May need to pass data to task it is interrupting Possible result: Inconsistent data Amr Ali Abdel-Naby@ 2009 Real-Time Operating Systems HW I/P Device ISR Shared Data Area SW using Data from ISR Old New
  • 76.
    Multi-Rate Executive withInterrupts ISRs write to one set of buffers. Tasks use data from another set of buffers. At each clock tick, data are copied. Not a weekend “Garage” project Sharing data among tasks, OK Polled and interrupt-driven device I/O Amr Ali Abdel-Naby@ 2009 Real-Time Operating Systems HW I/P Device ISR Shared Data Area Task Data Buffers DI Copy data from ISR buffers to task buffers EI
  • 77.
    Faster Response: PreemptiveScheduling All previous schedulers: Non-Preemptive Preemptive Scheduling == Task switches can take place at any point/time Tasks can be switched in mid-execution. Preemptive scheduler is very complex. Polled and interrupt-driven device I/O are OK. ISR data not delayed by a tick  Task can respond at once Amr Ali Abdel-Naby@ 2009 Real-Time Operating Systems Task 1 Task 2 Task 3 HW I/P Device ISR Task 3
  • 78.
    Preemptive Scheduling IssuesWhich task can preempt which task? Answer is in priority. Sharing data, Not OK OS provide safe mechanism for passing data between ISRs/Tasks. Amr Ali Abdel-Naby@ 2009 Real-Time Operating Systems Shared Data Area Task 1 Task 1 cont’d Task 2 with higher priority
  • 79.
    An Intertask CommunicationCatalog Data Transfer: Destructive reading, non-destructive writing Message queues Direct message passing Indirect message passing Mailboxes Pipes Data Transfer: Destructive writing, non-destructive reading RTOS-protected globals: notepad registers, environment variables, … Shared data area protected by a mutual exclusion mechanism. Amr Ali Abdel-Naby@ 2009 Real-Time Operating Systems
  • 80.
    An Intertask CommunicationCatalog cont’d -ve synchronization == mutual exclusion Semaphores Mutexes +ve synchronization Event flags Condition variables Signals Amr Ali Abdel-Naby@ 2009 Real-Time Operating Systems
  • 81.
    Exercise 3: IdentifyYour Embedded System Software Goal: Identify embedded systems hardware Each group of 2 persons should: Identify the embedded software for the example in exercise 1 Time: 15 minutes Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 82.
    Course Outline IntroductionEmbedded Hardware Embedded Software Embedded Development Tools Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 83.
    Embedded Development ToolsDepending on your business, you may need different set of tools. Integrated Device Manufacturer (IDM) Original Equipment Manufacturer (OEM) Embedded SW design house I will try to focus on the most commonly used tools. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 84.
    Assembler A SWprogram that converts source code written in assembly language into machine language. Examples include: GNU assembler Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 85.
    Compiler A SWprogram that converts source code written in a high level programming language into another programming language. C/C++  Assembly or Machine language Compilation can be: Native: Compiler and generated executables run on the same processor. Cross: Compiler runs on a processor and the generated executables runs on a different processor. Examples include: ARMCC GCC Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 86.
    Linker and LocatorA linker is a SW program that links the compilation and assemble operations’ outputs into a single executable. A locator is a SW program that can change the memory map of the linker output. It is common these days to see a combined linker-locator tool. Examples include: GCC Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 87.
    Simulator A SWprogram that imitates a real thing, state of affairs, or processes. Simulation is an approximation of the real time system. A simulator is used when: The real platform is not available. It is dangerous to test on real system directly. Examples include: Proteus Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 88.
    Debugger A SWprogram + HW device that interfaces my PC to my embedded HW. It can be used to: Set breakpoints Dump memories Trace execution Watch variables The HW can be In circuit debugger Debug agent SW on bard Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 89.
    Flash Loader ASW program + HW device that interfaces my PC to my embedded HW. It can be used to: Erase ROM/Flash Read ROM/Flash Program ROM/Flash Watch variables Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 90.
    Profiler A SWprogram that gathers information about a program during execution. Profiler is used to know which areas of code to optimize speed and memory. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 91.
    Integrated Development EnvironmentA SW program that provides a comprehensive facilities for programmers. It includes: Assemblers Compilers Linkers Debuggers Simulators Profilers Text editors Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 92.
    Schematic Capture/Circuit DesignTool A SW program that allows the circuit designer to enter his circuit design into CAD tools. It is used for: Design simulation Design sketching Examples include: OrCAD KiCAD Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 93.
    PCB Layout DesignTool A SW program that allows the transformation of the circuit schematic capture into PCB layout that cab printed on a circuit board. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 94.
    Oscilloscope A HWDevice that allows observation of constantly varying voltages. It observes the exact wave shape across time. Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems
  • 95.
    Exercise 4: IdentifyYour Embedded System Development Tools Goal: Identify embedded systems development tools Each group of 2 persons should: Identify the embedded system development tools for the example in exercise 1 Time: 15 minutes Amr Ali Abdel-Naby@2011 Introduction to Embedded Systems

Editor's Notes