4

Projects



4.1    Introduction

The project facility is a key element of the Tornado IDE. It provides graphical and automated mechanisms for creating applications that can be downloaded to VxWorks, for configuring VxWorks with selected features, and for creating applications that can be linked with a VxWorks image and started when the target system boots. The project facility provides mechanisms for:

  • Adding application initialization routines to VxWorks.

  • Organizing the files that make up a project.

  • Grouping related projects into a workspace.

  • Customizing and scaling VxWorks.

  • Defining varied sets of build options.

  • Building applications and VxWorks images.

  • Downloading application objects to the target.


*      
NOTE: For a tutorial introduction to the project facility and its use with the integrated version of the VxWorks target simulator and other Tornado tools, see the Tornado Getting Started Guide.


*      
WARNING: Use of the project facility for configuring and building applications is largely independent of the methods used prior to Tornado 2.x. (These methods included manually editing the configuration files config.h or configAll.h, while the project tool uses .cdf files). The project facility provides the recommended and simpler means for configuring and building, although the configuration file method may still be used (see 5. Command Line Configuration and Build). To avoid confusion and errors, the two methods should rarely be used together for the same project.

One exception is for any configuration macro that is not accessible through the project facility GUI (which may be the case, for example, for some BSP driver parameters). You can use a Find Object dialog box to determine if a macro is accessible or not (see Finding VxWorks Components and Configuration Macros). If it is not accessible through the GUI, a configuration file must be edited, and the project facility will implement the change in the subsequent build.

The order of precedence for determining configuration is (in descending order):

        project facility
        config.h
        configAll.h

For any macro that is exposed through the project facility GUI, changes made after creation of a project in either of the configuration files will not appear in the project.

A second exception may be building a project based on a BSP. If you have customized your BSP by modifying config.h and other configuration files, you can convert it to a project and combine it with your application in the project facility. See 5.7 Building Projects from a BSP.

In general, changes to header files in the BSP or the BSP makefile are only carried over to projects by recreating the projects. However, changes to .c files are automatically picked up by existing projects.


Terminology

There are several key terms that you must understand before you can use the project facility documentation effectively:

Downloadable application

Bootable application

Project


Workspace

Component

Toolchain

BSP

Project Facility GUI

The main components of the project facility GUI are:

  • A project selection window, which allows you to begin creation of a new project, or open an existing project.

  • An application wizard that guides you through creation of a new project.

  • A workspace window, which provides you with a view of projects, and the files, VxWorks components, and build options that make them up. The workspace window also provides access to commands for adding and deleting project files, creating new projects, configuring VxWorks components, defining builds, downloading object files, and so on.

  • A build toolbar, which provides access to all the major build commands.

As its name implies, the Workspace window provides the framework for the project facility. The window displays information about projects files, VxWorks components (if any), and build options in three tabbed views: Files, VxWorks, and Builds (Figure 4-1).

Figure 4-1:   Workspace Window Views: Files, VxWorks, and Builds

The workspace allows you to:

  • Scale and customize VxWorks by adding and deleting components, as well as display component dependencies and view object sizes.

  • Display information about the files, VxWorks components, and build options that make up a project, or set of projects.

  • Add, open for editing, compile, and delete source code files.

  • Download applications to the target.

  • Specify and modify one or more builds for a project, display detailed build information, and modify build options.

  • Add, delete, rename, or build a project.

A context-sensitive menu is available in each of the workspace views. A right-mouse click displays the menu. The first section of the menu provides commands relevant to the GUI object you have selected. The second section displays commands relevant to the current page of the window. And the third section displays global commands that are relevant to the entire workspace (Figure 4-2).

Many of the pop-up menu options are also available under the File, Project, and Build menus.

For information about using the Tornado editor, see 3. Editor. For information about using an alternate editor, integrating configuration management tools (such as ClearCase) with the project facility, and other customization options, see 12. Customization.

Figure 4-2:   Workspace Window Pop-up Menu

Workspace Icons

As you expand the tree structure in each workspace pane, the icons by each tree element tell you what it is or what it contains.

Table 4-1:   Workspace Icons


Icon
Location
Description

   
All panes
Workspace
   
Files and Builds panes
Downloadable application
   
All panes
Bootable system
   
VxWorks pane
Component folder
   
VxWorks pane
Selection folder
   
VxWorks pane
Component
   
Builds pane
Build specification
   
Files pane
Source or object folder
   
Files pane
Source file



4.2    Planning Your Projects

This section explains the steps necessary to get your product development underway. When you finish, you will be able to employ the features of the Tornado cross-development environment to their greatest utility.

To achieve full project facility support from Tornado, you will need to:

  • Obtain or create a functioning BSP.
  • Create a project from this BSP.
  • Add your application code to this project, or to another in the same workspace.
  • Create a new boot image (may not be required).

4.2.1   Getting a Functional BSP

To get a functioning BSP, you can:

  • Use a Wind River- or third-party-supplied BSP (this includes the integrated or optional simulator).

  • Create your own custom BSP to support custom hardware.

Using a Wind River or Third-Party BSP

Tornado 2.2 BSP

If your BSP was included with Tornado 2.2, you can create a bootable project from it directly. Use the project wizard for a bootable application to create a project based on your BSP or the pre-built project (bspName_vx.wpj) which is shipped with every Wind River-supplied BSP.

Tornado 2.0 BSP

For information on migrating a Tornado 2.0-compliant BSP to Tornado 2.2, see the Tornado Migration Guide.

Third-party or Tornado 1.0.1 BSP

If your BSP came from a third party or from Tornado 1.0.1, see the Tornado Migration Guide or the Tornado 2.0 documentation.

You may wish to enable the Tornado 1.0.1 compatibility mode, which exposes menu items to execute BSP builds in a BSP directory. (See 12. Customization.) Once your BSP builds, you may proceed to create a bootable project from it immediately. See 5.7 Building Projects from a BSP.

Using a Custom BSP For Custom Hardware

Creating a BSP

If you need to create your own BSP, refer to the VxWorks BSP Developer's Guide (a separate product available from Wind River). If you wish to develop the BSP and the application code in parallel, you may wish to begin application development on the VxWorks simulator. See Using the Simulator BSP.

Using a Pre-Existing BSP with the Project Facility

If you already have a custom BSP that is Tornado 2.0 compliant, see the Tornado Migration Guide for information on migrating from 2.0 to 2.2.

If you already have a custom BSP but it is not Tornado 2.0 compliant, you will need to modify it to conform to the guidelines outlined in the VxWorks BSP Developer's Guide in order to use it with the Tornado project facility. Once you have modified it, verify that it builds properly before creating a project for it.


*      
NOTE: If you do not make your BSP Tornado 2.0 compliant, Tornado will not be able to provide project-based support for customizing, configuring, or building it.

Using a BSP Outside the Project Facility

You may still use a non-compliant BSP by managing its customization and configuration manually. For information on using manual methods, see 5. Command Line Configuration and Build. You can still create downloadable projects to hold your application code and download them to a target booted with a non-compliant BSP.

Using the Simulator BSP

You can use the target simulator if you want to develop the BSP and application code for your product in parallel, or if your target hardware is not yet ready. The integrated simulator contains default VxWorks functionality sufficient for supporting many applications. It does not have networking support; for this you can use the full simulator (VxSim), which is available as an optional product.

4.2.2   Creating a Bootable Project Based on a BSP

Using the VxWorks Simulator

Integrated Simulator With Basic Functionality

If you are using the integrated simulator and do not need to customize it by adding or removing VxWorks functionality, you need not create a bootable project until you have your production BSP ready.

Integrated Simulator With Added Functionality

If you need additional VxWorks functionality, you will need to create a bootable project immediately. Use the project wizard for a bootable application. You will use a different base depending on what additional functionality you need.

  • No networking: If you do not need networking to support your application, you can create a bootable project based on the integrated simulator, configure it, and build it.

  • Networking: If you need network support, you will need the VxWorks full simulator (VxSim), which can be purchased from Wind River as an optional product.

The process for creating a project, and configuring it, is identical for both the integrated and full simulator.

