vxworks基础培训
VxWorks开发教程(2024)

03
无线通信应用案例分 析
通过分析一个具体的无线通信应用案 例,展示如何在VxWorks系统中实现 无线通信功能,并提供一些优化和改 进的建议。
2024/1/28
35
08
图形界面开发与多媒体应用支 持
Chapter
2024/1/28
36
图形界面开发框架介绍
WindML
2024/1/28
29
设备驱动开发流程
01
需求分析
明确设备的功能需求、性能需求 和接口需求,为后续的设备驱动
开发提供基础。
03
编码实现
依据设计文档,使用C语言等编程 语言实现设备驱动的代码编写。
2024/1/28
02
设计阶段
根据需求分析结果,设计设备驱 动的整体架构、数据结构和函数
接口等。
04
测试与验证
2024/1/28
10
建立工程及源代码管理
创建新工程
在Workbench中,选择“File”->“New”>“VxWorks Project”,然后按照向导创建一个 新的VxWorks工程。
配置工程属性
在工程属性中,你可以设置编译选项、包含路径 、链接库等。确保这些配置与你的目标机和源代 码相匹配。
配的内存。
使用memPartAlloc和memPartFree函数:VxWorks提供了内存分区管理功能,可以 使用memPartAlloc函数从指定的内存分区中分配内存,使用memPartFree函数释放
内存到相应的分区。
2024/1/28
使用taskAlloc和taskFree函数:针对任务相关的内存分配,可以使用taskAlloc和 taskFree函数。这些函数会从任务的控制块中分配和释放内存。
Vxworks开发简明培训教程服务器应用

Vxworks开发简明培训教程服务器应用一、教学内容本教程服务器应用部分,主要针对VxWorks操作系统的服务器应用进行讲解。
教材涵盖的章节有:第三章网络编程,第四章服务器编程,第五章Web服务器开发。
具体内容如下:1. 第三章网络编程:介绍VxWorks操作系统中的网络编程基础,包括套接字编程、TCP/IP协议栈的使用等。
2. 第四章服务器编程:讲解如何在VxWorks中实现网络服务器,包括基于TCP和UDP的服务器编程。
3. 第五章Web服务器开发:介绍Web服务器的基本原理,以及在VxWorks中如何开发Web服务器。
二、教学目标1. 使学生掌握VxWorks操作系统的基本网络编程方法。
2. 培养学生具备在VxWorks中实现网络服务器的能力。
3. 让学生了解Web服务器的工作原理,并能在VxWorks中进行开发。
三、教学难点与重点1. 教学难点:VxWorks网络编程中的socket API,Web服务器开发中的HTTP协议处理。
2. 教学重点:服务器编程的基本方法,Web服务器的核心模块实现。
四、教具与学具准备1. 教具:多媒体教学设备,VxWorks操作系统安装光盘。
2. 学具:学生个人电脑,VxWorks操作系统安装文件,网络编程实践案例。
五、教学过程1. 引入实践情景:以企业实际需求为背景,讲解网络编程在服务器应用中的重要性。
2. 讲解第三章网络编程:通过示例代码,讲解VxWorks中的套接字编程方法。
3. 讲解第四章服务器编程:以TCP服务器为例,讲解服务器程序的实现过程。
4. 讲解第五章Web服务器开发:介绍Web服务器的工作原理,以及在VxWorks中实现Web服务器的方法。
5. 随堂练习:让学生根据所学内容,编写一个简单的网络服务器程序。
6. 例题讲解:分析并讲解典型的网络编程问题,如Socket编程中的粘包问题。
7. 课后作业:布置作业题目,要求学生完成一个基于VxWorks的Web服务器程序。
VxWorks操作系统基础(适合初学者阅读)2024新版

