Products Support Documentation Download
Wind River VxWorks 7.x using Project Files

Introduction

These instructions are for RDM targeting VxWorks 7 and later using VxWorks kernel modules or VxWorks RTP. In the following we will explains these topics:

  • A Quick Overview of VxWorks
  • Task Priorities
  • How to Compile a VxWorks Kernel for RDM
  • How to compile RDM for VxWorks
  • How to Develop an Application for VxWorks Using RDM

A Quick Overview of VxWorks

VxWorks Kernel Modules

VxWorks kernel modules do not use ordinary executables as most other operating systems do. Instead, they use relocatable objects which can be compiled into the kernel or loaded during run time on a running target. The VxWorks loader is just a runtime link loader which is capable of both loading and unloading these objects on a running VxWorks kernel. For this to work, these relocatable files must fulfill some important requirements:

  • The C library must not be linked in
  • Startup code must not be linked in
  • Unresolved symbols in these relocatable files must either be entry points into VxWorks, entry points into libraries already loaded or entry points that are not used during execution.
  • No PIC (position independent code) should be used.

The GNU Toolkit can be used to compile objects that meet the above requirements. To prevent linking against the C library, we use the option "-nostdlib". To prevent ld from trying to produce an executable and instead produce a relocatable file, option "-r" is used.

Applications can be prepared for execution on the target in principally two ways:

  • Compile the application without linking against any library. On the target, we load RDM libraries and then the application.
  • Compile the application by linking against RDM libraries. On the target, we load our linked application.

With the first approach, it is possible to load more than one application that uses the same library. The second approach does not have that capability, but it is more convenient by only having to load one module.

VxWorks RTP

VxWorks Real Time Processes (RTPs) are running executables. With a Memory Management Unit (MMU) each of these processes run in their own address space protected from other processes and the kernel. The executables can be absolutely linked or relocatable.

Hardware without a MMU or where the MMU have been disable will run each RTP with its own region of virtual memory. In this mode, there is no protection between the RTPs and the kernel, but since no MMU need to be updated context switching is faster.

In any case, each process can contain several tasks similar to the kernel. It is the tasks within the RTPs that are scheduled and not the RTPs themselves. The RTPs communicate with the kernel through operating system calls.

Task Priorities

Please consult README-task-priorities.

How to do a VxWorks Source Build

The first step before compiling a VxWorks Kernel or compiling RDM for VxWorks is to set up a VxWorks Source Build (VSB). Follow these instructions unless you are using the VxWorks simulator (A standard install for VxWork 7 will include a prebuilt VSB for the simulator under .../vxworks-7/samples/prebuilt_projects).

Start WorkBench as follows, where ... is the location of the VxWorks 7 install:

$ .../wrenv.sh -p vxworks-7     c:> .../wrenv.bat -p vxworks-7
$ .../startWorkbench.sh           c:> .../startWorkbench.bat

You need WorkBench to create a VxWorks source build:

  • Select "File" -> "New" -> "Wind River Workbench Project"
  • Select "Source Build"

Continue with the appropriate subsection below.

VSB for vxworks7-rtp-x86_32 or vxworks7-x86_32

While clicking "Next>" several times do the following selections as they come up:

  • Set the Project Name to "vsb_x86_32"
  • Create project at external location
  • Directory: ".../vxworks-7/samples/prebuilt_projects/vsb_x86_32"
  • Based on "a VxWorks 7 board support package"
  • BSP: "itl_generic_1_0_1_1"
  • Address mode: "ILP32 32-bit libraries"
  • Board CPU: "CORE"
  • Compiler support: "Only primary compiler - no intrinsic functions"
  • Processor mode: "UP support in Libraries"
  • IP version setting: "IPV6 and IPV4 enabled libraries"

Build the project.

VSB for vxworks7-rtp-armv7 or vxworks7-armv7

While clicking "Next>" several times do the following selections as they come up:

  • Set the Project Name to "vsb_armv7"
  • Create project at external location
  • Directory: ".../vxworks-7/samples/prebuilt_projects/vsb_armv7"
  • Based on "a VxWorks 7 board support package"
  • BSP: "fsl_imx6_1_1_7_0"
  • Address mode: "ILP32 32-bit libraries"
  • Compiler support: "Primary and secondary compiler"
  • Board CPU: "ARMARCH7"
  • Floating point setting" "vector" - Processor mode: "UP support in Libraries" - IP version setting: "IPV6 and IPV4 enabled libraries"

