Presentation is loading. Please wait.

Presentation is loading. Please wait.

Embedded System Software and Hardware Basics

Similar presentations


Presentation on theme: "Embedded System Software and Hardware Basics"— Presentation transcript:

1 Embedded System Software and Hardware Basics
Embedded Systems Software Training Center Embedded System Software and Hardware Basics COPYRIGHT © 2016 DSR CORPORATION

2 Assumptions for Using this Teaching Material
NEXCESS Beginner's Course Fundamentals of Embedded Software Development Technology Embedded System Software Basics Copyright (C) 2006 by Nagoya University Extension Courses for Embedded Software Specialists Copyright (C) 2006 by Hiroaki Takada and Masaki Yamamoto The author (s) named above allow this content (including any adaptation or translation thereof) to be used, duplicated, modified, translated and/or redistributed for free only if such usage clears the requirements given in (1) to (3) below. The copyright notice found in this box shall be duplicated in the content in its original form. (2) When this content is adapted or translated, a mention of such adaptation or translation shall be included in the content. A copyright notice for such adapters or translators shall be given separately from the copyright notice found in this box. (3) Users of this context shall indemnify the author(s) for any damages, direct or indirect, that may result from its use. * Part of this content has been prepared as part of the Nagoya University Extension Courses for Embedded Software Specialists (NEXCESS), financed by a Ministry of Education, Culture, Sports, Science and Technology science and technology promotion coordination subsidy. * Product names and service names appearing in this content are either trademarks or registered trademarks of their respective owners. Copyright © 2016 DSR Corporation 2 2

3 Welcome Instructor Introduction Objectives and Content Class Materials
Agenda Copyright © 2016 DSR Corporation 3

4 Instructor Introduction
Matveev Alexey Igorevich Senior software developer, DSR corp. Copyright © 2015 DSR Corporation

5 All lectures themes Embedded System Software and Hardware Basics
Embedded Systems Peripherals Programming for Embedded Systems and RTOS Basics Itron Basics

6 Objectives Understand what are embedded systems
Understand the challenges and diversity of embedded systems Understand embedded systems CPU operating principle Copyright © 2016 DSR Corporation 6

7 Class Materials Embedded Systems Software Basics diagrams and Hands-on Exercises are available on site in training materials section: Copyright © 2016 DSR Corporation 7

8 Agenda What is an Embedded System?
Challenges and Diversity of Embedded Systems Definitions of the Embedded Software Embedded Hardware Basics CPU operating principle Copyright © 2016 DSR Corporation 8

9 Basic Knowledge of the Embedded System
Copyright © 2016 DSR Corporation 9

10 What is an Embedded System?
There is some ambiguity in the use of the word embedded with variation of use from person to person. The embedded system in general terms: An embedded system is a system that has embedded software and computer hardware, which makes it a system dedicated for an application(s) or specific part of an application or a product or part of a larger system In a broad sense, the term "embedded system“ applies to all systems except generic purpose computers such as PCs. Copyright © 2016 DSR Corporation 10 10

11 Where Embedded Systems are Used
The number of microprocessors used in embedded systems is nearly 98% of all produced microprocessors. 2% are used by general purpose PCs, big IT systems, and servers. The end user usually perceives embedded software as a set of functions that the system provides. Devices which are embedded systems: Electrical household devices (microwaves, rice cookers, drying machine, washing machines, air-conditioners). Audio-visual equipment (TVs, videos, digital cameras, audio equipment). Personal information equipment (PDAs, electronic organizers, car navigation systems). PC peripheral equipment (printers, scanners, DVD-drives). Networking equipment (switching equipment, network routers, hubs). Medical apparatus (blood pressure meters, electrocardiographs, X-rays, CT scanners). Space/military (rockets, satellites, missiles, rovers). Scientific and measurement tools (oscilloscopes, IC testers, electric power meters, DDMs). Copyright © 2016 DSR Corporation 11

12 Challenges of Embedded Systems
Real time The embedded system's timing must provide the expected action within a maximum specified time under all circumstances. For example: engine control system Reliability Unexpected behavior from an embedded system might seriously damage its environment. Embedded software must operate for decades without service. For example: sensors in home automation systems Safety Embedded software has an impact on people and can potentially pose a safety hazard. Safety is crucially important especially in systems such as airplanes, cars, or industrial plants. For example: steering and brake equipment in a car Copyright © 2016 DSR Corporation 12

