You are on page 1of 40

嵌入式系统

田 华
653528817@qq.com
课程特点、主要内容及学习目标 Cour
se characteristics, main content an
d learning objectives
 课程特点:软硬件并重、实践性强的特点

 主要内容: ARM 处理器体系结构、 ARM 处理器芯片、嵌入式 Linux 操


作系统、驱动程序及应用程序开发

 学习目标:掌握嵌入式系统的相关软硬件知识、初步具备嵌入式系统
软硬件设计能力,为今后从事嵌入式系统研究与开发打下良好的基础
 Course features: equal emphasis on software and hardware, strong
practical characteristics

 Main content: ARM processor architecture, ARM processor chip, em


bedded Linux operating system, driver and application development

 Learning objectives: master the relevant software and hardware kno


wledge of embedded systems, and initially have the ability to design
开发环境

( 1 )裸板程序开发(无操作系统)
Keil for ARM

( 2 )嵌入式 Linux 程序开发


 VMware/VMPlayer( 虚拟机 / 虚拟机播放器 )
 Linux 操作系统(多种可选)
 (1) Bare board program development (no operating system)
 Keil for ARM

 (2) Embedded Linux program development
 VMware/VMPlayer (virtual machine/virtual machine player)
选用教材
考核方式及成绩评定方法 Evaluation
method and performance evaluatio
n method

 闭卷考试
 平时成绩 40% :
学习通预习 + 出勤 + 随堂测试 + 作业 + 小测
+ 项目设计
 期末成绩 60%
 Closed book exam
 Normal grade 40%:

第 1 章 嵌入式系统基础知识
计算机系统( Computer System )
嵌入式系统( Embedded System )
嵌入式系统( Embedded System )
1.1 嵌入式系统的定义和组成

 1.1.1 嵌入式系统的定义
IEEE (国际电气和电子工程师协会)给出的定义

嵌入式系统( Embedded System )是“控制


、监视或者辅助设备、机器和车间运行的装
置”( devices used to control , monitor , or
assist the operation of equipment , machinery or
plants )。
国内普遍认同的定义

 以应用为中心、以计算机技术为基础,软件硬件可裁
剪,适应应用系统对功能、可靠性、成本、体积、功耗严格
要求的专用计算机系统。嵌入式系统是一种专用的计算机系
统,作为装置或设备的一部分。
 Application-centric and computer-based, software and
hardware can be tailored to meet the application syste
m's strict requirements for function, reliability, cost, vol
ume, and power consumption. An embedded system is
a dedicated computer system as a part of a device or e
到对象体系中的专用计算机系统” The definition of
embedded system by Professor Limin He of Beijing
University of Aeronautics and Astronautics: "dedicated
computer system embedded in the object system"

 对象体系是指嵌入式系统所嵌入的宿主系统。
 The object system refers to the host system
embedded in the embedded system.

 “ 嵌入性”、“专用性”与“计算机系统”是嵌
入式系统的 3 个基本要素。
 "Embeddedness", "speciality" and "computer
system" are the three basic elements of
embedded systems.
嵌入式系统一般由以下 4 个部分组成:

 嵌入式微处理器
 外围硬件设备
 嵌入式操作系统
 用户应用程序
Embedded systems generally consist of the following
4 parts:

 Embedded microprocessor
 Peripheral hardware equipment
1 .嵌入式系统的发展历史( 4 个阶段) 1. Th
e history of embedded system developme
nt (4 stages)
( 1 )无操作系统阶段( 20 世纪 60 年代)
(1) No operating system stage (1960s)
 单片机作为微控制器
 单线程的程序
 完成监测、伺服和设备指示等多种功能
 一般没有操作系统的支持
 程序设计多采用汇编语言
MCU as a microcontroller
 Single-threaded program
 Complete multiple functions such as monitoring, servo and
equipment instructions
 Generally not supported by the operating system
 Assembly language

简便、价格低廉,在工业控制领域中得到了非常广泛的应用
Simple and inexpensive, it has been widely used in the field of
industrial control
 ( 2 )简单操作系统阶段( 20 世纪 80 年代)

 高可靠性、低功耗的嵌入式 CPU (如 Power PC 等)

 一些简单的嵌入式操作系统开始出现并得到迅速发展。

 操作系统虽然还比较简单,但已经初步具有了一定的兼容性和扩展
性,内核精巧且效率高,大大缩短了开发周期,提高了开发效率。
 (2) Simple operating system stage (1980s)

 Embedded CPU with high reliability and low power consumpti


