
Click “Read the original text” to access more VxWorks resources
Free download of VxWorks technical materials, resources sourced from the internet, copyright belongs to the original author!

Integrating Python in VxWorks 7
1 Introduction
VxWorks is a real-time operating system provided by Wind River, while Python is an open-source interpreted programming language and runtime interpreter managed by the Python Software Foundation. Python Software Foundation: http://www.python.org. Wind River supports Python on PowerPC, ARM, and Intel architecture devices. This article describes how to compile and deploy the Python interpreter into VxWorks 7.
2 Prerequisites
This article assumes you are using:
-
Wind River VxWorks 7 SR0620
-
Intel target booting from UEFI BIOS
-
A USB flash drive (minimum 4 GB)
3 Creating/Compiling the VxWorks Source Build (VSB) Project
Open a DOS shell, configure the build environment, and then compile the project.
cd "WIND_HOME" // your installation directory
wrenv -p vxworks-7
cd // your workspace
vxprj vsb create python_vsb -bsp itl_generic -smp -force -S
cd python_vsb // your workspace
vxprj vsb add PYTHON // add the python layer to the VSB
make -j 32 // build the VSB
After the VxWorks Source Code Build (VSB) compilation is complete, check if it includes the Python runtime environment by verifying the existence of the following directory:
"YOUR_WORKSPACE"/python_vsb/usr/3pp/deploy
4 Creating/Compiling the Basic VxWorks Image Project (VIP)
Create a basic VxWorks image project as shown below
cd ..
vxprj create -smp itl_generic python_vip -profile PROFILE_INTEL_GENERIC -vsb python_vsb
cd python_vip
vxprj vip component add INCLUDE_MULTI_STAGE_WARM_REBOOT
vxprj vip bundle add BUNDLE_STANDALONE_SHELL
vxprj parameter set DOSFS_COMPAT_NT TRUE
vxprj build
Note: You have not yet added the Python interpreter to the VIP
5 Booting VxWorks on the Target Machine
5.1 Deploying the UEFI Loader and VxWorks Kernel Image
For instructions on how to compile and deploy the UEFI bootloader and VxWorks image files on a USB flash drive, refer to the readme file of the itl_generic BSP. Find this readme file at the following path:
"WIND_HOME"/vxworks-7/pkgs_v2/os/board/intel/itl_generic-a.b.c.d/itl_generic_readme.md
After deploying the UEFI bootloader and VxWorks kernel image according to the instructions below, you should find the following files on the USB flash drive:
-
EFI
-
BOOT
-
bootapp.sys
-
BOOTIA32.EFI
-
BOOTX64.EFI
5.2 Preparing the Intel Target Machine
Configure the BIOS of the target machine to boot from the USB flash drive and connect the USB flash drive to the target machine.
5.3 Booting the Target Machine
Power on the target machine, and after it boots, you will see the prompt of the VxWorks kernel shell.
->
6 Finding the Device Name of the VxWorks USB Flash Drive
Execute the following command on the VxWorks kernel shell to find the device name of the USB flash drive.
-> devs
drv refs name
1 [ 3] /
7 [ 3] /bd0a
5 [ 3] /pcConsole/0
3 [ 3] /ttyS0
value = 2 = 0x2
-> cd "/bd0a"
value = 0 = 0x0
-> ls
EFI
value = 0 = 0x0
In this instance, the device name is /bd0a. Note the USB device name on the target machine. Power off the target machine and reconnect the USB flash drive to the workstation.
7 Copying the Python Runtime Environment to the USB Flash Drive
Copy “YOUR_WORKSPACE”/python_vsb/usr/3pp/deploy to the root directory of the USB flash drive.
8 Updating the Basic VIP to Include the Python Runtime Environment
Return to the VIP directory and configure the Python runtime environment into the VIP.
cd "YOUR_WORKSPACE"\profile_vip
vxprj component add INCLUDE_PYTHON_SUPPORT
vxprj component add INCLUDE_FILESYSTEM_SYMLINK_CONFIG
vxprj parameter setstring FILESYSTEM_SYMLINK_CONFIG_STR
def=/bd0a/deploy;/bin=def/bin;/usr=def/usr;/etc=def/etc;/lib=def/lib;"
vxprj build
9 Deploying the Updated VxWorks Image File to the USB Flash Drive
Copy “YOUR_WORKSPACE”/profile_vip/default/vxWorks to the USB flash drive and rename it to EFI/BOOT/bootapp.sys
10 Creating a HELLO WORLD PYTHON Example in the Root Directory of the USB Flash Drive
Open a text editor and create a file named helloworld.py in the root directory of the USB flash drive. The file must contain the following:
# helloworld.py
import os
import sys
print("Hello World!")
11 Running the HELLO WORLD PYTHON Example Program on the Target
Reconnect the USB flash drive to the target machine, then boot the target machine to the VxWorks kernel shell. Find the helloworld.py file in the root directory of the USB flash drive, enter the command in the shell, and run this Python program.
-> cd "/bd0a"
value = 0 = 0x0
-> ls
EFI
helloworld.py
value = 0 = 0x0
-> cmd
[vxWorks *]# python3 helloworld.py
Launching process 'python3' ...
Process 'python3' (process Id = 0x809aa340) launched.
Hello World!
[vxWorks *]#
Note: Since Python is an interpreted language, you can also build Python programs interactively from the VxWorks kernel shell.
[vxWorks *]# python3
Launching process 'python3' ...
Process 'python3' (process ID = 0x809aa340) launched.
Python 3.8.0 (default, Apr 27 2020, 17:49:25)
[Clang 9.0.1.1 (ssh://[email protected]:7999/llvm/clang.git 67f1ee998a3a1d on vxWorks
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import sys
>>> print("Hello World!")
Hello World!
>>>