在vxworks中如何使用启动脚本startup script 1 选择一个合适的bsp,创建一个bootable vxworks image project,包含shell startup script组件。 在usrAppInit()中添加代码: printf("/nusrAppInit/n"); 这条语句的作用就是为了比较usrAppInit()和startup script谁先执行。 2 写一个demo.c,文件内容如下: #include "vxworks.h" void demo(void) { int x; for(x=0;x<5;x++) printf("x=%d/n",x); } 把它加入到vxworks的工程中。这是一个简单的用户函数例子。 3 在vxworks文件所在的目录下,创建一个文件myscripts.txt,其内容为: printf("hello/n") demo() routeShow() i 为了能够调用routeShow,vxworks配置中需要包含网络调试组件。 4 启动目标机,在bootrom引导vxworks时,指定startup script参数,如: boot device : cpm unit number : 0 processor number : 0 host name : chenqi file name : vxWorks inet on ethernet (e) : 192.168.0.200 host inet (h) : 192.168.0.118 user (u) : target ftp password (pw) : target flags (f) : 0x0 target name (tn) : 850pc startup script (s) : myscript.txt 5 如果一切正常,vxworks启动完毕之后,会有: Executing startup script myscript.txt ... printf("hello/n") hello value = 6 = 0x6 demo() x=0 x=1 x=2 x=3 x=4 value = 4 = 0x4 routeShow() ROUTE NET TABLE Destination Gateway Flags Refcnt Use Inte**ce -------------------------------------------------------------------- 192.168.0.0 192.168.0.200 0x101 1 0 cpm0 -------------------------------------------------------------------- ROUTE HOST TABLE Destination Gateway Flags Refcnt Use Inte**ce -------------------------------------------------------------------- 127.0.0.1 127.0.0.1 0x5 0 0 lo0 -------------------------------------------------------------------- value = 69 = 0x45 = 'E' i(0) Show routine of this object not configured into system. value = 56 = 0x38 = '8' Done executing startup script myscript.txt usrAppInit 由此可见,startup script在usrAppInit函数之前执行。 在上述试验中,需要注意最好让vxworks文件和myscript.txt文件在同一位置。 |