Safety-Critical Modeling with the VxWorks Real Time Operating System

Oct 24, 2020 | IBM, VxWorks

1 Introduction

Rhapsody is a Model driven, and Design development platform used by System engineers and Developers to create Real time Embedded Systems. The models and diagrams built using this tool is used to automatically produce production quality code for various environments, including VxWorks.

Rational Rhapsody provides the capability to test and validate the intended behaviour of the application continuously and lets the user collaborate efficiently with a team. Also as mentioned by the developer IBM, the tool helps accelerate industry standards such as DO-178, DO178B/C, and ISO 26262.

This blog gives a brief description of how Rhapsody can be used to integrate with the Wind River Workbench. This document will show the steps needed to configure Rhapsody for VxWorks configured build, and the workbench simulator configurations to be used to run the executable.

2 Prerequisites

These instructions assume that you are using:
1) IBM Engineering Systems Design Rhapsody 9.0.1
2) Wind River Workbench 4

3 Creating a Traffic Light Model on Rhapsody

A Rhapsody project has code configurations and UML diagrams that can be used to define the model and the code generated from it. When creating a new project, rhapsody by default produces components, packages, and configurations.

Create a new project as shown below. File > New

Windows Screenshot Of IBM Rhapsody New Project

Figure 1: Create A Rhapsody Project

Depending on the model window, Rhapsody provides ‘Diagram Tools’ on the right hand side of the window, which can be used to draw Blocks, Classes, Files etc. These options are limited depending on the model view opened.

Create a Block using the Diagram Tool and Name it to user preference. Once created, right click on the Block, and select Add New > State Chart

Create the state chart using the Diagram Tools shown below to select the states, Transition and the Default Transition lines.

Flow Diagram Of IBM Rhapsody Traffic Light State Machine

Figure 2: Traffic Light State Machine


Windows Screenshot Of IBM Rhapsody To Create State Machine

Figure 3: Design Tools to create the State Machine

Use the Features options of the States to add a kprintf string to all the States, as shown below.This will be used later on to view the state transition.

Windows Screenshot For Setting The Print Out During State Transition

Figure 4: Setting the print out during State Transition

4 Configuration for the Rhapsody for VxWorks integration

Rhapsody Project needs to be configured with VxWorks Workbench settings, in order to build the executable.

Open the features window for the configurations tab on the left (Component > DefaultComponent > Configurations > DefaultConfig) and select the initialization tab. Expand the Default and select the first instance. This will create a Traffic Light initialisation instance in main.

Windows Screenshot Of The Initialisation Tab Of The Configurations For The Rhapsody For VxWorks Integration

Figure 5: Initialisation Tab of the configurations

In the settings tab of the same features window, select the environment to be VxWorks_DKM as shown below.

Windows Screenshot Of The Settings Tab Of The Configurations For IBM Rhapsody

Figure 6: Settings Tab of the configurations

In the Properties tab, the VSBRootDirectory must be pointed to the base of the VSB Build and the stdio.h must be added for the printf to work. The following image shows the configurations that are set in the properties tab. The view may need to be changed to ‘All’, to view all the configurations.

Note: Be sure to use forward slash (/) when writing a path in Rhapsody.

Windows Screenshot Of The Properties Tab Of The Configurations For IBM Rhapsody

Figure 7: Properties Tab of the configurations

Now the user is ready to build the rhapsody project and create the executable.

Select the Generate/Make/Run option in the Code tab on top. This should create the .out executable needed for the VxWorks run.

Note: If Rhapsody is building for VxWorks environment for the first time, be sure to build the VxWorks framework before building the project. This can be done by selecting, Code > Build Framework.

5 Code configurations for VxWorks Execution

We tried to connect to the Workbench directly from Rhapsody, but the Connect option failed to show. This way of execution is explained later in the blog. For this blog, we hacked VxWorks code into Rhapsody and manually ran the executable on Workbench.

To move through the Traffic Light states, Events need to be triggered. Using the Watch dog timer and the Rhapsody API, the following code was written. The Watchdog timer controls the time between Event changes, and the rhapsody API, rootState_dispatchEvent() is used to send the Event to trigger a state change.

int vxmain(int argc, char* argv[]) {
    int status = 0;
    p_TrafficLightController = TrafficLightController_Create(RiCMainTask());
    widY = wdCreate ();
    wdStart (widY,
             (FUNCPTR) wdFunc, NULL);
    while (running)
        taskDelay (10);
    wdCancel (widY);
    return status;
void yellowTimeoutHandler ()
    statusR = rootState_dispatchEvent(p_TrafficLightController, evYellow_Default_id);

A snippet of the Main source file is shown above. The user would also have to make the rootState_dispatchEvent() a global and also edit that function to make it works without any errors. All the relevant files that needs to be changed are attached.




Note: Make sure to use Code > Build > Build “DefaultComponent.out”. This will prevent Rhapsody from regenerating the default code and build the changes into the executable.

6 Configurations on VxWorks

On the VxWorks Workbench, create a VxWorks Image Project based on the VSB mentioned in Rhapsody VSBRootDirectory. The prebuilt Default vxSim VSB can be used. This will be used to create a simulator connection where the Rhapsody Executable can be downloaded and Run.

Once created the kernel configurations of the VIP is used to add Standard C++ and kprintf Libraries.

Use the Target Manager to Create a VxWorks Simulator Connection as shown below.
The kernel image should be of the VIP that was created previously.

Windows Screenshot Of The Setup Of A VxWorks Simulator Connection

Figure 8: Setup of the Simulator Connection

Connect and Disconnect buttons of the Target Manager

Figure 9: Connect and Disconnect buttons of the Target Manager

Using the Connect button, establish a connection and a vxShell will be opened pointing to the current workspace. This is the shell used to execute the Rhapsody project.

7 Run the Executable on VxWorks

The shell created using the Simulator shall be up and running after the previous section. Once running, the executable needs to be loaded. This is done either by navigating to the .out rhapsody project file via the shell created or by copying the .out file from the project to the workspace where the shell is currently opened in.

Once located, the executable is loaded onto the shell using the ‘ld’ command and then spawned using the ‘sp’ command. Below is a figure showing how the executable is run and the results of it.

Windows Screenshot Of Commands On The Simulator To Be Executed and the Run

Figure 10: Commands on the Simulator to be executed and the Run


To stop the Traffic light project from changing state, either pass in “running=0” to get out of the while loop in the code, or disconnect the
simulator connection.

8 Connecting Workbench Direct from Rhapsody

Rhapsody can directly form a connection with VxWorks workbench and run the created executable and debug the project from workbench. During our trials we failed to establish the connection between the 2 IDEs. Below is a link that describes the necessary steps needed to form this connection:

Although this link is for a tutorial using old versions, the same principle applies.

Browse Category

Join our DO-178C group on LinkedIn

Got A Project In Mind?

We fix, develop and test embedded software for the aerospace & defence industry specialising in DO-178C safety-critical testing. Speak to us. We have laser focus, unprecedented attention-to-detail and provide phenomenal value.