系统库(System Library)
提供一系列操作系统服务,如文件操作、网络协议栈等。
驱动程序(Device Drivers)
与硬件设备交互,实现对硬件设备的控制和管理。
内核组成及作用
内核组成及作用
01
内核的主要作用包括
02 管理系统资源,如CPU、内存、I/O设备等 。
06
VxWorks文件系统操作指南
文件系统类型及特点介绍
RAM-based File System
基于RAM的文件系统,读写速度快,但数据在 关机后丢失。
TrueFFS
Wind River特有的闪存文件系统,提供磨损均 衡和掉电保护功能。
ABCD
DOS File System (dosFs)
兼容MS-DOS的文件系统,支持FAT12、FAT16 和FAT32格式。
01
VxWorks操作系统概述
VxWorks操作系统定义
VxWorks是一款由美国风河公司( Wind River)开发的嵌入式实时操 作系统(RTOS),专为需要实时响 应和高可靠性的应用而设计。
VxWorks提供了丰富的中间件和开发 工具,支持多种处理器架构和硬件平 台,广泛应用于航空、航天、通信、 医疗、工业自动化等领域。
在ISR中处理完中断事件后, 需要及时清除中断标志,避 免重复处理。
中断优先级设置和嵌套处理
01
VxWorks支持多级中断优先级,高优先级的中断可以打断低优先 级的中断处理。
02
中断优先级可以通过配置文件或动态调整进行设置,以满 足不同应用场景的需求。
03
在处理中断时,如果发生更高优先级的中断请求, VxWorks会自动保存当前中断的上下文信息,并跳转到更 高优先级的中断处理程序中。处理完成后,再恢复之前中 断的上下文信息并继续执行。这种机制称为中断嵌套处理 。
VxWorks入门

1. 概述1.1 TORNADO 组件1.1.1 开发工具1.1.2 实时系统1.1.3 Tornado 文件目录1.2 硬件/软件配置1.3 booting介绍1.4 Tornado开始过程1.5 WDB 代理2 Projects2.1 bootable projects2.2 集成模拟器vxsim2.3 Downloadable projects 2.4 build说明3 WindSh 和Browser3.1 WindSh3.2 Browser4 CrossWind4.1 Debugging简介4.2 任务级Debugging 4.3 系统级DebuggingVxWorks 是美国Wind River System 公司(以下简称风河公司,即WRS 公司)推出的一个实时操作系统。
WRS 公司组建于1981年,是一个专门从事实时操作系统开发与生产的软件公司,该公司在实时操作系统领域被世界公认为是最具有领导作用的公司。
VxWorks 是一个运行在目标机上的高性能、可裁减的嵌入式实时操作系统。
它以其良好的可靠性和卓越的实时性被广泛地应用在通信、军事、航空、航天等高精尖技术及实时性要求极高的领域中,如卫星通讯、军事演习、弹道制导、飞机导航等。
在美国的F-16、FA-18 战斗机、B-2 隐形轰炸机和爱国者导弹上,甚至连1997年4月在火星表面登陆的火星探测器上也使用到了VxWorks。
1984年WRS 公司推出它的第一个版本--VxWorks 1.0.1,在1999年推出了它的最新版本VxWorks 5.4。
从1995年以后,WRS 公司推出了一套实时操作系统开发环境-- Tornado。
1.1 Tornado2.0 组件Tornado是嵌入式实时领域里最新一代的开发调试环境。
Tornado给嵌入式系统开发人员提供了一个不受目标机资源限制的超级开发和调试环境。
T ornado包含三个高度集成的部分:. 运行在宿主机和目标机上的强有力的交叉开发工具和实用程序;. 运行在目标机上的高性能、可裁剪的实时操作系统VxWorks;. 连接宿主机和目标机的多种通讯方式,如:以太网,串口线,ICE或ROM仿真器等。
实时嵌入式系统 VxWorks培训

1.5.3GDB--调试界面
1.5.4WindView--多任务观察界面
1.5.5程序编辑--Source Insight
开发环境的主要部件是宿主机(host)、目标机 (target) 典型的交叉平台系统代码(如实时嵌入式操作系统、系统 软件和应用软件)通常保存在ROM和NVRAM存 储设备中。 对嵌入式系统软件的升级就是利用特殊的设备 与/或特殊的方法重写EPROM中的程序或重写闪 存(flash)中的程序。
1.5 vxWorks及其开发环境
VxWorks 操作系统是美国WindRiver 公司于 1983 年设计开发的一种嵌入式实时操作系统 (RTOS),是嵌入式开发环境的关键组成部分。 vxWorks5.5开发环境为Tornado 2.2.1
1.5.1Tornado—安装目录
1.5.2Tornado--集成编译环境
1.1.1实时系统特性
实时系统必须产生正确的结果 实时系统的响应必须在预定的周期内完成 实时系统是具有确定性的。在这些实时系统中, 响应时间决定事件是有界的。一个确定的实时系 统意味着系统的每个部件都必须具有确定的行为, 使得整个系统是确定性的。
1.2嵌入式处理器
通用目的的处理器:它的设计非常丰富,可以 提供全部的特性和广泛的功能。但这些处理器 能源消耗大,产生的热量高,尺寸也大,其复 杂性也带来了制造成本的昂贵 嵌入式处理器:它是为完成特殊的应用而设计 的特殊目的的处理器 – 注重尺寸、能耗和价格的处理器 – 注重性能的处理器 – 注重性能、尺寸、能耗和价格的处理器
一、实时嵌入式系统 VxWorks 和Tornado开发环境
1.1实时嵌入式系统
嵌入式系统是设计完成复杂功能的硬 件和软件,并使其紧密耦合在一起的计算 机系统。术语嵌入式反映了这些系统通常 是更大系统中的一个完整的部分,称为嵌 入的系统。嵌入的系统中可以共存多个嵌 入式系统。
vxWorks BSP培训文档

