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