13 Challenges of Embedded Systems (cont.)
Security Secured I/O to avoid data loss or damage. For example: automatic cash terminal, payment equipment, vending machines Limited Resources Small memory space and limited data-processing capabilities, low-cost microcontrollers, and low power consumption. For example: ZigBee devices with different profiles Heterogeneity During long lifetime environment changes: sensors and hardware parts. For example: BT radio chip us used in different devices Copyright © 2016 DSR Corporation 13

14 Main Characteristics of the Embedded System
An embedded system is a dedicated system Strict hardware restrictions High reliability Real time operations Embedded System = Embedded Software + Embedded Hardware Hardware: Flesh and blood of an Embedded System. CPU (MPU, MCU) is the heart of an Embedded System. Software: The spirit of an Embedded System. Copyright © 2016 DSR Corporation 14 14

15 Basic Knowledge of the embedded software
Copyright © 2016 DSR Corporation 15

16 Definitions of Embedded Software
The traditional definition: Software that is used in embedded systems. Narrow sense definition: Software that is considered as a part of a product, specific to the equipment. !Java programs downloaded onto mobile phones is not embedded software. !The BIOS of PCs is embedded software. !Software flashed into LSI (Large Scale Integration) for control is an embedded software. Copyright © 2016 DSR Corporation 16 16

17 Software Embedded in Equipment and in LSI
DSP – Digital Signal Processor LSI – Large Scale Integration Copyright © 2016 DSR Corporation 17 17

18 Challenges of Embedded Software Development
Programming closely related to hardware Reason: differences in the structure of the hardware and peripheral devices for individual systems. The quality of program depends on the programmer’s capabilities. It makes development difficult. For example: different radio modules for ZB and BT, different transport layer and commands. Low Resources for Software Limitation of CPU, RAM, and ROM. Need to do a lot of optimization for code size and memory usage. Example: ZigBee stack, code size 128 Kb, memory 64 Kb. Separation of the development and the target environment Development on targeted systems is not always possible. An environment for cross development and a remote debug is required. There are systems which need to be verified and debugged without being stopped. For example: development for ARM, MIPS, JTAG can be used but only for simple tasks, main debug is done using logging. Copyright © 2016 DSR Corporation 18 18

19 Challenges of Embedded Software Development (cont.)
Possibility of parallel development and co-design with hardware Need to get complete product as quickly as possible. System verification and debugging when both hardware and software are unreliable. The need for experienced experts. For example: For ZB development, a similar processor was used instead of a target platform. Various platforms (hardware, OS) The hardware and OS are optimized for each system. For example: ZB is developed for ARM and 8051. High costs of verification and testing The demand for high reliability. Indeterminacy due to timing. Example: RDBMS in Sony multimedia center. Copyright © 2016 DSR Corporation 19 19

20 Challenges of Embedded Software Development (cont.)
Exception processing software Very high percentage of exception and diagnostic processing on system failure. Exception processing could be a problem in terms of time constraints. For example: BT, working with radio module – handle packet loss and incorrect incoming data. Components Interaction Components interact with each other, need to handle them correctly. For example: distance measurement using radio signals, multiple devices interaction, and external environment influence. Copyright © 2016 DSR Corporation 20

21 Breakdown of the Total Development Cost in the Operating Department
The cost of software development accounts for 40% of total development costs. Copyright © 2016 DSR Corporation 21 21

22 Types of Targeted Processors
The 32 bits era Copyright © 2016 DSR Corporation 22 22

23 Programming Languages
C is most popular, works well with H/W C allows writing programs with simple flat structure Assembler is used for DSP development and optimization C++ is less popular because of overhead caused by programming methods C++ cross compiler is not available on some platforms COPYRIGHT © 2016 DSR CORPORATION 23 23

24 Embedded hardware basics
Copyright © 2016 DSR Corporation 24

25 Hardware in Embedded Software Development
Embedded software development requires knowledge of hardware because programming is close to hardware Embedded software is intended to control the system Programming deals with working directly with hardware C programming concepts are used Pointers, ROM/RAM, device registers Polling, interrupts Embedded software specific General-purpose computer technology is used Low power consumption, debugging, reliability, etc. Copyright © 2016 DSR Corporation

