vxworks学习经验

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。


vxWorks6.x BSP 驱动 怎么写(1-准备)
(2014-01-14 15:47:30)
标签:
vxworks
分类: vxWorks6.x_BSP

打算有空的时候写这样一个主题的系列文章,将这几年的工作用这种方式做一个总结,1来方便新入门的xdjm能够快速了解,2来对自己有一个交代(万一哪天不干这行了vxWorks6.x BSP 驱动 怎么写(1-准备)还能有点货能拿出来)。写这么一篇文章,或多或少有些班门弄斧的感觉,vxworks里的大牛们可以自动飘过,在下也是从校园里的青葱少年到现在对vxworks略知一二,经历过无数迷茫,知道干这行的无助和迷茫啊,感谢曾经伸出过援助之手的前辈们。废话少说,脑子里很乱,大概的思路如下:因本人长期从事基于PowerPPC的BSP和驱动开发,其中又主要是从事freescale的board开发,所以会更多的从这两方面入手,不可能面面俱到,因为东西太多,如果那里理解不对,也欢迎大牛们指点一二。



写BSP的时候你需要准备哪些东西?

1.最需要的是先找一个相同的,类似的BSP,这个太重要了,你可以省去太多太多的麻烦,再这样的基础上再做修改才能事半功倍,别闭门造车,写一个全新的BSP难度是非常大的,比如PPC的BSP,先从arch级别,至少是PPC的,再从core找,是e300,e500,e500mc之类的,再从系列找,比如mpc85xx系列,mpc83xx系列,P1P2系列,P3P5系列等等,到这一级别的时候,恭喜你,你已经离成功相当近了,只是时间问题。

2.可参考的关于板子的一切代码,uboot,linux之类的或者厂商提供的启动代码,test代码,这样你不用再对着datasheet看寄存器定义,犹豫该怎么配,如果有能启动的image,你也可以反向的dump出内存,看寄存器是怎么配的。当然vxworks的源码也是必须的,网上一抓一大把,别告诉我你找不到vxWorks6.x BSP 驱动 怎么写(1-准备)

3.调试工具,点灯 < 串口打印 < 第三方的调试工具,如果能把你串口打通,基本所有的调试用它就够了,arch的代码除外。

4.对硬件的了解,如果你对硬件的工作原理一窍不通,那么先学习之,不然你不明白代码为什么这样写,下一步要干什么。想让一个BSP跑起来,至少你需要了解时钟,中断,cpu需要哪些硬件的初始化。

5.google baidu之类的,你至少要对vxworks下的BSP有个初步了解,知道你要做什么,什么不用做。



做BSP最好分阶段进行,这样你的干扰会很少,第一阶段的基本目标是让时钟,中断,uart工作起来,bootrom或者vxworks可以跑起来,接着再开发其他的功能。


/vx567



vxWorks memDrv/ramDrv 的区别
(2013-07-08 17:18:27)
标签:
vxworks
it
分类: vxWorks6.x_FS
vxWorks里经常会看见有下面这2个组件

,INCLUDE_MEMDRV,INCLUDE_RAMDRV
特别容易混淆而且不明白它们具体是干什么用的,
今天做了个研究,共享之。

1. INCLUDE_MEMDRV(memDrv)

Component INCLUDE_MEMDRV {
NAME MEM disk driver
SYNOPSIS allows a filesystem to be put on top of memory
MODULES memDrv.o
INIT_RTN memDrv ();
HDR_FILES memDrv.h
}

#ifdef INCLUDE_MEMDRV
memDrv ();
#endif

typedef struct
{
DEV_HDR devHdr;
MEM_DRV_DIRENTRY dir;
off_t allowOffset;
} MEM_DEV;

风河的注释:
The memDrv device allows the I/O system to access memory directly as a
pseudo-I/O device. Memory location and size are specified when the device is
created. The device provides a high-level means for reading and writing bytes in
absolute memory locations through I/O calls. It is useful when data must be
preserved between boots of VxWorks or when sharing data between CPUs.
The memDrv driver is initialized automatically by the system with memDrv( )
when the INCLUDE_USR_MEMDRV component is included in VxWorks. The call
for device creation must be made from the kernel:
STATUS memDevCreate (char * name, char * base, int length)
Memory for the device is an absolute memory location beginning at base. The
length parameter indicates the size of the memory.

For additional information on the memory driver, see the memDrv( ),
memDevCreate( ), and memDevCreateDir( ) entries in the VxWorks API
reference.

我的理解是,把memDevCreate出来的这些存贮区域(可以是内存也可以是norflash上的一段地址空间)当成一个"文件"来用,一个假的IO设备,可以调用标准的IO操作和文件操作来访问这块区域。
memDrv的一个典型应用就是可以把vxWorks烧写到norflash的一片区域里,这片区域一定要通过memDevCreate创建,
bootrmo就可以直接加载memDevCreate里存的vxworks,在无网络的情况调试非常方便。直接上代码:

比如从norFlash的0xff800000(MMU 映射过)开始放vxWorks image,编译出来的vxWorks image的大小是0x1f6fa0,

在config.h中加入:

#define INCLUDE_BOOT_FILESYSTEMS
#define INCLUDE_MEMDRV

在usrConfig.c中memDrv初始化之后加入:

memDevCreate("/mem/",0xff800000, 0x1f6fa0);
注意:size一定要对,不能比实际的size小了。

重新编译bootrom并烧写到板子上,并且把vxWorks image烧写到0xff800000开始处
[VxWorks Boot]: devs
drv name
0 /null
1 /tyCo/0
1 /tyCo/1
5 /mem/
3 /tffs0
3 /tffs1
7 host:
[VxWorks Boot]:d 0xff800000
0xff800000: 7f45 4c46 0102 0100 0000 0000 0000 0000 *.ELF............*
0xff800010: 0002 0014 0000 0001 0001 0000 0000 0034 *...............4*
0xff800020: 002c dab4 8000 0000 0034 0020 0004 0028 *.,.......4. ...(*
0xff800030: 001c 001b 0000 0001 0000 00c0 0001 0000 *................*
0xff800040: 0001 0000 001c ef74 001c ef74 0000 0007 *.......t...t....*
0xff800050: 0000 0001 0000 0001 001c f034 001d ef74 *...........4...t*
0xff800060: 001d ef74 0000 012c 0

000 012c 0000 0006 *...t...,...,....*
0xff800070: 0000 0001 0000 0001 001c f160 001d f0a0 *...........`....*
[VxWorks Boot]: @

boot device : fs
unit number : 0
processor number : 0
host name : host
file name : /mem/0
inet on ethernet (e) : 192.168.101.108:fffffe00
host inet (h) : 192.168.101.63
gateway inet (g) : 192.168.101.1
user (u) : target
ftp password (pw) : vxTarget
flags (f) : 0x0
other (o) : motetsec1

Loading /mem/0...1896308 + 300 + 568 + 335992
Starting at 0x10000...


Adding 7654 symbols for standalone.


VxWorks

Copyright 1984-2012 Wind River Systems, Inc.

CPU: Unsupported processor
Runtime Name: VxWorks
Runtime Version: 6.6
BSP version: 6.6/0
Created: Jul 26 2012, 10:06:01
ED&R Policy Mode: Deployed
WDB Comm Type: WDB_COMM_END
WDB: Ready.

->


2. INCLUDE_RAMDRV(ramDrv)

Component INCLUDE_RAMDRV {
NAME RAM disk driver
SYNOPSIS allows a filesystem to be put on top of RAM
MODULES ramDrv.o
INIT_RTN ramDrv ();
HDR_FILES ramDrv.h
}

#ifdef INCLUDE_RAMDRV
ramDrv ();
#endif

typedef struct
{
BLK_DEV ram_blkdev;
off_t ram_blkOffset;
char *ram_addr;
} RAM_DEV;

风河注释:
This driver emulates a disk driver, but actually keeps all data in memory.
Once the device has been created, it must be associated with a name and file
system (dosFs, hrfs, or rawFs). This is accomplished in a two step
process. The ramDevCreate() call returns a pointer to a block device
structure (BLK_DEV). This structure contains fields that describe the
physical properties of a disk device and specify the addresses of routines
within the ramDrv driver. The BLK_DEV structure address should be passed to
an XBD wrapper via xbdBlkDevCreate() along with the name of the device. XBDs
are the new and preferred method for interfacing with file systems.

After the XBD wrapper is created, the file system framework will attempt to
identify the type of file system instantiated on the device. If it can not
be identified, then it is instantiated with rawFs. The desired file system (dosFs or hrfs)
can be instantiated on the ram drive using either dosFsVolFormat(), dosfsDiskFormat(),hrfsFormat(),
or hrfsDiskFormat(). The ram drive to be formatted is identified by the name
of the device given in the XBD wrapper.

EXAMPLE
In the following example, a 208-Kbyte RAM disk is created with automatically
allocated memory, 512-byte blocks, 32 blocks per track, and no block offset.
The device is then initialized for use with dosFs and assigned the name "/ramDrv":

BLK_DEV *pBlkDev;
pBlkDev = ramDevCreate (NULL, 512, 32, 416, 0);
xbdBlkDevCreate (pBlkDev, "/ramDrv");
dosFsVolFormat ("/ramDrv:0", DOS_OPT_BLANK, NULL);

The names used in xbdBlkDevCreate() and dosFsVolFormat() are slightly
different on purpose. The ":0" is appended to "/ramDrv" by xbdBlkDevCreate()
and represents the whole (unpartiti

oned) disk.

If the RAM disk memory already contains a disk image created elsewhere,
the first argument to ramDevCreate() should be the address in memory, and
the formatting parameters -- , , , and
-- must be identical to those used when the image was
created. For example:

pBlkDev = ramDevCreate (0xc0000, 512, 32, 416, 0);

In this case, the file system does not have to be explicitly created as the
file system framework will probe the ram drive to determine the type of file
system previously instantiated on it. The detected file system will be
automatically re-instantiated on the device. This procedure is useful if a
RAM disk is to be created at the same address used in a previous boot of
VxWorks. The contents of the RAM disk will then be preserved.

BLK_DEV* ramDevCreate
(
char *ramAddr,
int bytesPerBlk,
int blksPerTrack,
int nBlocks,
off_t blkOffset
)
不得不说,风河的注释写的太好了,什么意思一看就明白了,要注意的是ramDrv只能用于内存,flash不可以。

下面是我实现的用ramDrv+hrFs来加载vxWorks image的code:
1.config.h中加入

# define INCLUDE_RAMDRV
# define INCLUDE_DISK_UTIL
# define INCLUDE_DEVICE_MANAGER
# define INCLUDE_XBD
# define INCLUDE_XBD_BLK_DEV
# define INCLUDE_XBD_PART_LIB
# define INCLUDE_FS_MONITOR
# define INCLUDE_ERF
# define INCLUDE_FS_EVENT_UTIL
# define INCLUDE_BOOT_FILESYSTEMS

# define INCLUDE_HRFS
# define INCLUDE_HRFS_FORMAT
# define INCLUDE_HRFS_CHKDSK
(如果不想用hrfs,可以看我之前的一篇怎样用dosfs)

2.用用户保留区的内存来申请ramDisk(用malloc的话复位后会清0)
#define USER_RESERVED_MEM 0x600000

3. usrConfig.c中在ramDrv()之后加入:

BLK_DEV * pBlkDev1;
pBlkDev1 = ramDevCreate((char *) sysMemTop(), 512, 6144, 6144, 0);
xbdBlkDevCreateSync(pBlkDev1, "/ram");

4. 编译bootrom烧写后加载vxworks image,格式化"/ram"并且把vxworks image拷贝到"/ram"里。


[VxWorks Boot]: devs
drv name
0 /null
1 /tyCo/0
1 /tyCo/1
3 /ram:0
5 /mem/
3 /tffs0
3 /tffs1
7 host:
[VxWorks Boot]: @

boot device : fs
unit number : 0
processor number : 0
host name : host
file name : /ram:0/vxWorks
inet on ethernet (e) : 192.168.101.11:fffffe00
host inet (h) : 192.168.101.4
gateway inet (g) : 192.168.101.1
user (u) : target
ftp password (pw) : vxTarget
flags (f) : 0x0
other (o) : motetsec1

Loading /ram:0/vxWorks...1458740 + 188 + 596 + 212476
Starting at 0x100000...

Target Name: vxTarget


vxWorks volume size/vxWorks下得到卷大小函数
(2013-07-04 15:20:30)
分类: vxWorks6.x_FS
vxWorks里任何块设备都可以mount到dosfs或者hrfs文件系统上,vxWorks本身似乎没有什么API可以获得这些卷的大小,dosfs的话可以调用dosFsShow看volume信息,但是没有显示volume大小和free大小,有没有什么方法可

以得到呢....可以用这个API写个函数来实现。
STATUS statfs
(
char *name,
struct statfs *pStat
)
这个函数最终会调到下面这个系统调用上:
#define FIOFSTATFSGET 46
ioctl (fd, FIOFSTATFSGET, (int)pStat);

这个函数大概可以这样写:
STATUS volumeShow
(
char *devName
)
{
......
struct statfs fs;
statfs ((char*)devName, &fs)
printf ("%s: Total File System Size: %dKB, Free space: %dKB.\n",
devName,
(int)(fs.f_bsize * fs.f_blocks /1024),
(int)(fs.f_bsize * fs.f_bavail /1024));
......
}
E.g:
-> volumeShow "/tffs0"
/tffs0: Total File System Size: 3824KB, Free space: 3821KB.


vxWorks 网卡driver 和组件
(2013-07-04 14:43:08)
标签:
vxworks
it
分类: vxworks6.x_utility
vxWorks6.x下网卡driver和对应的组件list:
Driver 组件
fccVxbEnd.c INCLUDE_FCC_VXB_END
fecVxbEnd.c INCLUDE_FEC_VXB_END
fei8255xVxbEnd.c INCLUDE_FEI8255X_VXB_END
gei825xxVxbEnd.c INCLUDE_GEI825XX_VXB_END
mvYukonVxbEnd.c INCLUDE_MVYUKON_VXB_END
mvYukonIIVxbEnd.c INCLUDE_MVYUKONII_VXB_END
rtl8139VxbEnd.c INCLUDE_RTL8139_VXB_END
rtl8169VxbEnd.c INCLUDE_RTL8169_VXB_END
tsecVxbEnd.c INCLUDE_TSEC_VXB_END
vxbEtsecEnd.c INCLUDE_ETSEC_VXB_END
vxbDtsecEnd.c INCLUDE_DTSEC_VXB_END
vxbUccEnd.c INCLUDE_UCC_VXB_END
vxbAt91sam9260End.c DRV_VXBEND_AT91EMAC
vxbCpswEnd.c DRV_VXBEND_TI_CPSW
vxbDm9000aEnd.c DRV_VXBEND_DM9000A

还有一些,下次加入....




vxWorks 重定向
(2013-07-04 10:02:46)
标签:
vxworks
it
分类: vxworks6.x_utility
vxWorks里的重定向, 首先推荐大家看一下这篇文章《VxWorks for X86的输入输出定向》,对vxworks里的重定向有个初步认识。
下面讲讲一下具体用法:
vxworks里的定向主要有2种,定向输出输入 全局的 和 任务级的。
全局的:
#ifdef INCLUDE_IO_BASIC

if (consoleFd != NONE)
{
ioGlobalStdSet (STD_IN, consoleFd);
ioGlobalStdSet (STD_OUT, consoleFd);
ioGlobalStdSet (STD_ERR, consoleFd);
}
#endif
顾名思义,默认的输入输出设备,全局有效,一般它可以是串口或者pcconsole,如所有的printf的输出口。

任务级的重定向:
用ioTaskStdSet() 可以改变任务的input/output的fd,

ioTaskStdSet (0,STD_IN, consoleFd);
ioTaskStdSet (0,STD_OUT, consoleFd);
ioTaskStdSet (0,STD_ERR, consoleFd);
vxWorks里的本身很多代码如一些dbg代码使用了这种模式,任务级重定向顾名思义, 只针对当前的任务有效。
举个例子,spy的输出会很长,怎么样把输出重定向到某个文件中呢。
首先要明白 spy本身就是一个任务(tSpyTask),所以你的重定向代码只能放在这个任务中才有用,换句话说,任务级的重定向代码在哪个任务下调用,这个任务的输入输出就会被

重定向,因此spy要重定向的话,你可以在spy任务本身里加上重定向代码即可,如下

void spyComTask
(
int freq,
FUNCPTR printRtn
)
{
int delay = freq * sysClkRateGet ();

int consoleFd = open ("/tffs1/output.txt", 2, 0); //把spy任务输出重定向到 tffs里的output.txt文件
ioTaskStdSet (0, STD_IN, consoleFd);
ioTaskStdSet (0 ,STD_OUT, consoleFd);
ioTaskStdSet (0, STD_ERR, consoleFd);

while (TRUE)
{
spyReportCommon (printRtn);
taskDelay (delay);
}
}
tSpyTask任务会执行这个spyComTask函数,因此整个任务被重定向,输出到了output.txt文件。

-> i

NAME ENTRY TID PRI STATUS PC SP ERRNO DELAY
---------- ------------ -------- --- ---------- -------- -------- ------- -----
tIsr0 136068 970190 0 PEND 2490f0 9700f0 0 0
tExcTask 198934 2bc3c8 0 PEND 2490f0 2be580 0 0
tJobTask 1991fc 973c90 0 PEND 2490f0 973bb0 0 0
tLogTask logTask 976dc0 0 PEND 24721c 976c50 0 0
tShell0 shellTask 9de1e0 1 READY 251020 9dc7b0 0 0
tBulkClnt 103384 9b9c80 5 PEND 2499d8 9b9b60 0 0
tUfiClnt 104264 9c5aa0 5 PEND 2499d8 9c5970 0 0
tSpyTask spyComTask 96ab40 5 DELAY 25075c 96aa90 0 53
tErfTask 1453a0 97a4c0 10 PEND 2499d8 97a3e0 0 0
tVxdbgTask 117518 9c9710 25 PEND 2490f0 9c9640 0 0
tTffsPTask flPollTask 97dc70 100 DELAY 25075c 97dbc0 0 4
vxbUsbBulk> 23418c 9b38e0 100 PEND 24721c 9b37a0 0 0
vxbUsbCbiU> 23418c 9bf700 100 PEND 24721c 9bf5c0 0 0
BusM A 21e194 2c66d0 100 DELAY 25075c 2c6620 0 1
EHCD_IH0 usbEhcdInte> 9e1680 100 PEND 2490f0 9e15b0 0 0
tXbdServic> 1f6818 980720 200 PEND 2490f0 980650 0 0
tXbdServic> 1f6818 99d3d0 200 PEND 2490f0 99d300 0 0
value = 0 = 0x0
-> ll "/tffs1"

Listing Directory /tffs1:
drwxrwxrwx 1 0 0 1024 Jan 1 1980 data/
-rwxrwxrwx 1 0 0 96444 Jan 1 1980 output.txt
value = 0 = 0x0
-> ll "/tffs1"

Listing Directory /tffs1:
drwxrwxrwx 1 0 0 1024 Jan 1 1980 data/
-rwxrwxrwx 1 0 0 98712 Jan 1 1980 output.txt
value = 0 = 0x0
->




vxWorks load 加载文件到内存
(2013-07-04 09:50:41)
标签:
vxworks
it
分类: vxworks6.x_utility
vxWorks里怎样load一个文件到内存,这个文件可以是在SD、USB、ata这类的存储设备,也可以通过ftp 网络下载,不多说 直接上代码:共享之

STATUS ldToMem
(
char * fileName
)

{
UINT8 * pData;
FILE * fp;
UINT32 FileSize;



if (NULL == (fp = fopen(fileName,"rb")))
{
printf("open file failure\n");
return ERROR;
}

#if FALSE

pfile = fopen("/sd0:0/fileName","rb");
#endif



fseek (fp, 0, SEEK_END);
FileSize = (UINT32) ftell (fp);
fseek (fp, 0, SEEK_SET);

if ((pData = malloc(FileSize)) == NULL)
{
printf("malloc failure\n");
return ERROR;
}

if (fread (pData, 1, FileSize, fp) != FileSize)
{
printf("malloc failure\n");
free(pData);
return ERROR;
}

printf("ldToMem OK pointer @ 0xx FileSize %d\n",pData, FileSize);
}



vxworks startup 启动脚本
(2013-07-02 15:18:00)
标签:
it
vxworks
分类: vxworks6.x_utility
怎样用startup的启动脚本,大家应该都知道,举个例子:
需要define下面的两个宏:
#define INCLUDE_SHELL
#define INCLUDE_STARTUP_SCRIPT

usrConfig.c中会调用:
#ifdef INCLUDE_STARTUP_SCRIPT
usrStartupScript (startupScriptFieldSplit (sysBootParams.startupScript));
#endif

这里可能会遇到一个问题,就是sata/sd/usb 之类的不工作。原因是 这个函数是在usrRoot根任务下执行的,优先级是0,而sata/sd/usb 之类的会创建一个自己相应的任务去维护这些设备,显然只有当root任务执行完后这些任务才会开始执行,所以调到usrStartupScript 的时候,sata/sd/usb 之类还没有准备好,当然无法正常工作了,解决办法有很多,比如在usrStartupScript 之前加taskDelay(),让sata/sd/usb 之类的任务先运行,我推荐的一种方法是: 在这个函数里多open几次这个设备,第一次肯定不成功,第二次应该就可以了:

int times= 0;

fd = ERROR;
while ((++times<= 10) && (fd == ERROR))
{
fd = open (fileName, O_RDONLY, 0);

if (fd == ERROR)
{

if (times== 1)
{
printf ("Waiting for driver to mount\n");
}
else if (times== 10)
{
printf("\n");
}
else
{
printf(".");


taskDelay(sysClkRateGet());
}
}

把文件放在BSP目录下,然后修改bootrom里的startup参数即可。

boot device : fs
processor number : 0
host name : host
file name : /sd0:0/vxWorks.st
user (u) : target
ftp password (pw) (blank = use rsh): vxTarget
flags (f) : 0x0
target name (tn) : hjj
startup script (s) : start.txt
other (o) : qefcc




vxWorks component 组件显示是灰的 或斜的
(2013-06-28 13:

40:04)
标签:
vxworks
it
分类: vxWorks6.x_BSP
前面一篇文章讲过如过想加一个驱动的话,必须在指定的目录下写对应的文件,如果你不想或者不能这样做的话,有没有别的办法呢?比如你想把新的驱动文件全部都放在BSP目录下。源文件/头文件包含在sysLib.c中,不要.mk,dc,dr只用workbench编译,把cdf也放在BSP目录下,这样可以吗?你会发现workbench里能看到这个component但是是灰的或者斜的,不可用!

首先要知道workbench的搜索cdf tool只会在 target/config/comps/vxWorks这个目录下和BSP目录下去搜,所以能够搜到你的CDF文件,表现为你可以看见这个component,灰的或者斜的表示组件不可用,cdf文件的依赖关系有问题,最有可能的问题是找不到你的源文件。
比如:以Fresscale DMA driver comopent为例:

Component DRV_DMA_FSL {
NAME Freescale DMA Controller Driver
SYNOPSIS Freescale DMA Controller Driver
MODULES vxbFslDma.o
REQUIRES INCLUDE_VXBUS \
INCLUDE_PLB_BUS \
INCLUDE_DMA_SYS
_CHILDREN FOLDER_DRIVERS
INIT_RTN vxbFslDmaRegister();
PROTOTYPE void vxbFslDmaRegister(void);
_INIT_ORDER hardWareInterFaceBusInit
INIT_AFTER INCLUDE_PLB_BUS
}
你要是吧这样的cdf放在BSP下,workbench中看到的肯定是灰的,即使vxbFslDma.o在BSP目录下。因为” MODULES vxbFslDma.o“在BSP路径下找不到,原因很简单,root路径不是BSP目录。

这个有两个办法可以解决:
1)在Component 里删掉 MODULES 这行,在BSP的Makefile文件里通过EXTRA_MODULES 把它加进来。

Component DRV_DMA_FSL {
NAME Freescale DMA Controller Driver
SYNOPSIS Freescale DMA Controller Driver
REQUIRES INCLUDE_VXBUS \
INCLUDE_PLB_BUS \
INCLUDE_DMA_SYS
_CHILDREN FOLDER_DRIVERS
INIT_RTN vxbFslDmaRegister();
PROTOTYPE void vxbFslDmaRegister(void);
_INIT_ORDER hardWareInterFaceBusInit
INIT_AFTER INCLUDE_PLB_BUS
}
EXTRA_MODULES += vxbFslDma.o

2)指定源文件路径,让到你指定的路径下去找
用关键字CONFIGLETTES

Component DRV_DMA_FSL {
NAME Freescale DMA Controller Driver
SYNOPSIS Freescale DMA Controller Driver
CONFIGLETTES ../../../config/bsp/vxbFslDma.c ->> give the absolute path
REQUIRES INCLUDE_VXBUS \
INCLUDE_PLB_BUS \
INCLUDE_DMA_SYS
_CHILDREN FOLDER_DRIVERS
INIT_RTN vxbFslDmaRegister();
PROTOTYPE void vxbFslDmaRegister(void);
_INIT_ORDER hardWareInterFaceBusInit
INIT_AFTER INCLUDE_PLB_BUS
}
这两种方法都可以解决问题vxWorks component 组件显示是灰的 或斜的



winxp win7 删除 workbench
(2013-07-01 14:52:04)
标签:
vx

works
it
分类: vxworks6.x_utility
1. 删掉安装目录
2. 删掉快捷方式和程序里的目录
3. 执行 cmd -> regedit 删掉 HKEY_LOCAL_MACHINE/SOFTWARE/FLEXlm License Manager WRSD_LICENSE_FILE
LM_LICENSE_FILE
4. 删掉下面缓存目录以及临时文件夹
C:\Documents and Settings\{user}\.wind
C:\Documents and Settings\{user}\.workbench-x.x
C:\Documents and Settings\{user}\hostinfo.txt
C:\Documents and Settings\{user}\reginfo.txt
C:\Documents and Settings\{user}\.wrsInstaller
5. 从temp目录里删掉
delete %USER%_setupErr.log.

大功告成




vxWorks 添加新 驱动
(2013-06-28 13:25:41)
标签:
vxworks
it
分类: vxWorks6.x_驱动
在vxworks6.x下添加一个新的驱动 一般需要添加6个文件 分别是

target/src/hwif/xxx 下
xxx.c 和 xxx.mk --- 源文件和makefile文件
target/src/hwif/h/xxx 下
xxx.h -- 头文件
target/config/comps/vxworks下
xxx.cdf -- cdf文件用于被workbench识别
target/config/comps/src/hwif下
xxx.dc xxx.dr - dc dr用于命令行编译

Eg: 新加一个串口驱动
vxbUccSio.c
vxbUccSio.h
vxbUccSio.mk
vxbUccSio.dc
vxbUccSio.dr
40vxbUccSio.cdf

注意 如果是命令行编译的话(make),你还需要执行下面的内容,否则新驱动还是没有被更新到库文件中

* If you have added/modified files in
* /target/config/comps/src/hwif folder,
* you need to re-create vxbUsrCmdLine.c.
* Move to /target/config/comps/src/hwif and
* execute make vxbUsrCmdLine.c

cd target/config/all/vxbUsrCmdLine.c
rm -f vxbUsrCmdLine.c

cd /target/config/comps/src/hwif
make vxbUsrCmdLine.c


vxWorks SPI Flash TFFS实现
(2013-06-28 12:18:40)
标签:
spiflash
vxworks
it
分类: vxWorks6.x_FS

这个问题与并行norflash最大的区别就是要单独实现一套 sysTffsRead 和sysTffsMap 函数,为什么呢。因为对norFlash而言,sysTffsRead 就是memcpy,sysTffsMap 就是实地址映射(flash基地址+片内偏移),因为并行nroFlash片上可执行。所以只要重写这两个函数,问题基本就解决了, sysTffsRead 函数不用多说,按照spiFlash read命令去实现,关键是sysTffsMap,其实所有的串行Flash设备在这里的处理都一样,包括nandFlash和SPI flash,就是需要把 SPI flash内部的地址映射到 内存中去(从哪里开始映射多长,映射不用我说了吧,你懂得)这个问题就迎刃而解了vxWorks SPI Flash TFFS实现。 当然在tffs中还隐藏了一些小机关,就是在flIdentifyFlash时,会判断media是不是内存(依据是否可以直接读写),如果是直接return,norFlash没有问题,不能直接写数据,但是由于SPI flash映射到了内存,所以这里会过不去。知道这两点,哈哈 TFFS on SPI-flash 信手拈来。加那些组件参考我前一篇文章。





NorFlash和SPI flash上mount文件系统
(2013-06-28 09:56:26)
标签:
hrfs/dofs
it
分类: v

xWorks6.x_FS
目前,vxWorks有dosFs和hrFs都可以用做Nor或者SPI flash文件系统,需要定义如下宏:

#define INCLUDE_TFFS
#ifdef INCLUDE_TFFS
#define INCLUDE_TFFS_SHOW
#define INCLUDE_TFFS_MOUNT
#define INCLUDE_ERF
#define INCLUDE_DEVICE_MANAGER
#define INCLUDE_FS_EVENT_UTIL
#define INCLUDE_FS_MONITOR
#define INCLUDE_XBD
#define INCLUDE_XBD_BLK_DEV
#define INCLUDE_XBD_TRANS
#define INCLUDE_DISK_UTIL
#define INCLUDE_DISK_PART
#define INCLUDE_RAWFS
#endif

#undef INCLUDE_HRFS -- 用的话打开就行
#ifdef INCLUDE_HRFS
# define INCLUDE_HRFS_FORMAT
# define INCLUDE_HRFS_CHKDSK
#endif

#undef INCLUDE_DOSFS -- 用的话打开就行
#ifdef INCLUDE_DOSFS
# define INCLUDE_DOSFS_DIR_FIXED
# define INCLUDE_DOSFS_DIR_VFAT
# define INCLUDE_DOSFS_FAT
# define INCLUDE_DOSFS_FMT
# define INCLUDE_DOSFS_CHKDSK
# define INCLUDE_DOSFS_MAIN
# define INCLUDE_DOSFS_SHOW
#endif

建立文件系统过程如下:
-> tffsShowAll
TFFS Version 6.6
0: socket=RFA0: type=0x0, unitSize=0x20000, mediaSize=0x400000
1: socket=RFA1: type=0x0, unitSize=0x10000, mediaSize=0x100000
value = 47 = 0x2f = '/'
-> sysTffsFormat 0
Formatted 32 of 32 units = 100.0 %
value = 0 = 0x0
-> sysTffsFormat 1
Formatted 16 of 16 units = 100.0 %
value = 0 = 0x0
-> usrTffsConfig 0,0,"/tffs0"
Instantiating /tffs0 as rawFs, device = 0x50001
value = 0 = 0x0
-> usrTffsConfig 1,0,"/tffs1"
Instantiating /tffs1 as rawFs, device = 0x70001
value = 0 = 0x0
-> hrfsFormat "/tffs0"
Formatting /tffs0 for HRFS v1.2
Instantiating /tffs0 as rawFs, device = 0x50001
Formatting...OK.
value = 0 = 0x0
-> hrfsFormat "/tffs1"
Formatting /tffs1 for HRFS v1.2
Instantiating /tffs1 as rawFs, device = 0x70001
Formatting...OK.
value = 0 = 0x0
-> ll "/tffs0"

Listing Directory /tffs0:
drwxrwxrwx 2 0 0 4096 Jan 1 00:01 ./
drwxrwxrwx 2 0 0 4096 Jan 1 00:01 ../
value = 0 = 0x0
-> ll "/tffs1"

Listing Directory /tffs1:
drwxrwxrwx 2 0 0 2048 Jan 1 00:01 ./
drwxrwxrwx 2 0 0 2048 Jan 1 00:01 ../
value = 0 = 0x0
->
如何建立dosfs with TRFS
e.g., for a TFFS device,
you'd first "low level" format the TFFS disk (sysTffsFormat),
then the transaction layer (usrFormatTrans)
and then the above DosFS device (dosFsVolFormat).

-> usrFormatTrans "/tffs1",100,0
Instantiating /tffs1 as rawFs, device = 0x30001
Instantiating /tffs1 as rawFs, device = 0x60001
value = 0 = 0x0
-> dosFsVolFormat "/tffs1"
Formatting /tffs1 for DOSFS
Instantiating /tffs1 as rawFs, device = 0x60001
Formatting...Retrieved old volume params with 8 confidence:
Volume Parameters: FAT type: FAT32, sectors per cluster 0
0 FAT copies, 0 clusters, 0 sectors per FAT
Sectors reserved 0, hidden 0, FAT sectors 0
Root dir entries 0, sysId (null) , serial number a8f40000
Label:" " ...
Disk with 1669 sectors of 512

bytes will be formatted with:
Volume Parameters: FAT type: FAT12, sectors per cluster 1
2 FAT copies, 1644 clusters, 5 sectors per FAT
Sectors reserved 1, hidden 63, FAT sectors 10
Root dir entries 224, sysId VXDOS12 , serial number a8f40000
Label:" " ...
OK.
value = 0 = 0x0

几个小tips
1)如何判断是什么文件系统?
chkdsk() & hrfsChkDsk() 和 dosFsShow()

STATUS dosFsShow
(
void * pDevName,
u_int level
)
STATUS chkdsk
(
const char * pDevName,
u_int repairLevel,
u_int verbose
)
STATUS hrfsChkDsk
(
char * path,
int verbLevel,
int flags
)似乎这个不支持命令行编译,要用workbench编。

2)注意全局变量flFileSysSectorStart可能在某些版本下有用:
In 5.5.1 and 6.4 the variable flFileSysSectorStart is 0, but it is 1 in 6.4.2.
int flFileSysSectorStart = 1;

风河的注释:
* Starting sector of File System: protects overwriting TFFS at sector 0
* dosFS shares TFFS sector 0, other file systems may not. Since dosfs
* hrfs and other file systems now use the new discard interface, fat
* monitoring is not on and therefore it is better to always protect
* TFFS info sector.
我的理解,dosfs和tffs可以共享sector 0,tffs知道dosfs的boot sector的结构。其它FS不行,会冲掉tffs的boot sector 信息。

3)如果有时候sysTffsformat不好使了试试这个:
STATUS tffsRawio
(
int tffsDriveNo,
int functionNo,
int arg0,
int arg1,
int arg2
)
* tffsRawio(0, 3, 0, 8)
* The first argument in the tffsRawio() command shown above is the TrueFFS
* drive number, 0. The second argument, 3, is the function number (also
* known as TFFS_PHYSICAL_ERASE). The third argument, 0, specifies the unit
* number of the first erase unit you want to erase. The fourth argument, 8,
* specifies how many erase units you want to erase
这个函数可以直接调用底层擦除函数,因为一旦你定义了FORMAT_IF_NEED的话,tffs是不会帮你擦底层的。

4)tffs下的裸读裸写操作:按照块设备来操作即可
-> cd "/tffs1"
value = 0 = 0x0
-> open "hjj",0x202
value = 5 = 0x5
-> write 5,0x4200,256
value = 256 = 0x100
-> ll "/tffs1"

Listing Directory /tffs1:
-rwxrwxrwx 1 0 0 256 Jan 1 1980 hjj
value = 0 = 0x0
->



vxWorks 调试组件和命令
(2013-06-27 17:31:04)
标签:
vxworks
it
分类: vxworks6.x_utility
我总结的一些vxWorks下常用的调试组件,拿出来sharevxWorks 调试组件和命令

1.与任务相关的命令

sp adr,args... Spawn a task, pri=100, opt=0x19, stk=20000
sp 函数地址, 参数1, 参数2,...
sp copy,"vxWorks.st","/tffs0/vxWorks.st"
-启动任务,最多接受9个参数,默认的优先级100、堆栈20000字节

period n,,[arg1]

,...,[arg8]
-创建一个周期调用的任务,周期为n秒,最多接受8个参数
repeat m,,[arg1],...,[arg8]
-创建一个反复调用的任务,调用次数为m,m=0时永久调用,最多也是8个参数

ts tidX -挂起任务
tr tidX -恢复挂起的任务
td tidX -删除任务
i tidX -显示任务基本信息,参数为0时显示全部任务
ti tidX -显示任务详细信息,包括寄存器、堆栈等
tt tidX -显示任务的函数调用关系
tw (taskName) Find info about the object the task is pending on
checkStack tidX -显示任务堆栈使用的历史统计,参数为0时显示全部任务
[其中tidX可以为任务ID 也可以为任务名]

2、系统信息

ld < filename Load a file
unld < "moduleName" Unload file
bootChange Modify the saved boot parameters
logout Log out of the target
lkup ["string"] -在系统符号表中查找并列出含有"string"字符的函数及全局变量,有两个特殊参数:
0,给出符号表统计;""(空字符串),列出全部符号 lkup "excExcHandle"
lkAddr addr -显示addr地址附近的符号表
l addr,[n] -显示addr地址开始的n条指令的反汇编,n省略时默认为10条指
memShow 1 -显示系统分区上空闲和已分配空间的总数等
printErrno value -打印系统定义的错误码的宏

3. utility
中断show
# define INCLUDE_ISR_OBJECTS
# define INCLUDE_ISR_SHOW
# define INCLUDE_ISR_DEFER
vxBus 总线信息show
# define INCLUDE_VXBUS_SHOW
网络自动加载(不用 usrNetInit)
# define STANDALONE_NET
时钟组件
#define INCLUDE_TIMER_SYS
#define INCLUDE_AUX_CLK
#define INCLUDE_TIMESTAMP
#define INCLUDE_TIMESTAMP64
#define INCLUDE_VXB_TIMESTAMP
#define INCLUDE_VXB_TIMESTAMP64
#define INCLUDE_TIMER_SYS_SHOW
EDR 信息
#define INCLUDE_EDR_SHOW
#define INCLUDE_EDR_ERRLOG
#define INCLUDE_EDR_PM
#define INCLUDE_EDR_SYSDBG_FLAG
Telnet 和 ping
Telnet telnet
#define INCLUDE_IFCONFIG
#define INCLUDE_IPATTACH
#define INCLUDE_PING
#define INCLUDE_IPTELNETS
#define INCLUDE_TELNET_CLIENT
#define INCLUDE_NET_HOST_SHOW
PCI show
# define INCLUDE_PCI_BUS_SHOW
启动脚本
# define INCLUDE_SHELL
# define INCLUDE_STARTUP_SCRIPT
其它
#define INCLUDE_DISK_UTIL
#define INCLUDE_USB_SHOW
#define INCLUDE_SHOW_ROUTINES
#define INCLUDE_ADR_SPACE_SHOW

相对应的show命令:
ifShow ["ifname"] - show info about network interfaces
inetstatShow - show all Internet protocol sockets
tcpstatShow - show statistics for TCP
udpstatShow - show statistics for UDP
ipstatShow - show statistics for IP
icmpstatShow - show statistics for ICMP
arpShow - show a list of known ARP entries
mbufShow

- show network stack data pool statistics
netStackSysPoolShow - show network stack system pool statistics
routeShow - display all IP routes (summary information)
mRouteShow - display all IP routes (verbose information)
routestatShow - display routing statistics
routeAdd "destaddr","gateaddr" - add route to route table
routeDelete "destaddr","gateaddr" - delete route from route table

Object Information Commands

taskShow List info about the tasks from TCB
seqShow List info about the sequencers(EPICS state programs at LIGO) running on the target
semShow Show info about semaphore
moduleShow Show info about loaded modules (object files/programs)

Memory Information Commands

memShow Display allocated/free memory
memPartShow Show memory partition

hwMemShow
version
isrShow
arpShow
sysMsrGet()
vxHid2Get
vxHid0Get
vxHid1Get
taskArgsGet
vxSrr0Get
vxPvrGet()
vxSvrGet
vxPirGet()
vxPirSet()
vxBusShow ():
vxbTopoShow ():
aimMmuMapShow():
aimMmuPageTableShow()
aimMmuOptimizeMemShow()
vxbSysClkShow()
vxbTimestampShow()
coprocShow
taskRegsShow
adrSpaceShow 1
netstat

System Clock:
pSysClkName
sysClkDevUnitNo
sysClkTimerNo

Auxiliary Clock:
pAuxClkName
auxClkDevUnitNo
auxClkTimerNo

Timestamp timer:
pTimestampTimerName
timestampDevUnitNo
timestampTimerNo

sysAuxClkRateGet()
vxbSysClkShow
pciConfigTopoShow()
pciDeviceShow 0
pciHeaderShow (busNo, deviceNo, funcNo)
有些命令只存在于vx5.5,vx6.x后没有了。

相关文档
最新文档