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分 | |
【Zephyr】使用Zephyr外设初始化过程解析被打赏30分 | |
【S32K146】S32DS watchdog 配置使用被打赏20分 | |
【Zephyr】使用 IAR 调试 Zephyr 镜像被打赏20分 | |
赚取电动螺丝刀+电源电路理论知识分享1被打赏5分 | |
我想要一部加热台+分享常见运算放大器电路的应用被打赏5分 | |
【Zephyr】MCXN947 Zephyr 开发入门适配shell被打赏20分 | |
我想要一部加热台+常见的MOS管驱动电路被打赏5分 | |
【我要开发板】6.联合MATLAB记录数据被打赏50分 | |
【换取手持数字示波器】MicrochipMPLABHarmony框架下串口调试printf输出记录被打赏29分 |