26 Embedded Hardware Basics
A computer does mainly four functions: Receive input: Through various input devices Process information: Perform arithmetic or logical operations on the information Produce output: through output devices Store information: storage device Computer hardware falls into three categories: Processing hardware: CPU Peripheral devices: handle interaction between user/another computer and CPU Memory: stores information Copyright © 2016 DSR Corporation

27 Embedded Hardware Basics
Processor (CPU) is connected by a bus with I/O interfaces and memory LSI (large-scale integration) is used in each separate element Single-chip microcontroller Peripheral device CPU Memory I/O Interface Auxiliary circuit Bus I/O interface (LAN controller) Memory Copyright © 2016 DSR Corporation

28 Processor Basics ALU (Arithmetic Logic Unit)
Digital circuit that performs integer arithmetic and logical operations. CPU (Central Processing Unit) Performs data transfers, ALU, stack and input/output operations. MPU (Microprocessor Unit) Includes CPU and additional (FPU, caches, pipeline, etc.) blocks in single VLSI chip. MCU (Microcontroller Unit) Includes CPU, memory and several hardware units – peripheral (GPIO, timers, interrupt controller, etc.) in single VLSI chip. SoC (System on chip) Contains MCU, digital, analog and often radio-frequency units. Copyright © 2016 DSR Corporation

29 Processor Basics(cont.)
Memory Peripherals Control Unit RF ALU transceiver Registers Bus CPU MCU SoC

30 Embedded Processors Diversity
Wide spectrum of embedded hardware: from 8- to 64-bit processors Electronic thermometer: ATMEL AVR ATtiny15 (8 bit, 1.6MHz, 1kB ROM, No RAM) Wrist watch: Texas Instruments MSP430F5212 (16 bit, 25 MHz, 128kB ROM, 8kB RAM) Smart Home control panel: ARM Cortex-M3 STM32F207VGT6 (32 bit, 120 MHz, 1MB ROM, 128kB RAM) Wi-Fi routers, printers: WRTnode MIPS24KEc (32 bit, 600 MHz, 32M ROM, 128M RAM) Car navigation systems: ARM Cortex-A7 Allwinner A20 (32 bit, 1GHz, 4GB ROM, 512MB RAM) ATMs, POS terminals: even x86-64 processors (64 bit, 2.2 GHz, 120GB ROM, 2GB RAM ) Copyright © 2016 DSR Corporation 30

31 RISC and CISC Processor architecture classification by the type of instruction set CISC Complex Instruction Set Computer Variable length and complex instructions Example: PDP-11, VAX, x86 RISC Reduced Instruction Set Computer Easy to increase frequency Fixed-length instruction set, one instruction per clock Load-store architecture, all modifications are done in registers Simplified MMU (memory management unit), interrupt and exception handling Example: ARM, Atmel AVR, MIPS, DEC Alpha Copyright © 2016 DSR Corporation

32 Reading instruction fetch data
Registers Register is fast memory available as part of a CPU Registers are used to store data and processor state Program data is stored in memory The processor can not directly operate with values stored in memory Put the value in the register, perform calculations, write back to memory c = a + b; Compiling results Address Register load r1, 0x10 0x01 Reading instruction fetch data load r2, 0x11 CPU ROM (program) add r1, r2 store r1, 0x12 r1 5 a(3) 0x10 r2 2 b(2) 0x11 RAM (data) c(5) 0x12 Data write Copyright © 2016 DSR Corporation

33 The Cortex-M3/M4 registers
Copyright © 2015 DSR Corporation

34 Type of Registers Link register Program Counter (PC)
General purpose registers (R0-R12) R0-R12 are 32-bit general-purpose registers for data operations. Registers r0-r7 are accessible by all instructions that specify a general-purpose register. Registers r8-r12 are accessible by all 32-bit instructions that specify a general-purpose register. Registers r8-r12 are not accessible by all 16-bit instructions. Stack pointer Register r13 is used as the Stack Pointer (SP). Because the SP ignores writes to bits [1:0], it is autoaligned to a word, four-byte boundary. Link register Register r14 is the subroutine Link Register (LR). Program Counter (PC) Stores address of instruction to execute by the processor Copyright © 2016 DSR Corporation

