打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
A quick intro to Wind River Workbench development environment

Warning

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

1   Starting Wind River Workbench

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

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

Then the main IDE window is opened:

2   New Project

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

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

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

Click Next and then Finish button.

Now you can see the newly created project in the Project Explorertab.

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

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

3   Build and Run

As with most modern IDEs it is possible to build and run anapplication with a single click. It is, however, quite useful tounderstand what happens behind the scene. We will first look at theindividual steps that are needed to run a VxWorks application and thenwe 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→BuildProject. The build log can be watched in the Build console tab.

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

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

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

The Remote Systems tab will show the information about the runningsimulator.

To load the built application into the simulator chooseDownload→VxWorks Kernel Task… option from the target's contextmenu (see below). Download Configurations dialog appears and youneed to specify the path to the compiled binary file of yourapplication in Downloads tab. Click Add… and Select a buildtarget icon. Then select the binary with our compiled program:TestProject.out. Finish the operation by pressing the Downloadbutton.

To run the application in the simulator, type sp CreateTasks onthe target console (command line). Command sp creates a new taskwith CreateTasks function as the entry point. The command ilists all running tasks.

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

3.2   One click alternative

While developing your application you will typically need to run yourprogram repeatedly. For example, you run your program, realize that ithas 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 sectionover and over again. Fortunately, Workbench IDE can automate all ofthis. When you click the "play" icon for the first time, a dialogwindow will show up to let you setup basic parameters.

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

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

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 alreadyrunning task – in the Remote Systems tab select the task you wantto attach to, right-click it and choose Debug→Attach to TaskX from the contextmenu (right click).

First, the attached task needs to be stopped.

The Debug window shows the "backtrace" (the sequence offunction calls) of the stopped task. The stopped task can be furtherinspected (e.g. see Variables window) or traced using buttons inthe Debug window.

5   Help

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

If you want to read the documentation as book (not just a APIreference) select Help→Help Contents or just Contents in theHelp 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

6   System Viewer

The System viewer is a tool for monitoring activities inside a runningsystem. It facilitates logging of various events (task statetransition, context switch, IPC events, etc.) and shows themoff-line in graphs. To launch the System viewer right click on thevxsim0 item in the Remote Systems tab and choose LaunchSystem Viewer.

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

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

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

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

7   Assignment

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

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
µVision User's Guide: About µVision
Building advanced Cortex-M3 applications
Enterprise Integration Patterns - JMS Publish/Subscribe Example
Code Analysis with the Eclipse Profiler
Tornado2.2-vxworks5.5仿真测试和调试指南
tomcat设置远程连接
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服