Upload
mathhoang
View
214
Download
0
Embed Size (px)
Citation preview
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
1/41
Real-Time and EmbeddedSystems
Nam HoDr. Anh-Vu Dinh-Duc
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
2/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 2
Module Outline
Introduction to Real-Time SystemsReal-Time Task SchedulingReal-Time Operating Systems (RTOS)Measuring Execution Time and Real-Time Performance
Development of Embedded SystemsOur Research Results in EmbeddedSystems
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
3/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 3
Development of EmbeddedSystems
Development ProcessConsists of cycles of editing-testing-debuggingProcessor and hardware part oncechosen remains fixed, the applicationsoftware codes have to be perfected by anumber of runs and tests
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
4/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 4
Development of EmbeddedSystems
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
5/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 5
Development of EmbeddedSystems
Cross-Platform Development
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
6/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 6
Cross-Platform Development
Software for an embedded system is developed onone platform but runs on anotherThe host system is the system on which the
embedded software is developedThe target system is the embedded system underdevelopmentA set of connections might be available betweenthe host and the target system
JTAGBDMSerial PortEthernet
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
7/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 7
Host System
Offering essential development tools(toolchain)
EditorCross compiler, assemblerLinkerSource-level debugger
Produces executable binary image that will runon target system
At PC, workstation, laptop
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
8/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 8
Toolchain for BuildingEmbedded Software
Target system
Building Process
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
9/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 9
GNU Toolchain for Developmentof Embedded Systems
Free SoftwareGNU make : Automation tool for compilation andbuildGNU Compiler Collection (GCC): Suite of compilersfor several programming languagesGNU Binutils : Suite of tools including linker,assembler and other tools
GNU Debugger (GDB): Code debugging toolC Library : uLibc, gLibcSupporting x86, ARM, MIPS, PowerPC, SuperH
http://en.wikipedia.org/wiki/Make_%28software%29http://en.wikipedia.org/wiki/GNU_Binutilshttp://en.wikipedia.org/wiki/GNU_Debuggerhttp://en.wikipedia.org/wiki/GNU_Debuggerhttp://en.wikipedia.org/wiki/GNU_Binutilshttp://en.wikipedia.org/wiki/Make_%28software%298/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
10/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 10
Integrated DevelopmentEnvironments (IDE)
An IDE is referred as a programming environmentthat has been packaged as an application programTypically consisting of
Code editorSimulatorToolchainGraphical user interface (GUI) builder
Companies design the IDE to develop embedded
systems on specified microcontrollersIncluding BSPStartup CodeDevice Driver
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
11/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 11
KEIL IDE
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
12/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 12
Eclipse IDE for C/C++ Developerwith GNU Toolchain for ARM
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
13/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 13
Target System
Actual hardware for the embedded system under developmentEmbedded developers are required to understand the target system
How to store the program image on the target embedded systemHow to develop and debug the system iteratively
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
14/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 14
Target System & Final System
In target system, it might be repeated downloadingof the codes during the development phaseReprogramming the EEPROM or the flash memoryeach time the code changes due to bugs or codeaddition is time consumingDevelopers transfer the image directly into thetarget system's RAM memory over serial/networkconnection or through JTAG/BDM interfaceFinal system (product) may employs ROM in placeof flash, EEPROM or EPROM in embedded system
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
15/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 15
Compiling & Linking
Executableimage
Compiling/Linking
How ?
How ?
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
16/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 16
Compiling
Output from compilation is an object fileAn object file contains
File size, binary code and data size, andsource file name from which it was created
Machine-architecture-specific binaryinstructions and dataSymbol table and the symbol relocationtableDebug information, which the debuggeruses
Two common object file formatsCOFF (common object file format)ELF (extended linker format)
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
17/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 17
Compiling The ELF Format
.o .elf
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
18/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 18
Compiling Object File
Object file contains headerthat describe the rest of
the sectionsBlocks regrouped
Code blocks in text sectionInitialized global variables indata sectionUninitialized globalvariables in bss section
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
19/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 19
Linking
Linker combines several object (.o) files into asingle executable file (.elf)
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
20/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 20
Linking Linker
Merges text, data, and bss sectionsUnresolved symbol matching
Referred variable is undeclared in one file but isdeclared in another fileLinker will replace with reference to the actualvariable
Normally, the address in the executableimage is the absolute address (physicaladdress)
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
21/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 21
Linking Linker Script
Set of linker directives that controls how thelinker combines the sections and allocatesthe segments into the target systemTwo of the more common directivessupported by most linkers are MEMORYand SECTION
The MEMORY directive is used to describe thetarget systems memory map The SECTION specifies how the sections are tobe merged and at what location they are to beplaced
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
22/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 22
Linking Linker Script
MEMORY {ROM: origin = 0x0000h, length = 0x0020hFLASH: origin = 0x0040h, length = 0x1000hRAM: origin = 0x1000h, length = 0x10000h
}
SECTION {.text :{
my_section *(.text)}loader : > FLASHGROUP ALIGN (4) :{
.text,
.data : {}
.bss : {}} >RAM
}
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
23/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 23
Linking Linker Script
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
24/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 24
Downloading the ExecutableImage to the Target System
Programming the entire image into theEEPROM or flash memory
Downloading the image over either aserial (typically RS-232) or networkconnection
Downloading the image through eithera JTAG or BDM interface
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
25/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 25
Downloading the ExecutableImage to the Target System
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
26/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 26
Downloading the ExecutableImage to the Target System
The boot image prepares the system to execute the loader (ex. Testing RAM)The loader prepares the serial or network connection to receive the imagefrom host
Setting the baud rateInitiating the transfer protocol (FTP, TFTP)
The monitor (boot image + loader) has a set of commands allowing thedeveloper to (via serial/network connection)
download the imageread from and write to system memory locationsset and clear different types of breakpointssingle-step instructionsreset the system
Target debug agent functions much like the monitorThe target agent gives the host debugger enough information to provide visualsource-level debug capabilitySometimes a RTOS vendor offers a host-based debugger (target server)
Debugging solutionsICEJTAGBDM
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
27/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 27
Downloading the ExecutableImage to the Target System
VxWork runs on the x86 target
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
28/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 28
Debugging the ExecutableImage on the Target System
How to debug the loader/ monitor ? (Board bring-upprocess)Using an Emulator
A circuit for emulating target systemDebug startup code and programs running from ROM
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
29/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 29
Debugging the ExecutableImage on the Target System
In-Circuit Emulator (ICE)Replaces microprocessor in target systemExpensive
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
30/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 30
Debugging the ExecutableImage on the Target System
On-Chip Debugging (OCD)Built-in microprocessor debugging
BDM and JTAG solutions
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
31/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 31
Debugging the ExecutableImage on the Target System
JTAG (Joint Test ActionGroup)Founded by electronics
manufacturers to develop anew and cost-effective testsolutionThe IEEE1149.1 standard
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
32/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 32
Debugging the ExecutableImage on the Target System
BDM (Background Debug Mode)Introduced by Motorola and found onits processor chips
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
33/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 33
Target Boot Scenarios
After embedded processors are poweredon, they fetch and execute at the reset vector
The reset vector is usually a jump instructioninto another part of the memory spacewhere the real initialization code is foundAfter that the startup initialization code can
begin at the flash memory addressInitializes the hardware (only the necessarydevices)Contains the target image loader
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
34/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 34
Target Boot Scenarios
ldr pc, [pc, #64] ; 00000040
Embeddedprocessors are built-
in a small boot code
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
35/41
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
36/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 36
Executing from ROM usingRAM for data
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
37/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 37
Executing from RAM afterimage transfer from ROM
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
38/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 38
Executing from RAM afterimage transfer from Host
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
39/41
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
40/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 40
Target System SoftwareInitialization Sequence
Task objectsSemaphore objectsMessage-queue objectsTimer servicesInterrupt servicesMemory-management servicesCreating necessary stacks
Setting up execution handlersInitializing interrupt handlersInitializing bus interfaces, such asPCI, and USBInitializing board peripherals such asserial, LAN, and SCSI.
8/8/2019 RealTimeAndEmbeddedSystems_Part5 mathhoang vietnam_hoangminhnguyen
41/41
8/20/2010 Embedded Systems Course: Development of Embedded Systems - 2010 41
Reference
Qing Li and Carolyn Yao, Real-Time Concepts for Embedded Systems,
CMP Books, 2003Raj Kamal, Embedded Systems - Architecture, Programming and
Design , McGraw-Hill Pulisher, 2008