1. Start Wind River Workbench
You can start the Wind River Workbench IDE (Integrated Development Environment) by following these steps: select from the menu, Applications menu -> Development -> Wind River Workbench, or run /opt/WindRiver/workbench-4/startWorkbench.sh from the command line. The window below will prompt you to select a workspace.
The Workspace here is where your projects are stored. It is recommended to place the workspace in your Home directory (/home.nfs/).
2. Create a New Project
To create a new project, select File -> New -> Project, and choose VxWorks -> VxWorks Downloadable Kernel Module Project. (You will also deal with Real-Time Process Projects later). A dialog window will open where you can specify a project name, and optionally change the project save directory. Click the Next button to continue.
In the next window, select the type of project we are based on. Since we will run the program in the simulator, choose image project
and vip_vxsim_linux_llvm (prebuild)
, then click Finish.
Now you can see the newly created project in the Project Explore tab. This project contains a simple C language template dkm.c.
2.1 Example Code
Replace the code in dkm.c with the code below.
#include "taskLib.h"
#include "stdio.h"
#include "kernelLib.h"
int task_run[] = {100, 450, 200};
int task_stop[] = {18, 25, 30};
void task(int n){
long int x;
printf("Task %i has been started\n", n);
while (1) {
printf("task %d: running\n", n);
x = 1000000 * task_run[n];
while (x > 0) x--;
printf("task %d: delayed\n", n);
taskDelay(task_stop[n]);
}}
void CreateTasks(void){
TASK_ID id1, id2, id3;
/* kernelTimeSlice(1); */
cpuset_t affinity;
CPUSET_ZERO(affinity);
CPUSET_SET(affinity, 0);
taskCpuAffinitySet(taskIdSelf(), affinity);
id1 = taskSpawn("Task0", 210, 0, 4096, (FUNCPTR) task, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
id2 = taskSpawn("Task1", 210, 0, 4096, (FUNCPTR) task, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0);
id3 = taskSpawn("Task2", 210, 0, 4096, (FUNCPTR) task, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0);
}
3 Compile the Application
Like many modern IDEs, you can compile and run an application with a single click, but understanding what happens behind the scenes is also very helpful. We will look at each step required to run a VxWorks application and then show how to implement it with a single click.
To compile a project, right-click on the test project name and select Build (or press Ctrl + B, or Ctrl + P).
On the first compile, it will ask for the directory of header file search, here you can click Continue to proceed.
The compilation console will automatically open and display the output of the compilation process.
If you see the bold text “Build Finished”, it means the compilation is successful; otherwise, you need to fix the reported errors (and warnings).
4. Start the Simulator
Since we will run the program in the simulator, we must set it up first. From the Wind River Workbench toolbar, select New Connection from the dropdown list.
In the New Connection dialog, enter a Connection Name and choose:
-
Target Type: VxWorks Simulator
-
Connection Mode: Application Mode
Select Finish, and the simulator will start. Two tabs will open:
-
The Simulator tab will display Connection details
-
The Terminal tab will display the console of the simulated system
Try entering the command i
at the VxWorks console prompt in the terminal:
This command will show all tasks currently running in the system.
Similar information can also be obtained from the System Monitor tab.
5. Run the Application
Now, right-click the project and select Run/Debug Kernel Task to run the program.
In the Run Kernel Task dialog, specify the Entry Point, which is the name of the function to run, enter CreateTasks
or choose it via the Browse...
button.
Select CreateTasks from the available entry points.
After pressing the OK
button, the application will run in the simulator and the output will be displayed in the Terminal
tab.
If you want to run the program again, just press the combination Ctrl + Shift + F11, or select Run Kernel Task from the Target actions menu.
6. Terminate the Program
There are several ways to terminate the application:
-
Click the red icon to stop the entire simulator
-
From the System Monitor tab, right-click on a single application task to terminate it
7. Debugging
You can debug an application while it is running by selecting the Attach Debugger option.
The Workbench will stop the application at the entry point or any other manually added breakpoints. Now you can step through and debug the code like in other IDEs.
8. Help and Documentation
There are two types of documentation available:
-
Reference manuals
-
Guides and tutorials
The guide documentation is located in /opt/WindRiver/vxworks/22.06/docs. The most important document for everyone will be Kernel_Application_Development/VxWorks_Application_Programmer_s_Guide_22.06.pdf.
Reference manuals can be obtained within the IDE itself by selecting Help -> Show Context Help. The help window will display links to the documentation at the mouse position in the editor.
System Viewer
The System Viewer is a tool that allows you to trace system activities and display them graphically.
The System Viewer can be configured to record varying amounts of information. We will select a moderate amount by choosing Additional Instrumentation as described below.
Then you can start recording the running system’s traces.
After stopping the recording, a new window with the recorded data will appear.
You can also hide any tasks from the view.