集成的Vxworks目标仿真器—VxSim,它提供了与真实目标机一致的调试和仿真运行环境,允许开发者可以在没有BSP、操作系统配置以及目标机硬件设备的情况下进行开发和调试。VxSim对软件开发者的意义,主要是在嵌入式系统开发中软件的开发通常受到硬件开发进度的制约,由于软件开发必须滞后于硬件的开发,影响了产品的研发进度,VxSim在一定程度上解决了这个问题:使得用户可以在工程开发初期,在硬件环境不具备的情况下,可以利用Tornado进行与硬件无关模块的设计。 下面以简单的PC机仿真为目标机,进行简单的开发和调试过程,主要以图代替文本描述,对于初步的入门者也许提供一些帮助。 1、创建一个工程 2、创建一个Bootable VxWorks Image 3、选择一个BSP包 4、生成工程 5、生成的工程目录 6、编写一个main.c程序
8、添加main.c后的工程 9、在usrAppInit.c做如下修改
10、依赖性设置(点击工程右键即可) 11、编译全部(点击工程右键即可) vxrm *.o *.rpo ctdt.c symTbl.c vxWorks* *.out *.pl vxrm ..\prjComps.h ..\prjParams.h ..\prjConfig.c ..\linkSyms.c vxrm ..\libs.nm ..\libs.size wtxtcl C:\Tornado2.2\host\src\hutils\configGen.tcl ..\demo.wpj ccsimpc -c -g -mpentium -ansi -fno-builtin -fno-defer-pop -I.. -IC:\Tornado2.2\target\conf ig\simpc -IC:\Tornado2.2\target\h -IC:\Tornado2.2\target\config\comps\src -IC:\Tornado2.2\ target\src\drv -DCPU=SIMNT -DTOOL_FAMILY=gnu -DTOOL=gnu -DPRJ_BUILD C:\Tornado2.2\target \config\simpc\sysLib.c -o sysLib.o ccsimpc -g -mpentium -ansi -fno-builtin -fno-defer-pop -I.. -IC:\Tornado2.2\target\config\ simpc -IC:\Tornado2.2\target\h -IC:\Tornado2.2\target\config\comps\src -IC:\Tornado2.2\tar get\src\drv -DCPU=SIMNT -DTOOL_FAMILY=gnu -DTOOL=gnu -DPRJ_BUILD -c ..\usrAppInit.c ccsimpc -c -g -mpentium -ansi -fno-builtin -fno-defer-pop -I.. -IC:\Tornado2.2\target\conf ig\simpc -IC:\Tornado2.2\target\h -IC:\Tornado2.2\target\config\comps\src -IC:\Tornado2.2\ target\src\drv -DCPU=SIMNT -DTOOL_FAMILY=gnu -DTOOL=gnu -DPRJ_BUILD ..\prjConfig.c -o pr jConfig.o ccsimpc -c -g -mpentium -ansi -fno-builtin -fno-defer-pop -I.. -IC:\Tornado2.2\target\conf ig\simpc -IC:\Tornado2.2\target\h -IC:\Tornado2.2\target\config\comps\src -IC:\Tornado2.2\ target\src\drv -DCPU=SIMNT -DTOOL_FAMILY=gnu -DTOOL=gnu -DPRJ_BUILD ..\linkSyms.c -o lin kSyms.o ccsimpc -g -mpentium -ansi -fno-builtin -fno-defer-pop -I.. -IC:\Tornado2.2\target\config\ simpc -IC:\Tornado2.2\target\h -IC:\Tornado2.2\target\config\comps\src -IC:\Tornado2.2\tar get\src\drv -DCPU=SIMNT -DTOOL_FAMILY=gnu -DTOOL=gnu -DPRJ_BUILD -c ..\main.c vxrm ..\prjObjs.lst Generating ..\prjObjs.lst... ccsimpc -g -mpentium -ansi -fno-builtin -fno-defer-pop -I.. -IC:\Tornado2.2\target\config\ simpc -IC:\Tornado2.2\target\h -IC:\Tornado2.2\target\config\comps\src -IC:\Tornado2.2\tar get\src\drv -DCPU=SIMNT -DTOOL_FAMILY=gnu -DTOOL=gnu -DPRJ_BUILD -c C:\Tornado2.2\target\ config\comps\src\version.c ccsimpc -r -nostdlib -Wl,@..\prjObjs.lst \ version.o -Wl,--start-group \ -LC:\Tornado2.2\target\lib\simpc\SIMNT\gnu -LC:\Tornado2.2\target\lib\simpc\SIMNT\common C:\Tornado2.2\target\config\simpc\simpcDrv.a -lcplus -lgnucplus -lvxcom -lvxdcom -l arch -lcommoncc -ldrv -lgcc -lnet -los -lrpc -lwdb -lwind -lwindview C:\Tornado2. 2\target\lib\libSIMNTgnuvx.a -Wl,--end-group -o partialImage.o nmsimpc -g partialImage.o @..\prjObjs.lst | wtxtcl C:\Tornado2.2\host\src\hutils\munch.tcl -c simpc > ctdt.c ccsimpc -c -fdollars-in-identifiers -g -mpentium -ansi -fno-builtin -fno-defer-pop -I.. -I C:\Tornado2.2\target\config\simpc -IC:\Tornado2.2\target\h -IC:\Tornado2.2\target\config\c omps\src -IC:\Tornado2.2\target\src\drv -DCPU=SIMNT -DTOOL_FAMILY=gnu -DTOOL=gnu -DPRJ_BUI LD ctdt.c -o ctdt.o ccsimpc -g -mpentium -ansi -fno-builtin -fno-defer-pop -I.. -IC:\Tornado2.2\target\config\ simpc -IC:\Tornado2.2\target\h -IC:\Tornado2.2\target\config\comps\src -IC:\Tornado2.2\tar get\src\drv -DCPU=SIMNT -DTOOL_FAMILY=gnu -DTOOL=gnu -DPRJ_BUILD -c C:\Tornado2.2\target\ config\comps\src\dataSegPad.c ldsimpc --subsystem=windows -e _WinMainCRTStartup C:\Tornado2.2\host\x86-win32\i386-pc-min gw32\lib\crt1.o \ dataSegPad.o partialImage.o ctdt.o \ -T C:\Tornado2.2\target\h\tool\gnu\ldscripts\link.SIMNT -o vxWorks wtxtcl C:\Tornado2.2\host\x86-win32\bin\simpcToExe.tcl vxWorks echo -v vxWorks -v vxWorks
Done.
12、打开VxSim Lauch 13、下载对象文件main.o,这样我们可以调试main.c所有函数了 14、在main.c设置断点第6行 15、运行程序(run),Task以WinMain函数作为起点开始 16、运行程序后,程序指针指向WinMain函数开始处 17、让程序指针运行如图处,我们看看watch窗口和VxSim界面上的内容 a.变量窗口 b.Vxsim内容 18、Shell程序使用 A、Shell帮助 -> help help Print this list h [n] Print (or set) shell history i [task] Summary of tasks' TCBs ti task Complete info on TCB for task sp adr,args... Spawn a task, pri=100, opt=0, stk=20000 sps adr,args... Spawn a task, pri=100, opt=0, stk=20000 and leave it suspended td task Delete a task ts task Suspend a task tr task Resume a task tw task Print info about the object a task is pending on w Summary of tasks' pending information d [adr[,nunits[,width]]] Display memory m adr[,width] Modify memory mRegs [reg[,task]] Modify a task's registers interactively version Print VxWorks version info, and boot line
Type <CR> to continue, Q<CR> to stop:
b Display breakpoints b addr[,task[,count]] Set breakpoint bd addr[,task] Delete breakpoint bdall [task] Delete all breakpoints c [task[,addr[,addr1]]] Continue from breakpoint s [task[,addr[,addr1]]] Single step l [adr[,nInst]] List disassembled memory tt [task] Do stack trace on task bh addr[,access[,task[,count]]] Set hardware breakpoint access: 0 - instruction 1 - write 1 byte 3 - read/write 1 byte 5 - write 2 bytes 7 - read/write 2 bytes d - write 4 bytes f - read/write 4 bytes sysSuspend Suspend the system sysResume Resume the system
Type <CR> to continue, Q<CR> to stop:
devs List devices cd "path" Set current working path pwd Print working path ls ["path"[,long]] List contents of directory ld [syms[,noAbort][,"name"]] Load stdin, or file, into memory (syms = add symbols to table: -1 = none, 0 = globals, 1 = all) lkup ["substr"] List symbols in system symbol table lkAddr address List symbol table entries near address printErrno value Print the name of a status value period secs,adr,args... Spawn task to call function periodically repeat n,adr,args... Spawn task to call function n times (0=forever)
NOTE: Arguments specifying 'task' can be either task ID or name. value = 0 = 0x0 -> B、查看目录 -> ls 驱动器 C 中的卷没有标签。 卷的序列号是 782B-C07C
C:\vxworks_demo 的目录
[.] [..] [default] demo.wpj demo.wsp linkSyms.c main.c Makefile prjComps.h prjConfig.c prjObjs.lst prjParams.h usrAppInit.c 10 个文件 52,850 字节 3 个目录 34,592,718,848 可用字节 value = 0 = 0x0 ->
C、执行函数WinMain -> WinMain hello world! This is a demo program! value = 24 = 0x18 = __major_os_version__ + 0x14 -> |
|