vxWorks BSP 培训资料1BSP的概念1.1什么是BSP一个成熟的商用操作系统,其被广泛应用的必要条件之一就是能够支持众多的硬件平台,并实现应用程序的硬件无关性。
一般来说,这种无关性都是由操作系统来实现的。
但是,对于嵌入式系统来说,它没有像PC机那样所遵循的各种工业标准,各种嵌入式系统其具有的不同应用需求就决定了它一般都选用了各自定制的硬件环境,这种诸多变化硬件的环境就决定了无法完全由操作系统来实现上层软件与底层硬件之间的无关性。
因此当今的各种商用实时操作系统,都采用了分层的设计方法,它将系统中与硬件直接相关的一层软件独立出来,称之为Board Support Package即简称BSP。
顾名思义,这部分软件是针对某个单板而设计的,并且这一层软件对于用户(指开发者)也是开放的,用户可以根据不同的硬件需求对其作改动或二次开发,而操作系统本身仅仅提供了CPU内核的无关性。
1.2BSP的功能一个采用分层设计方法的典型系统,其结构如下(以UAS系统为例):图1 UAS软件总体框架BSP位于硬件平台与操作系统之间,用于对上层软件屏蔽各种硬件相关性。
BSP的主要功能在于配置系统硬件使其工作于正常的状态,完成硬件与软件之间的信息交互,为OS及上层应用程序提供一个与硬件无关的软件平台。
因此从执行角度来说,其可以分为两大部分:1)目标系统启动时的硬件初始化例程,只在系统启动过程中执行一次。
用于配置系统内硬件工作于指定状态。
2)目标板上控制各个硬件设备正常运行的设备驱动程序,由它来完成硬件与软件之间的信息交互。
其在整个软件系统中随着这种交互的发生而执行。
虽然通常BSP是为OS服务的,但实际上,BSP软件包中的部分程序对OS也并不是必须的,从这个角度,又可以将BSP 划分为两部分功能,1) 提供OS 运行所必须的硬件初始化例程及驱动程序,如单板最小系统BSP 等。
2) 为满足OS 之上的应用程序的需求而提供的一些外围设备的驱动程序,如网口,HDLC 控制器Driver 等,这些驱动程序一般需要应用程序通过OS 层与BSP 交互,当然可能还包括直接与应用程序交互的一些硬件驱动,如对各种控制信号的存取,自定义的驱动程序接口等,不经过OS 层。
vxworks培训教程(10)

vxworks培训教程(10)Wind River Systems Tornado Training Workshop ? Copyright Wind River Systems 10-1Chapter10Exceptions, Interrupts,and TimersException Handling and SignalsInterrupt Service RoutinesSystem Clock, Auxiliary Clock, Watchdog TimersWind River Systems Tornado Training Workshop ? Copyright Wind River Systems 10-2Exceptions, Interrupts, and Timers10.1Exception Handling and SignalsInterrupt Service RoutinesTimersException handlingUsing signalsInstalling user-de?ned signal handlerWind River Systems Tornado Training Workshop ? Copyright Wind River Systems 10-3Exception Handling Overview An exception is an unplanned event generated by theCPU. Examples include: trap or breakpoint instruction,divide by zero, ?oating point or integer over?ow, illegalinstruction, or address error.An exception will generate an “internal” interrupt.VxWorks installs exception handlers at system startup.These handlers will run on an exception and will try toinvoke a user-de?ned exception handler.A VxWorks exception handler communicates with auser tasks by sending a signal. The user-installedhandler will then run.Exceptions vary across CPU architectures. The help page for excLibcontains information about generic exception handling, while the page for excArchLib discusses architecture-speci?c routines.Wind River Systems Tornado Training Workshop ? Copyright Wind River Systems 10-4SignalsnormalCode(){........}mySignalHandler(){........}signal ? A signal is the software analog of an interrupt:A signal sent to a task indicates some asynchronous event has occurred.?There are 31 unique signals, each representing a different event.A task can attach a signal handler to take appropriate action when thesignal is received.Upon completion of signal handling, normal task execution is resumed(unless the signal corresponds to an exception).For more information on signals, see Advanced Programming in the UNIXEnvironment by Stevens.Wind River Systems Tornado Training Workshop ? Copyright Wind River Systems 10-5UNIX: UNIX vs. VxWorks Signals Signal is ignored if no handler is installed.“Automatic function restarting”Can install a handler to catch SIGKILL .No SIGCHLD ,SIGPIPE , or SIGURG .taskDelay() sets errno =EINTR and returns ERROR ifinterrupted by a signal.signalPend QReady QRunsignal-handler semTake(...,OrigDelay )“Automatic function restarting” describes behavior for a task whichcatches a signal while on the pend queue:1.Task receives a signal while pended.2.Task is removed from pend queue and made ready to run.3.When the task is the highest priority task on the Ready queue, it runs itssignal handler for the signal it caught.4.After running its signal handler, the task is returned to the pended state,with its originally speci?ed timeout.Wind River SystemsTornado Training Workshop ? Copyright Wind River Systems 10-6CaveatsSignals are not recommended for general intertaskcommunication. A signal:qMay be handled at too high a priority if it arrives during a priority inheritance.qDisrupts a task’s normal execution order. (It is better to create two tasks than to multiplex processing in one task via signals.)qCan cause reentrancy problems between a task running its signal handler and the same task running its normal code.q Can be used to tell a task to shut itself down.sigLib contains both POSIX and BSD UNIX interfaces.Do not mix them.Consider a task which enters a critical region by taking a mutexsemaphore guarding some shared resource. Suppose the task receives a signal while in the critical region. If the signal handler also attempts to take the mutex, it will succeed, and the resource may be corrupted.?Include signal.h or sigLib.h when programming with signals.To send a (non-exception) signal use the kill (tid, signo) function. Usesigqueue () to send queued signals.Wind River Systems Tornado Training Workshop ? Copyright Wind River Systems 10-7Registering a Signal Handler To register a signal handler:signal (signo, handler)signo Signal number.handlerRoutine to invoke when signal arrives (orSIG_IGN to ignore signal).Returns the previously installed signal handler, or SIG_ERR .The signal handler should be declared as:void sigHandler (int sig);/* signal number */? A VxWorks signal handler is passed not only the signal number but also two additional parameters. To access these additional parameters,declare your signal handler asvoid sigHandler(int sig,/* signal number */int code,/* additional code */struct sigcontext * pSigCtx);The code argument can be used to distinguish different exceptionswhich generate the same signal. See sigLib for the architecture speci?c codes. The pSigCtx argument points to saved context information for the task which received the signal. Its use is architecture dependent.? A third signal handler prototype is used for signals generated bysigqueue () and some routines in the POSIX Real-Time Extensions libraries. See sigLib for details.Wind River Systems Tornado Training Workshop ? Copyright Wind River Systems 10-8Signals and ExceptionsHardware exceptions include bus error, address error,divide by zero, ?oating point over?ow, etc..Some signals correspond to exceptions (e.g.,SIGSEGVcorresponds to a bus error on a 68k;SIGFPE correspondsto various arithmetical exceptions).myCode(){.......}bus error Task has SIGSEGV signal handler installed?Suspend task Log error messageraise signal ?When an executing task generates an exception: qIf the task has a signal handler installed to deal with that exception,VxWorks will raise the signal to that task.q If the task has no signal handler installed for that exception,VxWorks will suspend the task and log an error message to the console.The correspondence between signals and exceptions is architecturedependent. See sigLib .Wind River Systems Tornado Training Workshop ? Copyright Wind River Systems 10-9The Signal HandlerIf an exception signal handler returns:qThe offending task will be suspended.q A message will be logged to the console.Exception signal handlers typically call:q exit() to terminate the task, orq taskRestart() to restart the task, orq longjmp() to resume execution at location saved by setjmp().?For more information on setjmp()/longjmp(), see the onlinedocumentation or Advanced Programming in the UNIX Environment by Stevens.Signal handlers responding to asynchronously generated signals (sent byanother task or ISR) should return rather than exit non-locally with exit(),taskRestart(), or longjmp(). Such non-local exits, occurring in a signal handler called at an indeterminate point in the task’s execution,can leave shared resources (e.g., the system memory pool) corrupted.See also the reference entry for sigprocmask() for blocking signals during critical sections of a task’s execution.See the Exception Handling example in Appendix A.Wind River Systems Tornado Training Workshop ? Copyright Wind River Systems 10-10Exceptions, Interrupts, and Timers Exception Handling and Signals10.2Interrupt Service RoutinesTimersISR BasicsISR RestrictionsInterruptsInterrupts allow devices to notify the CPU that someevent has occurred.A user-de?ned routine can be installed to execute when an interrupt arrives.This routine runs at interrupt time. It is not a task.On-board timers are a common source of interrupts.Using them requires understanding interrupts.Tornado Training Workshop? Copyright Wind River Systems10-11Wind River SystemsDevice DriversUse interrupts for asynchronous I/O.Are beyond the scope of this course.For more information:intArchLib To install user de?ned ISR’s.Board Support Package Board-speci?c interrupt handling.Programmers Guide Architecture speci?c interrupt info.Tornado User’s Guide System mode debugging info.BSP Porting Kit Optional product for writing BSP’s.VxWorks Device Write VMEbus and VxWorksDriver Workshop standard device drivers.Tornado BSP BSP-speci?c interrupt issues, suchTraining Workshop as interrupt controllers and busses.Tornado Training Workshop? Copyright Wind River Systems10-12Wind River SystemsWind River Systems Tornado Training Workshop ? Copyright Wind River Systems 10-13Interrupt Handling Example (68k)save registers Interrupt ServiceRoutine (ISR)restore registerscall routine REThandlervectornumber hardware handler:Interrupt Vector TablemyISR (){..}.User ISR ?When an interrupt occurs:1.Switch to a dedicated interrupt stack (except for x86, R6000, CPU-32,MC68060, MC68000, and MC68010 which take interrupts on task stacks.).2.In handler wrapper routine, save volatile registers and errno .3.Call user-de?ned interrupt handler from handler wrapper.4.On return from handler, restore values previously saved and returnfrom interrupt level. May result in a reschedule of the previously executing task if a higher priority task was made ready to run.User-de?ned interrupt handler code can be installed by intConnect().Wind River Systems Tornado Training Workshop ? Copyright Wind River Systems 10-14Interrupt Handling Example (PowerPC) Exception Vector T able0x500External Exception Handler 0123456...Interrupt Table Exception Vector Interrupt Number User ISR #1User ISR #2...The PowerPC has a single external interrupt pin. A BSP may support an external interrupt controller to support nested interrupts. For details,see excArchLib and VxWorks Programmer’s Guide appendix on PowerPC.The number of entries in the interrupt table is dependent on which interrupt controller(s) your BSP supports. ISRs may be chained for a given BSP .The VxWorks external exception handler:qsaves CPU registers qreads interrupt number from interrupt controller qsequentially calls all chained interrupts at that number qcommunicates to interrupt controller that ISR is complete q restores CPU registers and returnsWind River Systems Tornado Training Workshop ? Copyright Wind River Systems 10-15Displaying the Interrupt Vector Table To show the interrupt vector table from the Browser,choose Vector Table in the selector box (Windows), orclick on the Interrupt button (UNIX).Not all CPU architectures support an interrupt vector table.This screenshot displays a portion of the interrupt vector table on amv162 BSP (MC68040 CPU). Interrupt numbers 144, 146, 148, 150, 152,154, 156, and 158 are mapped by this BSP to interrupts from the board’s Z8530 serial communications controller. The highlighted entry, 156, has installed handler _z8530IntRd, the receive ISR for this serial device.?Note that the same handler is also installed at number 148, because theZ8530 has two ports, each with its own installed ISRs. If the table we see _z8530IntRd at number 148 (SCC 1, channel B), and 156 (SCC 1,channel A). The interrupt mapping for this BSP is done set in mv162.h ,sysSerial.c ,sysScsi.c , and sysLib.c .Wind River Systems Tornado Training Workshop ? Copyright Wind River Systems 10-16Interrupts and PrioritiesInterrupt Interrupt Interrupt ...Task Task Task ...Execution Order Controlled by Hardware A b s o l u t e S y s t e m -W i d e P r i o r i t y Execution Order Controlled by Kernel Task Priority Interrupt Level (Programmable)(Hard Wired)?Interrupts preempt even highest priority task.Wind River Systems Tornado Training Workshop ? Copyright Wind River Systems 10-17Interrupt StackMost architectures use a single dedicated interruptstack.Interrupt stack is allocated at system start-up.The interrupt stack size is controlled by the macroINT_STACK_SIZE;default value de?ned in con?gAll.h .Must be large enough for worst-case nesting.Interrupt Stackint level 2int level 3int level 5x86, CPU-32, R6000, MC68060, MC68000, and MC68010 are CPU’swhich use tasks’ stacks for processing interrupts. Consequently, each task’s stack must have enough extra space to handle the worst-case nesting of interrupts.Use checkStack() or the Browser to check task stacks for stackcrashes.Interrupt stacks may be checked manually; on many architectures, the variables vxIntStackBase (where the stack starts) and vxIntStackEnd (towards which the stack grows) identify the ends of the interrupt stack region. Dump memory from vxIntStackEnd to vxIntStackBase. Thelocation where the 0xee bytes stop indicates the high water mark of ISR stack usage.Wind River Systems Tornado Training Workshop ? Copyright Wind River Systems 10-18ISR RestrictionsNo tasks can run until ISR has completed.ISR’s are restricted from using some VxWorks facilities.In particular, they can’t block:qCan’t call semTake().qCan’t call malloc() (uses semaphores).q Can’t call I/O system routines (e.g.,printf()).?The Programmer’s Gui de gives a list of routines which arecallable at interrupt time.The one I/O system call which can be made from an ISR is write( ) to apipe.ISR GuidelinesKeep ISR’s short, because ISR’s:q Delay lower and equal priority interrupts.q Delay all tasks.q Can be hard to debug.Avoid using ?oating-point operations in an ISR.q They may be slow.q User must call fppSave() and fppRestore().Try to off-load as much work as possible to some task:q Work which is longer in duration.q Work which is less critical.Tornado Training Workshop? Copyright Wind River Systems10-19Wind River Systems。
VxWorks基础培训

SHELL
EDIT DEBUGGER
Project
Browser
Windview
WDB
The WDB (Wind DeBug) protocol specifies how the target server (on the host) communicates with the target agent (on the target).
在VxWorks中,任务有几种状态 :就绪 (READY)、阻塞(PEND)、睡眠 (DELAY)、挂起(SUSPEND)及它们的 组合DELAY+S、PEND+S、PEND+T、 PEND+S+T、State+I。
任务状态转换
• Wind微内核的状态迁移表如下图所示:
Wind内核的任务调度
• 多任务处理需要一个调度法则对CPU准备运行的
基于优先级的抢占式调度与轮转调度算法相结合调度示意图
抢占上锁
• Wind的调度器可以通过tasklock( )和
taskUnlock( )对一个任务锁定或允许抢先调 度。当一个任务通过调用taskLock( )来锁定 抢先调度,在任务的运行期间就避免了高 优先级的任务的抢占。
VxWorks任务编程接口
删除安全
• 互斥中的另一个问题涉及到任务的删除。删除一
个在临界资源中的正在执行的任务往往会带来严 重的错误。
• 互斥信号量提供了一个SEM_DELETE_SAFE的参
数使得每个semTake()都含有taskSafe(),且每 个semGive()都含有taskUnsafe()。通过这个方法, 一个持有信号量的任务就可以得到删除保护。
共享内存访问互斥
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
烽火科技
VxSim的HelloWorld(四)
• 最后:查看新弹出的对话框(VxWorks Simulator),^_^ ,可以看到输出的 Hello World
•
此时,还会弹出了一个VxSim Launch的界面,这是主机用来连接目标机的。 点击OK。如果正确安装Tornado并配置正确的话,此时桌面右下角会出现 的图标(如果出现问题,会出现 的图标),点击它可以看到Target Server是 否正常工作。
烽火科技
开发板开发嵌入式程序
• 操作系统的制作与下载
– – – – – – 修改Config.h 制作BSP及bootrom 制作操作系统 配置FTP Server 启动超级终端 引导和下载操作系统
• 应用程序的编制和调试
烽火科技
操作系统的制作与下载
修改Config.h
• VxWorks的缺省配置参数由tornado\target\config\all目录中 的configAll.h决定,如第528行开始通信路径的配置 • 对于某一目标板特定的配置参数,如ads860,使用 tornado\target\config下相应目录中的config.h,下面以 ads860板为例 • 如果没有相应目录,可定制,如建立8240目录,其文件代 码由BSP开发人员编写
• WindShell
– 允许用户调用内存中的应用程序模块或是 VxWorks模块中的任何例程
烽火科技
创建任务
• 在usrAppInit函数中添加函数userMain( ),作为自己应用程序的入口函数。
•
编写一个C文件(uesr.c),内容如下:
烽火科技
编译代码及运行
• 选择Add Files,添加uesr.c到工程中:
烽火科技
Tornado中Host与target通信
Target Server以进程的形式(tgtsvr.exe)运行在Windows主机上,而Target Agent 则以VxWorks的一个任务(tWdbTask)运行在目标机上,两者通常使用网络进 行通讯,但也可以使用其他通讯方式。 Target Serve与Target Agent间使用WDB(Wind Debug)协议进行通信,这就好比 一座桥梁,将目标机与主机上的Tornado开发工具联系在一起。
修改Config.h
• 10M网口使用cpm(0,0), 100M网口使用motfec(0,0) • host:后跟VxWorks操作系统在主机的存放路径,h指主机IP 地址,e指目标板IP地址,u指用户名,pwd指密码 • 实例:使用10M网口,VxWorks在主机D:\,主机地址 10.16.17.1,目标板地址10.16.17.2,账号及密码均为 tornado,其代码为: • “cpm(0,0)host:d:/vxWorks h= 10.16.17.1 e= 10.16.17.2 u=tornado pwd=tornado”
• • • • 文本编辑器 GNU和Diab C/C++编译器 调试工具:Wind Shell, Browser, WindView… VxSim系统模拟器:VxWorks提供的在实验与测试环境下仿真VxWorks目标机的程序,无 需硬件的支持
– ②运行在目标机上的高性能、可裁剪的实时操作系统VxWorks; 即为编译生成的目标机上可执行代码镜像(image),内含os – ③连接宿主机和目标机的多种通讯方式,如:以太网,串口线,ICE或 ROM仿真器等。
操作系统的制作与下载
烧制bootrom • 目的:将build成功的bootrom 烧制到Flash中 • FADS860板通过配套的ADI卡烧制 • 按照ADI卡相应的8bug程序中的readme,安 装ADI卡 • 在DOS方式下键入:mpc8bug x y
烽火科技
操作系统的制作与下载
• • •–
•
WindShell:
– –
•
WindView:
–
•
VxSim:
–
烽火科技
VxWorks程序设计
• 任务(Task)
– 在VxWorks中,任务是一段独立运行的程序,类似于Linux中的进程。 – 从系统的角度看,任务是竞争系统资源的最小运行单元。任务可以使用 或等待CPU、I/O设备及内存空间等系统资源,并独立于其他任务。 – VxWorks实时内核Wind提供了基本的多任务环境,因此当系统运行多个 任务时,从表面上看多个任务正在同时执行,而实际上系统内核是根据 某一调度策略让它们交替运行。 – 系统调度器使用任务控制块(TCB)的数据结构来管理任务调度功能。每 一个任务都与一个TCB关联。TCB包括了任务的当前状态、优先级、要等 待的事件或资源、任务码的起始地址、初始堆栈指针等信息。 – 任务编程:任务创建taskSpawn、任务删除taskDelete、任务控制 taskSuspend/taskDelay等
烽火科技
VxSim的HelloWorld(一)
烽火科技
VxSim的HelloWorld(二)
• 选择 A BSP(板级支持包)在下拉菜单中选择simpc
•
打开文件usrAppInit.c(它的函数usrAppInit是应用的入口点),添加Hello World打印语句,保存文件。
烽火科技
VxSim的HelloWorld(三)
– 开发嵌入式应用时系统开发商提供的各种驱动支持库 – VxWorks:OS的驱动程序 – VxWorks提供的大部分功能模块与硬件无关,为使VxWorks能运行于不同 的处理器体系结构上,必须在功能模块与硬件之间加入一层软件,并对 这层软件规定标准接口,这层软件即为BSP – 提供对硬件进行的描述性操作 – 提供对目标板的初始化、中断管理以及一些简单的驱动程序 – 最好的情况下,OS与驱动程序的移植只需要更换相应平台下的BSP支撑 库 – 《Tornado BSP Developer’s Kit for VxWorks》
•
编译并启动:
烽火科技
启动Wind Shell
• 在Launch工具栏 shell的界面: 中选择 ,这时候就可以看到
•
输入i命令,回车,,即可以查看到我们起的任务tTick的有关信息:
烽火科技
Wind Shell常用命令
• i:显示所有的任务信息
• • • • • • • • Tt():显示一个任务的函数栈的调用状态 Ti():显示一个任务的tcb信息 Sp():启动一个任务 Ts():挂起一个任务 Tr():恢复一个任务 Td():删除某个任务 memShow:显示系统内存信息 checkStack:查看指定或所有任务的堆栈大小和使用率
Vxworks嵌入式编程基础
邓国旭
烽火科技
实时嵌入式系统
• 嵌入式系统:
– 由CPU控制,即自带CPU – 相对于常见的pc而言,不对用户提供开发环境,用户与系统交互的唯一接 口就是系统提供给用户的应用; – 提供功能通常带有针对性,大多为专用系统; – 手机,医疗设备,微波炉,mp3……
• 实时嵌入式系统:
烽火科技
VxWorks系统结构
烽火科技
Tornado集成开发环境
• Tornado:
– 基于VxWorks操作系统的嵌入式软件集成开发环境。 – 给嵌入式系统开发人员提供了一个不受目标机资源限制的超级开发和调 试环境。
• Tornado包含以下三部分:
– ①运行在宿主机和目标机上的强有力的交叉开发工具和实用程序;
• 交叉编译:在某一体系结构的宿主机上为另一体系结构的 目标板编译可运行的目标代码。即编译与运行不在同一地 方。
• 宿主机(host):编写代码和编译 • 目标机(target):调试和执行程序
烽火科技
VxWorks
• VxWorks:
– 美国风河公司(Wind River System)推出的一种嵌入式实时操作系统。 – 强实时性、微内核设计、可裁剪、可移植、高可靠
115200
烽火科技
操作系统的制作与下载
Build bootrom • • • • 修改BSP后,应生成对应的bootrom 在Tornado中选Build->Build Boot ROM BSP可选择ads860 Image一般选择bootrom.hex,仿真时选择 bootrom_uncmp
烽火科技
– 实时性:任务切换时间、抢占时间、中断等待时间、信号量延迟时间、 死锁解脱时间、任务间消息传递延迟、数据报吞吐量 – 小型化、可裁剪:系统资源有限 – 强稳定性:一旦运行不需要人过多干预 – 固化代码:操作系统和应用软件代码固化在嵌入式系统ROM中 – 弱交互性:工作过程不需人干预
烽火科技
嵌入式系统开发
• • 验证bootrom 连接主机与目标板的串口线 启动和配置FTP Server(方法后面介绍) 选择Tornado2->VxWorks COM1/COM2,启 动超级终端 超级终端中选文件->属性->配置,设置正确 的目标板波特率 目标板上电,检查终端是否能正确回显, 显示参数与BSP配置是否一致
• VxWorks系统功能:
– – – – – – – – Wind Kernel ANSI C/POSIX I/O系统 文件系统 TCP/IP网络协议栈 BSP开发包:提供BSP模块、驱动程序模板和BSP测试工具包 WDB(Wind Debug Agent):支持交叉调试 ……
烽火科技
BSP
• BSP(Board Support Package)
烽火科技
使用Tornado创建工程
• 创建工程.exe • WorkSpace & WorkProject
– 每一个工程都需要有一个WorkSpace来保存一些相关的环境变量;
• Bootable Vs Downable: