Recently I have been experimenting with Parasoft’s C++test tool for static analysis of C and C++ code. As part of this I went through the process of importing an existing C project developed in IAR’s Embedded Workbench toolset. Even though importing a project and checking it against MISRA-C isn’t too taxing, I though I would share my notes for doing this.
Importing a project
Starting with C++test already open:
Select File->New Project
Expand the C++test wizard option
Select “Import IAR Embedded Workbench projects” option and click Next >
The following dialog will be presented
Click in the “Select .ewp/.eww file or root directory:” box.
Click the Browse button and navigate to the project directory of the IAR project you want to import and select the .ewp or .eww file for the project.
Click “Finish” to launch the Import.
Once imported the project will appear in C++test
Select the project by clicking on it (C501_Ex5 in this example) and select from the main menu Project->Properties (right-clicking on the project name also offers the properties option).
Select “Build Settings” under the C++test option.
We need to point C++test at the IAR compiler and linker.
First we need to change the “Family:” setting to the correct version of the compiler (Version 5.4 in this project).
Next, select the box for “C compiler:” and browse to where the iccarm.exe is installed. The default path is:
C:\Program Files\IAR Systems\Embedded Workbench 5.4 Kickstart\arm\bin\iccarm.exe
do the same for the “C++ complier” option, and for the Linker (be sure to select ilinkarm.exe here rather than iccarm.exe).
Select “Apply” and then “OK“.
Your are now ready to run C++test on your project.
Before running the static analysis on your project you may also need to define any include paths your project may need. This is documented at the end of this section.
To run, for example, the MISRA C 2004 static analysis on the project select
C++test->Test Using->Builtin->Static Analysis->MISRA C 2004
The checker will now run against the project files
Once completed it will report the number of violations (as Tasks Reported).
Click on the “Review Tasks” icon (the magnifying glass)
This will now display the rule violations broken down by severity
Expanding each Severity group will document each individual violation
Right-Clicking on a rule will bring up a context menu that allows you to go to the rule, suppress the rule or look at the rule definition.
By selecting “Go To” (alternatively just double-click the rule violation) the tool will take you to the actual code causing the rule violation.
Adding the IAR EW Library Headers
If you are including standard headers (i.e. #include <stddef.h>) then C++test may report it cannot find them. To set up the include path follow to steps below.
Bring up the project’s properties option as before, but select under “C/C++ General” the “Paths and Symbols” option.
The default path is:
C:\Program Files\IAR Systems\Embedded Workbench 5.4 Kickstart\arm\inc
So there you have it; pretty straightforward and easy to use.
Niall has been designing and programming embedded systems for over 30 years. He has worked in different sectors, including aerospace, telecomms, government and banking.
His current interest lie in IoT Security and Agile for Embedded Systems.
Latest posts by Niall Cooling (see all)
- Peripheral register access using C Struct’s – part 1 - January 24, 2019
- An Introduction to Docker for Embedded Developers – Part 5 Multi-Stage Builds - October 11, 2018
- Updated: Developing a Generic Hard Fault handler for ARM Cortex-M3/Cortex-M4 using GCC - September 21, 2018