Build the project.

VSB for other targets

A VSB for other targets that are ABI compatible with one of the above target can be built instead. This is useful when the BSP you need for an actual target does not exactly match the BSP used for RDM. This method will only work if the libraries or downloadables (in the case those are also used) are ABI compatible. When creating the VSB, make sure to set the project name to the name of the VSB above that it replaces.

A VSB for other targets that are not ABI compatible with one of the above targets can also be built. It is only possible to use such an ABI with a RDM source package.

In the source for RDM, create a target directory under target similar to target/vxworks7-x86_32 for VxWorks downloadable kernel modules (DKM) or a target directory like target/vxworks7-rtp-x86_32 for VxWorks real time processes (RTP). Edit the files to matches the target directory and the newly created VSB. The template directory can most easily be made to create a DKM or a RTP project based on the VSB and copy in the project files.

How to compile a VxWorks Kernel for RDM

This section describes how to build a VxWorks image using WorkBench targeting VxWorks 7. The description her is for RDM using VxWorks kernel modules or VxWorks RTP.

Start WorkBench as follows:

$ .../wrenv.sh -p vxworks-7     c:> .../wrenv.bat -p vxworks-7
$ .../startWorkbench.sh           c:> .../startWorkbench.bat

You need WorkBench to create a VxWorks image project:

  • Select "File" -> "New" -> "Wind River Workbench Project"
  • Select "Kernel Image"

While clicking "Next>" several times do the following selections as they come up:

  • Set your desired Project Name
  • Based on "a source build project"
  • Select the source build project built in previous section
  • Profile: "PROFILE_DEVELOPMENT"

Click "Finish".

In the Project Explorer, click the triangle to the left of the project name, double click "Kernel Configuration," and make sure to include the following components below:

"Storage components"
-> "File System components"
   -> "Highly Reliable File System Component (HRFS)

"operating system components"
 -> "IO system components"
     -> "Highly Reliable File System Components" -> Include
 -> "kernel components"
     -> "kernel scheduler selection"
         -> "POSIX thread scheduler in RTPs"
            -> "Highly Reliable File System"
               ->Default Max Open Files (HRFS) -> 255
     -> "kernel scheduler selection"
        -> "Posix thread scheduler in RTPs"

You may also want to increase the maximum number of open files. We have increased this to 255 in RDM:

"operating system components"
 -> "IO system components"
     -> "IO Subsystem Components"
         -> "Basic IO System"
             -> "max # open files in the system" -> 255
 -> "Real Time Process Components"
     -> "RTP"
         -> "Number of entries in an RTP fd table"  255

You may also want to include other components depending on how you do your development, debugging, QA, or deployment. This is beyond the scope of this document.

In the Project Explorer, double click "usrAppInit.c" to edit the file. Include the following code for creating a HRFS RAM file system:

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <hrFsLib.h> 
#include <xbdPartition.h>
#include <xbdRamDisk.h>

#define BLOCKSIZE 512

STATUS fsSetup (void) {
    char *devname = "/ram";
    unsigned int disksize = 0x8000000; /* 128 MB */

    STATUS error;
    device_t xbd;

    /* Create a RAM disk. */
    xbd = xbdRamDiskDevCreate (BLOCKSIZE,  disksize, 0, devname);
    if (xbd == NULLDEV) {
        printf("Failed to create RAM disk. errno = 0x%x\n", errno);
        return (ERROR);
    }
    error = hrfsFormat (devname, 0ll, 0, 10000);
    if (error != OK) {
        printf("Failed to format RAM disk. errno = 0x%x\n", errno);
        return (ERROR);
    }
    printf ("%s now ready for use.\n", devname);
    return (OK);
}

/******************************************************************
*
* usrAppInit - initialize the users application
*/ 

void usrAppInit (void) {
#ifdef  USER_APPL_INIT
    USER_APPL_INIT;     /* for backwards compatibility */
#endif

    /* add application specific code here */
    fsSetup ();
}

A RAM file system is needed unless you use some other hardware with a file system on it. If you are using the simulator, we would strongly encourage you to use a RAM file system instead of the host file system.

Select the project in the Project Explorer and select "Project" -> "Build Project." The VxWorks image will show up as default/vxWorks under the location for the project.