35 Type of Register (cont.)
Program Status Register The Program Status Register (PSR) combines: Application Program Status Register (APSR) Interrupt Program Status Register (IPSR) Execution Program Status Register (EPSR). Exception mask registers The exception mask registers disable the handling of exceptions by the processor. Disable exceptions where they might impact on timing critical tasks. CONTROL register The CONTROL register controls the stack used and the privilege level for software execution when the processor is in Thread mode and, if implemented, indicates whether the FPU state is active. Copyright © 2016 DSR Corporation

36 Bus and Memory COPYRIGHT © 2016 DSR CORPORATION
36

37 Serial Bus and Parallel Bus
A bus is a subsystem that transfers data between components inside a computer Parallel Bus Sends several data signals simultaneously over several parallel channels SCSI, PCI, ISA, VMEBUS, AMBA… Serial Bus Sends data one bit at a time, sequentially, over a communication channel PCI Express, IEEE1394, CAN, USB, Ethernet… Parallel bus timing should be synchronized for all data channels that limits data rate for long distances. Therefore, for establishing connection between distant peers, serial bus is used. Copyright © 2016 DSR Corporation

38 Processor Bus Processor bus connects the processor with peripheral devices and memory, usually it is parallel bus The main characteristics: transfer speed, combination of several bus types (peripheral and high-performance buses, for example) Master Sends read and write requests to the bus Processor, DMA (Direct Memory Access), … Slave Receives read and write requests from the bus Memory, I/O Interface (GPIO, UART), ... Copyright © 2016 DSR Corporation

39 System Bus Address bus Is used to specify a physical address.
The width of the address bus determines the amount of memory a system can address Can be wider than data bus (e.g., 16-bit address bus vs 8-bit data bus) Data bus Is used to transfer actual data Consists of multiple bits of data Example: If 16-bit, 2-byte Control bus Carries commands from the CPU and returns status signals from devices Read/write request, wait command, external interrupt request Bus width Address range Addressable size 8 bits 0x00-0xFF 256 bytes 16 bits 0x0000-0xFFFF 64 KB 32 bits 0x xFFFFFFFFF 4 GB 64 bits 16 EB Copyright © 2016 DSR Corporation

40 Bus Interaction Address bus Data bus Control bus Master Slave Slave
Master output, slave input Data bus Reads: master input, slave output Write: master output, slave input Control bus Signal depends on situation Master Slave Slave CPU Memory I/O Interface Control bus Data bus Address bus Copyright © 2016 DSR Corporation

41 Bus Slave Selection Port enable (chip select)
Only one slave device is active and accepts requests from the bus Decode address: get the most significant bits of the address Memory Map Port enable 0x0000 Memory 1 Master Slave Slave 0x4000 Memory 2 CPU Memory 1 Memory 2 0x8000 EN EN Address Decoder “00” active 0x1000 : 0x2000 : 0x4000 : 0x5000 : The upper 2 bits Chip Select “01” active Address signal 16-bit Copyright © 2016 DSR Corporation

42 Memory A system usually deals with several kinds of memory:
RAM: Volatile DRAM (dynamic RAM): Large and relatively fast, must be refreshed SRAM (static RAM): Refresh is not needed, fast access ROM: Nonvolatile Mask ROM, PROM (programmable), UV-EPROM (ultra-violet erasable), EEPROM Flash Memory: Nonvolatile Can be rewritten in blocks There is a limited re-write number The write speed Bus State Controller Timing is different for each memory access, controller changes the settings according to the memory specification Copyright © 2016 DSR Corporation

43 Endian Endian is byte ordering when storing large data in external memory Big-endian store the most significant byte first Little-endian store the least significant byte first Big-endian, little-endian terms come from “Gulliver’s travel” book – conflict how to crack boiled eggs Example: 8-bit memory address 0x bytes of data store 0x Big-endian Little-endian 0x12 0x34 0x56 0x78 0x1000 0x1001 0x1002 0x1003 Copyright © 2016 DSR Corporation

44 Endian (cont.) Endianness of the processor
Processors: big-endian or little-endian Switchable endian (bi-endian): allows to switch endianness on OS initialization or using a jumper Different endian often causes an error while porting application or implementing communication between devices The value of c variable: In the big-endian, c == 0x12 In the little-endian , c == 0x78 int i = 0x ; char c = *((char *) &i); Big-endian Little-endian i 0x1000 0x12 i 0x1000 0x78 0x1001 0x34 0x1001 0x56 0x1002 0x56 0x1002 0x34 0x1003 0x78 0x1003 0x12 Copyright © 2016 DSR Corporation