on (such as Power PC, etc.)

 Some simple embedded operating systems began to appear


硬件实时性要求提高,嵌入式系统的软件规模扩大,实时多任
务操作系统逐渐形成。

系统能够运行在各种不同类型的微处理器上,具备文件管理、设
备管理、多任务、网络、图形用户界面等功能,并提供了大量的应用程
序接口( API ),使应用软件的开发变得更加简单。

分布控制、柔性制造、数字化通信、信息家电等。
Hardware real-time requirements have increased, the software
scale of embedded systems has expanded, and real-time
multitasking operating systems have gradually formed.

The system can run on a variety of different types of


microprocessors, with file management, device management,
multitasking, network, graphical user interface and other
functions, and provides a large number of application program
interfaces (API), so that the development of application software
It's easier.

Distributed control, flexible manufacturing, digital


communication, information appliances, etc.
( 4 )面向 Internet 阶段(进入 21 世纪)
(4) Internet-oriented stage (entering the 21st century)

 嵌入式技术与 Internet 技术结合


 推动信息家电、工业控制技术的飞速发展。
 Combination of Embedded Technology and Internet Techn
ology
 Promote the rapid development of information appliances
and industrial control technology.
2 .嵌入式系统的发展趋势
2. The development trend of embedded sy
stem

 ( 1 )新的微处理器层出不穷,精简系统内核,优化关键算法,降
低功耗和软硬件成本。

 ( 2 ) Linux 、 Windows CE 等嵌入式操作系统迅速发展。嵌入


式操作系统自身结构的设计更加便于移植。

 ( 3 )嵌入式系统的开发成了一项系统工程,开发厂商提供强大的
硬件开发工具和软件支持包。
 (1) New microprocessors emerge in endlessly, streamline syst
em cores, optimize key algorithms, and reduce power consum
ption and hardware and software costs.

 (2) Embedded operating systems such as Linux and Windows


CE are developing rapidly. The design of the embedded operat
ing system's own structure is more convenient for transplanta
ed system
嵌入式系统一般由嵌入式计算机系统和执行装置组成。
Embedded systems generally consist of embedded
computer systems and execution devices.
嵌入式计算机系统是整个嵌入式系统的核心,分为

硬件层
中间层
系统软件
应用软件层
Embedded computer system is the core of the entire
embedded system, divided into

Hardware layer
middle layer
system software
Application software layer
执行装置(被控对象):接受嵌入式计算机系统发出的控制命令,
执行所规定的操作或任务。 Execution device (controlled object):
accepts the control command issued by the embedded
computer system, and executes the specified operation or
1 .嵌入式计算机系统的硬件层
1. Hardware layer of embedded computer
system

 硬件层中包含嵌入式微处理器、存储器( SDRAM 、 ROM 、


Flash 等)、通用设备接口和 I/O 接口( A/D 、 D/A 、 I/O
等)。

 硬件层通常以嵌入式处理器为中心,包含有电源电路、时钟
电路和存储器电路的电路模块,操作系统和应用程序固化在
模块的 ROM 中。
 The hardware layer includes embedded microprocessor
s, memories (SDRAM, ROM, Flash, etc.), general equipm
ent interfaces and I/O interfaces (A/D, D/A, I/O, etc.).

 The hardware layer is usually centered on the embedded


( 1 )嵌入式微处理器
(1) Embedded
microprocessor
嵌入式系统硬件层的核心。 The core of the embedded syste
m hardware layer
体系结构:冯 · 诺依曼体系结构(程序和数据公用一个存储空间,统一编
址)
哈佛体系结构(程序和数据存储在不同存储空间,各
自独立编址)

指令系统:精简指令系统 ( RISC: Reduced Instruction Set Computer )


复杂指令集系统( CISC : Complex Instruction Set
Computer )。
Architecture: Von Neumann architecture (programs and data share
a storage space, unified addressing)
Harvard architecture (programs and data are stored in
different storage spaces, each with independent addressing)

Instruction System: Reduced Instruction Set Computer (RISC:


Reduced Instruction Set Computer)
Complex Instruction Set1000
目前嵌入式微处理器已经超过 Computer (CISC: Complex
多种,体系结构有 30 多个
Instruction Set Computer).
系列,其中主流的体系有 ARM 、 MIPS 、 PowerPC 等。
At present, there are more than 1,000 kinds of embedded
1 .嵌入式计算机系统的硬件层
1. Hardware layer of embedded c
omputer system

