Using RealView Compilation Tools from Visual Studio

Application Note 112



1                   Introduction

 

A Microsoft Visual Studio (Visual C++ 6.0) project can be modified with Custom build steps to use the RealView Compilation Tools (RVCT) that are provided as part of the RealView Developer Suite (RVDS) or the compilation tools that form part of the ARM Developer Suite (ADS 1.2).

Two small utility programs are provided with this application note to improve the integration.

 

·         Uniqadd.exe

 

This program adds an object file name to a linker ‘via’ file once only - no matter how many times a source file is compiled. The via file is used in a custom post-build step to link all compiled objects to create an ARM ELF image.

 

·         Swizzle1.exe

 

This program lets a Visual Studio Custom build step run RVCT when the user compiles a source file or makes a project. It shows how the tool is being called. It captures errors and warning messages and redirects them to the Visual Studio build tab in Microsoft format.

Using Microsoft format means that double-clicking on an error message which refers to a source file works as expected to open the appropriate file and position at the relevant line. For appropriate ADS1.2/RVCT compiler messages the editor caret is moved to the column with the exact source token causing the error. Other Visual Studio commands to navigate source file errors such as Edit->Go to->Next Error (F4) and Edit->Go to->Previous Error (Shift+F4) will also work.

 

If using RVCT 2.1 or above (as provided as part of RVDS 2.1) only Uniqadd.exe is required. The functionality provided by Swizzle1.exe is provided instead by an RVCT switch --diag_style=ide (unless armar is required in which case swizzle1.exe is still needed).

If using ADS 1.2 or RVCT 1.2 or 2.0 both utility programs are required.

 

Prerequisites:

Before continuing with this application note, you will require:

1.       One of the following ARM Software Development toolchains:

·         ADS 1.2 Compilation Tools, or

·         RVCT 1.2, or

·         RVDS 2.0 (RVCT 2.0.x), or

·         RVDS 2.1 (RVCT 2.1).

2.       Microsoft Visual Studio 6

3.       One of the following host operating systems

·         Windows 2000, or

·         Windows XP, or

·         Windows NT 4, Windows  ME or Windows 98 (with Microsoft VBScript Regular Expressions 5.5 Active-X control vbscript.dll from Windows Scripting Host).

2                   Installation of required executable files

The two programs Swizzle1.exe and Uniqadd.exe supplied along with this application note need to be placed into the Visual Studio or VC++ bin directory (or any directory in the PATH).

            C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin

or

C:\Program Files\Microsoft Visual Studio\VC98\Bin

 

VBScript Installation

The program swizzle1.exe relies on Microsoft VBScript Regular Expressions 5.5 Active-X control vbscript.dll. This is usually present on Windows 2000 and Windows XP computers and forms part of Windows Scripting Host 5.5 and 5.6.

Windows Script Host (WSH) is available to download from these locations as of September 2004.

http://msdn.microsoft.com/downloads/default.aspx

Additionally, vbscript.dll version 5.5.0.7426 or higher must be present and registered as a COM server. It is preinstalled on Windows 2000 and Windows XP.

 

Issues with machines that have had ADS 1.2 installed on them

 

If a machine is used that has had ADS1.2 installed on it then the following error message may be encountered when a build is carried out

Image

This is because ADS 1.2 provides a version of vbscript.dll with VBScript Regular Expressions 5.1 which is unsuitable for building with Visual Studio.

Uninstalling ADS1.2 may not un-register this vbscript.dll from the COM and it may be necessary to manually run ”regsvr32 /u vbscript.dll” before installing WSH5.5 or higher.

 

On Windows 2000 and Windows XP execute the following command to switch to the vbscript.dll supplied with this operating system, version 5.5.0.7426. It is upwards compatible with the vbscript.dll supplied in the bin directory of ADS1.2.

 

Open a Dos box or Command prompt:

C:\PROGRAM FILES\ARM\ADSv1_2\Bin\REGCOMIF "C:\WINNT\SYSTEM32\VBSCRIPT.DLL”

 

                                    You should see:

Library C:\WINNT\SYSTEM32\VBSCRIPT.DLL Registered OK

 

On other operating systems you should install Windows Scripting Host 5.5 or 5.6.

3                   Use of RealView Compilers with Visual Studio

3.1             Creating a project

1.       Start Microsoft Visual Studio.

2.       Create a new project based on Win32 Console Application and choose to create it empty.

3.       In the Workspace view switch from Class View to Files View.

4.       Select Resources group and press Delete key (there is no Resource compiler for RealView).

5.       Use Project->Add to project->Files… to add your source files.

Or

Use Project->Add to project->New… to add new source file to the project.

3.2             Define custom compile steps

1.       Select a source file in the Source Files group of the workspace view and use the Settings… context menu or Project->Settings (Alt+F7) menu item.

2.       Now change the Project Settings, General tab for any C source file to 'Always use custom build step'.