45 BASIC KNOWLEDGE OF CPU OPERATING

46 Processor Basics Program is placed in memory (ROM or RAM):
Program instructions are initially stored in ROM; Program can be executed directly from ROM; Some processors can execute program from RAM – need to copy the program from ROM to RAM before execution; Every time the CPU executes an instruction, it takes a series of steps called the machine cycle: Fetching: fetches the instruction from the memory Decoding: decode the program Executing: execute the command, CPU carries out the instruction in order by converting them into microcode Storing: store the results into registers Copyright © 2016 DSR Corporation

47 Processor Booting Modern PCs:
User switches the system CPU (x86) executed the code stored in ROM (BIOS) at 0xFFFF0 address BIOS checks hardware and search for boot device When boot device is found, execute OS from boot device. OS starts and provides UI for interaction. How does embedded system CPU know the address to execute the first instruction? Answer: It uses Reset Exception address

48 Processor Booting (cont.)
Reset Exception Each time when the system powers on or soft reset is performed, it starts execution from specific address called “Reset Exception Vector”. On startup: PC = 0xFFFFC PC = address(<Reset_handler>) initialize user (USP) and interrupt stack pointers (ISP) execute main program 0xFFFFF jmp <Reset_handler> 0xFFFFC jmp <NMI_handler> 0xFFFF8 jmp <DBC_handler> 0xFFFF4 <Reset_handler> mov.w USP,0x1000 mov.w ISP,0x2000 jmp main nop 48

49 Program Execution This program runs successfully on PC but fails on MCU. What’s wrong? Answer: Undefined behavior. main.c int main() { uint8_t a = 1; uint8_t b = 2; uint8_t c; c = a + b; return 0; } main.asm ... load r1, 0x1000 load r2, 0x1001 add r1, r2 store r1, 0x1002 mov r1, 0 ret There is no return from the main() function in embedded systems!

50 Program Execution (cont.)
This program runs successfully on MCU (but freezes on PC). main.c int main() { uint8_t a = 1; uint8_t b = 2; uint8_t c; c = a + b; while(1) {} return 0; } main.asm ... load r1, 0x1000 load r2, 0x1001 add r1, r2 store r1, 0x1002 jmp label1 label1: Super-loop architecture: MCU should continuously calculate something to be alive

51 Homework Some application is implemented to run on a Windows 32 platform. You get a request to port it on some mobile device. What characteristics should you know about the mobile device platform? What parts of the initial application will be changed/added/removed? What challenges could you meet during porting? You get a request to develop software for some part of the embedded system that could be ported later to another device. What should you take into account while developing the software? What subsystem, in general, will be in your application? Tabulate the advantages and disadvantages of using programming languages as follows: Machine coding Assembly coding C C++ Java Copyright © 2016 DSR Corporation 51

52 Homework Make data and functions prototype in C for interface that handles packet received from remote side. Packet is received in little-endian. Interface maybe compiled to run on big-endian or little-endian CPU. Prototype shows what data structure is used to store received data and how it is filled Packet structure: Packet header Configuration Bit Mask Length: 4 bytes stack_profile:4 protocol_version:4 Packet type: 2 bytes reserved:2 Configuration: 2 bytes, bitmask capacity:1 Value A: 1 byte device_depth:4 Value A: 1 byte end_device_capacity:1 Copyright © 2016 DSR Corporation

53 Authors Basic knowledge of the embedded system
Hiroaki Takada (Nagoya University) Basic knowledge of the embedded software Masaki Yamamoto (Nagoya University) Copyright © 2016 DSR Corporation 53 53

54 References Embedded systems:
Raj Kamal, “Embedded Systems: Architecture, Programming and Design – 2ed” Christof Ebert, Jurgen Salecker, “Embedded Software-Technologies and Trends” Steve Heath, “Embedded Systems Design - 2ed” Michael Barr; Anthony J. Massa, “Programming embedded systems: with C and GNU development tools” System and local bus. Copyright © 2016 DSR Corporation 54 54


Download ppt "Embedded System Software and Hardware Basics"

Similar presentations


Ads by Google