VxWorks Python | Python and VxWorks 7 Integration
Table of Contents
- 1. Introduction
- 2. Prerequisites
- 3. Create and Build the VxWorks Source Build (VSB) Project
- 4. Create and Build the Basic VxWorks Image Project (VIP)
- 5. Boot VxWorks on the Target
- 6. Discover the VxWorks USB flash drive device name
- 7. Copy the Python Runtime to the USB Flash Drive
- 8. Update the Basic VIP to Include Python
- 9. Deploy the Updated VxWorks Image File to the USB Flash Drive
- 10. Create a Hello World Python Example in the Root Directory of the USB Flash Drive
- 11. Run the Hello World Python Example Program on the Target
1 Introduction
VxWorks is a Real Time Operating System built by Wind River, and Python is an open-source interpreted programming language and run-time 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 VxWorks Python blog describes how to build and deploy the Python interpreter into VxWorks 7.
2 Prerequisites
These instructions assume that you are using:
- Wind River VxWorks 7 SR0620
- Intel target booting from UEFI BIOS
- A USB flash drive (4 GB minimum)
3 Create and Build the VxWorks Source Build (VSB) Project
Open a DOS shell, configure the build environment and then build the project.
cd <WIND_HOME> // your installation directory wrenv -p vxworks-7 cd <YOUR_WORKSPACE> // 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
Once your VxWorks source build (VSB) has built, check that it contains the Python runtime. Verify that the following directory exists:
<YOUR_WORKSPACE>/python_vsb/usr/3pp/deploy
4 Create and Build the Basic VxWorks Image Project (VIP)
Create the basic VxWorks image project (VIP) as follows.
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
You have not added the Python interpreter to the VIP yet.
5 Boot VxWorks on the Target
5.1 Deploy the UEFI Bootloader and the VxWorks kernel image
Refer to the itl_generic BSP readme file for instructions on how to build and deploy the UEFI boot loader and the VxWorks image file on the USB flash drive. Find this readme file here:
<WIND_HOME>/vxworks-7/pkgs_v2/os/board/intel/itl_generic-a.b.c.d/itl_generic_readme.md
After following these instructions to deploy the UEFI boot loader and vxWorks kernel image, you will find the following files on the USB flash drive:
EFI
BOOT
bootapp.sys
BOOTIA32.EFI
BOOTX64.EFI
5.2 Prepare the Intel target
Configure the target BIOS to boot the target from the USB flash drive.
Attach USB flash drive to the Intel target.
5.3 Boot the Target
Power-on the target. Once the target has booted, you will see the kernel shell prompt.
->
6 Discover the VxWorks USB flash drive device name
Execute the following commands on the kernel shell to discover the USB flash drive device name.
-> 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 example, the device name is /bd0a. Take a note of the USB device name on your target.
Shutdown the target and place the USB flash drive back into your workstation.
7 Copy the Python Runtime to the USB Flash Drive
Copy <YOUR_WORKSPACE>/python_vsb/usr/3pp/deploy to the root of the USB flash drive.
8 Update the Basic VIP to Include Python
Go back to the VIP directory and configure the Python runtime 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 Deploy the Updated VxWorks Image File to the USB Flash Drive
Copy <YOUR_WORKSPACE>/profile_vip/default/vxWorks to the USB flash drive as EFI/BOOT/bootapp.sys.
10 Create a Hello World Python Example in the Root Directory of the USB Flash Drive
Open a text editor and create the file helloworld.py at the root of the USB flash drive.
The file must contain:
# helloworld.py import os import sys print("Hello World!")
11 Run the Hello World Python Example Program on the Target
Return the USB flash drive to the target and boot the target to the kernel shell.
Locate the helloworld.py file at the USB flash drive root directory. Enter the command 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: Because Python is an interpreted language, you are also able to construct your program interactively from the 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://diabuild@stash.wrs.com: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! >>>