How to Develop an Application for VxWorks Using RDM

RDM examples written in C use the RDM_STARTUP_EXAMPLE macro. The argument to this macro must match the name of a named main function as shown below. The tims example uses this macro as follows:

int32_t EXTERNAL_FCN tims_main(
    int32_t            argc,
    const char *const *argv)
{
    ...
}

RDM_STARTUP_EXAMPLE(tims)

You also have the option of compiling in a hook for the RDM_STARTUP_EXAMPLE. We usually compile in a hook like this:

-DPSP_STARTUP_HOOK="chdir(\"/ram\");"

This will change the current working directory. This is most convenient when we launch this from WorkBench. WorkBench does not give you the option of specifying a current working directory. It must always be set programmatically unless you are using a target shell.

Using VxWorks Kernel Modules

The RDM_STARTUP_EXAMPLE macro as used above expands to a function with the following signature (this signature matches the requirements for sp and taskSpawn):

int32_t tims(
    int32_t a1,
    int32_t a2,
    int32_t a3,
    int32_t a4,
    int32_t a5,
    int32_t a6,
    int32_t a7,
    int32_t a8,
    int32_t a9,
    int32_t a10);

Use this function as the entry point to the tims example. The tims example does not take any argument. You should therefore pass in 0 as the first and only argument to this function.

  tims 0

This function takes care of initializing the RDM platform support layer (psp_init ()), builds up the argument list for the named main function, calls the named main function, and terminates the platform support layer (psp_term ()).

Examples and tools that do take arguments should have the arguments passed in as strings - one string for each parameter. You always need to pass in 0 after the last argument unless all ten arguments are specified.

Using VxWorks RTP

The RDM_STARTUP_EXAMPLE macro as used above expands to a normal main function under VxWorks RTP. This is just like many other host operating systems.

How to Compile RDM for VxWorks

Compiling RDM for VxWorks kernel modules consist of a native build for your host development platform and a cross compiled build for your VxWorks target.

Native Build for the Host Development Platform

Before you can compile RDM for VxWorks kernel modules or VxWorks RTP, you need a native build for your host development platform.

Native build for Linux

Please follow the steps outlined in Using "configure" and Using "make". Pay special attention to that you need to provide the command line option –enable-vxworks7-project-files or –enable-vxworks7-rtp-project-files when running configure for the VxWorks project files to be configured.

Native build for Windows

Please follow the steps outlined in Windows Development Host.

Setting up project files for Wind River Workbench

Assuming you have done a native build for your host development platform using the configure script and make on UNIX or the Visual Studio project files on Windows, you are now ready to set up the project files for Wind River Workbench.

On GNU/Linux the following is relative to the top build directory. On Windows it is relative to the top source or install directory:

$ cd target/vxworks7-...
$ .../workbench-4/wrtool -data . wrtool.txt
$ cd ../..

Cross Compiled Build for VxWorks

Assuming you have set up the project files as explained above.

Start WorkBench:

$ .../startWorkbench.sh           c:> .../startWorkbench.bat

Select the target/vxworks7-... as the work space.

You should now have one project file for each example and tutorial that you can build and run on your target.

Running an Example on the Target

Make sure you have built a kernel, have booted your target with it, have access to the console on the target or a debug connection from your host development host, and have built at least one example as described in previous sections.

Please also note that if you are launching the example through a debug connection, you may want to compile with this define:

-DPSP_STARTUP_HOOK="chdir(\"/ram\");"

to change the current working directory to a location where you have a file system. The above assumes a RAM file system under /ram as described in the section for building a VxWorks kernel above.

VxWorks Kernel Modules

As an example, when the bomExample has been loaded on the target, it can be launched interactively as follows from the console:

-> bom
...

Enter number of levels: 3

Enter number of members per level: 3

...
  total rolled up cost =      27.00
...

->

If you want to run it without any interaction, you can launch it as follows:

bom "-m", "3", "-l", "3"

VxWorks RTP

As an example, run the bomExample as follows:

-> rtpSp "/path/to/bomExample.vxe"
...

Enter number of levels: 3

Enter number of members per level: 3

...
  total rolled up cost =      27.00
...

->

If you want to run it without any interaction, you can launch it as follows:

-> rtpSp "/path/to/bomExample.vxe  -m 3 -l 3"