Skip to main content

Introduction to VxWorks 5.5 Programming

·1032 words·5 mins
VxWorks Tornado 2.2 WindView Real-Time Systems Embedded Development
Table of Contents

This exercise provides a practical refresher on VxWorks 5.5 program development. You will create a simple project, interact with the target system, and use WindView to observe and measure real-time performance characteristics.


๐Ÿ› ๏ธ Start a VxWorks Project
#

Launch the Tornado 2.2 development environment.

Start the Tornado

Create a new downloadable project.

Create Project

Name the project Simple. If youโ€™ve used Tornado before, you may reuse your existing workspace. New developers must create a workspace on the Z: drive; Tornado stores each project in its own directory inside this workspace.

VxWorks 5.5 Programming Step 1

Our target systems (“purpleboxes”) use Intel 80486 processors. Select the I80486gnu toolchain for all purplebox-related development.

VxWorks 5.5 Programming Step 2

Finish creating the project. This also creates the workspace automatically if one does not exist.

VxWorks 5.5 Programming Step 3


๐Ÿงฑ Create and Build the Simple Project
#

Copy simple.c into the Simple project directory. In the Files tab, right-click the project and add this file.

In the Builds tab, locate I80486gnu under Simple Builds. Right-click and rebuild simple.out. When prompted to regenerate dependencies, click OK.

VxWorks 5.5 Programming Dependencies

During the build, the Build Output window appears. Double-click any error to jump directly to its source.

VxWorks 5.5 Programming Build Simple Out

A successful build produces simple.out, which you will later download to the target.

VxWorks 5.5 Programming Simple Out


โš™๏ธ Start the Target System and Target Server
#

Powering up a purplebox causes it to FTP a standard VxWorks image from the development station. Therefore, start the FTP server before powering on the target.

VxWorks 5.5 Programming FTP Server

Connect power to the AVerKey iMicro video converter. The power connectors for the converter and the purplebox look identical but provide different voltagesโ€”the AVerKey cable is tied down to prevent misconnection.

VxWorks 5.5 Programming AVerKey

VxWorks 5.5 Programming Purplebox

Power the purplebox and switch the monitor input using the middle button. You should see the BIOS and VxWorks boot ROM. After the timeout, it downloads the VxWorks image.

VxWorks 5.5 Programming VxWorks Image Load

On the target monitor, verify that the system is ready by confirming the message: WDB: Ready.

Next, start a Target Server, which acts as a proxy between Tornado and the purplebox. Select the appropriate target based on the labels on the host and target devices. If the target list is empty, run the registry update file (Tornado22-registry-targets) located in C:\Tornado2.2.

VxWorks 5.5 Programming Target Server

Check the bullseye icon in the system tray: no exclamation mark means the connection succeeded. You can double-click it to confirm.

From Tornado, connect to the target server (there should be only one).

VxWorks 5.5 Programming Target Connection


๐Ÿ’ฌ Interact with the Target System
#

During development, you will primarily use the remote shell. Start it by clicking the shell icon.

VxWorks 5.5 Programming Shell Tool

The shell window gives you command-line access to the target. The Tornado User’s Guide documents all commands; typing help provides brief descriptions.

VxWorks 5.5 Programming Shell Information

Right-click Simple Files and download simple.out to the target. Run the program by typing its entry function:

progStart

Any function can be invoked simply by typing its name.


๐Ÿ“Š Gathering System Performance Data
#

WindView is Tornadoโ€™s tool for collecting detailed timing and event data from the target. Launch it from the toolbar.

VxWorks 5.5 Programming Wind View Tool

WindView collects events in on-target buffers. From the Upload Mode screen, choose whether to upload data continuously or defer uploads until logging stops.

VxWorks 5.5 Programming Defer Continuous

Deferred upload reduces runtime overhead but limits capture duration. You can also adjust buffer count and size in Advanced options. Use Deferred Upload for these exercises.

Control what events are logged using the Event Logging Level screen.

VxWorks 5.5 Programming Additional Config