( 2 )存储器

嵌入式系统的存储器包含
 Cache
 主存储器
 辅助存储器
 The memory of the embedded system contains
 Cache
 Main memory
 Auxiliary storage
①Cache

 位于主存储器和嵌入式微处理器内核之间的快速存储器阵列

 存放的是最近一段时间微处理器使用最多的程序代码和数据

 Fast memory array located between main memory and
embedded microprocessor core

 Stored is the most recently used program code and data of
the microprocessor.
微处理器尽可能的从 Cache 中读取数据,而不是从主存中读取,
提高微处理器和主存之间的数据传输速率。 The microprocessor
reads data from the Cache as much as possible, rather than from
the main memory, which improves the data transfer rate between
the microprocessor and the main memory.

Cache 一般集成在嵌入式微处理器内,可分为数据 Cache 、指令


Cache 或混合 Cache 。
Cache is generally integrated in an embedded microprocessor
and can be divided into data cache, instruction cache or hybrid
 ② 主存储器

 用来存放系统和用户的程序及数据
 嵌入式微处理器能直接访问
 包含 ROM 和 RAM ,可以位于微处理器的内部或外部。
 常用的 ROM 类存储器有 NOR Flash 、 EPROM 和 PROM 等
 RAM 类存储器有 SRAM 、 DRAM 和 SDRAM 等。
 Used to store system and user programs and dat
a
 Embedded microprocessor can directly access
 Contains ROM and RAM, which can be located in
side or outside the microprocessor.
③ 辅助存储器
③Auxiliary memory

硬盘、 NAND Flash 、 CF 卡、 MMC 和 SD 卡等


用来存放大数据量的程序代码或信息
容量大,读取速度比主存慢一些
Hard disk, NAND Flash, CF card, MMC and SD card, etc.
Program code or information used to store large amounts of
data
Large capacity, read speed is slower than main memory
1. Hardware layer of embedded c
omputer system
( 3 )通用设备接口和 I/O 接口

嵌入式系统与外界交互所需要的通用设备接口
 GPIO 、 A/D 、 D/A 接口
 RS-232 接口、 Ethernet
 USB 接口
 音频接口、 VGA 视频输出接口
 I2C (现场总线)
 SPI (串行外围设备接口)
 IrDA (红外线接口)等。
 (3) General equipment interface and I/O interface

 General equipment interface needed for embedded system to
interact with the outside world
 GPIO, A/D, D/A interface
 RS-232 interface, Ethernet
omputer system
 中间层也称为硬件抽象层( Hardware Abstract Layer , HAL )
或板级支持包( Board Support Package , BSP )
 The middle layer is also called Hardware Abstract Layer (HA
L) or Board Support Package (BSP)

BSP 是一个介于操作系统和底层硬件之间的软件层次,包括了系统
中大部分与硬件联系紧密的软件模块。
BSP is a software level between the operating system and the
underlying hardware, including most of the software modules
in the system that are closely related to the hardware.

BSP 使上层软件开发人员无需关心底层硬件的具体情况,根据 BSP


层提供的接口即可进行开发。
BSP enables upper-level software developers to develop
based on the interface provided by the BSP layer without
worrying about the specific conditions of the underlying
hardware.
3 .系统软件层
3. System software layer

系统软件层通常包含有

 嵌入式操作系统 ( EOS )
 文件系统
 图形用户接口( GUI )
 网络系统
 通用组件模块
 The system software layer usually includes

 Embedded Operating System (EOS)


 File system
1 )嵌入式操作系统
( Embedded Operating System , EOS )

EOS 负责嵌入式系统的软件、硬件的资源分配、任务调度,控制协调。

除了具备一般操作系统最基本的任务调度、同步机制、中断处理、文
件处理等功能外,还有如下特点:

EOS is responsible for the software and hardware resour


ce allocation, task scheduling, control and coordination
of the embedded system.

In addition to the most basic task scheduling, synchroniz


EOS 特点:

 实时性强;
 支持开放性和可伸缩性的体系结构,具有可裁减性;
 提供统一的设备驱动接口;
 提供操作方便、简单、友好的图形 GUI 和图形界面;
 支持 TCP/IP 协议及其他协议,提供 TCP/UDP/IP/PPP 协议支持及统一的 MAC
访问层接口,提供强大的网络功能;
 嵌入式操作系统的用户接口通过系统的调用命令向用户程序提供服务;
 嵌入式系统一旦开始运行就不需要用户过多的干预;
 嵌入式操作系统和应用软件被固化在嵌入式系统计算机的 ROM 中;
 具有良好的硬件适应性(可移植性)。
 Strong real-time;
 Support openness and scalability of the system structure, with scalability;
 Provide a unified device driver interface;
 Provide convenient, simple and friendly graphical GUI and graphical interfac
e;

2 )文件系统
(File System , FS)

 与通用操作系统的文件系统不完全相同,主要提供文件存储、检索
和更新等功能,一般不提供保护和加密等安全机制。

 通常支持 FAT32 、 JFFS2 、 YAFFS 等几种标准的文件系统,一


些嵌入式文件系统还支持自定义的实时文件系统。

 可以方便的挂接不同存储设备的驱动程序,支持多种存储设备。

 以系统调用和命令方式提供文件的各种操作
 It is not exactly the same as the file system of a general opera
ting system. It mainly provides functions such as file storage,
retrieval, and update. Generally, it does not provide security
mechanisms such as protection and encryption.
3 )图形用户接口
( Graphic User Interface , GUI )

 GUI 使用户可以通过窗口、菜单、按键等方式来方便地操作计算
机或者嵌入式系统。

 嵌入式 GUI 与 PC 机上的 GUI 有着明显的不同,嵌入式系统的 G


UI 要求具有轻型、占用资源少、高性能、高可靠性、便于移植、
可配置等特点。

 QT 、 MiniGUI 等。
 GUI allows users to conveniently operate a computer or em
bedded system through windows, menus, buttons, etc.

 The embedded GUI is obviously different from the GUI on t


he PC. The GUI of the embedded system is required to have
the characteristics of light weight, low resource consumpti
4 .应用软件层
4. Application software layer
 用来实现对被控对象的控制功能

 由所开发的应用程序组成,面向被控对象和用户。

 为方便用户操作,通常需要提供一个友好的人机界面。
 Used to realize the control function of the controlled object

 It is composed of the developed application program, facing th


e controlled object and user.

 In order to facilitate user operations, it is usually necessary to


provide a friendly man-machine interface.
1.1.4 实时操作系统( RTOS )

 RTOS ( Real-time operating system ,实时操作系


统)应用领域广泛。
 RTOS (Real-time operating system, real-time oper
ating system) has a wide range of applications.

RTOS 要求系统中的任务不但执行结果要正确,而且必
须在一定的时间约束( Deadline )内完成。
RTOS requires that the tasks in the system not
only have correct execution results, but also must
be completed within a certain time constraint
(Deadline).
1 . RTOS 定义

 RTOS 是指能够在指定或者确定的时间内完成系统功
能和对外部或内部、同步或异步事件做出响应的系统

 RTOS 的正确性不仅依赖于系统计算的逻辑结果,还
依赖于产生这个结果的时间。
 RTOS refers to a system that can complete syste
m functions and respond to external or internal, s
ynchronous or asynchronous events within a spe
cified or determined time.

 The correctness of the RTOS depends not only o


2 . RTOS 特点

( 1 )约束性
 RTOS 任务的约束包括
 时间约束
 资源约束
 执行顺序约束
 性能约束。
 (1) Constraint
 The constraints of RTOS tasks include
 Time constraint
 Resource constraints
 Execution order constraint
 ( 2 )可预测性
 RTOS 完成实时任务所需要的执行时间应是可知的。
 可预测性包括
 硬件时延的可预测性
 软件系统的可预测性
 (2) Predictability
 The execution time required for RTOS to complet
e real-time tasks should be known.
 Predictability includes
 Predictability of hardware delay
 ( 3 )可靠性
 大多数 RTOS 要求有较高的可靠性,要求系统在最坏情况下都能正常工
作或避免损失。可靠性是 RTOS 的重要性能指标。

 ( 4 )交互性
 嵌入式计算机系统作为控制系统,必须在规定的时间内对被控子系统请
求做出反应。
 被控子系统也必须能够正常工作或准备对任何异常行为采取动作。
 (3) Reliability
 Most RTOSs require high reliability and require the system to wor
k normally or avoid losses in the worst case. Reliability is an impo
rtant performance indicator of RTOS.

 (4) Interactivity
 As the control system, the embedded computer system must resp
ond to the request of the controlled subsystem within the specifie
d time.

You might also like