分享

A quick intro to Wind River Workbench development environment

 望穿墙 2018-02-01

Warning

Screenshots in this tutorial are from an older version. There are small differences between the current version and the old one.

1   Starting Wind River Workbench

To start Wind River Workbench IDE (Integrated Development Environment) select from menu Applications menu → Development → Wind River Workbench. The following figure will show up asking us to choose the workspace.

Workspace selection

The workspace is the place, where your projects will be stored. It is recommended to place workspace under your home directory (/home/<login> under Linux).

Then the main IDE window is opened:

The main IDE window

2   New Project

To create a new project right-clock in the Project Explorer and choose New→VxWorks Downloadable Kernel Module Project. (Later, you will also work with Real-Time Process Projects.) A dialog window opens, where you can specify the location and name of the project. Continue with the Next button.

New project dialog window

In the next dialog window do not make any changes unless you want to create your own Makefile. This is not needed right now. Continue with the Next button.

image2

image3

In the following dialog you can choose the architecture (x86, ARM, …) and the compiler (Diab, GNU). For the first time set Active build spec to SIMLINUXdiab. It means that we will use a simulator running on Linux with the Diab compiler as a target platform. Click on the Next button again.

image4

Click Next and then Finish button.

image5

image6

Now you can see the newly created project in the Project Explorer tab.

image7

The project does not contain any source files. To create a new C source file choose from menu File→New→File and enter its name into the dialog window that opens.

image8

An empty new C file is created. Now copy the following code to it.

2.1   Example code

#include <taskLib.h>
#include <stdio.h>
#include <kernelLib.h>

long 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: stopped\n", n);
                taskDelay(task_stop[n]);
        }
}

void CreateTasks(void)
{
        int id1, id2, id3;

        /*  kernelTimeSlice(1); */

        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);
}

image9

3   Build and Run

As with most modern IDEs it is possible to build and run an application with a single click. It is, however, quite useful to understand what happens behind the scene. We will first look at the individual steps that are needed to run a VxWorks application and then we will show how to do it with one click.

3.1   Manual, step by step procedure

To build the project choose Project→Build All or Project→Build Project. The build log can be watched in the Build console tab.

The built application needs to be executed on a target machine. We will start with using VxWorks simulator (vxsim) as the target "machine". The simulator should be already preconfigured in the IDE so you can launch and connect it by clicking the Connect vxsim0 button in the Remote Systems tab.

If you do not see vxsim0 in the Remote Systems tab, create the connection by right-clicking there and selecting New→Connection→Wind River VxWorks 6.x Simulator Connection, then Next and Finish.

image10

Then, you will see the simulator console in the Target Consoles tab. Note that the screenshot shows a separate window, which appeared in older versions.

image11

The Remote Systems tab will show the information about the running simulator.

To load the built application into the simulator choose Download→VxWorks Kernel Task… option from the target's context menu (see below). Download Configurations dialog appears and you need to specify the path to the compiled binary file of your application in Downloads tab. Click Add… and Select a build target icon. Then select the binary with our compiled program: TestProject.out. Finish the operation by pressing the Download button.

image12

image13

To run the application in the simulator, type sp CreateTasks on the target console (command line). Command sp creates a new task with CreateTasks function as the entry point. The command i lists all running tasks.

image14

Our application prints messages to the simulator console, which makes it hard to enter other commands. Fortunately, it is possible to start another console as follows: Right click on the vxsim0 item in the Remote Systems tab and choose Target Tools→WTX console from the opened menu. Now, you can type any commands easily, e.g. the td Task1 command deletes one of the tasks that we have run previously.

image15

3.2   One click alternative

While developing your application you will typically need to run your program repeatedly. For example, you run your program, realize that it has a bug, fix the bug in the source code and run the program again. It is annoying to repeat the steps described in the previous section over and over again. Fortunately, Workbench IDE can automate all of this. When you click the "play" icon for the first time, a dialog window will show up to let you setup basic parameters.

image16

In order to enter some of them, you need to be connected to the target. If you are not, you can do it by clicking the Connect button. After the Entry point of your program is filled in and the Run button is pressed, all the previously described steps will be performed automatically.

image17

From now on, you can press Ctrl-F11 to relaunch the last configured application.

image18

4   Debugging

To debug your program launch it either directly in the debugger (Run→Debug As→VxWorks Kernel Task) or attach the debugger to an already running task – in the Remote Systems tab select the task you want to attach to, right-click it and choose Debug→Attach to TaskX from the context menu (right click).

image19

First, the attached task needs to be stopped.

image20

The Debug window shows the "backtrace" (the sequence of function calls) of the stopped task. The stopped task can be further inspected (e.g. see Variables window) or traced using buttons in the Debug window.

image21

5   Help

Wind River Workbench IDE provides the complete documentation to the VxWorks OS and the IDE itself. When you choose Help→Dynamic Help it will offer (after a longer delay caused by creation of the index) a list of related topics to the keyword at current cursor position.

image22

If you want to read the documentation as book (not just a API reference) select Help→Help Contents or just Contents in the Help window. Then, you can browse all available documentation. Typically, you will navigate to the following chapters:

  1. If you develop a Downloadable Kernel Module:
    • Wind River Documentation→VxWorks→VxWorks Kernel Programmer's Guide
    • Wind River Documentation→VxWorks→VxWorks Kernel API Reference
  2. If you develop a Real-Time Process:
    • Wind River Documentation→VxWorks→VxWorks Application Programmer's Guide
    • Wind River Documentation→VxWorks→VxWorks Application API Reference

image23

6   System Viewer

The System viewer is a tool for monitoring activities inside a running system. It facilitates logging of various events (task state transition, context switch, IPC events, etc.) and shows them off-line in graphs. To launch the System viewer right click on the vxsim0 item in the Remote Systems tab and choose Launch System Viewer.

image24

In the configuration dialog choose the events you want to log. You can select either the context switch or task state transitions or specific ones like events related to semaphores, message queues, etc.

image25

After finishing the configuration, start event logging by clicking the Start System Viewer logging button (the green "play" button under the menu; see the figure above). Let System Viewer run for sufficient time (10–20 seconds) and then stop the logging by Stop System Viewer logging button.

image26

You can hide/filter out the tasks from the time diagram that are not interesting for you.

image27

Clicking the =? icon gives you the description of marks and line types used in the diagram.

7   Assignment

Use the System Viewer tool to compare the behavior of your program when kernelTimeSlice(1) is commented out and when it is not. Look up kernelTimeSlice documentation and compare the documentation with the observed behavior. Explain the teacher what the kernelTimeSlice function does.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多