3.       The Custom Build tab can then be edited to contain RVCT commands to compile the source and record the ARM object file for linking.

Note           The Custom Build tab fields Description, Commands and Outputs should be filled in the opposite order to that which they appear in the dialog because Visual Studio insists on having at least an output dependency whenever you change focus.

Note           Please ensure the correct path is used for the version of tools that you have installed.

In the command lines below replace “\Version#\Release#” with the version and release numbers relating to the specific version of RVCT that you have installed. For example, for RVCT 2.1 you might replace “\Version#\Release# with “\2.1\328”.

For ADS the path is typically C:\Program Files\ARM\ADSv1_2\Bin

Project Settings dialog box

Outputs:

$(IntDir)\$(InputName).o

Commands:

For RVCT 2.1 or above

"$(ARMROOT)\RVCT\Programs\version#\release#\win_32-pentium\armcc" -c --diag_style=ide –g -O0 $(InputPath) –o $(IntDir)\$(InputName).o

uniqadd $(IntDir)\$(InputName).o $(IntDir)\link.via

Or for ADS 1.2 or RVCT 1.2 or 2.0

swizzle1 "$(ARMROOT)\RVCT\Programs\version#\release#\win_32-pentium\armcc" -c –g -O0 $(InputPath) –o $(IntDir)\$(InputName).o

uniqadd $(IntDir)\$(InputName).o $(IntDir)\link.via

 Description:

 RealView compiling $(InputPath)

 

4.       Once these changes are made the Project Settings will look like Figure 1.

 

Image

Figure 1

 

3.2.1          Modify compilation options

 

Different files can be compiled with differing options, for example:

Some files could be compiled without Dwarf2 debug data and with optimisation by replacing
“-g -O0” with “--O2”.

This could be used for the project’s ‘release’ configuration.

  

1.       Thumb C source files can be compiled with

Commands:

For RVCT 2.1 or above

"$(ARMROOT)\RVCT\Programs\version#\release#\win_32-pentium\armcc" --thumb -c -g --apcs /interwork --diag_style=ide $(InputPath) –o $(IntDir)\$(InputName).o

Or for ADS 1.2 or RVCT 1.2 or 2.0

swizzle1 "$(ARMROOT)\RVCT\Programs\version#\release#\win_32-pentium\tcc" -c -g –apcs /interwork $(InputPath) –o $(IntDir)\$(InputName).o

 

2.       Any files which #include header files from other places than the directory containing the source file will need appropriate –I include directory options too. You can do this with either a –I <path> specified directly as an option to the compiler as:

Commands:

For RVCT 2.1 or above

“$(ARMROOT)\RVCT\Programs\version#\release#\win_32-pentium\armcc" --thumb –I “<path to file>” -c -g -–apcs /interwork --diag_style=ide $(InputPath) –o $(IntDir)\$(InputName).o

Or for ADS 1.2 or RVCT 1.2 or 2.0

swizzle1 "$(ARMROOT)\RVCT\Programs\version#\release#\win_32-pentium\tcc" –I “<path to file>” -c -g –apcs /interwork $(InputPath) –o $(IntDir)\$(InputName).o

 

3.       Or using the --via option with the –I “<path to file>” information in the via file.

Commands:

For RVCT 2.1 or above

"$(ARMROOT)\RVCT\Programs\version#\release#\win_32-pentium\armcc" --diag_style=ide --via $(IntDir)\path.txt -c -g $(InputPath) -o $(IntDir)\$(InputName).o

Or for ADS 1.2 or RVCT 1.2 or 2.0

swizzle1 "$(ARMROOT)\RVCT\Programs\version#\release#\win_32-pentium\armcc" -via $(IntDir)\path.txt -c -g $(InputPath) -o $(IntDir)\$(InputName).o

4                   Use of RealView Assembler with Visual Studio

 

Any ARM assembler source files with .s extension can be added to a project and assembled by using similar settings as for C source files.

4.1              Define custom assemble steps

Change the Project Settings, General tab for any Assembler source file to 'Always use custom build step ' and change these fields in the Custom build tab. You can copy from a compile step and replace  ‘armcc’ with ‘armasm’ and remove ‘–c’ and add any needed Assembler options.

 

Again, the Custom Build tab fields Description, Commands and Outputs should be filled in the opposite order to that which they appear in the dialog because Visual Studio insists on having at least an output dependency whenever you change focus. The version#\release# should again be changed to correspond to your specific installation.

 

Project Settings dialog box

Outputs:

$(IntDir)\$(InputName).o

 

Commands:

For RVCT 2.1 or above

"$(ARMROOT)\RVCT\Programs\version#\release#\win_32-pentium\armasm" -g --diag_style=ide $(InputPath) –o $(IntDir)\$(InputName).o

uniqadd $(IntDir)\$(InputName).o $(IntDir)\link.via

