The VxWorks 7 SDK is a development environment dedicated to VxWorks application developers which includes the following features:
This guide helps you get up and running with developing applications for platforms running VxWorks. You can use it for creating new applications, or just exploration of VxWorks capabilities.
You should start by downloading a VxWorks SDK for your platform of choice from https://labs.windriver.com and unpacking it. Refer to the documentation in docs in the unpacked SDK for additional information on creating and debugging applications.
The SDKs are meant to run on Linux hosts. Some of the examples in this document are specific to Debian derivatives.
On Debian derivatives, the following packages need to be installed:
$ sudo apt install build-essential libc6:i386 uml-utilities nfs-kernel-server
Having an FTP server installed on your development host will make application deployment easier and allow you to access the host file system from a VxWorks target.
To accommodate for the varying runtime configurations of the VxWorks kernel images included in the SDKs, you may be interested in using an FTP server option based on pyftpdlib.
Install pyftpdlib:
$ sudo apt install python-pip
$ sudo pip install pyftpdlib
Prebuilt VxWorks binaries can be located in vxsdk/bsps/sifive_generic_1_0_1_0.
A recent version of QEMU can be used to run the VxWorks kernel included in the SDK and to deploy VxWorks applications.
$ git clone https://git.qemu.org/git/qemu.git
$ cd qemu
$ ./configure --target-list=riscv64-softmmu,riscv32-softmmu
$ make -j`nproc`
$ sudo make install
Create a tap interface to enable networking for the VxWorks guest:
$ sudo -- sh -c "tunctl -d tap0 >/dev/null; tunctl -u $USER -t tap0; ifconfig tap0 192.168.200.1 up"
Open a Linux terminal window and navigate to the location of your unpacked VxWorks SDK. The following command can be used to start a VxWorks instance.
$ qemu-system-riscv64 -nographic -M sifive_u -smp 5 -m 2G -bios default \
-nic tap,ifname=tap0,script=no,downscript=no \
-append "gem(0,0)host:vxWorks h=192.168.200.1 e=192.168.200.2:ffffff00 u=target pw=vxTarget f=0x01" \
-kernel bsps/sifive_generic_1_0_1_0/uVxWorks
Customizing the values for the user (u) and password (pw) parameters to the ones matching a valid FTP user on your development host will allow you to access the host file system from the VxWorks instance running in QEMU. The VxWorks instance will have access to the root folder of your FTP server.
Start by opening a Linux terminal window and going to the location of your unpacked VxWorks SDK.
Source the SDK development environment before using the SDK.
$ source sdkenv.sh
The VxWorks compiler driver (wr-cc/wr-c++) utility lets you invoke VxWorks toolchains to compile your real time process (RTP) application from command line. The SDK development environment includes a set of environment variables (CC, CXX, CPP, etc) which match the various compiler driver utilities.
Procedure:
#include <stdio.h>
int main(void)
{
printf("hello, world!\n");
return 0;
}
$ wr-cc -rtp foo.c -static -o foo.vxe
or
$ $CC -rtp foo.c -static -o foo.vxe
Alternatively, you can also create a Makefile and then call make to compile the source file.
all:
$CC -rtp foo.c -static -o foo.vxe
$ make
By default, a generated VxWorks SDK includes CMake. When the application developer sources the SDK environment, they will automatically have access to CMake. There is no need to download, install and configure CMake separately. With VxWorks CMake, you can build existing CMake examples that are included in the generated SDK, or you can create your own projects.
CMake examples can be found in the directories
Procedure: 1. Create a project directory, called my_project.
$ mkdir my_project
Create the CMakeLists.txt file in the project folder.
To build your project, run the following command:
$ cmake -D CMAKE_TOOLCHAIN_FILE=${WIND_SDK_HOME}/vxsdk/sysroot/mk/rtp.toolchain.cmake .
Note: RTP is used in the example. If you would like to build a DKM project instead, change the toolchain name to dkm.toolchain.cmake.
After you have started VxWorks on your target, start an FTP server on port 21 with user "target" and password "vxTarget" and FTP root in the current user's home.
$ sudo python -m pyftpdlib -p 21 -u target -P vxTarget -d $HOME &
Switching to the "cmd" shell will allow you to navigate to the location of your application with greater ease.
-> cmd
[vxWorks *]#
Assuming the application is located in $HOME/opt:
[vxWorks *]# cd opt
[vxWorks *]# ls
opt/./hello
opt/./hello.c
[vxWorks *]# more hello.c
#include <stdio.h>
int main(int argc, char **argv) {
printf("Hello World\n");
return 0;
}
[vxWorks *]# hello
Launching process 'hello' ...
Process 'hello' (process Id = 0xffff8000004bb6e0) launched.
Hello World
Setup an NFS server in order to allow the VxWorks target to access the Python sysroot included in the VxWorks SDK.
Adapt the SDK path and add the following line to /etc/exports.
/opt/wrsdk-vxworks7/vxsdk/sdcard/sysroot *(rw,no_root_squash,no_subtree_check)
Restart the NFS server.
$ systemctl restart nfs-server.service
Prepare the environment on your running VxWorks target. Replace 192.168.200.1 with the IP address of the NFS server.
[vxWorks *]# C
->
-> hostAdd "dl","192.168.200.1"
-> nfsMount "dl", "/opt/wrsdk-vxworks7/vxsdk/sdcard/sysroot", "/sysroot"
-> fsSymlinkConfig "<def>=/sysroot;/lib=<def>/lib;/usr=<def>/usr"
-> cmd
[vxWorks *]#
Launch Python from the cmd shell to print the Hello World! string:
[vxWorks *] python3
Launching process 'python3' ...
Process 'python3' (process Id = 0x805a9ad0) launched.
Python 3.8.0a4+ (default, Jun 122019, 10:59:47)
[Clang 8.0.0.1 (ssh://diabuild@stash.wrs.com:7999/llvm/clang.git 0a578b9ee67aa4 on vxworks
Type "help", "copyright", "credits" or "license"for more information.
>>> import sys
>>> print("Hello World!")
Hello World!
>>> print (sys.platform)
vxworks
Python scripts can be executed as
[vxWorks *] python3 helloworld.py
Hello World!
Note:
If you launch Python from the shell, you may need to set the value of rtpSpStackSize before starting Python (for example, set the rtpSpStackSize to 0x1000000). For more information, see rtpSp( ) in the API reference.