Open the Log Overview tab. Set refresh to 1 second, then press the green Go button to start logging.

VxWorks 5.5 Programming Start Wind View

Allow the buffers to fill or click the red Stop button to end capture manually. Upload the event log using the Upload Event Log button.

VxWorks 5.5 Programming Upload Log

WindView will generate an event graph similar to the following:

VxWorks 5.5 Programming Wind View

Explore the event graph:

  • What do the icons represent?
  • What is the meaning of each interval?
  • How do you zoom in for detail?
  • Can specific event types be filtered?
  • How do you measure the time between two points?

For deeper analysis, export the data to CSV. Note: If zoomed in, only the zoomed portion will be exported.

VxWorks 5.5 Programming Export Data


๐Ÿ“ˆ Analyze the Data
#

From the exported CSV:

  • Calculate the average interval between executions of the simple task.
  • Identify the minimum and maximum intervals.
  • Plot a histogram. Does the distribution look uniform? Clustered? Sporadic?

This analysis shows how external factors, scheduling, or interrupt latency affect real-time behavior on VxWorks.

๐Ÿ› ๏ธ Source code
#

/* simple.c - a sample program to use as an introduction to VxWorks and Tornado */

/* $Id: simple.c,v 1.1 2007-03-12 05:47:46 se463 Exp $ */

/* includes */
#include "vxWorks.h"
#include "stdio.h"
#include "stdlib.h"
#include "semLib.h"
#include "taskLib.h"

#define DELAY_TICKS     50

#define STACK_SIZE	20000

/* run states, provides for shutdown in stages; ensures that no 
   routine tries to take a semaphore that no longer exists */
#define ALL_GO 		0	
#define SHUTDOWN 	1
#define GATEKEEPER_STOP 2
#define ALL_STOP        3

/* globals */
int tidGatekeeper;
int tidSimple;

int runState;                   /* running state of the system */
int count;                     /* track number of time simple runs */

SEM_ID syncSemId;		/* Controls when simple can run */

/* forward declarations */
void gatekeeper (void);
void simple (void);
void progStop (void);

/*************************************************************************
*
* progStart - start the simple program.
*
* RETURNS: OK
*/

STATUS progStart (void)
{
    syncSemId = semBCreate (SEM_Q_FIFO, SEM_EMPTY);

    /* get started */
    runState = ALL_GO;

    tidGatekeeper = taskSpawn ("tGateKeeper", 200, 0, STACK_SIZE,
        (FUNCPTR) gatekeeper,0,0,0,0,0,0,0,0,0,0);

    tidSimple = taskSpawn ("tSimple", 220, 0, STACK_SIZE,
        (FUNCPTR) simple,0,0,0,0,0,0,0,0,0,0);

    return (OK);
}

/*************************************************************************
*
* gatekeeper - routine that supplies the semaphore simple task waits on
*
*/

void gatekeeper (void)
{
    while (runState == ALL_GO)
    {
        semGive(syncSemId);
        taskDelay (DELAY_TICKS + (rand() & 0x0f) - 8);
    }

    runState = GATEKEEPER_STOP;
    semGive (syncSemId);
}

/*************************************************************************
*
* simple - consume the semaphore and do not do much else
*
*/

void simple (void)
{
    count = 0;
  
    while (runState != GATEKEEPER_STOP)
    {
        semTake (syncSemId, WAIT_FOREVER);	/* Wait for signal */
        count++;
    }

    runState = ALL_STOP;
}


/*************************************************************************
*
* progStop - stops the program 
*
* Call this routine to end it all.
*/

void progStop (void)
{
    runState = SHUTDOWN;

                                  /* Wait for everyone to finish up */
    while (runState != ALL_STOP)
	taskDelay (1);
                                  /* clean up */
    semDelete (syncSemId);
    
    printf ("Simple executed %d times.\n",count);
}


/*
    $Log: simple.c,v $
    Revision 1.1  2007-03-12 05:47:46  se463
    Set for the first day of class.

*/