The Tornado distribution includes several VxWorks system images for each target shipped. (See 4.4.4 Selecting the VxWorks Image Type.) 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-relocatable object module with no unresolved external references.
In most cases, you will find the supplied system image entirely adequate for initial development. However, later in the cycle you may want to configure the operating system to reflect your application requirements.
This chapter describes in detail the manual cross-development procedures used to create and run VxWorks systems and applications as well as how to configure the system by directly editing configuration files.
VxWorks has been ported to numerous target systems and can support many different hardware configurations. Some of the cross-development procedures discussed in this chapter depend on the specific system and configuration you are running. The procedures in this chapter are presented in generic form, and may differ slightly on your particular system.
For information specific to an architecture family, see the appropriate VxWorks Architecture Supplement. Information specific to particular target boards is provided with each BSP.
In the Tornado development environment, application modules for the target system are created and maintained on a separate development host. First, the source code, generally in C or C++, is edited and compiled to produce a relocatable object module. Application modules use VxWorks facilities by virtue of including header files that define operating system interfaces and data structures. The resulting object modules can then be loaded and dynamically linked into a running VxWorks system over the network.
The procedure for configuring a customized VxWorks image is described in 5.3 Configuring VxWorks. In the interim, you can use the default images shipped with Tornado.
The following sections describe in detail the procedures for carrying out cross-development manually (without using the project facility).
Many application modules make use of VxWorks operating system facilities or utility libraries. This usually requires that the source module refer to VxWorks header files. The following sections discuss the use of VxWorks header files.
VxWorks header files supply ANSI C function prototype declarations for all global VxWorks routines. The ANSI C prototypes are conditionally compiled; to use them, the preprocessor constant __STDC__ must be defined. ANSI C compilers define this constant by default. VxWorks provides all header files specified by the ANSI X3.159-1989 standard.
VxWorks system header files are in the directory installDir\target\h and its subdirectories.
|
|
|||||||||||||||||||
The header file vxWorks.h contains many basic definitions and types that are used extensively by other VxWorks modules. Many other VxWorks header files require these definitions. Thus, this file must be included first by every application module that uses VxWorks facilities. Include vxWorks.h with the following line:
#include "vxWorks.h"
Application modules can include other VxWorks header files as needed to access VxWorks facilities. For example, an application module that uses the VxWorks linked-list subroutine library must include the lstLib.h file with the following line:
#include "lstLib.h"
The API reference entry for each library lists all header files necessary to use that library.
All ANSI-specified header files are included in VxWorks. Those that are compiler-independent or more VxWorks-specific are provided in installDir\target\h while a few that are compiler-dependent (for example stddef.h and stdarg.h) are provided by the compiler installation. Each toolchain knows how to find its own internal headers; no special compile flags are needed.
|
|
|||||||||||||||||||
By default, the compiler searches for header files first in the directory of the source module and then in its internal subdirectories. In general, installDir\target\h should always be searched before the compilers' other internal subdirectories; to ensure this, always use the following flag for compiling under VxWorks:
-I %WIND_BASE%\target\h
Some header files are located in subdirectories. To refer to header files in these subdirectories, be sure to specify the subdirectory name in the include statement, so that the files can be located with a single -I specifier. For example:
#include "vxWorks.h" #include "sys\stat.h"
Some VxWorks facilities make use of other, lower-level VxWorks facilities. For example, the tty management facility uses the ring buffer subroutine library. The tty header file tyLib.h uses definitions that are supplied by the ring buffer header file rngLib.h.
It would be inconvenient to require you to be aware of such include-file interdependencies and ordering. Instead, all VxWorks header files explicitly include all prerequisite header files. Thus, tyLib.h itself contains an include of rngLib.h. (The one exception is the basic VxWorks header file vxWorks.h, which all other header files assume is already included.)
Generally, explicit inclusion of prerequisite header files can pose a problem: a header file could get included more than once and generate fatal compilation errors (because the C preprocessor regards duplicate definitions as potential sources of conflict). However, all VxWorks header files contain conditional compilation statements and definitions that ensure that their text is included only once, no matter how many times they are specified by include statements. Thus, an application module can include just those header files it needs directly, without regard to interdependencies or ordering, and no conflicts arise.
Some elements of VxWorks are internal details that may change and so should not be referenced in your application. The only supported uses of a module's facilities are through the public definitions in the header file, and through the module's subroutine interfaces. Your adherence ensures that your application code is not affected by internal changes in the implementation of a VxWorks module.
Some header files mark internal details using HIDDEN comments:
/* HIDDEN */ ... /* END HIDDEN */
Internal details are also hidden with private header files: files that are stored in the directory installDir\target\h\private. The naming conventions for these files parallel those in installDir\target\h with the library name followed by P.h. For example, the private header file for semLib is installDir\target\h\private\semLibP.h.
Tornado includes a full-featured C and C++ compiler and associated tools, collectively called the GNU ToolKit. Extensive documentation for this set of tools is available in the GNU ToolKit User's Guide. This section provides some general orientation about the source of these tools, and describes how the tools are integrated into the Tornado development environment.
|
|
NOTE:
The GNU tools are not available for the ColdFire architecture; the Diab tools are the default toolset. Diab tools are available as an optional product for the ARM/StrongARM/XScale, MIPS, PowerPC, and SuperH architectures. See 5.2.3 Compiling Application Modules Using Diab Tools.
|
||||||||||||||||||
GNU ("GNU's Not UNIX!") is a project of the Free Software Foundation started by Richard Stallman and others to promote free software. To the FSF, free software is software whose source code can be copied, modified, and redistributed without restriction. GNU software is not in the public domain; it is protected by copyright and subject to the terms of the GNU General Public License, a legal document designed to ensure that the software remains free--for example, by prohibiting proprietary modifications and concomitant restrictions on its use. The General Public License can be found in the file COPYING that accompanies the source code for the GNU tools, and in the section titled Free Software at the back of the GNU ToolKit User's Guide.
It is important to be aware that the terms under which the GNU tools are distributed do not apply to the software you create with them. In fact, the General Public License makes no requirements of you as a software developer at all, as long as you do not modify or redistribute the tools themselves. On the other hand, it gives you the right to do both of these things, provided you comply with its terms and conditions. It also permits you to make unrestricted copies for your own use.
The Wind River GNU distribution consists of the GNU ToolKit, which contains GNU tools modified and configured for use with your VxWorks target architecture. The source code for these tools is available upon request.
The GNU cross-development tools in Tornado have names that clearly indicate the target architecture. This allows you to install and use tools for more than one architecture, and to avoid confusion with corresponding host native tools. A suffix identifying the target architecture is appended to each tool name. For example, the cross-compiler for the PowerPC processor family is called ccppc, and the assembler asppc. The suffixes used are shown in Table 5-1. Note that the GNU ToolKit User's Guide refers to these tools by their generic names (without a suffix).
|
|
|||||||||||||||||||
|
|
|||||||||||||||||||
|
|
|||||||||||||||||||
Tornado supports multiple target architectures. To accommodate this support, several VxWorks header files contain conditional compilation directives based on the definition of the variable CPU. When using these header files, the variable CPU must be defined in one of the following places:
To define CPU in the source modules or header files, add the following line:
#define CPU cputype
To define CPU on the compilation command line, add the following flag:
-DCPU=cputype
The constants shown in Table 5-2 are supported values for cputype.
With makefiles, the CPU definition can be added to the definition of the flags passed to the compiler (usually CFLAGS).
In the source code, the file vxWorks.h must be included before any other files with dependencies on the CPU flag.
As well as specifying the CPU value, you must usually run the compiler with one or more option flags to generate object code optimally for the particular architecture variant. These option flags usually begin with -m; see Compiling C Modules With the GNU Compiler.
The following is an example command to compile an application module for a VxWorks PowerPC 604 system:
c:\> ccppc -mcpu=604 -mstrict-align -I %WIND_BASE%\target\h \ -DCPU=PPC603 -DTOOL_FAMILY=gnu -DTOOL=gnu -c applic.c
This compiles the module applic.c into an object file applic.o.
Below we give summary descriptions of the target-independent flags used in the example. Flags that are specific to a particular target architecture are described in the relevant architecture supplement. For more information on any of these flags, see the GNU ToolKit User's Guide.
The GNU compiler drivers can be used to compile both C and C++ source files. C++ source files are recognized by their extension (typically .cc, .cpp, or .C). For complete information on using C++, including a detailed discussion of compiling C++ modules, see the VxWorks Programmer's Guide: C++ Development.
|
|
|||||||||||||||||||
The Diab C/C++ compiler suites are high performance programming tools. In addition to the benefits of state-of-the-art optimization, they reduce time spent creating reliable code because the compilers and other tools include many built-in, customizable, checking features which help detect problems earlier.
The compilers are particularly helpful in speeding up or reducing the size of existing programs developed with other tools.
With over 250 command-line options and special pragmas, and a powerful linker command language for arranging code and data in memory, the Diab C/C++ compiler suites can be customized to meet the needs of any embedded systems project. A number of options are specifically designed to be compatible with other tools to ease porting of existing code.
If you are using the Diab tools, you need to be sure that two settings are in place:
The Diab cross-development tools in Tornado are always called by the same names: dcc, dld, and so forth. The architecture-specific version of the tool is specified by the -t option in the command line or makefile. For Tornado 2.2, the -t option always includes the architecture family and the VxWorks specifier, for example:
-tPPC403FS:vxworks55
When you install Diab in the Tornado tree, the defaults are set correctly for the architecture you installed. You can use the command dcc -Xshow-target to display the value and dctrl -t to change it.
You may need to change the architecture family and its characteristics (for example, PPC403FS). Detailed information is available in the Diab C/C++ Compiler User's Guide: Selecting a Target and Its Components.
Tornado supports multiple target architectures. To accommodate this, several VxWorks header files contain conditional compilation directives based on the definition of the variable CPU. When using these header files, the variable CPU must be defined in one of the following places:
To define CPU in the source modules or header files, add the following line:
#define CPU cputype
To define CPU on the compilation command line, add the following flag:
-DCPU=cputype
The constants shown in Table 5-2 are supported values for cputype.
|
|
|||||||||||||||||||
|
|
|||||||||||||||||||
|
|
|||||||||||||||||||
With makefiles, the CPU definition can be added to the definition of the flags passed to the compiler (usually CFLAGS).
In the source code, the file vxWorks.h must be included before any other files with dependencies on the CPU flag.
As well as specifying the CPU value, you must usually run the compiler with one or more option flags to generate object code optimally for the particular architecture variant. For detailed information, see Diab C/C++ Compiler User's Guide: Selecting a Target and Its Components.
The following is an example command to compile an application module for a VxWorks PowerPC 604 system:
c:\> dcc -g -tPPC403FS:vxworks55 -Xmismatch-warning=2 \ -ew1554,1551,1552, 1086,1047,1547 -Xclib-optim-off -Xansi \ -Xstrings-in-text=0 -Wa,-Xsemi-is-newline-ei1516,1643,1604 \ -Xlocal-data-area-static-only -W:c++:,-Xexceptions -Xsize-opt \ -Wall -I%WIND_BASE%\target\h -DCPU=PPC604 -DTOOL=diab -c applic.c
This compiles the module applic.c into an object file applic.o.
Below we give summary descriptions of the target independent flags used in the example. Flags that are specific to a particular target architecture are described in the relevant architecture supplement. For more information on any of these flags see the Diab C/C++ Compiler User's Guide.
|
|
|||||||||||||||||||
After you compile an application module, you can load it directly into the target with the Tornado dynamic loader (through the shell or through the debugger).
In general, application modules do not need to be prelinked before being downloaded to the target. The exception is when several application modules cross reference each other. In this case, the modules should be linked to form a single downloadable module. When using C++, this prelinking should be done before the munch step (see the VxWorks Programmer's Guide: C++ Development).
The following example is a command to link several application modules, using the GNU linker for the PowerPC family of processors.
c:\> ldppc -o applic.o -r applic1.o applic2.o applic3.o
Similarly, the following example is a command to link several application modules, using the Diab linker for the PowerPC family of processors.
c:\> dld -o applic.o -r applic1.o applic2.o applic3.o
This creates the object module applic.o from the object modules applic1.o, applic2.o, and applic3.o. The -r option is required, because the object-module output must be left in relocatable form so that it can be downloaded and linked to the target VxWorks image.
Any VxWorks facilities called by the application modules are reported by the linker as unresolved externals. These are resolved by the Tornado loader when the module is loaded into VxWorks memory.
|
|
|||||||||||||||||||
After application object modules are compiled (and possibly linked by the host ldarch command), they can be dynamically loaded into a running VxWorks system by invoking the Tornado module loader. You can do this either from the Tornado shell using the built-in command ld( ), or from the debugger using the Debug menu or the load command.
The following is a typical load command from the Tornado shell:
-> ld <applic.o
This relocates the code from the host file applic.o, linking to previously loaded modules, and loads the object module into the target's memory. Once an application module is loaded into target memory, any subroutine in the module can be invoked directly from the shell, spawned as a task, connected to an interrupt, and so on.
The shell ld( ) command, by default, adds only global symbols to the symbol table. During debugging, you may want local symbols as well. To get all symbols loaded (including local symbols), you can use the GDB command load from the debugger. Because this command is meant for debugging, it always loads all symbols. Alternatively, you can load all symbols by calling the shell command ld( ) with a full argument list instead of the shell-redirection syntax shown above. When you use an argument list, you can get all symbols loaded by specifying a 1 as the first argument, as in the following example:
-> ld 1,0,"applic.o"
In the previous examples, the object module applic.o resides in the shell's current working directory. Normally, you can use either relative path names or absolute path names to identify object modules to ld( ). If you use a relative path name, the shell converts it to an absolute path (using its current working directory) before passing the download request to the target server. In order to avoid trouble when you call ld( ) from a shell that is not running on the same host as its target server, Tornado supplies the LD_SEND_MODULES facility; see 7. Shell. If you are using a remote target server and ld( ) fails with a "no such file" message, be sure that LD_SEND_MODULES is set to "on."
|
|
CAUTION:
If you call ld( ) with an explicit argument list, any backslash characters in the module-name argument must be doubled. If you supply the module name with the redirection symbol, as in the earlier example in this section, no double backslashes are needed. See 7. Shell for more discussion of this issue.
|
||||||||||||||||||
For more information about loader arguments, see the discussion of ld( ) in the reference entry for windsh.
For information about the target-resident version of the loader (which also requires the target-resident symbol table), see the VxWorks Programmer's Guide: Target Tools and the VxWorks reference entry for loadLib. For information on booting VxWorks, see 2.5 Booting VxWorks.
When a module is loaded, it is assigned a module ID and a group number. Both the module ID and the group number are used to reference the module. The module ID is returned by ld( ) as well as by the target-resident loader routines. When symbols are added to the symbol table, the associated module is identified by the group number (a small integer). (Due to limitations on the size of the symbol table, the module ID is inappropriate for this purpose.) All symbols with the same group number are from the same module. When a module is unloaded, the group number is used to identify and remove all the module's symbols from the symbol table.
Whenever you load a particular object module more than once, using the target server (from either the shell or the debugger), the older version is unloaded automatically. You can also unload a module explicitly; both the Tornado shell and the target-resident VxWorks libraries include an unloader. To remove a module from the shell, use the shell routine unld( ); see the reference entry for windsh.
For information about the target-resident version of the unloader (which also requires the target-resident symbol table and loader), see the VxWorks Programmer's Guide: Target Tools and the VxWorks reference entry for unldLib.
After a module has been unloaded, any calls to routines in that module fail with unpredictable results. Take care to avoid unloading any modules that are required by other modules. One solution is to link interdependent files using the static linker ldarch as described in 5.2.4 Static Linking (Optional), so that they can only be loaded and unloaded as a unit.
The configuration of VxWorks is determined by the configuration header files installDir\target\config\all\configAll.h and installDir\target\config\bspname\config.h. These files are used by the usrConfig.c, bootConfig.c, and bootInit.c modules as they run the initialization routines distributed in the directory installDir\target\src\config to configure VxWorks.
The VxWorks distribution includes the configuration files for the default development configuration. You can create your own versions of these files to better suit your particular configurations; this process is described in the following subsections. In addition, if you need multiple configurations, environment variables can be set so you can move easily between them.
Including optional components in your VxWorks image can significantly increase the image size. VxWorks BSP Developer's Guide you receive a warning from vxsize when building VxWorks, or if the size of your image becomes greater than that supported by the current setting of RAM_HIGH_ADRS, be sure to see Scaling Down VxWorks and 5.6 Creating Bootable Applications for information on how to resolve the problem.
|
|
WARNING:
Use of the project facility for configuring and building applications is largely independent of the methods used prior to Tornado 2.0 (which included manually editing the configuration files config.h or configAll.h). The project facility provides the recommended and simpler means for configuration and building; the manual method is described in this section.
|
||||||||||||||||||
To avoid confusion and errors, the two methods should not 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): |
|||||||||||||||||||
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. |
|||||||||||||||||||
The directory installDir\target\config\bspname contains the Board Support Package (BSP), which consists of files for the particular hardware used to run VxWorks, such as a VME board with serial lines, timers, and other devices. The files include: Makefile, sysLib.c, sysALib.s, romInit.s, bspname.h, and config.h.
Wind River-supplied BSPs conform to a standard, introduced with BSP Version 1.1. The standard is fully described in the VxWorks BSP Developer's Guide.
The file sysLib.c provides the board-level interface on which VxWorks and application code can be built in a hardware-independent manner. The functions addressed in this file include:
The sysLib library does not support every feature of every board. Some boards may have additional features, others may have fewer, others still may have the same features with a different interface. For example, some boards provide some sysLib functions by means of hardware switches, jumpers, or PALs, instead of by software-controllable registers.
The configuration modules usrConfig.c and bootConfig.c in installDir\target\config\all are responsible for invoking this library's routines at the appropriate time. Device drivers can use some of the memory mapping routines and bus functions.
For boards with MMU support, the data structure sysPhysMemDesc defines the virtual-to-physical memory map. This table is typically defined in sysLib.c, although some BSPs place it in a separate file, memDesc.c. It is declared as an array of the data structure PHYS_MEM_DESC. No two entries in this descriptor can overlap; each entry must be a unique memory space.
The sysPhysMemDesc array should reflect your system configuration, and you may encounter a number of reasons for changing the MMU memory map, for example: the need to change the size of local memory or the size of the VME master access space, or because the address of the VME master access space has been moved. For information on virtual memory mapping, as well as an example of how to modify sysPhysMemDesc, see VxWorks Programmer's Guide: Virtual Memory Interface.
|
|
|||||||||||||||||||
The file target.nr in the installDir\target\config\bspname directory is the source of the online reference entry for target-specific information. (You can also view the HTML version of this document from the Tornado IDE: Help>Manuals Contents>BSP Reference>bspname.) The target.nr file describes the supported board variations, the relevant jumpering, and supported devices. It also includes an ASCII representation of the board layout with an indication of board jumpers (if applicable) and the location of the ROM sockets.
You can use Tornado environment variables to build variations of system configurations. In general, your Tornado environment consists of three parts: the host code (Tornado), the target code, and the configuration files discussed in this section. On Windows hosts, the IDE automatically locates Tornado code in the following locations:
|
installDir\host\hosttype\bin or |
|||||||||||||||||||
|
installDir\target\config\all or |
|||||||||||||||||||
To use different versions of usrConfig.c, bootConfig.c, and bootInit.c, store them in a different directory and change the value of CONFIG_ALL. To use different target code, point to the alternate directory by changing the value of TGT_DIR.
You can change the value of CONFIG_ALL by changing it either in your makefile or on the command line. The value of TGT_DIR must be changed on the command line.
|
|
|||||||||||||||||||
To change CONFIG_ALL in your makefile, add the following command:
CONFIG_ALL = $WIND_BASE/target/config/newDir
To change CONFIG_ALL on the command line, do the following:
c:\> make ... CONFIG_ALL = %WIND_BASE%\target\config\newDir
To change TGT_DIR on the command line, do the following:
c:\> make ... TGT_DIR = %ALT_DIR%\target
The configAll.h header file, in the directory installDir\target\config\all, contains default definitions that apply to all targets, unless they are redefined in the target-specific header file config.h. The following options and parameters are defined in configAll.h:
The BSP-specific header file, config.h, is located in the directory installDir\target\config\bspname. This file contains definitions that apply only to the specific target, and can also redefine default definitions in configAll.h that are inappropriate for the particular target. For example, if a target cannot access a device controller at the default I/O address defined in configAll.h because of addressing limitations, the address can be redefined in config.h.
The config.h header file includes definitions for the following parameters:
|
|
|||||||||||||||||||
VxWorks ships with optional features and device drivers that can be included in, or omitted from, the target system. These are controlled by macros in the project facility or the configuration header files that cause conditional compilation in the installDir\target\config\all\usrConfig.c module.
The distributed versions of the configuration header files configAll.h and config.h include all the available software options and several network device drivers. If you are not using the project facility (see 4. Projects), you define a macro by moving it from the EXCLUDED FACILITIES section of the header file to the INCLUDED SOFTWARE FACILITIES section.1 For example, to include the ANSI C assert library, make sure the macro INCLUDE_ANSI_ASSERT is defined; to include the Network File System (NFS) facility, make sure INCLUDE_NFS is defined. Modification or exclusion of particular facilities is discussed in detail in 5.3.5 Alternative VxWorks Configurations.
Use of the VxWorks configuration header files to configure your VxWorks system should meet all of your development requirements. Users should not resort to changing the Wind River-supplied usrConfig.c, or any other module in the directory installDir\target\config\all. If, however, an extreme situation requires such a change, we recommend you copy all the files in installDir\target\config\all to another directory, and add a CONFIG_ALL macro to your makefile to point the make system to the location of the modified files. For example, add the following to your makefile after the first group of include statements:
# ../myAll contains a copy of all the ../all files
CONFIG_ALL = ../myAll
The discussion of the usrConfig module in 5.3.4 The Configuration Module: usrConfig.c outlined the default configuration for a development environment. In this configuration, the VxWorks system image contains all of the VxWorks modules that are necessary to allow you to interact with the system through the Tornado host tools.
However, as you approach a final production version of your application, you may want to change the VxWorks configuration in one or more of the following ways:
The following sections discuss the latter two alternatives to the typical development configuration. For a discussion on reconfiguring the target agent, see 4. Projects.
In a production configuration, it is often desirable to remove some of the VxWorks facilities to reduce the memory requirements of the system, to reduce boot time, or for security purposes.
Optional VxWorks facilities can be omitted by commenting out or using #undef to undefine their corresponding control constants in the header files configAll.h or config.h. For example, logging facilities can be omitted by undefining INCLUDE_LOGGING, and signalling facilities can be omitted by undefining INCLUDE_SIGNALS.
VxWorks is designed to make it easy to exclude facilities you do not need. However, not every BSP is organized in this way. If you wish to minimize the size of your system, be sure to examine your BSP code and eliminate references to facilities you do not need. Even though you exclude them, if your code refers to them, your exclusion will be overridden.
The definition of the following constants in configAll.h is optional, because referencing any of the corresponding kernel facilities from the application automatically includes the kernel service:
These configuration constants appear in the default VxWorks configuration to ensure that all kernel facilities are configured into the system, even if not referenced by the application. However, if your goal is to achieve the smallest possible system, exclude these constants; this ensures that the kernel does not include facilities you are not actually using.
There are two other configuration constants that control optional kernel facilities: INCLUDE_TASK_HOOKS and INCLUDE_CONSTANT_RDY_Q. Define these constants in configAll.h if the application requires either kernel callouts (use of task hook routines) or a constant-insertion-time, priority-based ready queue. A ready queue with constant insert time allows the kernel to operate context switches with a fixed overhead regardless of the number of tasks in the system. Otherwise, the worst-case performance degrades linearly with the number of ready tasks in the system. Note that the constant-insert-time ready queue uses 2 KB for the data structure; some systems do not have sufficient memory for this. In those cases, the definition of INCLUDE_CONSTANT_RDY_Q may be omitted, thus enabling use of a smaller (but less deterministic) ready queue mechanism.
In some applications it may be appropriate to eliminate the VxWorks network facilities. For example, in the ROM-based systems or standalone configurations described in 5.6 Creating Bootable Applications, there may be no need for network facilities.
To exclude the network facilities, be sure the following constants are not defined:
Option dependencies are coded in the file installDir\target\src\config\usrDepend.c, so that when a particular option is chosen, everything required is included. This assures you of a working system with minimum effort. Although you can exclude the features that you do not need by undefining them in config.h and configAll.h, you should be aware that in some cases they may not be excluded because of dependencies.
For example, you cannot use telnet without running the network. Therefore, if in your configAll.h file, the option INCLUDE_TELNET is selected but the option INCLUDE_NET_INIT is not, usrDepend.c defines INCLUDE_NET_INIT for you. Because the network initialization requires the network software, the userDepend.c file also defines INCLUDE_NETWORK.
Because most of the dependencies are taken care of in usrDepend.c, that file is currently included in usrConfig.c. This simplifies the build process and the selection of options. However, you can change or add dependencies if you choose.
You can put VxWorks or a VxWorks-based application into ROM; this is discussed in 5.6.3 Creating a VxWorks System in ROM. For an example of a ROM-based VxWorks application, see the VxWorks boot ROM program. The file installDir\target\config\all\bootConfig.c is the configuration module for the boot ROM, replacing the file usrConfig.c provided for the default VxWorks development system.
In such ROM configurations, the text and data segments of the boot or VxWorks image are first copied into the system RAM, then the boot procedure or VxWorks executes in RAM. On some systems where memory is a scarce resource, it is possible to save space by copying only the data segment to RAM. The text segment remains in ROM and executes from that address space, and thus is termed ROM resident. The memory that was to be occupied by the text segment in RAM is now available for an application (up to 300 KB for a standalone VxWorks system). Note that ROM-resident VxWorks is not supported on all boards; see the reference entry for your target if you are not sure that your board supports this configuration.
The drawback of a ROM-resident text segment is the limited data widths and lower memory access time of the EPROM, which causes ROM-resident text to execute more slowly than if it was in RAM. This can sometimes be alleviated by using faster EPROM devices or by reconfiguring the standalone system to exclude unnecessary system features.
Aside from program text not being copied to RAM, the ROM-resident versions of the VxWorks boot ROMs and the standalone VxWorks system are identical to the conventional versions. A ROM-resident image is built with an uncompressed version of either the boot ROM or standalone VxWorks system image. VxWorks target makefiles include entries for building these images; see Table 5-4.
Because of the size of the system image, 512 KB of EPROM is recommended for the ROM-resident version of the standalone VxWorks system. More space is probably required if applications are linked with the standalone VxWorks system. For a ROM-resident version of the boot ROM, 256 KB of EPROM is recommended. If you use ROMs of a size other than the default, modify the value of ROM_SIZE in the target makefile and config.h.
A separate make target, vxWorks.res_rom_nosym, has been created to provide a ROM-resident image without the symbol table. This is intended to be a standard ROM image for use with the Tornado environment where the symbol table resides on the host system. Being ROM-resident, the debug agent and VxWorks are ready almost immediately after power-up or restart.
The data segment of a ROM-resident standalone VxWorks system is loaded at RAM_LOW_ADRS (defined in the makefile) to minimize fragmentation. The data segment of ROM-resident boot ROMs is loaded at RAM_HIGH_ADRS, so that loading VxWorks does not overwrite the resident boot ROMs. For a CPU board with limited memory (under 1 MB of RAM), make sure that RAM_HIGH_ADRS is less than LOCAL_MEM_SIZE by a margin sufficient to accommodate the data segment. Note that RAM_HIGH_ADRS is defined in both the makefile and config.h. These definitions must agree.
Figure 5-1 shows the memory layout for ROM-resident boot and VxWorks images. The lower portion of the diagram shows the layout for ROM; the upper portion shows the layout for RAM. LOCAL_MEM_LOCAL_ADRS is the starting address of RAM. For the boot image, the data segment gets copied into RAM above RAM_HIGH_ADRS (after space for bss is reserved). For the VxWorks image, the data segment gets copied into RAM above RAM_LOW_ADRS (after space for bss is reserved). Note that for both images the text segment remains in ROM.
You can redefine the VxWorks configuration in two ways: interactively, as described 4. Projects, or by editing VxWorks configuration files as described in 5.3 Configuring VxWorks. In either case, after you alter the configuration, VxWorks must be rebuilt to incorporate the changes. This includes recompiling certain modules and re-linking the system image. This section explains the procedures for rebuilding the VxWorks system image using manual techniques.
Boot ROM images come in three flavors: compressed, uncompressed, and ROM-resident.
Downloaded VxWorks images come in two basic varieties, Tornado and standalone. (Here "Tornado" is a Vxworks image that uses the host-based tools and symbol table, while "standalone" is an image that uses the target tools and symbol table.)
VxWorks uses the GNU make facility to recompile and relink modules. A file called Makefile in each VxWorks target directory contains the directives for rebuilding VxWorks for that target. See the GNU Make User's Guide for a detailed description of GNU make and of how to write makefiles.
If you choose to use manual techniques on Windows hosts, you must use the command line for building individual application modules. You can use either the command line or the project facility in Tornado 1.0.1 compatibility mode to rebuild BSPs. For information on how to implement Tornado 1.0.1 compatibility mode, see 12.4.3 Customizing the Build Menu.
To rebuild VxWorks from the Windows command prompt (or from a batch file), change to the config directory for the desired target and invoke make as follows:
C:\> cd installDir\target\config\bspname C:\installDir\target\config\bspname> make
make compiles and links modules as necessary, based on the directives in the target directory's makefile.
|
|
NOTE:
For the sake of compactness, most examples of calling make in this chapter use the command line; the Project menu is usually more convenient. (See 4.4.5 Building VxWorks.) This is true for Windows hosts even if you use the Tornado 1.0.1 methods described in this section.
|
||||||||||||||||||
The directory installDir\target\src\usr contains the source code for certain portions of VxWorks that you may wish to customize. For example, usrLib.c is a popular place to add target-resident routines that provide application-specific development aids. For a summary of other files in this directory, see A. Directories and Files.
If you modify one of these files, an extra step is necessary before rebuilding your VxWorks image: you must replace the modified object code in the appropriate VxWorks archive. The makefile in installDir\target\src\usr automates the details; however, because this directory is not specific to a single architecture, you must specify the value of the CPU variable on the make command line:
c:\> make CPU=cputype TOOL=tool
If you do this frequently on a Windows host, you can record the CPU definition in the Build Target field of a custom command in the Project menu; see 12.4.3 Customizing the Build Menu.
This step recompiles all modified files in the directory, and replaces the corresponding object code in the appropriate architecture-dependent directory. After that, the next time you rebuild VxWorks, the resulting system image includes your modified code.
The following example illustrates replacing usrLib with a modified version, rebuilding the archives, and then rebuilding the VxWorks system image. For the sake of conciseness, the make output is not shown. The example assumes the epc4 (I80386) BSP; replace the BSP directory name and CPU value as appropriate for your environment.
c:\> cd %WIND_BASE%\target\src\usr c:\installDir\target\src\usr> copy usrLib.c usrLib.c.orig c:\installDir\target\src\usr> copy develDir\usrLib.c usrLib.c c:\installDir\target\src\usr> make CPU=PPC860 ... c:\installDir\target\src\usr> cd %WIND_BASE%\target\config\epc4 c:\installDir\target\config\epc4> make ...
The commands used to link a VxWorks system image are somewhat complicated. Fortunately, it is not necessary to understand those commands in detail because they are included in the makefile in each VxWorks target directory. However, for completeness, this section gives an explanation of the flags and parameters used to link VxWorks modules.
VxWorks operating system modules are distributed in the form of archive libraries. One set of archives is provided for each target architecture. These archives are located under installDir/target/lib. For more details about the archive directory structure, see the Tornado Migration Guide: Binary Compatibility.
These modules are combined with the configuration module usrConfig.o by the ccarch command on the host. (The file usrConfig.c is described in 5.3.4 The Configuration Module: usrConfig.c.) The following are example commands for building and linking a VxWorks system using the GNU compiler for PowerPC.
For a partial image (partially linked):
ccppc -r -nostdlib -Wl,-X -o vxWorks.tmp sysALib.o sysLib.o \ miiLib.obj usrConfig.o version.o -Wl,--start-group \ -L\vobs\wpwr\target\lib\ppc\PPC604\gnu \ -L\vobs\wpwr\target\lib\ppc\PPC604\common -lcplus -lgnucplus \ -lvxcom -lvxdcom -larch -lcommoncc -ldcc -ldrv -lgcc -lnet -los \ -lrpc -lsecurity -ltffs -lusb -lvxfusion -lvxmp -lvxvmi -lwdb \ -lwind -lwindview \vobs\wpwr\target\lib\libPPC604gnuvx.a -Wl,--end-group
For the final image (fully linked):
ldppc -X -N -e _sysInit -Ttext 00100000 -o vxWorks dataSegPad.o \ vxWorks.tmp ctdt.o -T \vobs\wpwr\target\h\tool\gnu\ldscripts\link.RAM
The Tornado target server uses the VxWorks symbol table on the host system, both for dynamic linking and for symbolic debugging. The symbol table file is created by the supplied tool xsym. Processing an object module with xsym creates a new object module that contains all the symbols of the original file, but with no code or data. The line in the makefile that creates this file executes the command:
xsym < vxWorks > vxWorks.sym
The file vxWorks.sym is downloaded to the target to build the target symbol table when INCLUDE_NET_SYM_TBL is included.
Makefiles for VxWorks applications are easy to create by exploiting the makefiles and make include files shipped with VxWorks BSPs. This section discusses how the VxWorks BSP makefiles are structured. For more information, see B. Makefile Details. An example of how to utilize this structure for application makefiles is in 5.5.2 Using Makefile Include Files for Application Modules.
A set of supporting files in installDir\target\h\make makes it possible for each BSP or application makefile to be terse, specifying only the essential parameters that are unique to the object being built.
Example 5-1 shows the makefile from the installDir\target\config\mbx860 directory; the makefile for any other BSP is similar. Two variables are defined at the start of the makefile: CPU, to specify the target architecture; and TOOL to identify what compilation tools to use. Based on the values of these variables and on the environment variables defined as part of your Tornado configuration, the makefile selects the appropriate set of definitions from installDir\target\h\make. After the standard definitions, several variables define properties specific to this BSP. Finally, the standard rules for building a BSP on your host are included.
Example 5-1: Makefile for mbx860
# Makefile - makefile for target/config/mbx860 # # Copyright 1984-2001 Wind River Systems, Inc. # Copyright 1997,1998 Motorola, Inc., All Rights Reserved # # DESCRIPTION # This file contains rules for building VxWorks for the # MBX Board with a PowerPC 860 or PowerPC 821 processor. # # INCLUDES # makeTarget #*/ CPU = PPC860 TOOL = gnu TGT_DIR = $(WIND_BASE)/target include $(TGT_DIR)/h/make/defs.bsp #include $(TGT_DIR)/h/make/make.$(CPU)$(TOOL) #include $(TGT_DIR)/h/make/defs.$(WIND_HOST_TYPE) ## Only redefine make definitions below this point, or your definitions will ## be overwritten by the makefile stubs above.
TARGET_DIR = mbx860 VENDOR = Motorola BOARD = MBX860 ## The constants ROM_TEXT_ADRS, ROM_SIZE, and RAM_HIGH_ADRS are defined ## in config.h and Makefile. All definitions for these constants must be ## identical. ROM_TEXT_ADRS = FE000100 # ROM entry address ROM_SIZE = 00080000 # number of bytes of ROM space RAM_LOW_ADRS = 00010000 # RAM text/data address RAM_HIGH_ADRS = 00200000 # RAM text/data address USR_ENTRY = usrInit BOOT_EXTRA = mbxI2c.o mbxALib.o MACH_EXTRA = mbxALib.o RELEASE += bootrom.bin ## Only redefine make definitions above this point, or the expansion of ## makefile target dependencies may be incorrect. include $(TGT_DIR)/h/make/rules.bsp
The following make include file defines variables. This file is useful for application-module makefiles, as well as for BSP makefiles.
The following include file defines make targets and the rules to build them. This file is usually not required for building application modules in separate directories, because most of the rules it defines are specific to the VxWorks run-time system and boot programs.
The variables defined in the make include files provide convenient defaults for most situations, and allow individual makefiles to specify only the definitions that are unique to each. This section describes the make variables most often used to specify properties of BSPs or applications. The following lists are not intended to be comprehensive; see the make include files for the complete set.
|
|
CAUTION:
Certain make variables are intended specifically for customization; see Variables for Customizing the Run-Time. Be very cautious about overriding other variables in BSP makefiles. They are described in the following sections primarily for expository purposes.
|
||||||||||||||||||
The variables grouped in this section are useful for either BSP makefiles or application-module makefiles. They specify aspects of how to invoke the compiler.
The variables included in this section specify properties of a particular BSP, and are thus recorded in each BSP makefile. They are not normally used in application-module makefiles.
The variables listed in this section make it easy to control what facilities are statically linked into your run-time system. You can specify values for these variables either from the make command line, or from your own makefiles (when you take advantage of the predefined VxWorks make include files).
You can exploit the VxWorks makefile structure to put together your own application makefiles quickly and tersely. If you build your application directly in a BSP directory (or in a copy of one), you can use the makefile in that BSP, by specifying variable definitions (Variables for Customizing the Run-Time) that include the components of your application.
You can also take advantage of the Tornado makefile structure if you develop application modules in separate directories. Example 5-2 illustrates the general scheme. Include the makefile headers that specify variables, and list the object modules you want built as dependencies of a target. This simple scheme is usually sufficient, because the Tornado makefile variables are carefully designed to fit into the default rules that make knows about.2
|
|
NOTE:
The target name exe is the Tornado convention for a default make target. You may either use that target name (as in Example 5-2), or define a different default rule in your makefiles. However, there must always be an exe target in makefiles based on the Tornado makefile headers (even if the associated rules do nothing).
|
||||||||||||||||||
Example 5-2: Skeleton Makefile for Application Modules
# Makefile - makefile for ... # # Copyright ... # # DESCRIPTION # This file specifies how to build ... ## It is often convenient to override the following with "make CPU=..." CPU = cputype TOOL = gnu include $(WIND_BASE)/target/h/make/defs.bsp ## Only redefine make definitions below this point, or your definitions ## will be overwritten by the makefile stubs above. exe : myApp.o
As you approach a final version of your application, you will probably want to add modules to the bootable system image, and include startup of your application with the system initialization routines. In this way, you can create a bootable application, which is completely initialized and functional after booting, without requiring any interaction with the host-resident development tools.
Linking the application with VxWorks is a two-step process. You must include the application initialization code in config.h, and you must modify the makefile to link the application statically with VxWorks.
#define USER_APPL_INIT \
{ \
IMPORT int myAppInit(); \
taskSpawn ("myApp", 30, 0, 5120, \
mpAppInit, 0x1, 0x2, 0x3, 0,0,0,0,0,0,0); \
}
To include your application modules in the bootable system image, add the names of the application object modules (with the .o suffix) to MACH_EXTRA in the makefile. For example, to link the module myMod.o, add a line like the following:
MACH_EXTRA = myMod.o
Building the system image with the application linked in is the final part of this step. In the target directory, execute the following command:
c:\> make vxWorks
Application size is usually an important consideration in bootable applications. Generally, VxWorks boot ROM code is copied to a start address in RAM above the constant RAM_HIGH_ADRS, and the ROM in turn copies the downloaded system image starting at RAM_LOW_ADRS. The values of these constants are architecture dependent, but in any case the system image must not exceed the space between the two. Otherwise the system image overwrites the boot ROM code while downloading, thus killing the booting process.
To help avoid this, the last command executed when you make a new VxWorks image is vxsize, which shows the size of the new executable image and how much space (if any) is left in the area below the space used for ROM code:
vxsize 386 -v 00100000 00020000 vxWorks vxWorks: 612328(t) + 69456(d) + 34736(b) = 716520 (235720 bytes left)
If your new image is too large, vxsize issues a warning. In this case, you can reprogram the boot ROMs to copy the ROM code to a sufficiently high memory address by increasing the value of RAM_HIGH_ADRS in config.h and in your BSP's makefile (both values must agree). Then rebuild the boot ROMs by executing the following command:
c:\> make bootrom.hex
The binary image size of typical boot ROM code is 128KB or less. This small size is achieved through compression; see Boot ROM Compression. The compressed boot image begins execution with a single uncompressed routine, which uncompresses the remaining boot code to RAM. To avoid uncompressing and thus initialize the system a bit faster, you can build a larger, uncompressed boot ROM image by specifying the make target bootrom_uncmp.hex.
It is sometimes useful to create a VxWorks system that includes a copy of its own symbol table. The procedure for building such a system is somewhat different from the procedure described in 5.6.1 Linking Bootable Applications. No change is necessary to usrConfig.c. A different make target, vxWorks.st, specifies the standalone form of VxWorks:
c:\> make vxWorks.st
The rules for building vxWorks.st create a module usrConfig_st.o, which is the usrConfig.c module compiled with the STANDALONE flag defined. The STANDALONE flag causes the usrConfig.c module to be compiled with the built-in system symbol table, the target-resident shell, and associated interactive routines.
The STANDALONE flag also suppresses the initialization of the network. If you want to include network initialization, define STANDALONE_NET in either of the header files installDir\target\config\bspname\config.h or installDir\target\config\all\configAll.h.3
VxWorks is linked as described previously, except that the first pass through the loader does not specify the final load address; thus the output from this stage is still relocatable. The makeSymTbl tool is invoked on the loader output; it constructs a data structure containing all the symbols in VxWorks. This structure is then compiled and linked with VxWorks itself to produce the final bootable VxWorks object module.
To include your own application in the system image, add the object modules to the definition of MACH_EXTRA and follow the procedures discussed in 5.6.1 Linking Bootable Applications.
Because vxWorks.st has a built-in symbol table, there are some minor differences in how it treats VxWorks symbols, in contrast with the host symbol table used by Tornado tools through the target server. First, VxWorks symbol table entries cannot be deleted from the vxWorks.st symbol table. Second, no local (static) VxWorks symbols are present in vxWorks.st.
To put VxWorks or a VxWorks-based application into ROM, you must enter the object files on the loader command line in an order that lists the module romInit.o before sysALib.o. Also specify the entry point option -e _romInit. The romInit( ) routine initializes the stack pointer to point directly below the text segment. It then calls bootInit( ), which clears memory and copies the vxWorks text and data segments to the proper location in RAM. Control is then passed to usrInit( ).
A good example of a ROM-based VxWorks application is the VxWorks boot ROM program itself. The file installDir\target\config\all\bootConfig.c is the configuration module for the boot ROM, replacing the file usrConfig.c provided for the default VxWorks development system. The makefiles in the target-specific directories contain directives for building the boot ROMs, including conversion to a file format suitable for downloading to a PROM programmer. Thus, you can generate the ROM image with the following make command:
c:\> make bootrom.hex
Tornado makefiles also define a ROMable VxWorks run-time system suitable for use with Tornado tools as the target vxWorks.res_rom_nosym. To generate this image in a form suitable for writing ROMs, run the following command:
c:\> make vxWorks.res_rom_nosym.hex
VxWorks target makefiles also include the entry vxWorks.st_rom for creating a ROMable version of the standalone system described in 5.6.2 Creating a Standalone VxWorks System with a Built-in Symbol Table. The image vxWorks.st_rom differs from vxWorks.st in two respects: (1) romInit code is loaded as discussed above, and (2) the portion of the system image that is not essential for booting is compressed by approximately 40 percent using the VxWorks compress tool (see Boot ROM Compression).
To build the form of this target that is suitable for writing into a ROM (most often, this form uses the Motorola S-record format), enter:
c:\> make vxWorks.st_rom.hex
When adding application modules to a ROMable system, size is again an important consideration. Keep in mind that by using the compress tool, a configuration that normally requires a 256-KB ROM may well fit into a 128-KB ROM. Be sure that ROM_SIZE (in both config.h and the makefile) reflects the capacity of the ROMs used.
VxWorks boot ROMs are compressed to about 40 percent of their actual size using a binary compression algorithm, which is supplied as the tool compress. When control is passed to the ROMs on system reset or reboot, a small (8 KB) uncompression routine, which is not itself compressed, is executed. It then uncompresses the remainder of the ROM into RAM and jumps to the start of the uncompressed image in RAM. There is a short delay during the uncompression before the VxWorks prompt appears. The uncompression time depends on CPU speed and code size; it takes about 4 seconds on an MC68030 at 25 MHz.
This mechanism is also available to compress a ROMable VxWorks application. The entry for vxWorks.st_rom in the architecture-independent portion of the makefile, installDir\target\h\make\rules.bsp, demonstrates how this can be accomplished. For more information, see also the reference manual entries for bootInit and compress.
In some cases, you may wish to change and customize your BSP using the techniques described in this chapter, and then build the VxWorks image for use by application developers using the project facility. This is the one case where you can "mix" the two methods of configuration. Using one of these make targets creates a project based on the BSP you have created with all your customizations. This project can serve as a base for further development.
|
|
|||||||||||||||||||
1: To see the available macros with their descriptions, see installDir\target\config\all\configAll.h (for macros applicable to all BSPs) and installDir\target\config\bspname\config.h (for macros applicable to a specific BSP).
2: However, if you are working with C++, it may be also convenient to copy the .cpp.out rule from installDir\target\h\make\rules.bsp into your application's makefile.
3: vxWorks.st suppresses network initialization, but it includes the network. The STANDALONE option defines INCLUDE_STANDALONE_SYM_TBL and INCLUDE_NETWORK, and undefines INCLUDE_NET_SYM_TBL and INCLUDE_NET_INIT. The alternative option STANDALONE_NET includes INCLUDE_NET_INIT.