Vxworks Cli Tools Users Guide 6.7 PDF
Vxworks Cli Tools Users Guide 6.7 PDF
Vxworks Cli Tools Users Guide 6.7 PDF
6.7
VxWorks Command-Line Tools User's Guide, 6.7
Copyright 2008 Wind River Systems, Inc.
All rights reserved. No part of this publication may be reproduced or transmitted in any
form or by any means without the prior written permission of Wind River Systems, Inc.
Wind River, Tornado, and VxWorks are registered trademarks of Wind River Systems, Inc.
The Wind River logo is a trademark of Wind River Systems, Inc. Any third-party
trademarks referenced are the property of their respective owners. For further information
regarding Wind River trademarks, please see:
http://www.windriver.com/company/terms/trademark.html
This product may include software licensed to Wind River by third parties. Relevant
notices (if any) are provided in your product installation at the following location:
installDir/product_name/3rd_party_licensor_notice.pdf.
Wind River may refer to third-party documentation by listing publications or providing
links to third-party Web sites for informational purposes. Wind River accepts no
responsibility for the information provided in such third-party documentation.
Corporate Headquarters
Wind River Systems, Inc.
500 Wind River Way
Alameda, CA 94501-1153
U.S.A.
toll free (U.S.): (800) 545-WIND
telephone: (510) 748-4100
facsimile: (510) 749-2010
For additional contact information, please visit the Wind River URL:
http://www.windriver.com
For information on how to contact Customer Support, please visit the following URL:
http://www.windriver.com/support
VxWorks Command-Line Tools User's Guide, 6.7
2 Dec 08
Part #: DOC-16305-ND-00
iii
Contents
1 Overview ............................................................................................... 1
1.1 Introduction ............................................................................................................. 1
1.2 Related Documentation ....................................................................................... 2
2 Setting Environment Variables ........................................................... 5
2.1 Introduction ............................................................................................................. 5
2.2 Setting Environment Variables With wrenv ................................................... 6
Solaris and Linux ...................................................................................... 6
Windows .................................................................................................... 6
Setting Environment Variables Without Spawning a Shell ................ 6
2.3 How wrenv Works ................................................................................................. 7
2.4 wrenv Command Options .................................................................................... 8
3 Configuring and Building VxWorks .................................................... 11
3.1 Introduction ............................................................................................................ 11
3.2 Working With VxWorks Image Projects: VIPs ................................................ 12
3.2.1 Setting Environment Variables ............................................................... 12
VxWorks
Command-Line Tools User's Guide, 6.7
iv
3.2.2 Creating VxWorks Image Projects ........................................................ 12
Checking the Toolchain ........................................................................... 14
Copying VIPs ............................................................................................ 14
Using Profiles ............................................................................................ 15
3.2.3 Deleting VIPs ........................................................................................... 15
3.2.4 Modifying VIPs ........................................................................................ 16
Adding Components ............................................................................... 16
Removing Components ........................................................................... 17
Setting Configuration Parameter Values .............................................. 17
Changing the Project Makefile Name ................................................... 18
Adding and Removing Individual Application Files ......................... 18
3.2.5 Getting Information About VIPs ........................................................... 18
Listing Components ................................................................................. 18
Listing Bundles ......................................................................................... 19
Listing Profiles .......................................................................................... 19
Comparing Projects .................................................................................. 20
Checking a Component ........................................................................... 20
Checking Component Dependencies .................................................... 20
Listing Configuration Parameters and Values ..................................... 20
Listing the Source Files in a Project ....................................................... 21
3.2.6 Building VIPs ........................................................................................... 22
Build Specifications, Build Rules, and Image Types ........................ 22
Examining Build Specifications and Rules ........................................... 24
Changing Build Specifications ............................................................... 24
Adding and Changing Build Rules ....................................................... 25
Building VxWorks .................................................................................... 25
3.2.7 Example vxprj Session ............................................................................. 26
3.3 Working With VxWorks Source Build Projects: VSBs ................................... 26
3.3.1 Using VSB Projects: Basic Steps ............................................................. 27
3.3.2 Setting Environment Variables ............................................................... 28
3.3.3 Displaying BSP and CPU Options for VSB Projects ........................... 28
3.3.4 Creating VSB Projects ............................................................................. 28
3.3.5 Selecting VSB Options ............................................................................ 30
3.3.6 Reconfiguring a VSB Project ................................................................... 31
Contents
v
3.3.7 Changing the CPU for a VSB Project .................................................... 32
3.3.8 Changing the BSP for a VSB Project ..................................................... 33
3.3.9 Building a VSB Project ............................................................................ 34
3.3.10 Deleting a VSB Project ............................................................................ 35
3.3.11 Using a VSB Project With a VxWorks Image Project .......................... 35
3.3.12 Identifying a VIP-VSB Association ....................................................... 35
3.3.13 Validating a VIP-VSB Association ........................................................ 36
3.4 Building Customized VxWorks Source Code .................................................. 36
3.4.1 Limitations and Restrictions ................................................................... 37
3.4.2 Third-Party Binary Files .......................................................................... 37
3.4.3 VxWorks Library Source Code and Archive Locations ...................... 37
3.4.4 Setting Environment Variables ............................................................... 38
3.4.5 Building Customized Kernel Source Code with VSB Projects .......... 38
3.4.6 Building With Make Directly .................................................................. 38
UP and SMP Kernel Build Commands ................................................. 39
User (RTP) Build Command ................................................................... 39
Building Compiler Intrinsics Libraries ................................................. 39
4 Building Kernel Applications and Libraries ...................................... 41
4.1 Introduction ........................................................................................................... 42
4.2 About Building Kernel Applications and Libraries ....................................... 42
4.3 Setting Environment Variables ............................................................................ 42
4.4 Using the VxWorks Build Environment ........................................................... 43
4.5 Example Makefile for a Kernel Application .................................................... 43
4.6 Setting CPU and TOOL Make Variables .......................................................... 44
4.7 Building Kernel Applications for UP, SMP, and VSB Variants .................... 45
4.7.1 Building Applications With Default VxWorks UP Libraries ............ 45
VxWorks
Command-Line Tools User's Guide, 6.7
vi
4.7.2 Building Applications With Default VxWorks SMP Libraries .......... 46
4.7.3 Building Applications With User-Configured Variant Libraries ...... 46
4.8 Linking Kernel Application Modules ............................................................... 47
4.9 Linking Kernel Application Modules With VxWorks ................................... 47
4.10 make Variables for Kernel Applications and Libraries ................................. 48
4.11 Running Kernel Applications ............................................................................. 49
5 Building RTP Applications and Libraries ........................................... 51
5.1 Introduction ............................................................................................................ 52
5.2 About Building RTP Applications and Libraries ............................................ 52
5.3 Setting Environment Variables ............................................................................ 53
5.4 Using the VxWorks Build Environment ........................................................... 53
5.5 Make Rules for RTP Applications and Libraries ............................................ 54
5.6 Setting CPU and TOOL Make Variables .......................................................... 54
5.7 Top-Level Makefile for Applications and Libraries ....................................... 54
5.8 Building RTP Libraries ......................................................................................... 55
5.8.1 Basic Library Makefile ............................................................................ 55
5.8.2 More Complex Library Makefile ........................................................... 56
5.8.3 Library Build Output ............................................................................... 57
5.8.4 Library Build Commands ....................................................................... 58
5.9 Building RTP Applications ................................................................................. 58
5.9.1 Basic Application Makefile for a Dynamic Executable ...................... 58
5.9.2 More Complex Application Makefile ................................................... 59
5.9.3 RTP Application Build Output ............................................................... 60
5.9.4 RTP Application Build Commands ....................................................... 60
Contents
vii
5.10 Using a Custom Build Environment .................................................................. 61
5.10.1 Generating PIC Object Modules ............................................................ 62
5.10.2 Generating the Shared Library ............................................................... 62
5.10.3 Generating the Applications Object Modules ..................................... 63
5.10.4 Generating the Application Executable ................................................ 63
5.11 Compiler Options for Shared Objects and Dynamic RTP Applications .... 64
5.11.1 Options for Shared Objects ..................................................................... 64
5.11.2 Options for Dynamic RTP Application Executables ........................... 65
Identifying the Run-time Paths of Shared Libraries ........................... 65
5.12 Make Variables for RTP Applications and Libraries ..................................... 66
5.13 Running RTP Applications ................................................................................. 69
6 Configuring and Building VxWorks Using config.h .......................... 71
6.1 Introduction ............................................................................................................ 71
6.2 Using config.h to Configure VxWorks ............................................................... 72
6.3 Configuration Examples ....................................................................................... 73
6.3.1 Removing Network Support .................................................................. 73
6.3.2 Adding RTP Support ............................................................................... 73
6.4 Using make .............................................................................................................. 74
6.4.1 Makefile Details ........................................................................................ 74
Customizing the VxWorks Makefile ...................................................... 75
Commonly Used Makefile Macros ........................................................ 76
6.4.2 Building Custom Boot Loaders .............................................................. 79
Index .............................................................................................................. 81
VxWorks
Command-Line Tools User's Guide, 6.7
viii
1
1
Overview
1.1 Introduction 1
1.2 Related Documentation 2
1.1 Introduction
This guide describes how to use the command-line build environment provided
with VxWorks. It complements the Wind River Workbench by Example guide for
programmers who prefer to do development tasks outside of the Workbench
graphical interface or who need to create scripted build environments.
The Workbench IDE includes many features, such as code browsing, host-target
communication, and multicore debugging, that are not available from the
command line. For a complete description of the Workbench environment, see the
Wind River Workbench by Example guide, which also provides information about
setting up the host-target development environment.
For information about the VxWorks operating system and developing applications
that run under it, see the VxWorks Kernel Programmers Guide and VxWorks
Application Programmers Guide.
VxWorks ships with two compilers and associated toolchains: the Wind River
Compiler (sometimes called the Diab compiler) and GCC (part of the GNU
project). Both toolchains use the GNU make utility for VxWorks application
development. To the largest extent possible, these toolchains have been designed
VxWorks
Command-Line Tools User's Guide, 6.7
2
for interoperability, but it is not always safe to assume that code written for one set
of tools will work perfectly with the other. While examples in this guide may use
either or both compilers, it is best to select one compiler and toolchain before
starting a project.
The Wind River Compiler and tools are documented in a separate users guide for
each supported target architecture. For example, information about the PowerPC
compiler is in the Wind River Compiler for PowerPC Users Guide. GCC and the other
GNU tools are documented in a series of manuals from the Free Software
Foundation, which are provided with this release.
1.2 Related Documentation
The following guides provide information closely related to the topics covered in
this one:
If you reconfigure the project (see 3.3.6 Reconfiguring a VSB Project, p. 31), the
default selections are those recorded the last time you worked with the project
(when you created it, or the last time you reconfigured it).
The NEW designation in parentheses means that the option is new to this project.
This would be the case when projects are first created, but also when new
options are introduced by the installation of additional features (for example,
another networking protocol) after a project has been created. For information
about how to configure new options without having to run through all
possible options, see 3.3.6 Reconfiguring a VSB Project, p. 31.
3.3.6 Reconfiguring a VSB Project
To reconfigure a VSB project, use the following syntax:
vxprj vsb config [vsbfile|vsbdir] [-d|-D defFile |-o |-s|-S]
The options have the same meaning as when used to create a project (see
3. Configuring and Building VxWorks), with the additions and differences described
below.
Note that the reference to new VSB options below refers to VSB options that become
available to a project when additional features are installed after a project has been
created.
-d
Reconfigure a project based on a VSB configuration file called
default.vxconfig. The file must be located in the directory of the project that is
to be modified.
VxWorks
Command-Line Tools User's Guide, 6.7
32
-D defFile
Reconfigure a project based on another VSB project configuration file (for
example, using /home/xeno/myVsb/vsb.config). Any new VSB options are
added with the default settings.
-o
Run the configuration tool, but prompt only for any new VSB options that
have become available (through installation of other features) since the project
was created. This option provides the means for adding them to a project.
-s
Reconfigure a project based on an existing VSB project. The configuration tool
runs silently. A defFile is created in each VSB project directory (for example,
/home/xeno/myVsb/vsb.config). The user is, however, prompted for any new
VSB options that have become available (through installation of other features)
since the project was created.
-S
Reset a VSB project to the default options. The configuration tool runs silently.
3.3.7 Changing the CPU for a VSB Project
To change the CPU on which a VSB project is based, use the following command
syntax:
vxprj vsb setCpu cpuName [vsbfile|vsbdir] [-d|-D defFile |-o |-s|-S]
Options in addition to CPU are available because changing the CPU causes the
interactive VSB option selection process to be restarted, and the vxprj vsb
command options provide various ways to manage selection.
Note that the reference to new VSB options below refers to VSB options that become
available to a project when additional features are installed after a project has been
created.
The options have the same meaning as when used to create a project (see
3. Configuring and Building VxWorks), with the following additions and differences:
-d
Reconfigure a project based on a VSB configuration file called
default.vxconfig. The file must be located in the directory of the project that is
to be modified.
3 Configuring and Building VxWorks
3.3 Working With VxWorks Source Build Projects: VSBs
33
3
-D defFile
Reconfigure a project based on another VSB project configuration file (for
example, using /home/xeno/myVsb/vsb.config). Any new VSB options are
added with the default settings.
-o
Run the configuration tool, but prompt only for any new VSB options that
have become available (through installation of other features) since the project
was created. This option provides the means for adding them to a project.
-s
Reconfigure a project based on an existing VSB project. The configuration tool
runs silently. A defFile is created in each VSB project directory (for example,
/home/xeno/myVsb/vsb.config). The user is, however, prompted for any new
VSB options that have become available (through installation of other features)
since the project was created.
-S
Reset a VSB project to the default options. The configuration tool runs silently.
3.3.8 Changing the BSP for a VSB Project
To change (or set) the BSP on which a VSB project is based, use the following
command syntax:
vxprj vsb setBsp bsp|bspdir [vsbfile|vsbdir] [-d|-D defFile|-o |-s|-S]
Options in addition to BSP are available because changing the BSP causes the
interactive VSB option selection process to be restarted, and the vxprj vsb options
provide various ways to manage selection (for example, to only deal with new
items).
Note that the reference to new VSB options below refers to VSB options that become
available to a project when additional features are installed after a project has been
created.
The options have the same meaning as when used to create a project (see
3. Configuring and Building VxWorks), with the following additions and differences:
-d
Reconfigure a project based on a VSB configuration file called
default.vxconfig. The file must be located in the directory of the project that is
to be modified.
VxWorks
Command-Line Tools User's Guide, 6.7
34
-D defFile
Reconfigure a project based on another VSB project configuration file (for
example, using /home/xeno/myVsb/vsb.config). Any new VSB options are
added with the default settings.
-o
Run the configuration tool, but prompt only for new options. New options
may be available to a project if additional features are installed after a project
has been created, and this option provides the means for adding them to a
project.
-s
Reconfigure a project based on an existing VSB project. The configuration tool
runs silently. A defFile is created in each VSB project directory; for example,
/home/xeno/myVsb/vsb.config.
-S
Reset a VSB project to the default options. The configuration tool runs silently.
3.3.9 Building a VSB Project
To build a VSB project, simply execute make in the project directory.
The Wind River Compiler (diab) is used to build VxWorks source for all
architectures except IA. The GNU compiler is used to build source for IA. The
compiler intrinsics libraries are built with the opposite (secondary) compiler;
that is the one not used for the primary build (for information about compiler
intrinsics, see the VxWorks Kernel Programmers Guide: Target Tools).
Note that the secondary compiler can also be used for building certain VxWorks
networking and middleware facilities that are delivered only in source code
format. For information in this regard, see the Wind River VxWorks Platforms Users
Guide.
The build takes VxWorks source code in installDir/vxworks-6.x/target/src as input
and writes output to subdirectories of the VSB project directory. For example, for a
PPC32 VSB project, the libraries would be created in directories below
vsbdir/ppc/PPC32/.
Note that if a VSB configuration is changed, the libraries are cleaned before the
next build takes place.
3 Configuring and Building VxWorks
3.3 Working With VxWorks Source Build Projects: VSBs
35
3
3.3.10 Deleting a VSB Project
To delete a VSB project, use the following syntax:
vxprj vsb delete path/vsbFile
This command removes the entire VSB project directory, and must therefore be
executed outside of that directory.
3.3.11 Using a VSB Project With a VxWorks Image Project
In order to use the customized libraries that you have created with a VSB project
instead of the default libraries provided with the product installationyou must
associate a VxWorks image project (VIP) with the VSB project. You can make this
association when you create the VIP or afterwards.
To associate a VIP with a VSB when the VIP is created, use the -vsb option with
vxprj create. For example:
% vxprj create wrSbc8560 diab -vsb /home/xeno/myVsb /home/xeno/myVip
To associate a VIP with a VSB after the VIP is created, use the following command
syntax:
vxprj vsb set [prjfile|prjdir] [vsbfile|vsbdir|-default]
The -default option sets the VIP to use default libraries (in target/lib or
target/lib_smp) instead of VSB libraries. The selection of UP or SMP default
libraries is made automatically based on the selection for the VIP itself (that is,
without or with the -smp option).
For detailed information about VxWorks image projects, see 3.2 Working With
VxWorks Image Projects: VIPs, p. 12.
3.3.12 Identifying a VIP-VSB Association
To identify which VSB (if any) a VIP is associated with, use the following command
syntax:
vxprj vsb info [prjfile|prjdir]
For example:
C:\workspace\mv5100VIP>vxprj vsb info
VSB directory is set to ./../myPpc32Vsb
VxWorks
Command-Line Tools User's Guide, 6.7
36
If the VIP is not associated with a VSB, the output of the command indicates that
it is associated with the default installed libraries, as follows:
C:\workspace\mv5100VIP_3>vxprj vsb info
VSB directory is set to C:/WindRiver/vxworks-6.7/target/lib
3.3.13 Validating a VIP-VSB Association
To check that the association of a VSB and a VIP is valid, use the following
command syntax:
vxprj check
3.4 Building Customized VxWorks Source Code
If you choose to customize (edit) VxWorks kernel source code, you have the
following options for rebuilding it:
Rebuild using the make command directly in the appropriate source directory.
In the case of VSB projects, the new libraries do not overwrite the default libraries
in the VxWorks installationthe output is written to the VSB project directory. VSB
projects can be used only for kernel libraries, and not user (RTP) libraries.
In the case of using make directly, the new libraries do overwrite the default
libraries in the VxWorks installation. Using make directly is simpler in the sense
that you do not have to create a VSB project yourself; but you do need to back up
the libraries you are rebuilding if you want to preserve the defaults provided with
the distribution.
If you choose to customize (edit) user mode (RTP) code, you must use make
directly.
NOTE: You can rebuild kernel libraries (whether UP or SMP) with either the VSB
or direct make method. You must rebuild user-mode (RTP) libraries with the make
methodthey cannot be rebuilt with VSB projects.
3 Configuring and Building VxWorks
3.4 Building Customized VxWorks Source Code
37
3
3.4.1 Limitations and Restrictions
There are some limitations and restrictions you must be aware of when
recompiling the VxWorks source:
You must build the source code in the vxworks-6.x installation tree with the
host tools and makefiles provided with the VxWorks installation.
There may be certain portions of VxWorks object code for which source code
has not been provided. See 3.4.2 Third-Party Binary Files, p. 37.
Modifications to the source code may not be covered by Wind River Customer
Support.
3.4.2 Third-Party Binary Files
Due to licensing restrictions, the VxWorks source code does not include source files
licensed by Wind River from third parties. This code is instead distributed in the
form of binary (.o) files.
When you build the VxWorks source code, the third-party binaries are copied
automatically into the source build directory.
Third party binaries are located in installDir/vxworks-6.x/target/precomp. For a
complete list of the affected files and architectures, search this directory for files
with a .o extension.
3.4.3 VxWorks Library Source Code and Archive Locations
The VxWorks library source code and archives are installed in the following
locations:
UP Kernel
installDir/vxworks-6.x/target/src
installDir/vxworks-6.x/target/lib
! CAUTION: Do not delete the precompiled files in
installDir/vxworks-6.x/target/precomp. Doing so may prevent you from creating
projects that rely on these files.
VxWorks
Command-Line Tools User's Guide, 6.7
38
SMP Kernel
installDir/vxworks-6.x/target/src
installDir/vxworks-6.x/target/lib_smp
User (RTP)
installDir/vxworks-6.x/target/usr/src
installDir/vxworks-6.x/target/usr/lib
3.4.4 Setting Environment Variables
Environment variables are set automatically if you are using the VxWorks
Development Shell on Windows. Otherwise you must use the wrenv utility to set
them. For more information, see 2.2 Setting Environment Variables With wrenv, p. 6.
3.4.5 Building Customized Kernel Source Code with VSB Projects
For information about using VSB projects, see 3.3 Working With VxWorks Source
Build Projects: VSBs, p. 26.
3.4.6 Building With Make Directly
To build VxWorks from source using the make command directly, execute the
make command with the appropriate CPU and TOOL variable assignments in the
appropriate source directory.
For information about the CPU and TOOL variables, see the VxWorks Architecture
Supplement.
! CAUTION: Remember to back up your VxWorks source and binaries before
modifying and rebuilding them.
3 Configuring and Building VxWorks
3.4 Building Customized VxWorks Source Code
39
3
UP and SMP Kernel Build Commands
To build UP or SMP kernel-mode libraries, first change directory to:
installDir/vxworks-6.x/target/src
For UP libraries, execute the make command using the following syntax:
make CPU=cpuName TOOL= toolchain
For SMP libraries, execute the make command using the following syntax:
make CPU=cpuName TOOL= toolchain VXBUILD=SMP
User (RTP) Build Command
To build user-mode (RTP) libraries, change directory to:
installDir/vxworks-6.x/target/usr/src
Then execute the make command using the following syntax:
make CPU=cpuName TOOL= toolchain
Building Compiler Intrinsics Libraries
VxWorks can be configured with compiler intrinsics components to provide
support for dynamically loading kernel modules, including those built with a
different compiler than was used for the VxWorks kernel itself.
The compiler intrinsics libraries are built automatically when VxWorks source
code is built using a VSB project. If you use make directly, however, you must build
VxWorks a second time, using the other (secondary) compiler. That is, if your first
build is performed with the Wind River Compiler (Diab), then you must perform
a second build with the GNU compiler.
NOTE: You can build a debug version of the source by providing a -g flag with
ADDED_CFLAGS and ADDED_C++FLAGS in the following file:
installDir/vxworks-6.x/target/src/Makefile
Or use the variables from the command-line as follows:
% make CPU=cpuVal TOOL=toolChain ADDED_CFLAGS+=-g ADDED_C++FLAGS+=-g
VxWorks
Command-Line Tools User's Guide, 6.7
40
For more information about compiler intrinsics and downloadable kernel
modules, see the VxWorks Kernel Programmers Guide: Target Tools. For information
about compiler options, see the VxWorks Architecture Supplement.
41
4
Building Kernel Applications
and Libraries
4.1 Introduction 42
4.2 About Building Kernel Applications and Libraries 42
4.3 Setting Environment Variables 42
4.4 Using the VxWorks Build Environment 43
4.5 Example Makefile for a Kernel Application 43
4.6 Setting CPU and TOOL Make Variables 44
4.7 Building Kernel Applications for UP, SMP, and VSB Variants 45
4.8 Linking Kernel Application Modules 47
4.9 Linking Kernel Application Modules With VxWorks 47
4.10 make Variables for Kernel Applications and Libraries 48
4.11 Running Kernel Applications 49
VxWorks
Command-Line Tools User's Guide, 6.7
42
4.1 Introduction
This chapter explains how to build VxWorks kernel applications and associated
libraries using command-line build facilities. You can build applications and
libraries using a default set of makefile rules and make.
You can use kernel applications as downloadable modules or linked with the
VxWorks kernel itself. You can also create custom static libraries for use with
kernel applications.
For detailed information about writing code for kernel applications and libraries,
see the VxWorks Kernel Programmers Guide. For information about how to use
Wind River Workbench to build applications and libraries, see the Wind River
Workbench by Example guide.
4.2 About Building Kernel Applications and Libraries
To build a kernel-mode application or library from the command line, you can use
the default makefile system and invoke the make utility directly. Wind River
supplies a general build model implemented by a series of make rules, with
standard make variables that control aspects of the build process such as target
CPU and toolchain.
For information about writing code for kernel applications and libraries (including
use of kernel facilities and APIs, C and C++ libraries, header files, and so on), see
the VxWorks Kernel Programmers Guide.
4.3 Setting Environment Variables
Environment variables are set automatically if you are using the VxWorks
Development Shell on Windows. Otherwise you must use the wrenv utility to set
them. For more information, see 2.2 Setting Environment Variables With wrenv, p. 6.
4 Building Kernel Applications and Libraries
4.4 Using the VxWorks Build Environment
43
4
4.4 Using the VxWorks Build Environment
Using the command-line interface (CLI) build environment provided with the
VxWorks installation allows you to take advantage of a set of default makefile
rules to build kernel applications and libraries.
4.5 Example Makefile for a Kernel Application
# basic build file for a kernel application
# for Windows hosts, fix slashes
WIND_HOME := $(subst \,/,$(WIND_HOME))
WIND_BASE := $(subst \,/,$(WIND_BASE))
WIND_USR := $(subst \,/,$(WIND_USR))
include $(WIND_BASE)/target/h/make/defs.vsbvars.mk
# project-specific macros
EXE = hello.out
OBJ = hello.o
SRC = hello.c
# libraries, includes
LIBS =
INCLUDES = -I$(WIND_BASE)/target/h \
-I$(WIND_BASE)/target/h/wrn/coreip
# define CPU and tools
CPU = SIMPENTIUM
TOOL_FAMILY = diab
TOOL = diab
# compiler, linker (dcc, dld)
CC = dcc
LL = dld
# See Wind River compiler guide for complete details on linker options
# -r retains relocation entries, so the file can be re-input to the linker
LFLAGS = $(TARGET_SPEC) -r
# See Wind River compiler guide for information on target selection.
TARGET_SPEC = -tX86LH:vxworks66
##############################
# generic build targets, rules
VxWorks
Command-Line Tools User's Guide, 6.7
44
# executable constructed using linker from object files
$(EXE) : $(OBJ)
$(LL) $(LFLAGS) -o $@ $(OBJ) $(LIBS)
# objects compiled from source
$(OBJ) : $(SRC)
$(CC) $(TARGET_SPEC) $(INCLUDES) \
-DCPU=$(CPU) \
-DTOOL=$(TOOL) \
-DTOOL_FAMILY=$(TOOL_FAMILY) \
$(ALLFLAGS_VSBDEFS)
-o $@ -c $<
# clean up
clean :
rm $(EXE) $(OBJ)
# See the Wind River compiler documentation for more details on
# compiler and linker options.
The inclusion of defs.vsbvars.mk allows you to build an application using
VxWorks source build (VSB) variant libraries or SMP libraries as well as the default
uniprocessor (UP) libraries. For information about the make commands used to
build applications for different types of systems, see 4. Building Kernel Applications
and Libraries.
4.6 Setting CPU and TOOL Make Variables
The makefile defaults for processor architecture and compiler are PowerPC
architecture and the Wind River Compiler (Diab). Variable assignments can be
used at the command line or in a makefile to identify other architectures and
compilers. For example, the command used to build an application with the GNU
compiler for Pentium2 would be as follows:
make CPU=PENTIUM2 TOOL=gnu
For information about the CPU and TOOL variables, see the VxWorks Architecture
Supplement.
4 Building Kernel Applications and Libraries
4.7 Building Kernel Applications for UP, SMP, and VSB Variants
45
4
4.7 Building Kernel Applications for UP, SMP, and VSB Variants
The VxWorks CLI build system provides make variables that you can use to build
kernel applications for the following types of VxWorks systems:
UP or SMP systems using variant (that is, non-default) libraries. These systems
use libraries you create with a VxWorks source build (VSB) project. In order to
make use of the variant libraries, you associate the VIP project for the system
with the VSB project when you configure the system is configured.
For information about configuring VxWorks with a VIP (using the default
libraries), see 3.2 Working With VxWorks Image Projects: VIPs, p. 12. For information
about creating variant libraries using a VSB project, and associating a VIP project
with a VSB project, see 3.3 Working With VxWorks Source Build Projects: VSBs, p. 26.
The build options described below ensure that the application is linked against the
libraries that are appropriate for the system on which the application will run. That
is, they specify whether an application is linked against UP libraries, SMP libraries,
or variant libraries of either a UP or an SMP variety.
4.7.1 Building Applications With Default VxWorks UP Libraries
To generate a kernel application for use with a VxWorks UP kernel using default
libraries, use the following command syntax or add the variable assignments to the
applications makefile:
make CPU=cpuType TOOL= toolchain
For information about the CPU and TOOL variables, see the VxWorks Architecture
Supplement.
! CAUTION: VxWorks kernel applications must be built specifically for the type of
system on which they will run. Applications built for uniprocessor (UP) VxWorks,
for symmetric multiprocessor (SMP) VxWorks, or for VxWorks systems based on
variant libraries created with a VxWorks source build (VSB) project (either UP or
SMP), are not binary compatible. Note that the loader does not generate an error if
a kernel module is incompatible with the system onto which it is loaded.
VxWorks
Command-Line Tools User's Guide, 6.7
46
4.7.2 Building Applications With Default VxWorks SMP Libraries
To build a kernel application for use with a VxWorks SMP kernel using default
libraries, use the following command syntax or add the variable assignments to the
applications makefile:
make CPU=cpuType TOOL= toolchain VXBUILD=SMP
The VXBUILD=SMP ensures that the application will be linked against the default
SMP libraries.
For information about the CPU and TOOL variables, see the VxWorks Architecture
Supplement.
4.7.3 Building Applications With User-Configured Variant Libraries
To build a kernel application for a VxWorks kernel (UP or SMP) using variant
libraries that you have created with a VSB project, the makefile must include
rules.dkm.mk.
Use the following command syntax or add the variable assignments to the
applications makefile:
make CPU=cpuType TOOL= toolchain VSB_DIR=pathToVsbProjectDir
The VSB_DIR assignment ensures that the application will be linked against the
specified set of variant libraries. Whether these libraries are UP or SMP was
determined when the VSB project was created.
For information about the CPU and TOOL variables, see the VxWorks Architecture
Supplement.
NOTE: No specific designation of UP or SMP is required for an application linked
against VSB variant libraries. The variant libraries themselves were defined as UP
or SMP in the source build project (VSB) with which they were created. In fact the
use of the VSB_DIR variable with VXBUILD=SMP is not supported. For
information about VSB projects, see 3.3 Working With VxWorks Source Build Projects:
VSBs, p. 26.
4 Building Kernel Applications and Libraries
4.8 Linking Kernel Application Modules
47
4
4.8 Linking Kernel Application Modules
In general, if you are going to download kernel object modules to a VxWorks target
you do not need to link them prior to download. However, if modules cross
reference each other, you should link them to form a single module. With C++
code, this linking should be done before the munch step. (For information about
munching, see the VxWorks Kernel Programmers Guide.)
For example, the following command links several modules, using the Wind River
linker for the PowerPC family of processors:
c:\> dld -o applic.o -r applic1.o applic2.o applic3.o
Similarly, this example uses the GNU linker:
c:\> ldppc -o applic.o -r applic1.o applic2.o applic3.o
In either case, the command 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 kernel application modules are reported by
the linker as unresolved externals. These are resolved by the loader when the
module is loaded into VxWorks memory.
4.9 Linking Kernel Application Modules With VxWorks
In order to produce complete systems that include kernel application object
modules, the modules must be statically linked with the VxWorks image. The
makefile EXTRA_MODULES variable can be used to do so.
It can be used from the command line as follows:
c:\workspace\myVIP> make EXTRA_MODULES="foo.o"
Note that the command must be issued in the VxWorks image project (VIP)
directory.
! WARNING: Do not link each kernel application module with the VxWorks libraries.
Doing this defeats the load-time linking feature of the loader, and wastes space by
adding multiple copies of VxWorks system modules to the target.
VxWorks
Command-Line Tools User's Guide, 6.7
48
To include your kernel application modules in the system image using a makefile,
identify the names of the application object modules with EXTRA_MODULES. For
example, to link the module myMod.o with the operating system, add a line like
the following:
EXTRA_MODULES = myMod.o
Building the system image with the module linked in is the final part of this step.
In the project directory, execute the following command:
c:\workspace\myVIP> make vxWorks
For information about how to have kernel applications start automatically at boot
time, see the VxWorks Kernel Programmers Guide.
For information about using vxprj to add link kernel applications with VxWorks
with a VxWorks image project (VIP), see Adding and Removing Individual Application
Files, p. 18. The vxprj method has the advantage of making the application an
integral part of the VxWorks project (and it remains so even when the project is
cleaned).
4.10 make Variables for Kernel Applications and Libraries
You can specify values for the following variables either from the make command
line, or from your own makefiles (when you take advantage of the predefined
VxWorks make include files).
ADDED_CFLAGS
Application-specific compiler options for C programs.
ADDED_C++FLAGS
Application-specific compiler options for C++ programs.
You can use additional variables to link kernel application modules with the
VxWorks image; see 4.9 Linking Kernel Application Modules With VxWorks, p. 47.
! CAUTION: Specific make variables are required if you are building an application
for a symmetrical multiprocessing SMP configuration of VxWorks or for a system
based on variant libraries (created with a VxWorks source build project). For more
information, see 4.7 Building Kernel Applications for UP, SMP, and VSB Variants, p. 45.
4 Building Kernel Applications and Libraries
4.11 Running Kernel Applications
49
4
4.11 Running Kernel Applications
You can statically link kernel applications to a VxWorks image or download them
from the host system, and start them automatically or interactively. For
information on these topics, see the VxWorks Kernel Programmers Guide: Kernel
Applications, the VxWorks Kernel Programmers Guide: Target Tools, the Wind River
Workbench Host Shell Users Guide, and the Wind River Workbench by Example guide.
VxWorks
Command-Line Tools User's Guide, 6.7
50
51
5
Building RTP Applications
and Libraries
5.1 Introduction 52
5.2 About Building RTP Applications and Libraries 52
5.3 Setting Environment Variables 53
5.4 Using the VxWorks Build Environment 53
5.5 Make Rules for RTP Applications and Libraries 54
5.6 Setting CPU and TOOL Make Variables 54
5.7 Top-Level Makefile for Applications and Libraries 54
5.8 Building RTP Libraries 55
5.9 Building RTP Applications 58
5.10 Using a Custom Build Environment 61
5.11 Compiler Options for Shared Objects and Dynamic RTP
Applications 64
5.12 Make Variables for RTP Applications and Libraries 66
5.13 Running RTP Applications 69
VxWorks
Command-Line Tools User's Guide, 6.7
52
5.1 Introduction
This chapter explains how to build VxWorks user-mode applications and libraries,
using command-line build facilities. You can build applications and libraries using
a default set of makefile rules and make, or with a custom build environment.
VxWorks user-mode applications are standalone executables. They are referred to
as real-time process (RTP) applications. You can use the default (or a custom) build
environment to build static libraries, shared libraries, and plug-ins for use with
RTP applications.
For detailed information writing code for applications and libraries, see the
VxWorks Application Programmers Guide. For information about how to use
Wind River Workbench to build applications and libraries, see the Wind River
Workbench by Example guide.
5.2 About Building RTP Applications and Libraries
To build a user-mode, real-time process (RTP) application or library (either static
or shared), or plug-in from the command line, you can make use of the default
makefile system and invoke the make utility directly. Wind River supplies a
general build model implemented by a series of make rules, with standard make
variables that control aspects of the build process such as target CPU and
toolchain. You can also use a custom build environment.
RTP application and library projects can be created by following the models in
target/usr/apps/samples/ and target/usr/src/usr/ under the VxWorks installation
directory.
For information writing code for RTP applications, libraries, and plug-ins
(including use of kernel facilities and system calls, C and C++ libraries, header
files, and so on), see the VxWorks Application Programmers Guide.
NOTE: Relocatable RTP application executables (the default) can be run on a
system that has been configured for the overlapped virtual memory model.
However, to take advantage of this model, RTP applications must be built as
absolutely-linked executables. For more information, see the VxWorks Application
Programmers Guide: Real-Time Processes.
5 Building RTP Applications and Libraries
5.3 Setting Environment Variables
53
5
5.3 Setting Environment Variables
Environment variables are set automatically if you are using the VxWorks
Development Shell on Windows. Otherwise you must use the wrenv utility to set
them. For more information, see 2.2 Setting Environment Variables With wrenv, p. 6.
5.4 Using the VxWorks Build Environment
It can be useful to set up a project with a top-level directory with subdirectories for
the application and for each shared library. The makefiles would be as follows:
Some middleware products (see the Platform release notes for further
information).
Boot loaders, when the BSP does not support the PROFILE_BOOTAPP
configuration profile.
VxWorks
Command-Line Tools User's Guide, 6.7
72
You can also use the config.h method for uniprocessor BSP development prior to
the CDF (configuration description file) development, which is required for
configuration with vxprj and Workbench.
6.2 Using config.h to Configure VxWorks
In the absence of CDFs (configuration description files), you can configure a boot
loader or VxWorks image using the config.h file. For example, you can select a
different network driver, or networking components can be removed if the system
does not require networking to boot or to operate.
In general, you should only configure a build manually if it is not already set up to
use vxprj or Workbench.
To add or remove components from a boot loader or VxWorks image, you must use
two BSP configuration files: configAll.h (for reference purposes only) and
config.h:
installDir/vxworks-6.x/target/config/all/configAll.h
installDir/vxworks-6.x/target/config/bspName/config.h
The configAll.h file provides the default VxWorks configuration for all BSPs. The
INCLUDED SOFTWARE FACILITIES section of this header file lists all components
that are included in the default configuration. The EXCLUDED FACILITIES section
lists those that are not. To add or remove components from a kernel configuration,
examine the configAll.h file to determine the default, then change the default for
a specific BSP by editing the config.h file for that BSP, defining or undefining the
appropriate components.
The config.h header file includes definitions for the following parameters: