VxWork BSP 和启动过程

来源:百度文库 编辑:神马文学网 时间:2024/04/28 06:23:32
开发BSP主要的两点:
系统image的生成,image的种类,image的download下载过程,系统的启动顺序和过程,调试环境的配置及远端调试的方式和方法,相应BSP设置文件的修改(网络,串口..),BSP各文件的组成和作用.
要对系统底层驱动清楚,也就是对CPU及相关的硬件有所了解.主要是32微处理器(上电启动过程, download image的方式方法,读写ROM,地址空间分配,MMU,寄存器,中断定义,..).参照硬件资料,多读一些源码会有所帮助.
Tornado 2 开发调试环境协议框图
主机开发(Host Development System)
目标机(Target System)
Tornado 工具
WTX协议通信<==========>
Editor
Project
Shell
Debugger
Browser
Windview
Target Server
|
Target Agent
VxWorks Target Simulator
WDB协议通信
<==========>
Application
VxWorks OS
VxWorks Target (WDB)Agent
两个主要两个协议
WTX协议(Wind River Tool eXchange): 用于开发机内部Tornado工具与Target Server之间通信.
WDB协议(Wind DeBug): 用于主机Target Server与目标机之间的通信.
一.基本概念
BSP定义:
Provides VxWorks with primary interface to hardware environment.
作用:
在通电后,初始化硬件.
支持VxWorks和硬件驱动通信.
使hardware-dependent 和 hardware-independent在VxWorks系统中很好的结合.
主要BSP主要文件目录的组成及主要文件的作用:
目录target/config/All:
这个目录下的文件是所有BSP文件共享的,不是特别需要不要更改里面的任何文件.
configAll.h:
缺省定义了所有VxWorks的设置.如果不用缺省的设置,可在BSP目录下的config.h文件中用#define或#undef方式来更改设置.
bootInit.c:
在romInit.s后,完成Boot ROM的第二步初始化.程序从romInit.s中的romInit()跳到这个文件中的romStart().来执行必要的解压和ROM image的放置.
bootConfig.c: 完成Boot ROM image的初始化和控制.
usrConfig.c: VxWorks image的初始化代码.
目录target/config/comps/src:
涉及系统核心的components,主要由target/config/All中usrConfig.c中函数调用
目录target/config/bspname:
包含系统或硬件相关的BSP文件.
Makefile
一些命令行控制images的生成,参见BSP设置部分及生成下载
README
BSP发布纪录,版本,总的文档
config.h
包括所有涉及CPU主板的设置及定义(includes,definations),参见BSP设置文件及生成下载
configNet.h
网络驱动的主要设置文件,主要对END驱动设置.
romInit.s
汇编语言文件,是VxWorks Boot ROM和ROM based image的入口,参见系统启动部分
sysALib.s
汇编语言文件,程序员可以把自己的汇编函数放在这个文件里,在上层调用.VxWorks image的入口点_sysInit在这个文件里,是在RAM中执行的第一个函数.
sysLib.c
包含一些系统相关的函数例程,提供了一个board-level的接口,VxWorks和应用程序可以以system-indepent的方式生成.这个文件还能包含目录target/config/comps/src的驱动.
sysScsi.c
可选文件用于Scsi设备设置和初始化.
sysSerial.c
可选文件用于所有的串口设置和初始化.
bootrom.hex
ASIC文件包含VxWorks Boot ROM代码
VxWorks
运行在目标机上,完整的,连结后的VxWorks二进制文件.
VxWorks.sym
完全的,连结后带有符号表的VxWorks二进制文件
VxWorks.st
完全的,连结后,standalone,带有符号表的VxWorks二进制文件
BSP用"make"来编译连接生成(Created),而不是用Tornado的工具.
BSP和应用程序都可以在"make"或"tornade"上开发(developed)
BSP被设置包括以下驱动:
中断控制interrupt controller,计时器timer(sys/aux),串口UART(serial),显示屏LCD,键盘Keyboard(opt),触摸屏touch-screen(opt).
前面三个是BSP的主要部分.
BSP默认的download VxWorks RAM image方式是从ethernet.
串口电缆需要用来和开发板(COM1)通信,通过协议WDB.
VxWorks Image的种类:
Loadable images.
ROM-based images---compressed/uncompressed.
ROM-Resident images.
ROM-resident image 对一些系统内存RAM资源较少的情况下,为了节省资源,只拷贝image中的数据部分(data segment)到内存RAM,留下程序部分(text segment)在ROM中执行。这样空出更多的RAM空间给应用程序。
并不是所用得板子都支持这种VxWorks image.
VxWorks boot images---A VxWorks image designed to load another VxWorks images containing application code (often refer to as "boot code")
"Burned" into ROM or loaded into Flash.
Maybe execute in ROM/Flash (ROM-resident).
Maybe execute out of RAM.
VxWorks images---A VxWorks image containing "end-user" code,Sub-types:
Loadable VxWorks image--VxWorks images loaded by VxWorks boot image.
Loadable VxWorks image是通过VxWorks boot image装载的VxWorks images.
VxWorks ROM image--VxWorks image "burned" into ROM or loaded into Flash.May execute in Flash.
VxWorks images consist of:
Text segment---executable instruction.
Data segment---Initilized global and static varibles.
BSS.
VxWorks Image文件类型的说明
Uploaded images(通过网口或串口下载到RAM):
vxWorks - basic Tornado, shell 和 symbol table 在主机端
vxWorks.st(文件很大)- 独立的 image,包含shell和 symbol table在目标板运行
ROM based images(直接烧入ROM的VxWorks):
vxWorks_rom - Tornado in ROM,非压缩, 在 RAM 中运行
vxWorks.res_rom_nosym - Tornado in ROM, 非压缩,在 ROM 中运行
vxWorks.st_rom - Stand-alone in ROM, 压缩, RAM 中运行
vxWorks.res_rom - Stand-alone in ROM, 非压缩, ROM 中运行
非BSP make文件中包括:
include $(TGT_DIR)/h/make/rules.library
include $(TGT_DIR)/h/make/defs.default(define default value for makefile)
...............
BSP make文件中包括: include $(TGT_DIR)/h/make/rules.bsp ...
ARM7 做VxWorks imgage 时,在makefile 文件中用 MACH_EXTRA 代替 LIB_EXTRA, 这样生成的VxWorks时不压缩的在ROM中运行的程序(uncompressed ROM-based VxWorks image),否则就是压缩的在RAM中运行的程序(compressed RAM-based VxWorks image).
启动顺序的一些概念
The sequence of events which occur as power-up are a function of type VxWorks image with will run.
处理器"跳"到再ROM或Flash中Boot-strap 程序的起点. 这个程序主要有以下作用:
关闭中断(来自处理器)
初始化目标内存(target memory)
装载要运行的VxWorks image segments
Jumps to code to place target in quiet state
启动顺序 Boot Sequence--Loadable VxWorks image
Bootstrap code executes and loads text and data segments of boot code(from ROM or Flash) into RAM.具体执行如下:
Boot code compressed-Decompression during copy
Boot code uncompressed-copy
Boot code is ROM-resident-copy data segment only
Boot program executes and loads VxWorks image into RAM.Jumps to VxWorks load point.
System initialization code statically linked into loaded VxWorks image executes and completes initialization.
Startup Sequence--VxWorks 初始化
做以下工作:
Place hardware environment in a quiet state.
Initalize and start the wind kernel
Spawn a tast to complete system initialization
System initialization task will initialize support for end-user specified facilities,and start the end-user‘s application
二.系统启动顺序
VxWorks image
分为在ROM中运行和在RAM中运行两种.两者启动顺序的区别在于sysInit()函数的调用.该函数在RAM运行的VxWorks中初始化RAM.
ROM中运行的VxWorks
VxWorks在ROM中运行,即写入ROM中的VxWorks是非压缩的,不需要解压,系统直接跳到ROM的首地址,运行VxWorks.注意:ROM运行的VxWorks并不支持所有的主扳,应以主扳手册为准.
文件romInit.s中的romInit()---->文件bootInit.c中的romStart()---->文件usrConfig.c中的usrInit()----->sysHwInit()----->usrKernelInit()----->KernelInit(usrRoot,...)
VxWorks在ROM中运行主要是为了节省RAM空间,以便应用程序有更大的空间运行.只把VxWorks image的data段复制到RAM的LOCAL_LOW_ADRS, text部分留在ROM并在ROM中执行.
ROM中运行的VxWorks缺点是运行速度慢.
RAM中运行的VxWorks
VxWorks在RAM中运行,即写入ROM中的Boot或VxWorks Image是压缩的,需要先解压copy所有的text和data到RAM的LOCAL_LOW_ADRS中,下面sysInit()主要是初始化RAM用的,系统直接跳到RAM的首地址,运行VxWorks
usrInit()前面不压缩,即romInit(),romStart()不能压缩.
文件romInit.s中的romInit()---->文件bootInit.c中的romStart()---->sysaLib.s中的sysInit()---->文件usrConfig.c中的usrInit()----->sysHwInit()----->usrKernelInit()----->KernelInit(usrRoot,...)
RAM运行的Boot或VxWorks image的text段或data段会从ROM复制到RAM,在RAM中运行.
其中usrRoot()是VxWorks启动的第一个任务,由它来初始化 driver,network等
描述: romInit.s first execute in flash,minal initiliz,then jump to romStart.
romStart() 开始装载和解压image到RAM,sysaLib.s是在RAM中执行的第一个函数.
BootROM image
BootROM image
最少的系统初始化,主要用于启动装载VxWorks image.一般有压缩和不压缩两种形式,如bootrom和boot_uncmp.与VxWorks image的区别在于一个Bootrom调用bootConfig.c,而VxWorks调用usrConfig.c.
文件romInit.s中的romInit()---->文件bootInit.c中的romStart()---->文件bootConfig.c中的usrInit()----->sysHwInit()----->usrKernelInit()----->KernelInit(usrRoot,...)
其中 /target/config/all/bootConfig.c是Boot ROM设置模块.用于通过网络加载VxWorks image.
usrRoot()---->bootCmdLoop(void)命令行选择,或autobooting----->bootLoad(pLine, &entry)加载模块到内存(网络,TFFS,TSFS...)----->netifAttach()---->go(entry)----->(entry)()从入口开始执行,不返回.
各个函数的主要作用
romInit()-----power up,disable interrupt,put boot type on the stack,clears caches.
romStart()-----load Image Segments into RAM.
usrInit()-----Interrupt lock out,save imformation about boot type,handle all the Initialization before the kernel is actually started,then starts the kernel execution to create an initial task usrRoot().This task completes the start up.
sysHwInit()-----Interrup locked,Initializes hardware,registers,activation kernel
KernelInit(usrRoot,...)-----
Initializes and starts the kernel.
Defines system memory partition.
Activates a task tUsrRoot to complete initalization.
Unlocks inierrupts.
Uses usrInit()stack.
usrRoot()
初始化内存分区表(memory partition library)
初始化系统系统时钟(system clock)
初始化输入输出系统(I/O system)----可选
Create devices----可选
设置网络(Configure network)--------可选
激活WDB目标通信(Activate WDB agent)---------可选
调用程序(Activate application)
VxWorks Image在RAM中解压的位置
RAM Low Address
RAM High Address
VxWorks运行的位置
Boot image由ROM解压后Copy的位置,即bootRom区
RAM Low Address,RAM High Address和有关定义在BSP,config.h,makefile文件中定义.可参见BSP配置文件及生成下载
VxWorks 在ROM中的情况
ROM 低高地址位
ROM 低地址位
压缩的VxWorks Imgage
没有压缩的romInit.s和romStart()在ROM的起始位置,系统power up后,从这个起始位开始执行,即执行romInit(),起始位置由硬件定义,一般为0x00000000
注:浅蓝色为整个VxWorks Image.
其中 RAM_LOW_ADRS, RAM_HIGH_ADRS 等一些地址在makefile 和BSP config.h中定义.可参见BSP配置文件及生成下载

作者Blog:http://blog.csdn.net/wangyh76/