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 Interface
--------------------------------------------------------------------
192.168.0.0 192.168.0.200 0x101 1 0 cpm0
--------------------------------------------------------------------
ROUTE HOST TABLE
Destination Gateway Flags Refcnt Use Interface
--------------------------------------------------------------------
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文件在同一位置。
打赏帖 | |
---|---|
分享一种检测按键状态的方法被打赏20分 | |
周末总结一下,STM32C0系列的开发经验被打赏50分 | |
【换取手持数字示波器】MicrochipMPLABHarmony框架下定时器配置被打赏20分 | |
【换取手持数字示波器】MicrochipMPLABHarmony框架下PWM配置被打赏20分 | |
【Cortex-M】Systick Timer使用被打赏10分 | |
分享汽车防盗系统的组成与分类(一)被打赏5分 | |
VOFA+波形显示+JYD-31蓝牙发送和解析不定长数据被打赏10分 | |
【换取手持数字示波器】-STM32F4PWM控制LED灯管亮度被打赏22分 | |
【换取手持数字示波器】STM32F4驱动RPR-0521RS照度、接近一体型传感器被打赏23分 | |
宏定义和const关键字定义被打赏5分 |