Or for ADS 1.2 or RVCT 1.2 or 2.0

swizzle1 "$(ARMROOT)\RVCT\Programs\version#\release#\win_32-pentium\armasm" -g $(InputPath) –o $(IntDir)\$(InputName).o

uniqadd $(IntDir)\$(InputName).o $(IntDir)\link.via

 

Description:

RealView Assembling $(InputPath)

 

5                   Use of RealView Linker, fromelf and armar with Visual Studio

 

Visual Studio can also be configured to use the RealView linker, fromelf and armar.

5.1             Define custom post-build step to link

The linking of objects into an ELF executable to be debugged can be achieved by editing the Project Settings, selecting the root item (the project) in the FileView pane and modifying the Post-build step with a Post-build command to call the RealView linker.

Post-build description:

RealView Linking

Post-build commands:

For RVCT 2.1 or above

"$(ARMROOT)\RVCT\Programs\version#\release#\win_32-pentium\armlink" --diag_style=ide --info totals --via $(IntDir)\link.via -o $(TargetName).axf

Or for ADS 1.2 or RVCT 1.2 or 2.0

swizzle1 "$(ARMROOT)\RVCT\Programs\version#\release#\win_32-pentium\armlink" -info totals -via $(IntDir)\link.via -o $(TargetName).axf

5.2             Make the project

Now the Build menu commands, Build (F7), Compile (Ctrl+F7), Clean and Rebuild all will work as expected but using the RealView compilation tools.

 

5.3             Define optional fromelf custom post-link step

The ELF executable can be transformed into a form suitable for a Flash/EPROM by adding a second command to the Post-build step to call the RealView fromELF tool

 

Post-build commands:

For RVCT 2.1 or above

"$(ARMROOT)\RVCT\Programs\version#\release#\win_32-pentium\fromelf" --diag_style=ide -–m32 --output $(TargetName).m32 $(TargetName).axf

Or for ADS 1.2 or RVCT 1.2 or 2.0

swizzle1 "$(ARMROOT)\RVCT\Programs\version#\release#\win_32-pentium\fromelf" –m32 -output $(TargetName).m32 $(TargetName).axf

This creates an output binary file as a Motorola-S record.

 

5.4             Define optional armar custom post-link step

The object files can be added to a library by adding a third command to the Post-build step to call the RealView armar tool. The location of the object files are passed as in the link step using the link.via file.

 

Post-build commands:

--diag_style is not implemented in armar in RVCT 2.1. Consequently swizzle1.exe is needed in order to display error messages correctly in all versions of RVCT as well as ADS 1.2.

For RVCT 2.1 or above

swizzle1 "$(ARMROOT)\RVCT\Programs\version#\release#\win_32-pentium\armar" --create $(TargetName).a --via $(IntDir)\link.via

Or for ADS 1.2 or RVCT 1.2 or 2.0

swizzle1 "$(ARMROOT)\RVCT\Programs\version#\release#\win_32-pentium\armar" -create $(TargetName).a -via $(IntDir)\link.via

6                   Usage Limitations

There are a number of issues to be aware of when using Visual Studio.

 

·         Visual Studio does not know about RVCT #include dependencies, so modifying a header file will not cause a recompilation of all the source files which use it. However dependencies can be added to source files by selecting a source file in the Source Files group of the workspace view and use the Settings… context menu or

Project->Settings (Alt+F7) menu item, click on the dependencies tab to add the header file. Also header files are not automatically added into the Header Files group of the Workspace Files view.

 

·         Any compile (Ctrl+F7) or build (F7) attempt always tries to link possibly giving redundant link error messages.

 

·         Visual Studio does not know the options available to control RVCT and there is no GUI in Project Settings to ease this. You have to add new options manually into a dialog box text field that is smaller than is usually required. It is possible to use a via file to hold settings common to many compilation steps, see note below.

 

·         It is not possible to make the same edit apply to lots of files at once. However, it is possible to use a via file to hold settings common to many compilation steps, see note below.

 

         New files added to the project are compiled with the Microsoft C compiler until the Project Settings are changed to 'Always use custom build step' with the above commands.

 

         Changing a Custom Build command does not make an Output object file marked as out of date and requiring recompilation.

 

         Removing a source file from the project does not remove it from the via response file. Workaround: Delete the link.via file and use Project->Rebuild all.

 

Note           It is possible to use a via file containing common settings that can then included in multiple compilation or assembly steps. For example a via file \223setting.txt\224 could be made containing switches such as \223-g --fpu vfpv2 --cpu ARM1023E\224, the line --via settings.txt can then be inserted in the custom build steps. This saves altering every custom build line whenever an option needs to be changed. For more information on via files please see the RealView Compiler and Libraries guide.

 

 

 

 

 

 

Copyright © 2007 ARM Limited. All rights reserved. ARM DAI 0112B
Non-Confidential