Download Blackfin操作系统及应用

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

VS/9 wikipedia , lookup

RSTS/E wikipedia , lookup

Linux adoption wikipedia , lookup

Copland (operating system) wikipedia , lookup

Burroughs MCP wikipedia , lookup

Distributed operating system wikipedia , lookup

Smallfoot wikipedia , lookup

DNIX wikipedia , lookup

Unix security wikipedia , lookup

Linux kernel wikipedia , lookup

CP/M wikipedia , lookup

Process management (computing) wikipedia , lookup

Spring (operating system) wikipedia , lookup

Paging wikipedia , lookup

Security-focused operating system wikipedia , lookup

Transcript
Blackfin 实时系统及应用
EFLAG Technology
1
Agenda
‹
Introduction
‹
Real Time Systems on Blackfin
‹
uClinux on Blackfin
‹
Applications
‹
Q&A
2
Modern, Real Time Systems Contain Numerous
Hard and Soft, MIPS-Intensive Tasks
How do we balance these tasks?
MPG4 Video
Frame Decode
TCP/IP
Network Stack
MP3 Block
Decode
UI : Keypad
SIP
File System
time
3
Real Time Systems
Hard Real-Time vs. Soft Real-Time Tasks
‹
Hard Real-Time Task: A task is considered hard real-time if it must
execute and complete within a predetermined, finite window of time.
→ Failure to do so will compromise the stability and/or
acceptable performance of the system.
z Example
‹ Engine Control Timing System
‹
Soft Real-Time Task : A task is considered soft real-time if it should
execute and complete within a predetermined, finite window of time.
→ Failure to do so will not compromise the stability and/or
acceptable performance of the system.
z
Example
‹ User Interface
4
Big Challenge = Many Questions!
‹
‹
‹
‹
‹
What processor features are important in real-time
systems?
What hardware feature help guarantee hard real-time
performance?
Do we need an operating system?
What type of operating system is suitable?
What operating system features should we look for?
5
The Conventional DSP-based Real Time System
“Conventional” Real Time System
networks
systems
ADCs
Microcontroller
UI
Typical uC Operations
Operating System
Network Stacks
User Interface
Security
File System
Etc, Etc, Etc, Etc
DSP
DACs
Typical DSP Operations
Digital Filtering
Video Processing
Spectral Analysis
Speech Recognition
Audio Compression
Etc, Etc, Etc, Etc
6
What does
Human Interface
ƒ Speech Recognition
ƒ Text To Speech
ƒ Handwriting
ƒ Audio
Wired Connectivity
ƒ USB
ƒ TCP/IP
ƒ MOST Network
ƒ H.323/MEGACO
Operating
Systems /
RTOS
Enable?
Digital
Signal
Processing
MicroProcessing
Wireless Connectivity
ƒ Bluetooth
ƒ GSM
ƒ 3rd Generation
Image
Processing
Digital Imaging
CODECs
ƒ MPEG
ƒ JPEG
ƒ H.263
ƒ H.264
Designed for
High Level
Language
System Control / Applications Software
7
The Goal : Change the way people approached
real-time systems
The “Evolved” Real Time System
networks
ADCs
systems
DACs
UI
Typical Blackfin Operations
Operating Systems
Digital Filtering
Network Stacks
Video Processing
User Interface
Spectral Analysis
File System
Etc, Etc, Etc, Etc, Etc
8
The Characteristics of a
“Well Balanced Processor Architecture”
…to effectively manage all of the tasks of a real-time system,
we must begin with a “well-balanced processor architecture”
1. Efficient, high-speed peripherals enable fluid movement
of high-bandwidth data on and off chip.
2. High performance memory system enables efficient
processing data.
3. High performance DMA system allows simultaneous,
non-intrusive transfers of high-speed data between
multiple peripherals and memory system.
4. Powerful core capable of efficiently realizing complex,
real-time applications.
9
1. Blackfin Peripherals
10
Blackfin – Memory Hierarchy
‹
Supports a Cache (RISC) and an SRAM (DSP) Memory
Model
z
z
z
z
Dynamically configurable between Cache and SRAM
Sustained Dual Data Accesses
Supports accesses of 8,16,32 bit data
Separate Multi ported L1 Instruction and Data Memories
L1 Instruction
SRAM & Cache
Blackfin
Core
L1 Data
SRAM & Cache
Scratchpad SRAM
L2
Instruction
& Data
SRAM
DMA
11
Blackfin MMU
‹
Not full-fledged MMU bring you certain level memory
management as well as power efficiency and low cost
‹ Blackfin page based MMU enable
z
z
z
‹
Supervisor and user isolation modes
Storage attributes for cache policy
Independent enabling instruction protection from data protection
Blackfin MMU won’t enable
z
Virtual to physical translation for page based memory
User
Task A
Access Violation
System Data Region
Supervisor Access
System Task
Invalidate
CPLB Entry
Task A Data Region
Invalid CPLB
User
Task B
Task B Data Region
12
Blackfin Cache
‹
4-way set associative instruction cache.
‹ 2-way set associative data cache.
‹ To allow users to take advantage of single cycle
memory without having to specifically move
instructions and or data “manually”
‹ Page based MMU: manage protection attributes at
a page level with complete control over access
rights and cache behaviour.
SDRAM: Cacheable
Eight 4MB pages
Async: Non-cacheable
One 4MB page
CORE
(Registers)
L1 Instruction:
Non-cacheable
1MB page
L1 Data:
Non-cacheable
One 4MB page
Async: Cacheable
Two 4MB pages
SDRAM: Cacheable
Eight 4MB pages
Async: Non-cacheable
One 4 MB page
Async: Cacheable
One 4 MB page
13
Blackfin DMA
DMA Features:
‹ Fully integrated DMA controller carries out
the data transfers independent of
processor activity.
‹ Easy configuration and using.
‹ Chain-DMA supported.
‹ Separate peripheral DMA bus granted a
DMA transfer with low latency.
‹ Max rate each channel: one 16bit data
transfer per SCLK.
Data Buffer
PPI
SPI
Internal or
external
memory
DMA 1
A
B
SPORT
/UART
E MAC
DMA Types
DMA 2
Ping-Pong DMA
scenarios
14
2-D Direct Memory Access
Significantly decreases S/W overhead!
Helpful in video applications!
Data Capture & Storage
to Linear L2 Memory
A B C D E
I J K L M
F
G H
N O P
Programmable
Programmable
XX&Y
&YCount
Count&&
Stride
StrideValues
Values
A
B
C
D
E
F
G
H
I
J
K
L
.
.
.
.
2-D DMA to
L1 Memory
A, B, I, J
15
How do you guarantee exceptional C/C++
compiler efficiency and performance?
Put a team of compiler engineers on your
silicon design team!
16
The Blackfin Core
Designed for Compiler Efficiency!
‹
Extensive set of multi-function
instructions – do more work in a
single clock cycle
‹
Dedicated hardware C stack and
frame pointers
‹
Multiple addressing modes
‹
Flexible, algebraic instruction set
Support E-mail:
[email protected]
17
“Well-Balanced Architecture” - BLACKFIN
‹
We can effectively and efficiently move real-time data on and
off chip without burdening the core.
‹
The core can dedicate 100% of its processing power to the
intensive real-time tasks rather than helping to facilitate data
movement and arrangement/re-arrangement.
‹
Equipped with a powerful instruction set, the core can process
applications with greater efficiency than a typical DSP or MCU.
18
Events (Interrupts / Exceptions)
…to help ensure that our hard real-time events can efficiently receive
the required priority, we add a powerful hardware event controller.
‹
The Event Controller manages 5 types of Events:
z Emulation (via SW or external pin)
z Reset (via SW or external pin)
z Non-Maskable Interrupt (NMI) - for events that require
immediate processor attention (via SW or external pin)
z Exception
z Interrupts
– Global Interrupt Enable (not on BF533/2/1)
– Hardware Error
– Core Timer
– 9 General-Purpose Interrupts for servicing peripherals
19
Event Priorities
Event
Number
Event Class
Name
MMR Location
EVT0
Emulation
EMU
0xFFE0 2000
EVT1
Reset
RST
0xFFE0 2004
EVT2
NMI
NMI
0xFFE0 2008
EVT3
Exception
EVX
0xFFE0 200C
EVT4
Reserved
Reserved
0xFFE0 2010
EVT5
Hardware Error
IVHW
0xFFE0 2014
EVT6
Core Timer
IVTMR
0xFFE0 2018
EVT7
PPI Video
Interrupt
7 In DMA
IVG7
0xFFE0 201C
EVT8
I2S Audio 8
L/R Sample
Interrupt
IVG8
0xFFE0 2020
EVT9
Interrupt
9
PWM Capture
IVG9
0xFFE0 2024
EVT10
Interrupt 10
IVG10
0xFFE0 2028
EVT11
Interrupt 11
IVG11
0xFFE0 202C
EVT12
Interrupt 12
IVG12
0xFFE0 2030
EVT13
Interrupt 13
IVG13
0xFFE0 2034
EVT14
Interrupt 14
IVG14
0xFFE0 2038
EVT15
Interrupt 15
IVG15
0xFFE0 203C
Highest
Lowest
20
Operating
Systems on
Blackfin
21
If your application has these attributes an OS
may be right for you.
‹
Multiple tasks, of different priorities, that execute at different rates:
z Sample data
z Process data
z Control User interfaces
z Manage Protocol
‹ Anytime managing a protocol is part of the application
z TCP/IP
z USB
z CAN
‹ Porting code from a system that already uses an OS
‹ Have different teams that write application and firmware
22
Kernel? OS? Or Application?
‹
A Kernel…
z …is the foundation of layered
operating system architecture
‹ …manages the most basic
operations of the operating
system
‹ …provides device drivers for lowlevel hardware interfaces and
peripherals
z Such as VDK, UC/OSII, ThreadX
‹ An Operating System or “OS”
z …runs on top of a kernel
z …provides foundational software
elements to applications
z Such as uCLinux, QNX, Integrity
‹ An Application…
z …is a program which runs within an
operating system
z Such as WWW Browser, MP3 Player
Application
Application
Application
Application
OS
KERNEL
SCHEDULER
23
Why Blackfin is well-suited to run an
RTOS?
‹
‹
‹
‹
Powerful Hardware Event Controller
Flexible Memory Model
z Extremely Fast L1 Memory can be used as cache for data and/or
instructions
z Critical portions of the kernel can reside in L1 SRAM
Memory Management Unit (MMU)
z MMU provides protection of both internal and external memory segments in
1K, 4K, 1M and 4M granularity.
z MMU provides caching strategies for external memory segments allowing
some code to always be cached and other code never to be cached.
Protected Runtime Model
z Blackfin supports User and Supervisor operating modes.
z The kernel runs in supervisor mode and has complete access to the
memory space and on-chip peripherals.
z Threads run in user mode and have limited access to memory. Any illegal
memory accesses cause exception which is handled by kernel. Thread can
be terminated instead of processor crash.
24
Why Blackfin is well-suited to run an
RTOS cont?
‹
‹
Watchdog Timer
z Blackfin’s watchdog timer adds another layer of
application protection.
z When in use, it will reset the part of throw an
exception if the application stops responding.
Real time clock (RTC)
z Blackfin’s real time clock with dedicated battery
supply allows the processor to keep real-world time
even when it’s powered down.
z RTC alarm can wake up processor from deep-sleep
low-power state.
25
Blackfin – Mainstream RTOS and OS
Support
‹
‹
Control
Applications
OS
Real Time
DSP Code
VCSE
Kernel (or RTOS)
Blackfin
‹
Operating Systems
z Embedded Linux – Now
RTOSs and Kernels
z VDK from ADI – Now
z UC/OSII – Now
z Nucleus PLUS – Now
z ThreadX – Now
z CMX – Now
z Live Devices – Now
z uITRON (API) – Now
Networking Stacks
z Kadak Kwik-Net – Now
z Unicoi Fusion Net – Now
z Net-X – Now
26
VDK
‹
‹
‹
Features
z Supplied free with VisualDSP++, basic hard real time
scheduler
z A kernel but not full blown RTOS with all
bells/whistles and collateral
Supported Tools
z VisualDSP++
Success Stories
z Networked Wire Bonder; basic functions needed
z Sound Bridge; basic functions enough
27
UC/OSII
‹
Features
z Low Cost (Free)
z Security, Reliability, Robustness
z Small footprint
z Fast (<1us Context Switch)
z Easy-to-Use (Full Source Code, Easy API, Simple)
‹ Supported Tools
z VisualDSP++
‹ Success Stories
z Digital camcorder.
z Digital Camera.
z Radio Modems.
z Video Surveillance Systems.
z Digital Audio Recorder.
28
Introduction to
μCLinux
29
What’s so special about Linux!?
‹
‹
‹
‹
‹
‹
‹
Multiple choices vs. sole source
Source code freely available
Robust and reliable – field proven
Modular, configurable, scalable
Superb support for networking and Internet
No runtime licenses
Large pool of skilled developers
30
A Brief History of Linux and ucLinux
‹
‹
1969
z Unix NOS (Network Operating System) developed
based on research from GE, MIT, AT&T
August, 1991
z Linus Torvalds at the University of Helsinki posts the
following message on August 25th on comp.os.minix
(minix = another UNIX-like NOS)
“Hello everybody out there using minix - I'm
doing a (free) operating system (just a
hobby, won't be big and professional like
gnu) for 386(486) AT clones. This has been
brewing since april, and is starting to get
ready. I'd like any feedback on things
people like/dislike in minix, as my OS
resembles it somewhat (same physical layout
of the file-system (due to practical
reasons) among other things).”
‹
January, 1998
The first ports of Linux to systems without a MMU
was done by Kenneth Albanowski and D. Jeff
Dionne
31
uCLinux on Blackfin
‹
ADSP-BF533
z All releases and updates will be posted on
www.blackfin.uclinux.org
z Porting by EFLAG, China
‹
ADSP-BF537
z Next target processor for ADI team – release scheduled
towards end of summer, 2005
‹
ADSP-BF561
z Porting by EFLAG, China
32
ucLinux on Blackfin : Size of uClinux?
‹
Most of binaries and source code for the kernel have been rewritten
to tighten-up and slim-down the code base
‹ The uClinux is much smaller than the original Linux 2.0 kernel.
‹ Retains main advantages of the Linux OS:
z stability
z superior network capability(a full TCP/IP stack),
z excellent file system support (Only NFS, ext2, MS-DOS and
FAT16/32)
z common Linux API
‹ Memory Footprint
z uCKernel < 512 KB
z uCKernel + tools < 900 KB
33
ucLinux on Blackfin : Blackfin has an MMU
Q : “Blackfin has an MMU, why can’t I run full Linux?”
z
Blackfin MMU does not support VM (Virtual Memory) which is a
requirement for Linux. Blackfin MMU is considered a “full” MMU.
Q : “I want to run full Linux because it is more stable!”
z
Not on Blackfin! The Blackfin MMU supports memory protection and
run-time modes which allows ucLinux to run with much more stability!
‹ 1MB CPLB is placed over the kernel space – if thread crashes and
attempts to overwrite kernel space, exception is generated and the
thread is killed by the kernel.
‹
‹
All threads run in user mode ensuring they do not accidentally
change any control register or access protected memory.
ucLinux Kernel runs in supervisor mode.
34
Real-Time Work on Linux
Today Linux can provide Soft Real-Time out of the box.
‹ Two Approaches to Real-Time Linux
z Put Regular Linux on top of a small real-time kernel
‹ Such kernel as RT-Linux or RTAI
‹ Programs need predictable real-time run on RT
Kernel
‹ All other tasks/services run on Linux kernel
z Modify Linux kernel to achieve hard real-time interrupt
latency
‹
35
Real-Time Work on Linux
‹
Several Vendors are working on Real-Time solutions:
z MontaVista has a Real-Time kernel that they are trying
to get accepted by the Linux Community.
z RTLinux provides a Real-Time kernel uses Linux a thread
of the Real-Time OS.
z Lineo has implemented the Real Time Application
Interface (RTAI) for Linux.
‹
Several Open Source Development teams are working on
Real-Time solutions:
z Fixes have gone into the 2.6 kernel
36
2.4 kernel real time performance
37
2.6 kernel real time performance
38
Hard real-time Linux alternatives
‹
‹
‹
‹
‹
Linux 2.6
z New scheduler algorithm – O(1) algorithm
z Kernel preemption patch
z Improved threading model and in-kernel support for NPTL
z Merging of much of the uCLinux project
Linux with RTAI
z Real-Time Application Interface – hard real-time extension
z All RATI tasks run in kernel-space as well as RATI itself
Linux with LXRT
z LXRT – an extension to RTAI
z Allow hard and soft real-time tasks to run in user-space
Preemption latency – important real-time measurement
Test show RTAI and LXRT provide deterministic behaviors
39
uCLinux Real-Time Capabilities satisfy your
multimedia application
‹
‹
‹
Common Time Constraint
z Dictated by the ability of the user to recognize A/V
glitches
z Normally fall in the area of 10ms
z Easy to be satisfied with soft real-time capability
Stricter Timing requirement
z Change scheduler, such as the new O(1) scheduler
and kernel preemption in kernel 2.6.x
Most cases, scheduler have enough time to handle low
number of processes (network stack…) while decoding
video and audio
40
EBF-533 与 Uclinux
‹
‹
‹
‹
开发环境
交叉编译工具
bootloader :uboot
Uclinux发行包与EFLAG
41
Uclinux开发环境
所有程序在pc机上使用交叉编译器进行编译
‹ 内核和应用程序通过网络下载到目标板上
‹ 通过jtag接口进行调试
‹
开发主机
Jtag线
Ethernet线
42
交叉编译套件
生成运行于处理器上的程序包括编译,链接两个主要过程,交叉编译工
具提供了这
个过程中需要的软件,以及一些辅助工具。主要包括:
1. gcc:gnu的编译器。完成从高级语言到机器码的翻译过程。
2. as:汇编器,处理汇编语言的源文件。
3. ld:链接器,解决编译器生成二进制文件之间符号解析,定位问
题,生成最终可运行文件。
4. nm: 列出目标文件中所有的符号。
5. ar:打包库函数文件。
6. objdump:反编译分析工具
开发中可能使用到的其它工具:
1. make:项目编译管理工具。在重建整个项目时,自动检测工程文件
中自上次编译后更新的源文件,并寻找依赖于这些文件的其他文
件,编译更改后的文件和依赖于它们的文件,链接新生成的和未改
变的二进制文件,重建项目。make的具体使用请参考
43
http://www.gnu.org/software/make/manual/make.html
u-boot
u-boot是烧写到flash起始地址的一段程序。在系统上电后,处理器将从u-boot开始执行。
它通过串口和pc进行命令的通讯,通过网络进行数据通讯。
主要功能有:
1.
硬件初始化:包括ebiu,sdram,PLL,网卡,flash,uart。
2.
支持简单命令:分析从串口接收到的数据流,执行相应的命令。
3.
内核/文件系统下载:通过网络,使用tftp协议从pc机下载文件到sdram指定地址
4.
内核引导:从flash中取出kernel镜像,进行校验并执行。
5.
擦写flash:将sdram中内容写入flash指定位置。常用来固化内核和文件系统
44
uclinux发行包
1.
2.
3.
4.
来源:可以从ADI网站下载或使用EFLAG开发包
uclinux发行包包括:
•
内核源代码:最新版本为2.6.x
•
运行库:uclibc,jpeg库等
•
应用程序
配置与编译:内核,运行库和应用程序都可以按照需要,选择是否编入最终产品
•
在uClinux-dist根目录下键入make menuconfig激活配置界面,将分别对内
核,运行库和应用程序进行选择。
•
键入make。激活make程序,根据配置选择相应的编译链接对象,生成内核镜
像和文件系统镜像。
•
使用uboot将内核和文件系统下载到目标板。
•
在uboot中,键入bootm引导linux运行。
EFLAG在uclinux中的工作:
•
针对blachfin评估板系列进行内核移植。
•
补充大量驱动,包括音视频采集输出驱动,各种存储设备(IDE,USB,MMC)驱
动,显示驱动(lcd等)。
•
利用blackfin+uclinux开发出dvs和pmp等产品。
45
EFLAG可提供的嵌入式操作系统与协议栈
‹
EFLAG-uCLinux 2.6.8(基于ADSP-BF561/BF53X)
z 解决网上发布的uCLinux的低效率问题
z 使用EFLAG-uCLinux-Patch
z 将中断、DMA机制以及驱动程序进行优化
z 解决了核心算法库向片内L1 Memory加载的问题
z 支持基于uCLinux的众多协议栈,如TCP/IP,PPPOE等
z 支持MicroWindow GUI
z 用H.323协议栈OOH323进行了验证
z 在ADSP-BF533上完成了PMP MPEG-4+MP3 Decoder 25fps
z 基于ADSP-BF561完成了网络视频服务器的全部功能
‹ EFLAG-uC/OS-II(基于ADSP-BF561/BF53X)
z 支持多种文件系统和GUI
z 提供丰富的高性能外设驱动
z 支持各种音视频算法
46
亿旗EBF-533评估板配套uclinux
硬件模块
配套软件模组
Bf533/bf532/bf531/bf561
uclinux2.6.8,u-boot1.1.1(通过网络下载,flash烧写,内核引导)
Usb2.0host
Ohci驱动,支持usb键盘,鼠标,存储等设备
Video decoder
V4l驱动,单桢/流模式图像采集
Video encoder
Framebuffer驱动,支持ntsc/pal
Usb device
Storage 类设备驱动,接入pc
Lcd
Framebuffer驱动
Nor flash
Mtd驱动,定制分区。支持Jffs2文件系统
Nand flash
Mtd驱动,定制分区。坏块检测,错误校验。支持jffs2文件系统
Ethernet
Net驱动。支持ipv4/6所有协议栈
Audio encoder
oss驱动。音频录制/回放,采样率,采样精度控制
Can
Can节点通讯驱动
Sd/mmc
支持fat等格式的sd卡和mmc卡
ATA/ATAPI接口
支持硬盘,cdrom等ata标准设备及协议栈
RS232
双工串口驱动
CMOS SENSOR
V4l驱动,支持多种图像采集方式
按键,led
直接控制驱动
47
Uclinux应用实例:DVS
‹
‹
‹
‹
‹
‹
‹
‹
‹
‹
‹
压缩:Mpeg4标准压缩。支持PAL/NTSC输入;支持HALF D1,CIF,QCIF格式;PAL制桢率25,
NTSC桢率30;亮度,对比度,色度,饱和度可调;多种码流模式针对不同带宽和用户需求 。音
频: 16位采样精度,低码率且保持原始声音品质。
支持ide和usb的硬盘接入,精确至分钟的视频存储方案设定。
可串接多种485设备,内置多种云台解码器协议,支持通过网络控制485设备。
支持多种网络协议,pppoe,tcp,ftp等。
两路音频入,两路视频入。一路音频出。
一个以太 网接口。
两个usb2.0接口。
一个ide接口。
2路报警输入,2路报警输出。
一个232接口。
一个485接口。
在561的A核上运行了uclinux,利用其完备的协议栈(网络部分,usb/ide部分),实现复杂的业务逻
辑。
B核负责音视频流采集压缩。双核通过内存进行数据交换。
48
Uclinux应用实例:PMP
‹
‹
‹
1.
2.
3.
4.
便携多媒体播放平台,支持多种格式音视频;同时具有PDA的事务处理功能。
发挥bf53x系列处理器强大数据处理能力,支持各种复杂解码算法
发挥linux在嵌入式领域应用的优势:
功能不断增强的内核。
完备的协议栈:usb,文件系统,硬盘等,网络
丰富的代码资源。
可调整控制的sdram和flash容量
49
谢
谢!
50