Base this project on the simulator BSP (either the integrated simulator or the optional product), or the pre-built, default simulator project (simhost_vx.wpj. At this point, your project will build an image identical to the integrated simulator as you received it from Wind River. Now add any components you need using the VxWorks tab in the Workspace view (see 4.4.3 Configuring VxWorks Components).

Using a Real Target

Create a bootable project using the project wizard. Base the project on your BSP. If project creation fails, then your BSP is probably not Tornado 2.2-compliant. Refer to the VxWorks BSP Developer's Guide for information on how to make it compliant.

Image Size Considerations

Use size information to make sure your image will fit in your target memory space. The approximate image size information displayed in the Component Add Dialog reports the size of the VxWorks code in your configuration and the increase or decrease resulting from adding or removing components. This size will be smaller than your actual image size, as it does not reflect your BSP support code or any application code you will be adding.

4.2.3   Developing and Adding Your Application Source Code

Adding Existing Application Source Code

Use Your Existing Build System

If you already have a working application, or if your application is very large, you may want to use your own build system. You can use the project facility to link the output of an external build into VxWorks and even start external builds (see External Build System).

Alternatively, you may want to use the project facility to configure your VxWorks image and produce a makefile. You can build your application outside Tornado and call the project facility-generated makefile from your build to produce a final image.

Integrate It with Your Bootable Project

Use this approach if your edit-compile-reboot cycle is relatively quick. Add the files to the bootable project using the Add File(s) to Project context menu available in the File tab of the Workspace view. Then edit the VxWorks initialization file, usrAppInit.c, adding calls to your application's initialization and startup routines. The VxWorks application initialization component is required, and is included by default. See 4.4 Creating a Custom VxWorks Image and 4.5 Creating a Bootable Application.

Create a Separate, Downloadable Project for Your Code

Use this method if rebooting your target is inconvenient, and if your code is modular enough that it can be added to the running target without interrupting execution or if you have the means to start and stop your application. Create a downloadable project using the Downloadable Project Wizard. Add application files with the Add File(s) to Project context menu. Build your downloadable project. Boot the target using the appropriate image described in 4.2.2 Creating a Bootable Project Based on a BSP. Download the partially linked and munched .out file produced by your project.2 See 4.3 Creating a Downloadable Application.

Creating New Application Source Code

Use File>New from the main Tornado menu bar to create a new file and specify the project into which it should be added.

Building with Custom Build Rules

If some of your source files require processing with tools not included with Tornado, you may want to add custom build rules to process them. You have two choices:

This ensures that the custom rule will be invoked only to process the specified source file. For example, you may wish to add a custom rule to process a yacc file into a C source file. To create a custom rule, see 4.6 Working With Build Specifications.


*      
NOTE: If you migrate source files from one project to another, you will need to recreate the custom build rules for these files in the new project.

A build-specific custom rule can invoke any command and reference any build dependencies. The rule can be selected as the current build rule to build the desired output explicitly or, if the Invoke this rule before building Project box is checked, it will be built implicitly prior to building any of the built-in rules (such as vxWorks, or project.a) for the project.


*      
NOTE: Custom build rules cannot be copied between projects. If you will use either form of custom build rules, and know that you will be migrating files between projects, you may wish to put files with similar build settings into separate projects. These projects can then be built and linked together. For more information, see the hierarchical sub-project model discussed in Sub-Projects.

Developing Architecture-Independent Applications

The techniques for developing applications that are independent of target architecture are described below.

Migrating Files

You may migrate application source files between any two projects that coexist in the same workspace. Use the Add File(s) from Project context menu from the File tab. If you have defined custom build rules for any of your source files, you will have to replicate them in the destination project by hand.


*      
CAUTION: It is important that you only migrate application source files between projects. BSP-specific files, and those synthesized by Tornado for your project, cannot be migrated. Only Tornado's project wizards can be used to create or reference these files.

Creating Sub-Projects

If you have a number of files that must be built with special build rules or flags, it may be easier to create a new project to build these particular files, and then build that project as a sub-project of your main project. For more information, see Structuring Your Projects.

Using Configuration Management

Tornado provides configuration management integration. To enable and configure it, see 12. Customization.

Configuring VxWorks

VxWorks must be configured to support the calls your application makes to it, or you will not be able to link your image. If your BSP provides a "bare-bones" VxWorks configuration, you may wish to use Project>Auto Scale to detect and add most of the VxWorks functionality you require. Auto Scale will compile your code, analyze the symbols in your object modules, map them to components, and offer to include those components. There may be some components that Auto Scale does not detect. If you Auto Scale, build, and still get link errors, you will need to add the additional components from the workspace VxWorks tab. For information on using Auto Scale, see 4.5.1 Using Automated Scaling of VxWorks.

Structuring Your Projects

You have three choices in how you organize the complete build of your application into VxWorks.

Single Project

Add all your application source code to one bootable project. This method is the simplest. All your source code is added to the bootable project, which already contains the BSP code and is linked to the VxWorks libraries.

External Build System

The Tornado workspace is very convenient for configuring VxWorks, building small applications, or building, downloading, and debugging small parts of a large application. It is not designed to handle a complete build of a large, modular application, which often requires sub-projects (though this can be achieved using custom rules and macros). For this reason, you may want to use an external build system to build your application, then link it to VxWorks using the EXTRA_MODULES or LIBS macros. You can write a custom rule to invoke your external build process; see Sub-Projects. Alternatively, your build can kick off a VxWorks build and link your application code as the final step.

Sub-Projects

Sub-projects allow you to create as many projects as are needed to hierarchically organize and build your product. This approach accommodates existing hierarchically-organized source code. You will want to use this approach if:

  • some source files need different build settings or custom rules.
  • a split of your code is desirable for organizational or structural reasons.

Tornado has only limited support for managing and building these hierarchical sub-projects. You must use macros and custom rules to create the hierarchy and structure the builds manually. For directions on how to organize your application code into sub-projects, please refer to Example 1, below.

Example 1:   Using Sub-Projects

This example illustrates how a master project can be used to build several sub-projects. The master project builds the sub-projects as .pl (partially linked) modules. Then they are linked with the master project and munched (integrated with code to call C++ static constructors and destructors) in the final build step.

In this example, the master project is a bootable project, and there are two sub-projects that are downloadable projects. However, a downloadable project can also serve as a master project. You could use this approach if you wanted to build several downloadable sub-projects and link them into a single downloadable project. You could also use this approach to integrate an external application build into VxWorks. You need to modify the custom rules in the example to invoke your external build (for example, using make).

Assumptions:

  • The bootable project is called Master and resides in a directory of the same name. It contains a build specification called default based on the simpc (Windows host simulator) BSP.

  • The two downloadable projects are called Project1 and Project2, and they also reside in directories of the same name. Each contains a build specification called SIMNTgnu based on the PC simulator toolchain.

  • Project1 contains a C source file called foo.c, containing a function called Test( ).

  • Project2 contains a C source file goo.c, which in turn contains a function called Test2( ).

  • Test( ), which calls Test2( ), is the main application entry point.

  • Dependencies have been generated for each of the two downloadable projects, and they have been saved. This creates makefiles for them. Without the makefiles, the build fails.

Go first to the Build tab. Expand the project Master. Double-click on the build specification default to display the build property sheet. In the build property sheet, select the Rules page. Click New/Edit and add the new rules.

You enter a new rule by filling in the Target, Dependencies, and Commands fields of the Create or Edit Rule dialog box. For example, to add the clean rule, you type clean in the Target field, CleanProject1 CleanProject2 vxWorks in the Dependencies field, and nothing in the Commands field. For each rule, you must also uncheck the Invoke this rule before building project checkbox.

The required rules are listed below in makefile syntax. The first example shows the syntax. Fill in the appropriate boxes for each rule.

SYNTAX: 
    target : dependencies 
        commands
RULES: 
    ../../Project1/SIMNTgnu : 
        - mkdir $@
Master : ../../Project1/SIMNTgnu/Project1.pl ../../Project2/SIMNTgnu/Project2.pl VxWorks 
 
../../Project1/SIMNTgnu/Project1.pl : ../../Project1/SIMNTgnu 
wind_force_make 
    $(MAKE) -C ../../Project1/SIMNTgnu -f ../../Project1/Makefile 
BUILD_SPEC=SIMNTgnu Project1.pl 
 
../../Project2/SIMNTgnu : 
    - mkdir $@ 
 
../../Project2/SIMNTgnu/Project2.pl : ../../Project2/SIMNTgnu 
wind_force_make 
    $(MAKE) -C ../../Project2/SIMNTgnu -f ../../Project2/Makefile 
BUILD_SPEC=SIMNTgnu Project2.pl 
 
CleanProject1 : ../../Project1/SIMNTgnu 
    $(MAKE) -C ../../Project1/SIMNTgnu -f ../../Project1/Makefile 
BUILD_SPEC=SIMNTgnu clean 
 
CleanProject2 : ../../Project2/SIMNTgnu 
    $(MAKE) -C ../../Project2/SIMNTgnu -f ../../Project2/Makefile 
BUILD_SPEC=SIMNTgnu clean 
 
clean : CleanProject1 CleanProject2


*      
CAUTION: The clean rule must have the correct case, and it cannot include any commands. In this example, CleanProject1 and CleanProject2 are added as dependencies to the default clean rule for VxWorks. The clean rule ensures that the ReBuild All command rebuilds Project1, Project2, and VxWorks.

If you wish your rules to be portable between architectures, substitute $(CPU)$(TOOL) for SMNTgnu.

In the Rules pane, set the default build rule for project Master to be the rule Master. Next, in the Build pane, in the MACROS tab for project Master, append to the EXTRA_MODULES macro "../../Project1/SIMNTgnu/Project1.pl" and "../../Project2/SIMNTgnu/Project2.pl" and click the Add/Set button.


*      
NOTE: You can use PRJ_LIBS to link extra modules to downloadable projects, in the same way that EXTRA_MODULES is used for bootable projects.

Add to the source file usrAppInit.c, in project Master, a function prototype for, and a call to, the function Test( ):

void Test(void); 
 
void usrAppInit (void) 
    { 
    #ifdef  USER_FF 
    USER_APPL_INIT; /* for backwards compatibility */ 
    #endif 
 
    /* add application specific code here */ 
    Test(); 
    }

When you build Master, all three will be built, munched, and linked into one bootable image. (For information on munching, see the VxWorks Programmer's Guide: C++ Development.)


*      
NOTE: The sub-project objects in the example (Project1.pl and Project2.pl) need not have been generated by Tornado downloadable projects. They could also have been the result of an external build system.

To modify this example to integrate an external application build system, you could, for instance:

  • Replace all instances of Project1.pl with the partial link product of your external application build.

  • Replace the Project2.pl rule with a rule appropriate for starting your external application build.

Example 4-2:   Avoiding Absolute Paths

One problem that arises from using a version control system is that different users may extract projects and source files to different locations (for example, in Visual SourceSafe, or CVS), or map views to different drive letters (Clearcase on Windows). It helps greatly if projects do not have any absolute paths written into them.

If source files or subprojects are in a directory which is at the same directory level as the parent project directory or deeper, they are recorded in the parent project file with a path relative to the parent project directory. Organizing your source files and projects in this way is recommended to avoid absolute paths in project files and makefiles.

If you cannot organize your source files and projects in this way, we provide two environment variables to allow you to define the root of your source directory tree or your project directory tree: WIND_SOURCE_BASE and WIND_PROJ_BASE.

Below we give some examples showing how to avoid absolute paths to source files or to sub-projects.

  1. Avoiding absolute paths to source files

Suppose your project is in directory t:\source_root\myproj and your source files are organized as follows:

t:\source_root\myproj\foo1.c 
t:\source_root\src\foo2.c 
t:\source_root\myproj\src\foo3.c

Your project will contain no absolute paths. Instead, the above files will be recorded in the project file as:

$(PRJ_DIR)/foo1.c 
$(PRJ_DIR)/../src/foo2.c 
$(PRJ_DIR)/src/foo3.c

Organizing your source files and projects in any of these ways is the recommended procedure for avoiding absolute paths in project files and makefiles.

If you cannot organize your source files and projects in one of these ways, the WIND_SOURCE_BASE environment variable allows you to define the root of your source directory tree. To illustrate the use of WIND_SOURCE_BASE, assume you wish to add the file:

t:\other_source_root\goo.c

If WIND_SOURCE_BASE is not defined, it appears in the project file with an absolute path (we do not support $(PRJ_DIR)/../../). However, before you add the file, you can use Tools->Options->Workspace to define:

WIND_SOURCE_BASE = t:\other_source_root

Then t:\other_source_roo\goo.c is recorded in the project file as:

$(WIND_SOURCE_BASE)/goo.c

The major drawback to the WIND_SOURCE_BASE variable is that all users of myproj must have WIND_SOURCE_BASE defined or the workspace cannot find goo.c.

  1. Avoiding absolute paths to sub-projects

This example refers to a master project called master and various sub projects called sub1, sub2,... The master project could be a bootable project and the sub-projects could refer to external build systems or downloadable projects.

Assume the master project is in directory t:\prj_root\master and your sub-projects are organized as follows:

t:\prj_root\sub1 
t:\prj_root\master\sub2 
t:\prj_root\subprojects\sub3 
t:\prj_root\master\subprojects\sub4

In this case, your master project will contain no absolute paths. Instead, the above directories will be recorded in the master project file as:

$(PRJ_DIR)/../sub1 
$(PRJ_DIR)/sub2 
$(PRJ_DIR)/../subprojects/sub3 
$(PRJ_DIR)/subprojects/sub4

Organizing your projects in any of the above ways is the recommended procedure for avoiding absolute paths in project files and makefiles.

If you cannot organize your projects in any of these ways, we provide the WIND_PROJ_BASE environment variable to allow you to define the root of your project directory tree. To illustrate the use of WIND_PROJ_BASE, assume you wish to add the project:

t:\other_prj_root\sub5

If WIND_PROJ_BASE is not defined, then it appears in the master project file with an absolute path (we do not support $(PRJ_DIR)/../../). However, before you add the project you could use Tools->Options->Workspace to define:

WIND_PROJ_BASE=t:\other_prj_root

Now when you add t:\other_prj_root\sub5, this sub-project will be recorded in the master project file as:

$(WIND_PROJ_BASE)/sub5

The major drawback to the WIND_PROJ_BASE variable is that all users of the master project have to define WIND_PROJ_BASE, or the workspace is unable to find sub5.


*      
NOTE: WIND_SOURCE_BASE and WIND_PROJ_BASE must be set before a source file is added or the variable is not recorded in the file path. The property page always reflects the path from which a source file was originally loaded, not the current path calculated from WIND_SOURCE_BASE (if it has changed). The build always uses the correct value, but the source editor launches against the stale copy of the file. To avoid confusion, reload the workspace whenever you change WIND_SOURCE_BASE and WIND_PROJ_BASE.



4.3    Creating a Downloadable Application

A downloadable application is a collection of relocateable object modules that can be downloaded and dynamically linked to VxWorks, and started from the shell or debugger. A downloadable application can consist of a single "hello world" routine or a complex application.

To create a downloadable application, you must:

  1. Create a project for a downloadable application.
  1. Write your application, or use an existing one.
  1. Add the application files to the project.
  1. Build the project.

You can then download the object module(s) to the target system and run the application.

4.3.1   Creating a Project for a Downloadable Application

All work that you do with the project facility, whether a downloadable application, a customized version of VxWorks, or a bootable application, takes place in the context of a project.

If the Create Project window is open (the default when you first start Tornado3 ), click the New tab. Otherwise, click File>New Project. Then choose the selection for a downloadable application, and click OK (Figure 4-3)

Figure 4-3:   Create Downloadable Application

.

The application wizard appears. This wizard is a tool that guides you through the steps of creating a new project.

First, enter the full directory path and name of the directory you want to use for the project (only one project is allowed in a directory), and enter the project name. It is usually most convenient to use the same name for the directory and project, but it is not required.


*      
NOTE: You may create your projects anywhere on your file system. However, it is preferable to create them outside of the Tornado directory tree to simplify the process of future Tornado upgrades.

You may also enter a description of the project, which will later appear in the property sheet for the project (Figure 4-4). Finally, identify the workspace in which the project should be created. Click Next to continue.

Figure 4-4:   Application Wizard: Step One for Downloadable Application

Identify the toolchain with which the downloadable application will be built. You can do so by referencing an existing project, or by identifying a toolchain. Basing a project on an existing one means that the new project will reference the same source files and build specifications as the one on which it was based. Once the new project has been created, its build specifications can be modified without affecting the original project, but changes to any shared source files will be reflected in both.

For example, to create a project that will run on the target simulator, select A toolchain and select the default option for the target simulator from the drop-down list (Figure 4-5).4 Click Next.

Figure 4-5:   Application Wizard: Step Two for Downloadable Application

The wizard confirms your selections (Figure 4-6). Click Finish.

Figure 4-6:   Application Wizard: Step Three for Downloadable Application

The Workspace window appears, containing a folder for the project. Note that the window title includes the name of the workspace (Figure 4-7).

Figure 4-7:   Initial Workspace Window for a Downloadable Application


*      
NOTE: Pop-up menus provide access to all commands that can be used with the objects displayed in, and the pages that make up, the Workspace window (use the right mouse button).

4.3.2   Project Files for a Downloadable Application

The project facility generates a set of files whose contents are based on your selection of project type, toolchain, build options, and build configurations. During typical use of the project facility you need not be concerned with these files, except to avoid accidental deletion, to check them in or out of a source management system, or to share your projects or workspaces with others. The files are created in the directories you identify for the workspace and project. The files initially created are:

projectName.wpj

workspaceName.wsp

Both of these files contain information that changes as you modify your project, and add projects to, or delete projects from, the workspace.

When you build your application, a makefile is dynamically generated in the main project directory, and a subdirectory is created containing the objects produced by the build. The subdirectory is named after the selected build specification. If other build specifications are created and used for other builds, parallel directories are created for their objects.

4.3.3   Working With Application Files

The Files view of the Workspace window displays information about the projects, and the directories and files that make up a project (Figure 4-8).

Figure 4-8:   Workspace Files View

The first level of folders in the Files view are projects. Each project folder contains:

  • Project source code files, which are added to the project by the user.

  • An Object Modules folder, which contains a list of objects that the project's build will produce. The list is automatically generated by the project facility.

  • An External Dependencies folder, which contains a list of make dependencies. The list is automatically generated by the project facility.

Initially, there are only the default folders for Built Objects and External Dependencies, and the projectName.out file. The file projectName.out is created as a single, partially-linked module when the project is built. It comprises all of the individual object modules in a project for a downloadable application, and provides for downloading them all to the target simultaneously.


*      
WARNING: Use of the projectName.out file is essential for downloading C++ modules, which require munching for proper static constructor initialization. You should also use the projectName.out file for downloading C modules to avoid any potential link order issues related to dynamic loading and linking.

Creating, Adding, and Removing Application Files

To create a new file, click File>New, or press CTRL+N. Select the file type from the New dialog box. Then select the project to which the file should be added. Finally, enter the file name and directory, and click OK (Figure 4-9). The editor window opens, and you can write your code and save the file. (See 3. Editor).

Figure 4-9:   New File Dialog Box

Add existing files to a project by right-clicking in the Workspace window, selecting Add Files or Add Files from project from the pop-up menu, and then using the associated dialog box to locate and select the file(s).

To link object files with your project, use the PRJ_LIBS macro or the Linker page of the build specification property sheet (see Linker Options). To link library (archive) files with your project, add the libraries to the list defined by the LIBS macro in the Macros page of the build specification property sheet (see Makefile Macros).

Remove files from the project by right-clicking on the file name and selecting Remove from the pop-up menu, or by selecting the file name and pressing DELETE.


*      
CAUTION: Adding a file to a project or removing a file from a project does not affect its existence in the file system. The project facility does not copy, move, or delete user source files; merely the project facility's references to them. Removing a file from one workspace context does not affect references to it in any others, nor its existence on disk. However, if a file is included in more than one project or workspace, an edit made in one context will be reflected in all. (If this behavior is not desired, copy source files to another directory before adding them to a project.)

Displaying and Modifying File Properties

To display information about the properties of a file, right-click on the file name in the Workspace window, and select Properties from the pop-up menu. The extent of information displayed depends on the type of file and whether or not make dependencies have been generated. In the case of source code, a Properties sheet for the file appears, displaying information about make dependencies; general file attributes such as modification date; and the associated make target, custom dependencies, and commands used for the build process (Figure 4-10).

Figure 4-10:   Source File Property Sheet

See Calculating Makefile Dependencies, for information about how and when to calculate makefile dependencies. See Compiler Options for information about overriding default compiler options for individual files.

Opening, Saving, and Closing Files

The File and pop-up menus provide options for opening, saving, and closing files. You can also use standard Windows key and mouse shortcuts (such as double-clicking on a file name to open the file in the editor, using CTRL+S to save a file, and so on).

See 12. Customization for information about customizing the editor, including how it handles DOS and UNIX end-of-line markers.

4.3.4   Building a Downloadable Application

The project facility uses the GNU make utility to automate compiling and linking an application.5 It automatically creates a makefile prior to building the project. But before it can create a makefile, the makefile dependencies must be calculated. The calculation process, which is based on the project files' preprocessor #include statements, is also an automated feature of the project facility.

Binaries produced by a given build are created in a project subdirectory with the same name as the name of the build specification (projectName\buildName).


*      
NOTE: All source files in a project are built using a single build specification (which includes a specific set of makefile, compiler, and linker options) at a time. If some of your source requires a different build specification from the rest, you can create a new project for it in the same workspace, and customize the build specification for those files. One project's build specification can then be modified to link in the output from the other project. See Sub-Projects.


*      
NOTE: The project facility allows you to create specifications for different types of builds, to modify the options for any one build, and to select the build specification you want to use at any given time easily. See 4.6 Working With Build Specifications.


*      
CAUTION: Different versions of C++ run-time support are provided for the GNU and Diab toolchains. For this reason, you cannot combine C++ objects compiled with GNU with C++ objects compiled with Diab. All C++ applications must be compiled with the same tool.

Calculating Makefile Dependencies

To calculate makefile dependencies, select Dependencies from the workspace pop-up menu. The Dependencies dialog box appears (Figure 4-11). Click OK.

Figure 4-11:   Dependencies Dialog Box

After dependencies have been calculated, the files are listed in the External Dependencies folder (Figure 4-12).

Figure 4-12:   External Dependencies

If you do not calculate dependencies before you start a build, Tornado prompts you to do so for any of the project files for which dependencies have not previously been calculated. Dependencies are not calculated for each build specification. If your dependencies change for different build specifications (for example, if they are CPU-dependent), then you may want to:

  • Create a new project for each build specification.

  • Regenerate dependencies when you switch build specifications.

Tornado assumes that your header files are in either your project directory or installDir\target\h. If you have placed files in other locations, you need to make two changes to your project build specification. Right-click on the name of your build specification (for example, SIMNTgnu). Select Properties from the pop-up menu. On the C/C++ compiler tab, click the Include paths button. Add a separate entry for each directory path.

The Advanced option allows you to speed up the build process by specifying paths in which none of the dependencies could have changed since the last build. The timestamps for the files in the specified paths are not checked (Figure 4-13).

Figure 4-13:   Dependency Calculation Option

Build Specifications

Each build specification for a downloadable application consists of a set of options for makefile rules and macros, as well as for the compiler, assembler, and linker. A default build specification is defined when you create your project. To display its property sheet, double-click on the build specification name in the Builds view of the workspace to display the property sheet for the build specification.

Rules Tab

The Rules page (Figure 4-14) allows you to select from the following build target options:

Figure 4-14:   Build specification Property Sheet

objects

archive

projectName.out

projectName.pl

You can use the project facility to change the options for a given build specification, create and save new build specifications, and select the specification to use for a build. You can, for example, create one build specification for your project that includes debug information, and another that does not. For more information, see 4.6 Working With Build Specifications.


*      
NOTE: It is sometimes useful to build an application for the target simulator, and then to create a new build specification to build it for a real target.

Macros Tab

The Macros tab contains pre-set build macros. Do not delete the pre-existing macros; while you can reenter them, the value will be lost. You can add and delete your own macros by typing in the Name window and then clicking the Add button.

Macros that are useful with bootable projects:

EXTRA_MODULES

Extra object modules to link into the VxWorks image.

LIBS

Libraries against which VxWorks is linked.

POST_BUILD_RULE

Shell commands to execute after the build has completed.

RAM_HIGH_ADRS

RAM address where the boot ROM data segment is loaded. It must be a high enough value to ensure loading VxWorks does not overwrite part of the ROM program.

RAM_LOW_ADRS

Beginning address to use for the VxWorks run-time in RAM.


*      
WARNING: RAM_HIGH_ADRS and RAM_LOW_ADRS are also defined in config.h; the two definitions must match!

Macros that are useful with downloadable projects:

PRJ_LIBS

Libraries or modules against which a downloadable application is linked.

POST_BUILD_RULE

Shell commands to execute after the build has completed.

Environment Variables

If you are using the Diab tools, you must have two settings in place:

  • Be sure that installDir\host\diab\WIN32\bin is in the system path.

  • Be sure that the environment variable DIABLIB is set to installDir\host\diab.

There is a batch file called torVars.bat in installDir\host\x86-win32\bin that will set DIABLIB for you.

Building an Application

To build a project with the default options, select the name of the project (or any subordinate object in its folder) and then select Build 'projectName.out' from the pop-up menu. If you have created build specifications in addition to the default, you can select the build specification you want to use from the Build drop-down list at the top of the workspace window before you start the build.


*      
WARNING: Tornado only calculates dependencies upon the first use of a file in a build. Once an initial set of dependencies has been calculated, Tornado does not attempt to detect changes in dependencies that may have resulted from modification of the file. If you have changed dependencies by adding or deleting #include preprocessor directives, you should regenerate dependencies.

The Build Output window displays build messages, including errors and warnings (Figure 4-15).

Figure 4-15:   Build Output

Any compiler errors or warnings include the name of the file, the line number, and the text of the error or warning text. Double-clicking on the line containing the error message opens the file in the editor with a context pointer on the offending line. The error or warning text is also displayed in the status bar at the bottom of the main Tornado window.

Use the Edit>Next Error/Tag and Edit>Previous Error/Tag menu options to navigate between errors when you are using the Tornado editor.


*      
WARNING: The default compiler options include debugging information. Using debugging information with the optimization set to anything but zero may produce unexpected results. See 4.6 Working With Build Specifications for information about modifying builds and creating new build specifications.

To force a rebuild of all project objects, select Rebuild All from the pop-up menu (which performs a make clean before the build).

Build Toolbar

The Build toolbar provides quick access to build commands. Display of the toolbar is controlled with the View>Toolbar>Build Toolbar menu option. The toolbar is shown free-floating in Figure 4-16, but is docked by default.

Figure 4-16:   Build Toolbar

The Build toolbar commands (Table 4-2) are also available from the main menus and the Workspace pop-up menu.

Table 4-2:   Build Toolbar Buttons


Button
Menu
Description

Build>Build
Build project.
Build>Rebuild All
Rebuild project (performing a make clean first).
Build>Compile
Compile selected source file.
Build>Dependencies
Update dependencies.
Build>Stop Build
Stop build.
Project>Download
Download object file (or boot image for target simulator).

4.3.5   Downloading an Application

Before you can download and run an application, you must boot VxWorks on the target system, have access to a Tornado registry, and configure and start a target server. For more information, see 2. Setup and Startup and 8. Target Server.

You can download an entire project from the project workspace by selecting Download 'projectName.out' from the pop-up menu for the Files view, or by using the download button on the Build toolbar. You can download individual object modules by selecting the file name and then selecting the Download 'filename.o' option from the pop-up menu. However, you may inadvertently introduce errors by downloading individual object modules out of sequence. We strongly recommend that you always download the partially-linked projectName.out file.

C++ projects must be downloaded as projectName.out because this file is produced from application files and munched for proper static constructor initialization.

To run a downloaded application, use WindSh or CrossWind. For more information see 7. Shell or 10. Debugger.

To unload a project from the target, use the Unload 'projectName.out' option on the pop-up menu.

4.3.6   Adding and Removing Projects

New projects can be added to a workspace by selecting File>New Project and creating a new project when the workspace is open.

Existing projects can be added to a workspace by selecting the menu options File>Add Project to Workspace, and using the file browser to select a project file (projectName.wpj).

Projects can be removed from a workspace by selecting the project name in the Files view, and then selecting the Remove option from the pop-up menu, or by selecting the project name and pressing DELETE.


*      
NOTE: When you remove a project, you only remove it from the workspace. The project directory and its associated files are not removed from disk.



4.4    Creating a Custom VxWorks Image

The Tornado distribution includes a VxWorks system image for each target shipped. The system image is a binary module that can be booted and run on a target system. The system image consists of all desired system object modules linked together into a single non-relocateable object module with no unresolved external references. In most cases, you will find the supplied system image adequate for initial development. However, later in the cycle you may want to create a custom VxWorks image.

VxWorks is a flexible, scalable operating system with numerous facilities that can be tuned, and included or excluded, depending on the requirements of your application and the stage of the development cycle. For example, various networking and file system components may be required for one application and not another, and the project facility provides a simple means for either including them in, or excluding them from, a VxWorks application. In addition, it may be useful to build VxWorks with various target tools during development (such as the target-resident shell), and then exclude them from the production application.

Once you create a customized VxWorks, you can boot your target with it and then download and run applications. You can also create a bootable application simply by linking your application to VxWorks and adding application startup calls to the VxWorks system initialization routines (see 4.5 Creating a Bootable Application).

4.4.1   Creating a Project for VxWorks

All work that you do with the project facility, whether a downloadable application, a customized version of VxWorks, or a bootable application, takes place in the context of a project.

If the Create Project window is open (the default when you first start Tornado6 ), click the New tab. Otherwise, click File>New Project. Then choose the selection for a bootable application, and click OK (Figure 4-17)

Figure 4-17:   Create Bootable Application

.

The application wizard appears (Figure 4-18). This wizard is a tool that guides you through the steps of creating a new project.

First, enter the full directory path and name of the directory you want to use for the project (only one project is allowed in a directory), and enter the project name. It is usually most convenient to use the same name for the directory and project, but it is not required.


*      
NOTE: You may create your projects anywhere on your file system. However, it is preferable to create them outside of the Tornado directory tree to simplify the process of future Tornado upgrades.

You may also enter a description of the project, which will later appear in the property sheet for the project. Finally, identify the workspace in which the project should be created. Click Next to continue.

Figure 4-18:   Application Wizard: Step One for Bootable Application

Then you identify the BSP with which you will build the project. You can do so by referring to an existing project, or by identifying a BSP that you have installed.


*      
NOTE: If you are creating a customized VxWorks image or a bootable application, the project will be generated faster if you base it on an existing project rather than on a BSP. This is because the project facility does not have to regenerate configuration information from BSP configuration files. All Tornado 2.x BSPs include both GNU and Diab project files for this purpose. Options for BSP projects are available in the drop-down list for existing projects. For example, the mbx860 BSP project files are:

        
installDir\target\proj\mbx860_gnu\mbx860_gnu.wpj
        
installDir\target\proj\mbx860_diab\mbx860_diab.wpj

Basing a project on an existing one means that the new project will reference the same source files as the one on which it was based, but it will start with copies of the original project's VxWorks configuration and build specifications. The build specifications and VxWorks configuration for the new project can be modified without affecting the original project, but changes to any shared source files will be reflected in both.

For example, to create a project for a module that will run on a mbx860 target, select An existing project and then select mbx860_gnu.wpj (or mbx860_diab.wpj if you have purchased the Diab tools) from the drop-down list (Figure 4-19). Click Next.

Figure 4-19:   Application Wizard: Step Two for Bootable Application

If, on the other hand, you must base your project on a BSP, select A BSP and choose one of the BSPs you installed or the appropriate simulator. If your BSP offers both GNU and Diab toolchains, select a toolchain as well. Click Next.

The wizard confirms your selections (Figure 4-20). Click Finish.

Figure 4-20:   Application Wizard: Step Three for Bootable Application

The Workspace window appears.

4.4.2   Project Files for VxWorks

The project facility generates, or includes copies of, a variety of files for a VxWorks project. The names of the files that you may need to work with are displayed in the workspace File view (Figure 4-21).

Figure 4-21:   VxWorks Project Files


*      
NOTE: Pop-up menus provide access to all commands that can be used with the objects displayed in, and the pages that make up, the Workspace window (use the right mouse button).

During typical use of the project facility you do not need to be concerned with these files, except to avoid accidental deletion, to check them in or out of a source management system, or to share your projects or workspaces with others. You will need to edit usrAppInit.c, however, when you create a bootable application (see 4.5 Creating a Bootable Application).


*      
CAUTION: Do not check in linkSyms.c, prjConfig.c, prjComps.h, or prjParams.h; these files are regenerated whenever the project file changes.

The VxWorks project files serve the following purposes:

linkSyms.c

prjConfig.c

romInit.s

romStart.c

sysALib.s

sysLib.c

userAppInit.c

The following files are created in the main project directory as well, but are not visible in the workspace:

prjComps.h

Makefile

prjParams.h

projectName.wpj

workspaceName.wsp

When you build the project from the GUI, a makefile is dynamically generated in the main project directory, and a subdirectory is created containing the objects produced by the build. The subdirectory is named after the selected build specification. If other build specifications are created and used for other builds, parallel directories are created for their objects.

You can also build your project from the command line. When you do so, you must create the makefile first. See Using the Command Line.

The Files view can also display the default list of objects that would be built, and the external dependencies that make up the new project, in the Built Objects and External Dependencies folders, respectively.

4.4.3   Configuring VxWorks Components

The VxWorks view of the workspace displays all VxWorks components available for the target. The names of components that are selected for inclusion appear in bold type. The names of components that are excluded appear in plain type. The names of components that have not been installed appear in italics. Note that the names of folders appear in bold type if any (but not necessarily all) of their components are included. (Figure 4-22.)

Figure 4-22:   VxWorks Components


*      
NOTE: See the VxWorks Programmer's Guide for detailed information about the use of VxWorks facilities, target-resident tools, and optional components.

Finding VxWorks Components and Configuration Macros

You can locate individual components and configuration parameters in the component tree, based on their macro names, with the Find Object dialog box. Open the dialog box with the pop-up menu for the VxWorks view (Figure 4-23).

Figure 4-23:   Find Object


*      
NOTE: The Find Object dialog box is particularly helpful in conjunction with VxWorks documentation, which discusses VxWorks configuration in terms of preprocessor symbols, rather than the descriptive names used in the project facility GUI.

Displaying Descriptions and Online Help for Components

The component tree in the VxWorks view provides descriptive names for components. You can display a component description property sheet, which includes the name of the preprocessor macro for the component, by double-clicking on the component name (Figure 4-24).

Figure 4-24:   VxWorks Component Properties and HTML Reference

To display online reference documentation, double-click on the topic of your choice displayed in the Help Link box of the property sheet. The corresponding HTML reference material is displayed in a Web browser (Figure 4-24).

Including and Excluding Components

VxWorks components that are not needed for a project can be excluded, and components that have been excluded can be included again. The pop-up menu provides Include and Exclude options for components you select in the VxWorks view. You can also use the DELETE key to exclude options.

Tornado automatically determines component dependencies each time a component is included or excluded. That is, it determines if a component you want to include is dependent upon other components that have not been included in the project, or if a component that you are deleting is required by other components. When a component is included, any components it requires are automatically included. When a component is excluded, any dependent components are also excluded. In either case, a dialog box provides information about dependencies and the option of cancelling the requested action. For example, if you exclude POSIX clocks, the dialog box informs you that the ANSI time component would be excluded (Figure 4-25).

Figure 4-25:   Exclude VxWorks Component


*      
WARNING: The results of calculating dependencies is not necessarily identical for inclusion and removal. Including a component you previously excluded does not automatically include the components that were dependent on that component, and that were therefore excluded with it. For example, excluding the POSIX clocks component automatically excludes the ANSI time component, which is dependent on it. But if the POSIX clocks component is subsequently included, there are no components required by it, so the ANSI time component is not automatically included (Figure 4-26).

Figure 4-26:   Include VxWorks Component

You can also include folders of components. However, not all components in a folder are necessarily included by default (nor would it always be desirable to do so, as there might be conflicts between components). Tornado offers a choice about what components to include. For example, if you include target shell components, not all of the components are included by default, and you are prompted to accept or modify the default selection (Figure 4-27).

Figure 4-27:   Including a Component Folder

Tornado automatically calculates an estimate of the change in the size of the image resulting from the inclusion or exclusion, as well as the new image size. The Include and Exclude dialog boxes display this information. (Also see Estimating Total Component Size).

Some folders contain component options that are explicitly combinative or mutually exclusive (in the sense of being potentially in conflict). These folders are called selections, and their names are preceded by a checkbox icon in the folder tree. You can make or change your selection either by opening the folder and performing an include or exclude operation on individual components, or by displaying the property sheet for the folder and making selections with the check boxes on the Components page (Figure 4-27).

Figure 4-28:   Including Conflicting Components

Component Conflicts

If you include components that potentially conflict, or are missing a required component, Tornado warns you of the conflict by displaying a message box with a warning, and by highlighting the full folder path to the source of the conflict. The property sheet for the folder also displays error information in its Errors page. For example, if you attempt to include both symbol table initialization components, a warning is first displayed. Once you acknowledge the warning, the folder names development tool components, symbol table components, select symbol table initialization are highlighted. You can display the property sheet for the folder for a description of the problem and how to correct it. (See Figure 4-29 for all GUI elements.)


*      
WARNING: You can build VxWorks even if there are conflicts between the components you have selected, but you may have linker errors or the run-time results may be unpredictable.

Figure 4-29:   Component Conflicts

Changing Component Parameters

In the VxWorks view, the pop-up menu provides access to component parameters (preprocessor macros). For example, selecting the operating system components folder, then Params for 'operating system components' from the pop-up menu (or double-clicking on the folder name), displays a dialog box that allows you to change the values of the parameters defined for the operating system components (Figure 4-30). Parameters specific to individual components can be accessed similarly.

Figure 4-30:   Component Parameters

For more information about component parameters, see the VxWorks Programmer's Guide and the VxWorks Network Programmer's Guide.

Estimating Total Component Size

To calculate and display the estimated size of the components included in an image, select the project name (in any of the workspace views), then select Properties from the pop-up menu, and select the Size tab in the property sheet that appears (Figure 4-31). Note that this estimate is for the components only, and does not include the BSP or any application code.

Figure 4-31:   Total Component Size

4.4.4   Selecting the VxWorks Image Type

The default VxWorks is a RAM-based image. If you want to create something other than the default images, use one of the other build specifications created when you created your project:

  • default_rom
  • default_romCompress
  • default_romResident

These build specifications are identical to the default, except that instead of building the vxWorks rule, default_rom, for example, is set up to build the vxWorks_rom rule. (Figure 4-32).

Figure 4-32:   Build Rules for VxWorks Images

The options available for a VxWorks image are:

vxWorks

default_rom

default_romCompress

default_romResident


*      
NOTE: Project files used only for a ROM-based image can be flagged as such, so that they are only used when a ROM-based image is built. See Compiler Options.

4.4.5   Building VxWorks

VxWorks projects are built in the same manner as downloadable applications. To build a project with the default options, select the name of the project (or any subordinate object in its folder) and then select the Build option from the pop-up menu. The name of the build specification that will be used is displayed in the Build drop-down list at the top of the workspace window.

For more information about a generic build, see 4.3.4 Building a Downloadable Application. For information about modifying builds and creating new build configurations, see 4.6 Working With Build Specifications.

Using the Build Menu

The build menu allows you to choose boot ROMs or BSPs to build. Figure 4-33 illustrates the Build dialog box in a Tornado system that has a PowerPC BSP and the Diab compiler installed.

Figure 4-33:   Rebuilding VxWorks from the Build Menu

Select a BSP

Select an Image to build



*      
WARNING: Be sure not to use make clean in your VxWorks tree, in other words, in installDir\target\src. The make clean command is designed to force a complete rebuild of your project files. If you use it in installDir\target\src, you will remove VxWorks objects for which you do not have source and which you will therefore be unable to recreate.

Select a tool

When you click OK in the build dialog box, Tornado builds the corresponding object in the BSP directory. Output from the build goes to a Build Output window, which you can use as a diagnostic aid.

To rebuild VxWorks, select the vxWorks target name in the Select an Image list. For example, Figure 4-33 shows the vxWorks target selected for the mbx860 BSP.


*      
NOTE: All source files in a project are built using a single build specification (which includes a specific set of makefile, compiler, and linker options) at a time. If some of your source requires a different build specification from the rest, you can create a project for it in the same workspace, and customize the build specification for those files. One project's build specification can then be modified to link in the output from the other project. See Linker Options.


*      
WARNING: The default compiler options include debugging information. Using debugging with the optimization set to anything but zero may produce unexpected results. See 4.6 Working With Build Specifications for information about modifying builds and creating new build configurations.

Using the Command Line

Using the command line allows you to automate builds. Projects must be created and configured in the GUI, and dependencies must be generated there as well. However, makefile generation and building are possible from the command line. To generate the makefile, use the makegen utility and to build, use make.

Change to the build directory and type make with flags, for example:

% cd installDir/target/proj/Project1/mbx860_gnu 
% makegen 
% mkdir default_rom 
% cd default_rom 
% make -f ../Makefile BUILDSPEC=default_rom

Your build output will be in the default_rom directory and the build will use the default_rom build specification.

4.4.6   Booting VxWorks

For information about booting VxWorks (and bootable applications), see 2.5 Booting VxWorks. VxWorks images for the target simulator can be downloaded and booted with the pop-up menu Start command.



4.5    Creating a Bootable Application

A bootable application is completely initialized and functional after a target has been booted, without requiring interaction with Tornado development tools. For information about developing your application, 4.2.3 Developing and Adding Your Application Source Code.

4.5.1   Using Automated Scaling of VxWorks

The auto scale feature of the project facility determines if your code, or your custom version of VxWorks, requires any components that are not included in your VxWorks project, and adds them as required. It also provides information about components that may not be required for your application. To automatically scale VxWorks, select Auto Scale from the pop-up menu in the VxWorks view of the workspace window to display the Auto Scale dialog box, and click OK.


*      
NOTE: The auto scale feature detects only statically calculable dependencies between the application code and VxWorks. Some components may be needed even if they are not called by your application. This is especially true for servers such as WDB, NFS, and so on.

4.5.2   Adding Application Initialization Routines

When VxWorks boots, it initializes all operating system components (as needed), and then passes control to the user's application for initialization. To add application initialization calls to VxWorks, double-click on userAppInit.c to open the file for editing, and add the calls to usrAppInit( ). Figure 4-34, for example, illustrates the addition of a call to runItAll( ), the main routine in the application file helloWorld.c.

Figure 4-34:   Adding Application Initialization Calls to VxWorks



4.6    Working With Build Specifications

The project facility allows you to create, modify, and select specifications for any number of builds. Default build specifications are defined when you create your project.

  • While a BSP is usually designed for one CPU, you can create build specifications for different image types and optimization levels, specifications for builds that include debugging information and builds that do not, and so on.

  • A downloadable project can have build specifications for different CPUs, for example, for a simulator and a real target.

4.6.1   Changing a Build Specification

Each build specification consists of a set of options that define the VxWorks image type (for VxWorks and bootable application projects), makefile rules, macros, as well as compiler, assembler, and linker options.


*      
NOTE: For detailed information about compiler, assembler, and linker options, see the GNU ToolKit User's Guide or the Diab C/C++ Compiler User's Guide.

You can change default or other previously defined build options by double-clicking on the build name in the Builds view of the workspace window. The build's property sheet appears (Figure 4-35).

Figure 4-35:   Build Property Sheet

You can use the property sheet to modify:

  • build targets
  • makefile rules
  • makefile macros for the compiler and linker
  • compiler options
  • assembler options
  • linker options

For information about build targets for downloadable applications, see Build Specifications. For information about build targets for bootable applications, see 4.4.4 Selecting the VxWorks Image Type. Other features of the build property sheet are covered in the following sections.

Custom Makefile Rules

The buttons at the bottom of the build property sheet allow you to create, edit, or delete makefile rules (default project entries cannot be deleted; only those created by a user can be deleted). When you click the New/Edit button, the Create or Edit Rule dialog box appears (Figure 4-36). Once you have created or edited an entry, click OK. Note that the default is to invoke the rule before building the project (see checkbox). If the default is not selected, the rule is only invoked if it is the rule currently selected for the build (with the drop-down list in the Rules page of the build property sheet) or if it is a dependency of the currently selected rule. New rules are added to the projectName.wpj file and written to the makefile prior to a build.

Figure 4-36:   Makefile Rule

Makefile Macros

Select the Macros tab of the build specification property sheet to view the makefile macros associated with the current project, build specification, and rules (Figure 4-37).

Figure 4-37:   Makefile Macros

You can use the Macros page to modify the values of existing makefile macros, as well as to create new rules to be executed at the end of the build. Use the Delete button to delete a macro from the build. To change an existing macro, modify the value and click the Add/Set button. To add a macro, change the name and value of an existing macro, and click the Add/Set button.

The recommended way to link library (archive) files to your bootable project is to add the libraries to the list defined by the LIBS macro and the modules to the list defined by the EXTRA_MODULES macro. Use the PRJ_LIBS macro for downloadable projects.

Compiler Options

The C/C++ compiler page of the build specification property sheet displays compiler options. You can edit the options displayed in the text box (Figure 4-38). You can also click the Include Paths button and use the dialog box to enter and order your include paths.

Figure 4-38:   Compiler Options

     

Figure 4-39:   Include Paths Dialog Box


*      
WARNING: The default compiler options include debugging information. Using debug information with the optimization option set to anything but zero may produce unpredictable results. Selecting Include debug info automatically sets optimization to zero. This can be changed by editing the option.

If you use the -I option to add include file paths for the build, you must use forward slashes ( / ) rather than standard Windows backward slashes ( \ ). Failure to do so causes dependencies from directories other than the current directory to try to make a target of the header file, preventing you from building real targets.

You can override the default compiler flags for individual files by right-clicking on the file name in the Files view, selecting Properties from the pop-up menu, and specifying a new set of options in the Build page of the property sheet. Unchecking the Use default build rule for this file box allows you to edit the fields in this page (Figure 4-40).

Figure 4-40:   Compiler Options for Individual Files

If the file should be used only when building a ROM-based image, check the Build for ROM images only box. See 4.4.4 Selecting the VxWorks Image Type.

Assembler Options

Select the assembler tab of the build specification property sheet to view assembler options. You can edit the options displayed in the text box (Figure 4-41).

Figure 4-41:   Assembler Options

Link Order Options

Select the Link Order tab of the build specification property sheet to view module link order (Figure 4-42). You can change the link order using the Down and Up buttons to ensure that static C++ constructors and destructors are invoked in the correct order.

Figure 4-42:   Link Order Options

Linker Options

Select the linker tab of the build specification property sheet to view linker options. You can edit the options displayed in the text box (Figure 4-43).

Figure 4-43:   Linker Options

To link an object or library (archive) file with a project, you can list the full path to the file here. However, the recommended way to link library (archive) files is to add the libraries to the list defined by the LIBS, EXTRA_MODULES, or PRJ_LIBS macros on the Macros tab (see Makefile Macros).


*      
WARNING: You cannot link another project object file (projectName.out) with the project you are building. You must compile the other project as a library (see Build Specifications) or as a partial link (projectName.pl), and then link it with the current project.

4.6.2   Creating New Build Specifications

You can create new build specifications for a project with the Add New Build Specification window, which is displayed with the New Build option on the pop-up menu. For example, one build specification can be created that includes debug information, and another that does not; specifications can be created for different image types, optimization levels, and so on. You can create a new build specification by copying from an existing specification, or by creating it as a default specification for a given toolchain(Figure 4-44).

Figure 4-44:   New Build Specification

Once you have created a new build specification, use the build specification property sheet to define it (see 4.6.1 Changing a Build Specification).


*      
NOTE: Within a bootable project, you are restricted to the toolchains that support the CPU required by the BSP. You can still create multiple build specifications (for example, with different optimization levels or rules).

4.6.3   Selecting a Specification for the Current Build

When you want to build your project, select the build specification from the Build Spec drop-down list (Figure 4-45).

Figure 4-45:   Build Specification Selection

Binaries produced by a build are created in the buildName subdirectory of your project directory.



4.7    Configuring the Target-Host Communication Interface


*      
WARNING: During development you must configure VxWorks with the target agent communication interface required for the connection between your host and target system (network, serial, NetROM, and so on). By default, VxWorks is configured for a network connection. Also note that before you use Tornado tools such as the shell and debugger, you must start a target server that is configured for the same mode of communication. See 2.4 Host-Target Communication Configuration; and 8.2 Configuring and Starting a Target Server.

To display the options for the communication interface for the target agent in the VxWorks view, select development tool components>WDB agent components>select WDB connection (Figure 4-46).

Figure 4-46:   Target Agent Connection Options

To select an interface, select it from the list and select the Include 'component name' option from the pop-up menu. (You can also make a selection by double-clicking on the select WDB connection option to display the property sheet, and then making the selection from the Components page.)

To display general information about a component, or to change its parameters, simply double-click on its name, which displays its property sheet (see Figure 4-47). The options for the target agent communication interface are described below.


*      

Configuration for an END Driver Connection

When VxWorks is configured with the standard network stack, the target agent can use an END (Enhanced Network driver) connection. Add the WDB END driver connection component. This connection has the same characteristics as the network connection, but also has a polled network interface that allows system and task mode debugging.

Configuration for Integrated Target Simulators

To configure a target agent for an image that will run with the VxWorks integrated target simulator, add the WDB simulator pipe connection component.

Configuration for NetROM Connection

To configure the target agent to use a NetROM communication path, add the WDB netROM connection component. (See 2.4.4 The NetROM ROM-Emulator Connection).

Several configuration macros are used to describe a board's memory interface to its ROM banks. You may need to override some of the default values for your board. To do this, display the component property sheet, and select the Params tab to display and modify macro values.

Figure 4-47:   NetROM Connection Macros

WDB_NETROM_MTU

WDB_NETROM_INDEX

WDB_NETROM_NUM_ACCESS

WDB_NETROM_POLL_DELAY

WDB_NETROM_ROMSIZE

WDB_NETROM_TYPE

WDB_NETROM_WIDTH

The size of the NetROM dual-port RAM is 2 KB. The NetROM permits this 2 KB buffer to be assigned anywhere in the pod 0 memory space. The default position for the NetROM dual-port RAM is at the end of the pod 0 memory space. The following line in installDir\target\src\config\usrWdb.c specifies the offset of dual-port RAM from the start of the ROM address space.

dpOffset = (WDB_ROM_SIZE - DUALPORT_SIZE) * WDB_NETROM_WIDTH;

If your board has more than one ROM socket, this calculation gives the wrong result, because the VxWorks macro ROM_SIZE describes the total size of the ROM space--not the size of a single ROM socket. In that situation, you must adjust this calculation.

Refer to the NetROM documentation for more information on the features governed by these parameters.

Configuration for Network Connection

To configure the target agent for use with a network connection, add the WDB network connection component. (See 2.4.1 Network Connections).

The default MTU is 1500 octets. To change it, display the component property sheet, select the Params tab, select the WDB_MTU item and change the value associated with it (Figure 4-48).

Figure 4-48:   Network Connection Macro

Configuration for Serial Connection

To configure the target agent to use a raw serial communication path, add the WDB serial connection component. (See 2.4.3 Serial-Line Connections).

By default, the agent uses serial channel 1 at 9600 bps.7 For better performance, use the highest line speed available, which is often 38400 bps. Try a slower speed if you suspect data loss. To change the speed, display the component property sheet, select the Params tab, select WDB_TTY_BAUD and change the value associated with it.

Figure 4-49:   Serial Connection Macros

If your target has a single serial channel, you can use the target server virtual console to share the channel between the console and the target agent. You must configure your project with the CONSOLE_TTY parameter set to NONE and the WDB_TTY_CHANNEL parameter set to 0. See Console and Redirection for more information regarding the target server virtual console.

When multiplexing the virtual console with WDB communications, excessive output to the console may lead to target server connection failures. The following actions may help resolve this problem:

  • Decrease the amount of data being transmitted to the virtual console from your application.

  • Increase the timeout period of the target server (see Back End).

  • Increase the baud rate of the target agent and the target server connection

Configuration for tyCoDrv Connection

To configure a target agent to a use a serial connection, add the WDB tyCoDrv connection component. Display the component property sheet and select the Params tab to display and modify macro values.

Scaling the Target Agent

In a memory-constrained system, you may wish to create a smaller agent. To reduce program text size, you can remove the following optional agent facilities:

  • WDB banner (INCLUDE_WDB_BANNER)

  • VIO driver (INCLUDE_WDB_VIO)

  • WDB task creation (INCLUDE_WDB_START_NOTIFY)

  • WDB user event (INCLUDE_WDB_USER_EVENT)

These components are in the development tool components>WDB agent components>WDB agent services folder path.

You can also reduce the maximum number of WDB breakpoints with the WDB_BP_MAX parameter of the WDB breakpoints component. If you are using a serial connection, you can also set the INCLUDE_WDB_TTY_TEST parameter to FALSE.

If you are using a communication path which supports both system and task mode agents, then by default both agents are started. Since each agent consumes target memory (for example, each agent has a separate execution stack), you may wish to exclude one of the agents from the target system. You can configure the target to use only a task-mode or only a system-mode agent with the WDP task debugging or WDB system debugging options (which are in the folder path development tool components>WDB agent components>select WDB mode).

Configuring the Target Agent for Exception Hooks

If your application (or BSP) uses excHookAdd( ) to handle exceptions, host tools will still be notified of all exceptions (including the ones handled by your exception hook). If you want to suppress host tool notifications, you must exclude the component WDB exception notification. When this component is excluded, the target server is not notified about target exceptions, but the target will still report them in its console. In addition, if an exception occurs in the WDB task, the task will be suspended and the connection between the target server and the target agent will be broken.

Starting the Agent Before the Kernel

By default, the target agent is initialized near the end of the VxWorks initialization sequence. This is because the default configuration calls for the agent to run in task mode and to use the network for communication; thus, wdbConfig( ) must be called after kernelInit( ) and usrNetInit( ). (See G. VxWorks Initialization Timeline for an outline of the overall VxWorks initialization sequence.)

In some cases (for example, if you are doing a BSP port for the first time), you may want to start the agent before the kernel starts, and initialize the kernel under the control of the Tornado host tools. To make that change, perform the following steps when you configure VxWorks:

  1. Choose a communication path that can support a system-mode agent (NetROM or raw serial). The END communication path cannot be used as it requires that the system be started before it is initialized.
  1. Change your configuration so that only WDB system debugging is selected (in folder path development tool components>WDB agent components>select WDB mode). By default, the task mode starts two agents: a system-mode agent and a task-mode agent. Both agents begin executing at the same time, but the task-mode agent requires the kernel to be running.
  1. Create a configuration descriptor file called fileName.cdf (for example, wdb.cdf) in your project directory that contains the following lines:
InitGroup usrWdbInit { 
    INIT_RTN    usrWdbInit (); wdbSystemSuspend (); 
    _INIT_ORDER usrInit 
    INIT_BEFORE INCLUDE_KERNEL 
}

This causes the project code generator to make the usrWdbInit( ) call earlier in the initialization sequence. It will be called from usrInit( ), just before the component kernel is started.8

After the target server connects to the system-mode target agent, you can resume the system to start the kernel under the agent's control. (See 7.2.7 Using the Shell for System Mode Debugging for information on using system mode from the shell, and 10.6 System-Mode Debugging for information on using it from the debugger.)

After connecting to the target agent, set a breakpoint in usrRoot( ), then continue the system. The routine kernelInit( ) starts the multi-tasking kernel with usrRoot( ) as the entry point for the first task. Before kernelInit( ) is called, interrupts are still locked. By the time usrRoot( ) is called, interrupts are unlocked.

Errors before reaching the breakpoint in usrRoot( ) are most often caused by a stray interrupt: check that you have initialized the hardware properly in the BSP sysHwInit( ) routine. Once sysHwInit( ) is working properly, you no longer need to start the agent before the kernel.


*      
CAUTION: When the agent is started before the kernel, there is no way for the host to get the agent's attention until a breakpoint occurs. There are two reasons for this: 1) For the NetROM connection, the agent cannot spawn the NetROM polling task to check periodically for incoming packets from the host. 2) For other types of connections, only system mode is supported and the WDB communication channel is set to work in polled mode only. On the other hand, the host does not really need to get the agent's attention: you can set breakpoints in usrRoot( ) to verify that VxWorks can get through this routine. Once usrRoot( ) is working, you can start the agent after the kernel (that is, within usrRoot( )), after which the polling task is spawned normally.


*      
WARNING: If you are using the serial connection, take care that your serial driver does not cause a stray interrupt when the kernel is started, because the serial-driver interrupt handlers are not installed until after usrRoot( ) begins executing: the calling sequence is usrRoot( ) sysClkConnect( ) sysHwInit2( ) intConnect( ). You may want to modify the driver so that it does not set a channel to interrupt mode until the hardware is initialized. This can be done by setting a flag in the BSP after serial interrupts are connected.



4.8    Configuring and Building a VxWorks Boot Program

The default boot image included with Tornado for your BSP is configured for a networked development environment. The boot image consists of a minimal VxWorks configuration and a boot loader mechanism. You need to configure and build a new boot program (and install it on your boot medium) if:

  • You are working with a target that is not on a network.

  • You do not have a target with NVRAM, and do not want to enter boot parameters at the target console each time it boots.

  • You want to use an alternate boot process, such as booting over the Target Server File System (TSFS).


*      
WARNING: Configuration of boot programs is handled independently of the project facility so normally you can configure your boot ROM differently than your other images. However, any changes you make to config.h that are not masked by project facility selections may be absorbed by your projects (see the warning in 4.1 Introduction). To prevent this, copy your BSP and create your boot image from the copy.

Configuring Boot Parameters

To customize a boot program for your development environment, you must edit installDir\target\config\bspname\config.h (the configuration file for your BSP). The file contains the definition of DEFAULT_BOOT_LINE, which includes parameters identifying the boot device, IP addresses of host and target, the path and name of the VxWorks image to be loaded, and so on. For information about the boot line parameters defined by DEFAULT_BOOT_LINE, see 2.5.4 Description of Boot Parameters and Help>Manuals Contents>VxWorks Reference Manual> Libraries>bootLib.

Building a Boot Image

To build the new boot program, select Build>Build Boot ROM from the Tornado GUI. Then select the BSP for which you want to build the boot program and the type of boot image in the Build Boot ROM dialog box (Figure 4-1). Then click OK.

Figure 4-50:   Build Boot ROM

The three main options for boot images are:

bootrom

bootrom_uncmp

bootrom_res

TSFS Boot Configuration

The simplest way to boot a target that is not on a network is over the TSFS (which does not involve configuring SLIP or PPP). The TSFS can be used to boot a target connected to the host by one or two serial lines, or a NetROM connection.


*      
WARNING: The TSFS boot facility is not compatible with WDB agent network configurations. See 4.7 Configuring the Target-Host Communication Interface.

To configure a boot program for TSFS, edit the boot line parameters defined by DEFAULT_BOOT_LINE in config.h (or change the boot parameters at the boot prompt). The boot device parameter must be tsfs, and the file path and name must be relative to the root of the host file system defined for the target server (see Configuring Boot Parameters and Target Server File System).

Regardless of how you specify the boot line parameters, you must reconfigure (as described below) and rebuild the boot image.

If two serial lines connect the host and target (one for the target console and one for WDB communications), config.h must include the lines:

#undef CONSOLE_TTY 
#define CONSOLE_TTY         0 
#undef WDB_TTY_CHANNEL 
#define WDB_TTY_CHANNEL     1 
#undef WDB_COMM_TYPE 
#define WDB_COMM_TYPE WDB_COMM_SERIAL 
#define INCLUDE_TSFS_BOOT

If one serial line connects the host and target, config.h must include the lines:

#undef CONSOLE_TTY 
#define CONSOLE_TTY         NONE 
#undef WDB_TTY_CHANNEL 
#define WDB_TTY_CHANNEL     0 
#undef WDB_COMM_TYPE 
#define WDB_COMM_TYPE WDB_COMM_SERIAL 
#define INCLUDE_TSFS_BOOT

For a NetROM connection, config.h must include the lines:

#undef WDB_COMM_TYPE 
#define WDB_COMM_TYPE WDB_COMM_NETROM 
#define INCLUDE_TSFS_BOOT

With any of these TSFS configurations, you can also use the target server console to set the boot parameters by defining the INCLUDE_TSFS_BOOT_VIO_CONSOLE macro in config.h. This disables the auto-boot mechanism, which might otherwise boot the target before the target server could start its virtual I/O mechanism. (The auto-boot mechanism is similarly disabled when CONSOLE_TTY is set to NONE, or when CONSOLE_TTY is set to WDB_TTY_CHANNEL.) Using the target server console is particularly useful for a single serial connection, as it provides an otherwise unavailable means of changing boot parameters from the command line.

When you build the boot image, select bootrom.hex for the image type (Building a Boot Image).

See the VxWorks Programmer's Guide: Local File Systems for more information about the TSFS.



4.9    Building a Custom Boot ROM

If your boot strategy utilizes a boot ROM, and this boot ROM requires a new driver, you will need to rebuild the boot ROM. Boot ROMs are not yet fully supported as projects in Tornado 2.2. To build a boot ROM, Select Build>Build Boot Rom from the Tornado main menu bar. From the dialog, select the BSP and boot ROM target you wish to build.

If the boot ROM you wish to build is not shown, do the following:

  1. Enable extended build options by using the Tools>Options menu from the main menu bar to bring up the Tools Options dialog box. Select the Project pane and select the appropriate check box.
  1. Invoke the Build>Customize menu item to bring up the custom build dialog. Click the Add button to bring up a template dialog. Enter menu text (for example, "Build My boot ROM"), the name of the boot ROM image (for example, bootrom.hex), and the BSP directory (for example, installDir\target\config\mv162 for a Windows host).
  1. Close the dialog, return to the Build menu, and invoke the newly created menu item. This will build the boot ROM image in the BSP directory.
You can also use the command line as described in Using the Command Line.


1:  The text and data sections of a relocateable object module are in transitory form. Because of the nature of a cross-development environment, some addresses cannot be known at time of compilation. These sections are modified (relocated or linked) by the Tornado object-module loader when it inserts the modules into the target system.

2:  For information about munching, see the VxWorks Programmer's Guide: C++ Development.

3:  You can modify the default behavior by un-checking the Show this window on startup box at the bottom of the window.

4:  The default toolchain names for target simulators take the form SIMHOST_OSgnu (for example, SIMNTgnu).

5:  See the GNU Make User's Guide for more information about make.

6:  You can modify the default behavior by un-checking the Show this window on startup box at the bottom of the window.

7:  VxWorks serial channels are numbered starting at zero. Thus Channel 1 corresponds to the second serial port if the board's ports are labeled starting at 1. If your board has only one serial port, you must change WDB_TTY_CHANNEL to 0 (zero).

8:  The code generator for prjConfig.c is based on a component descriptor language that specifies when components are initialized. The component descriptors are searched in a specific order, with the project directory last in the search path. This allows the .cdf files in the project directory to override default definitions in the generic .cdf files.