Professional Documents
Culture Documents
COPYRIGHT
© Copyright 2009-2014 Atollic AB. All rights reserved. No part of this document may be reproduced
or distributed without prior written consent of Atollic AB. The software product described in this
document is furnished under a license and may only be used, or copied, according to the license terms.
TRADEMARKS
Atollic, Atollic TrueSTUDIO, Atollic TrueVERIFIER, Atollic TrueANALYZER and Atollic TrueSTORE and
the Atollic logotype are trademarks or registered trademarks owned by Atollic. ARM, ARM7, ARM9
and Cortex are trademarks, or registered trademarks, of ARM Limited. ECLIPSE is a registered
trademark of the Eclipse foundation. Microsoft, Windows, Word, Excel and PowerPoint are registered
trademarks of Microsoft Corporation. Adobe and Acrobat are registered trademarks of Adobe Systems
Incorporated. All other product names are trademarks, or registered trademarks, of their respective
owners.
DISCLAIMER
The information in this document is subject to change without notice and does not represent a
commitment of Atollic AB. The information contained in this document is assumed to be accurate, but
Atollic assumes no responsibility for any errors or omissions. In no event shall Atollic AB, its employees,
its contractors, or the authors of this document be liable for any type of damage, losses, costs, charges,
claims, demands, claim for lost profits, fees, or expenses of any nature or kind.
DOCUMENT IDENTIFICATION
TS-UG-ARM November 2012
REVISION
3rd June 2013 – Applies to Atollic TrueSTUDIO® v4.1
4th September 2013 – Applies to Atollic TrueSTUDIO® v4.2
5th November 2013 – Applies to Atollic TrueSTUDIO® v4.3
6th April 2014 – Applies to Atollic TrueSTUDIO® v5.0
7th June 2014 – Applies to Atollic TrueSTUDIO® v5.1
8th October 2014 – Applies to Atollic TrueSTUDIO® v5.2
ii | P a g e
Table of Contents
Contents
About this Document ............................................................. 29
Intended Readers ..................................................................................... 29
Document Conventions ........................................................................... 30
Getting Started .................................................... 31
Introduction .............................................................................................. 32
Support ..................................................................................................... 34
Lite, Pro and Premium Versions ............................................................... 35
Preparing for Start .................................................................................... 36
Workspaces & Projects ................................................................................... 36
Perspectives & Views ...................................................................................... 37
Views ................................................................................................ 40
Starting the Program ................................................................................ 42
Starting With Different Language ................................................................... 44
Change What is Started................................................................................... 45
Creating a New Project ............................................................................. 46
One-Click Example Project Installation ........................................................... 53
Using an Existing Project ................................................................................. 54
Creating a Static Library .................................................................................. 54
Creating a Makefile Project From Existing Code ............................................. 56
Importing From Processor Expert® ................................................................. 57
Configuring the Project’s Build Settings ................................................... 61
Debug and Release Build Settings ................................................................... 65
Source Folders ................................................................................................. 65
Include Libraries .............................................................................................. 68
Compiler Optimization .................................................................................... 69
Link Time Optimization (LTO) .......................................................................... 71
Changing Toolchain Version ............................................................................ 72
iii | P a g e
Table of Contents
Creating a .hex-File.......................................................................................... 75
Temporary Assembly File ................................................................................ 76
Building the Project .................................................................................. 78
Enable Build on Save ....................................................................................... 79
Rebuild All ....................................................................................................... 79
Headless Build ................................................................................................. 80
Logging ............................................................................................................ 82
The Build Size .................................................................................................. 82
Command Line Patterns .................................................................................. 84
Create .list-Files................................................................................ 85
Building One File ............................................................................................. 86
Linking the Project .................................................................................... 88
Referring Project ............................................................................................. 88
Dead Code Removal ........................................................................................ 90
Linker Script..................................................................................................... 90
Generate a New Linker Script ......................................................................... 91
Place Code In a New Memory Region ............................................................. 93
Place Variables at Specific Addresses ............................................................. 94
Linking In a Block of Binary Data ..................................................................... 95
Managing Existing Workspaces ................................................................ 97
Backup of Preferences for a Workspace ......................................................... 97
Copy Properties Between Workspaces ........................................................... 97
Keeping Track on Java Heap Space ................................................................. 98
Unlocking Locked Workspaces ........................................................................ 98
Managing Existing Projects..................................................................... 100
The Index ....................................................................................................... 100
Finding Include Paths, Macros etc. ............................................................... 102
Locate Where a File is Included .................................................................... 105
Creating Links to External Files ..................................................................... 105
I/O Redirection ....................................................................................... 107
iv | P a g e
Table of Contents
v|Page
Table of Contents
vi | P a g e
Table of Contents
vii | P a g e
Table of Contents
viii | P a g e
Table of Contents
ix | P a g e
Table of Contents
Mutexes......................................................................................................... 258
Message Queues ........................................................................................... 259
Event Flags .................................................................................................... 260
Timers............................................................................................................ 261
Memory Block Pools...................................................................................... 261
Memory Byte Pools ....................................................................................... 262
TOPPERS/ASP.......................................................................................... 264
Requirements ................................................................................................ 264
Finding the Views .......................................................................................... 264
Tasks .............................................................................................................. 265
Static Information Tab ................................................................... 265
Current Status Tab ......................................................................... 266
Dataqueues ................................................................................................... 267
Static Information Tab ................................................................... 267
Current Status Tab ......................................................................... 268
Event Flags .................................................................................................... 269
Static Information Tab ................................................................... 269
Current Status Tab ......................................................................... 270
Mailboxes ...................................................................................................... 270
Static Information Tab ................................................................... 271
Current Status Tab ......................................................................... 271
Memory Pools ............................................................................................... 272
Static Information Tab ................................................................... 272
Current Status Tab ......................................................................... 273
Cyclic Handlers .............................................................................................. 274
Static Information Tab ................................................................... 274
Current Status Tab ......................................................................... 275
Alarm Handlers.............................................................................................. 275
Static Information Tab ................................................................... 276
x|Page
Table of Contents
xi | P a g e
Table of Contents
xii | P a g e
Table of Contents
xiii | P a g e
Table of Contents
xiv | P a g e
List of Figures
Figures
Figure 1 - Workspaces and Projects ............................................................. 37
Figure 2 – Editing Perspective ...................................................................... 38
Figure 3 - Switch Perspective ....................................................................... 39
Figure 4 - Switch Perspective ....................................................................... 39
Figure 5 – Toolbar Buttons for Perspectives and Views .............................. 39
Figure 6 - View Menu toolbar button .......................................................... 40
Figure 7 - Show View Dialog Box .................................................................. 41
Figure 8 – Toolbar Buttons for Perspectives and Views .............................. 41
Figure 9 - Workspace Launcher .................................................................... 42
Figure 10 - Information Center .................................................................... 43
Figure 11 – Information Center Menu Command ....................................... 44
Figure 12 – Information Center Toolbar Button (A)..................................... 44
Figure 13 – Startup Preferences................................................................... 45
Figure 14 – Project Creation Buttons ........................................................... 46
Figure 15 - Starting the Project Wizard ........................................................ 46
Figure 16 - C Project Configuration .............................................................. 47
Figure 17 - TrueSTUDIO® Hardware Configuration ...................................... 48
Figure 18- TrueSTUDIO® Software Configuration ........................................ 49
Figure 19 - TrueSTUDIO® Debugger Configuration ...................................... 50
Figure 20 - Select Configurations ................................................................. 51
Figure 21 - Project Explorer View ................................................................. 52
Figure 22 – Editor View ................................................................................ 52
Figure 23 – Project Creation Buttons ........................................................... 53
Figure 24 – Atollic TrueSTORE ...................................................................... 53
Figure 25 – Selection of Existing Project File ............................................... 54
Figure 26 – Selection of Static Library Project ............................................. 55
Figure 27 – Create a Makefile Project from existing code ........................... 56
Figure 28 – Locate the code and select <none> .......................................... 56
Figure 29 – Edit the PATH variable ............................................................... 57
Figure 30 – Import Existing Projects into Workspace .................................. 58
Figure 31 – Edit the PATH variable ............................................................... 58
Figure 32 – Processor Expert Integration console ....................................... 59
Figure 33 – Project Created by Processor Expert......................................... 59
Figure 34 – Project Created by Processor Expert......................................... 60
xv | P a g e
List of Figures
xvi | P a g e
List of Figures
xvii | P a g e
List of Figures
xviii | P a g e
List of Figures
xix | P a g e
List of Figures
xx | P a g e
List of Figures
xxi | P a g e
List of Figures
Figure 257 – TOPPERS Cyclic Handlers Static Information Tab .................. 274
Figure 258 – TOPPERS Cyclic Handlers Current Status Tab........................ 275
Figure 259 – TOPPERS Alarm Handlers Static Information Tab ................. 276
Figure 260 – TOPPERS Alarm Handlers Current Status Tab ....................... 276
Figure 261 - View Top Level Menu ............................................................. 279
Figure 262 - Show View Toolbar Button .................................................... 279
Figure 263 - µC/OS-III System Information View ....................................... 280
Figure 264 - µC/OS-III Task List View.......................................................... 281
Figure 265 - µC/OS-III Semaphores View ................................................... 283
Figure 266 - µC/OS-III Mutexes View ......................................................... 283
Figure 267 - µC/OS-III Message Queues View............................................ 284
Figure 268 - µC/OS-III Event Flags View ..................................................... 285
Figure 269 - µC/OS-III Timers View ............................................................ 286
Figure 270 - µC/OS-III Memory Partitions View ......................................... 287
Figure 271 – Atollic TrueSTUDIO Support for the Code Review Workflow 290
Figure 272 – Project Properties Menu Selection ....................................... 293
Figure 273 - GUI for Creating and Managing Code Reviews ...................... 293
Figure 274 - Dialog for Creating a New Review ID ..................................... 294
Figure 275 - Dialog for Managing the Work Product of a Review ............. 294
Figure 276 - Add Reviewers to the Review ................................................ 295
Figure 277 - Choose Author for the Review Session .................................. 295
Figure 278 - Review Comment Parameter Options ................................... 296
Figure 279 - Setting Default Options for Review Parameters .................... 296
Figure 280 - Naming the Review Issue Data Folder ................................... 297
Figure 281 - Filter Settings for the Different Phases .................................. 297
Figure 282 - Editing the DEFAULT Review Template ................................. 299
Figure 283 - Code Review Selected via Open Perspective Command ....... 300
Figure 284 - The Code Review Perspective ................................................ 300
Figure 285 – The Code Review Table View ................................................ 301
Figure 286 – The Code Review Editor View ............................................... 302
Figure 287 - Individual Phase Selected in the Code Review Toolbar ......... 303
Figure 288 - Reviewer ID Selection Dialog ................................................. 303
Figure 289 - The Source Code Button & Drop-Down Menu ...................... 304
Figure 290 - Add Code Review Issue... ....................................................... 304
Figure 291 – A Code Review Issue in the Review Editor View ................... 304
Figure 292 - Review Marker Displayed on Editor Line 101 ........................ 305
Figure 293 - Team Phase Toolbar Button................................................... 305
xxii | P a g e
List of Figures
Figure 294 - Code Review Editor View Content in Team Phase................. 306
Figure 295 - Review Markers and Tooltip Information in the Editor ......... 306
Figure 296 - Team Phase Toolbar Button................................................... 307
Figure 297 - Code Review Editor View Content in the Rework Phase ....... 308
Figure 298 - Accessing Code Review Preference Settings ......................... 308
Figure 299 - Customize Filters Applied for All Phases ................................ 309
Figure 300 - Customize Visible Code Review Table Columns .................... 309
Figure 301 - The Rule Setting Panel ........................................................... 313
Figure 302 - Selecting Rules ....................................................................... 314
Figure 303 - Excluding files and folders from analysis ............................... 315
Figure 304 – Opening the Static Code Analysis Perspective ...................... 316
Figure 305 - Starting a Code Analysis Session ............................................ 316
Figure 306 - The Static Code Analysis Perspective ..................................... 317
Figure 307 - MISRA violations in the editor ............................................... 317
Figure 308 - The static code analysis perspective ...................................... 318
Figure 309 - The Inspection Summary View (Rule mode) .......................... 319
Figure 310 - The Inspection Summary View (Severity mode) .................... 319
Figure 311 - The Inspection Summary View (Source mode) ...................... 320
Figure 312 - The Inspection Summary View (Syntax Error mode) ............. 320
Figure 313 - The Rule Description View ..................................................... 321
Figure 314 - The Violation View ................................................................. 322
Figure 315 - Individual Violations ............................................................... 322
Figure 316 – Generate Report Toolbar Button .......................................... 322
Figure 317 - The Report Generator Dialog Box .......................................... 323
Figure 318 - The Open Folder Message Box .............................................. 323
Figure 319 - View the Generated Report ................................................... 324
Figure 320 – The Code Metric View (Module Mode)................................. 327
Figure 321 – Metric Mode Toolbar Button ................................................ 327
Figure 322 - The Code Metric View (File Mode) ........................................ 328
Figure 323 – Metric dropdown list ............................................................. 328
Figure 324 – Metric Mode Toolbar Button ................................................ 328
Figure 325 - The Code Metric View (Function Mode) ................................ 329
Figure 326 – Generate Report Toolbar Button .......................................... 330
Figure 327 - The Report Generator Dialog Box .......................................... 330
Figure 328 - The Open Folder Message Box .............................................. 330
Figure 329 – Rule Violation Markers .......................................................... 331
Figure 330 – Remove Violation Button ...................................................... 331
xxiii | P a g e
List of Figures
xxiv | P a g e
List of Figures
xxv | P a g e
List of Figures
xxvi | P a g e
List of Tables
Tables
Table 1 – Typographic Conventions ............................................................. 30
Table 2 – Exception Data Columns ............................................................. 201
Table 3 – Exception Statistics Columns ...................................................... 202
Table 4 – embOS System Variables ............................................................ 223
Table 5 – embOS Task Parameters............................................................. 224
Table 6 – embOS Timer Parameters .......................................................... 225
Table 7 – embOS Resource Semaphore Parameters ................................. 226
Table 8 – embOS Mailbox Parameters ....................................................... 227
Table 9 – eTaskSync Task Parameters ........................................................ 229
Table 10 – FreeRTOS Task Parameters....................................................... 233
Table 11 – FreeRTOS Queue Parameters ................................................... 234
Table 12 – FreeRTOS Semaphore Parameters ........................................... 235
Table 13 – FreeRTOS Timer Parameters .................................................... 236
Table 14 – MQX Task Parameters .............................................................. 238
Table 15 – RTXC Kernel Information .......................................................... 241
Table 16 – RTXC Task List Parameters........................................................ 243
Table 17 – RTXC Stack Info ......................................................................... 243
Table 18 – RTXC Alarm Parameters ........................................................... 244
Table 19 – RTXC Counter Parameters ........................................................ 245
Table 20 – RTXC Event Source Parameters ................................................ 246
Table 21 – RTXC Exception Backtrace Parameters .................................... 247
Table 22 – RTXC Exception Parameters ..................................................... 248
Table 23 – RTXC Mailbox Parameters ........................................................ 248
Table 24 – RTXC Mutex Parameters ........................................................... 250
Table 25 – RTXC Partition Parameters ....................................................... 251
Table 26 – RTXC Pipe Parameters .............................................................. 252
Table 27 – RTXC Queue Parameters .......................................................... 253
Table 28 – RTXC Semaphore Parameters................................................... 254
Table 29 – ThreadX Thread Parameters..................................................... 257
Table 30 – ThreadX Semaphore Parameters ............................................. 258
Table 31 – ThreadX Mutex Parameters ..................................................... 259
Table 32 – ThreadX Message Queue Parameters ...................................... 260
Table 33 – ThreadX Event Flag Parameters ............................................... 260
Table 34 – ThreadX Timer Parameters....................................................... 261
xxvii | P a g e
Overview
xxviii | P a g e
Introduction
INTENDED READERS
This document is primarily intended for users of Atollic TrueSTUDIO®, or any of the
bundled products Atollic TrueANALYZER® and Atollic TrueVERIFIER®.
29 | P a g e
Introduction
DOCUMENT CONVENTIONS
The text in this document is formatted to ease understanding and provide clear and
structured information on the topics covered. The following typographic conventions
apply:
Style Use
Identifies a Caution.
30 | P a g e
Getting Started
GETTING STARTED
This section provides information on how to begin using Atollic TrueSTUDIO® for ARM®.
Introduction
Debugging
31 | P a g e
Getting Started
INTRODUCTION
Welcome to Atollic® TrueSTUDIO® and its optional add-on modules! The TrueSTUDIO
product family is the most powerful C/C++ IDE available for development of high-quality
ARM® software.
Atollic believe the world deserves better embedded software, and our vision is to provide
the best tools available anywhere to create high-quality embedded software. Unlike
traditional C/C++ development tools, the TrueSTUDIO IDE guides you through the process
of developing high quality software. TrueSTUDIO brings the best principles from the
automotive and aerospace industries to all embedded developers. We offer 7 specific
functionality modules to help improve the software quality:
32 | P a g e
Getting Started
Using the above modules for software engineering, team collaboration, code analysis,
automatic software testing and test quality measurement, embedded products of superior
quality can be released. Make sure to use the advanced productivity and quality enhancers
available in Atollic TrueSTUDIO and its optional add-on modules!
33 | P a g e
Getting Started
SUPPORT
Atollic provides technical support from our European and USA offices, and via our
international distributors in various countries all over the world.
Technical support is granted to customers with Atollic TrueSTUDIO Pro or Premium license
and a valid Support & Upgrade Agreement (SUA) license. Always make sure to state the
SUA-license number when requesting Support.
support@atollic.com
support.usa@atollic.com
Atollic Support Team always tries to solve the problem with the fastest possible response-
time. The support lead-time can be dramatically reduced by taking the following important
pro-active steps:
For any other type of problem - always attach the workspace log-file. This file is
named .log, and is located in %WORKSPACE%\.metadata\
For problems related to building, attach the project build log. By default it is
found in
%WORKSPACE%\.metadata\.plugins\org.eclipse.cdt.ui\myProject.b
uild.log
Include the USB-key number for problems with an USB-license Key. The number is
found on the USB-license key.
34 | P a g e
Getting Started
The Premium version also includes the Atollic TrueVERIFIER® unit testing tool and the
Atollic TrueANALYZER® MC/DC-level code coverage analysis tool in a single seamless and
smoothly integrated package. The TrueSTUDIO Premium version is designed to help
embedded systems developers to achieve two important, but often mutually exclusive,
goals of achieving higher software quality, while at the same time, meeting ever increasing
time-to-market requirements for product releases.
For more information on the features and differences between the Lite and Pro version,
please read the Atollic TrueSTUDIO® Feature Comparison Guide, which is available here:
www.atollic.com/index.php/feature-comparison
35 | P a g e
Getting Started
A single computer may hold several workspaces at various locations in the file
system. Each workspace may contain many projects.
The user may switch between workspaces, but only one workspace can be active
at any one time.
The user may access any project within the active workspace. Projects located in
another workspace cannot be accessed, unless the user switches to that
workspace.
Switching workspace is a quick way of shifting from one set of projects to another
set of projects. It will trigger a quick restart of the product.
36 | P a g e
Getting Started
Atollic TrueSTUDIO®
Debugging
Version Control
Code Review
37 | P a g e
Getting Started
As an example, the C/C++ Editing perspective displays docking views that relate to code
editing, such as Editor Outline and Class Browser. The Debug perspective displays docking
views that relate to Debugging, such as Breakpoints and CPU Registers.
Switching from one perspective to another is a quick way to hide some docking views and
display others.
As the figure below outlines, the idea is that one perspective shall be used for each work
task. It is however clear that one perspective, the C/C++ editing perspective is the
“master” perspective where developers spend most time. Therefor that perspective is the
center-point of Atollic TrueSTUDIO, and developers temporarily jump to other
perspectives to do other tasks, and when completed, jump back to the editing and building
perspective again.
The C/C++ Editing perspective is also the perspective that is opened when Atollic
TrueSTUDIO is started the first time.
Version
control
Editing
Debug
Building ...
We think it is valuable to use the editing and building perspective as the master
perspective, and all other perspectives used temporarily for other work tasks.
To switch perspective, select the Open Perspective toolbar button or use the menu
command View, Open Perspective:
38 | P a g e
Getting Started
Alternatively, click any of the perspective buttons in the top right corner of the main
window (only the last few ones active are displayed here):
One can always return to the default C/C++ Editing and Building perspective by clicking the
Return to editor and building perspective toolbar button (D). Editing and Building is the
main activity for most C/C++ developers, hence the dedicated button.
39 | P a g e
Getting Started
VIEWS
When Atollic TrueSTUDIO is started for the first time, the C/C++ Editing Perspective is
activated by default. This perspective does not show all available docking views by default,
to reduce information overload. The same principle applies to all perspectives.
To access additional features built into the product, open additional docking views. To do
this, select the View toolbar button (C) or use the menu command View:
The above list of views, while comprehensive, is still not complete. This list only contains
the most common views for the work task related to the currently selected Perspective. To
access even more docking views, select Other… from the list. This opens the Show View
dialog box. Double click on any docking view to open it and access the additional features:
40 | P a g e
Getting Started
Information Center (A) – Displays the initial welcome screen from the first time the
product was started, after being installed. More details will follow in “Starting the
Program” below.
41 | P a g e
Getting Started
6. Wait for the program to start, and the Workspace Launcher dialog to be
displayed.
This dialog enables the user to select the name and location of the Active
Workspace. The Active Workspace is a folder that will hold all projects
currently accessible by the user. The user may open any existing project in the
workspace. Any newly created projects will be stored in the workspace.
7. Enter the full name (with path) of the workspace folder to be used for the current
session. Alternatively, browse to an existing workspace folder, or use the default
workspace folder. This is located within the home directory of the current user,
e.g. C:\Users\User\Atollic\TrueSTUDIO
If the appointed workspace folder does not yet exist, it will be created.
42 | P a g e
Getting Started
The user must have write-access to the home directory to be able to start
Atollic TrueSTUDIO®.
Atollic recommends that the Active Workspace folder is located not too
many levels below the file system root. This is to avoid exceeding the
Windows® path length character limitations. This can cause build errors if the
file paths become longer than Windows can handle.
43 | P a g e
Getting Started
This window enables the user to quickly reach information regarding the product, and how
to use it, by clicking on the corresponding hypertext links. It is not required to read all
material before using the product for the first time. Rather, it is recommended to consider
the Information Center as a collection of reference information to return to, whenever
required during development.
The Information Center window may be reached at any time via the Help, Welcome menu
command or via the Information Center toolbar button.
10. Start using Atollic TrueSTUDIO® by closing the Welcome page (click the “X” in
the Welcome page tab above its main window area). The Information Centre
window is closed, but may be restored at any time, as described above.
44 | P a g e
Getting Started
45 | P a g e
Getting Started
The toolbar has three buttons for quick creation of new projects.
46 | P a g e
Getting Started
47 | P a g e
Getting Started
48 | P a g e
Getting Started
Please note that evaluation boards may have hardware switches for
configuration of Code location in RAM or FLASH. The setting selected in the
project wizard must correspond to the settings on the board.
The Mix HW/SW implementation is for those projects that have libraries that
aren’t compiled for hardware floating point. In this implementation the
function calls are not using the FPU-registers as in a pure Hardware
implementation. The FPU will however still be used inside the project
functions.
When finished, click the Next button.
Select the desired Runtime library to be used. For information about the
differences between Newlib–nano and the regular Newlib, please refer to the
Newlib-nano readme file, accessible from the Information Center (Figure 10).
If the target board has a limited amount of memory, the Use tiny
printf/sprinf/fprintf (small code size) setting is recommended. If there are no
particular memory requirements, use the default selection.
When finished, click the Next button.
49 | P a g e
Getting Started
Atollic TrueSTUDIO® supports several different types of JTAG probes. Select the
probe to be used during debugging.
When finished, click the Next button.
50 | P a g e
Getting Started
51 | P a g e
Getting Started
7. Expand the project folder (“MyProject” in this example) and the src
subfolder in the Project Explorer docking view.
8. Double click on the main.c file in the Project Explorer tree to open the file
in the editor.
52 | P a g e
Getting Started
To find the examples relevant to a specific target board, select the Download button in the
toolbar (C in the image below).
53 | P a g e
Getting Started
Select the project(s) of interest and click Finish. The project is imported into the Active
Workspace and is immediately ready to be built and executed on the target board.
The whole process typically takes less than a minute.
Wait for Atollic TrueSTUDIO® to start, as a result of double-clicking the .project file.
Please note that if the File Browser is configured not to display file extensions,
two nameless icons will appear in the file list, representing the .project and
the .cproject files. The use of files without a filename is an unfortunate
heritage from the ECLIPSE™ framework.
54 | P a g e
Getting Started
The project will then be built as an archive file with the name lib{project-namn}.a, as
for an instance libMyLibrary.a
If the library project should be recompiled at the same time as the project
that have included it, the library project should be added as a reference to
the other project. Select Project, Properties and in Project References select
the library project.
The command line tools are needed to create an archive file from an object file without
first creating a library project.
55 | P a g e
Getting Started
Enter the name of the new project and the location of the existing code.
Make sure to select <none> as the Toolchain for the Indexer Settings.
Then add the path to the existing toolchain to the system PATH environment variable.
That can be done from within Atollic TrueSTUDIO by select Project, Properties and then
C/C++ Build, Environment.
Locate the PATH variable in the list, select it and click Edit. If PATH can’t be located, click
Add and write PATH in the Name textbox.
56 | P a g e
Getting Started
In the Value textbox, add the full path to the location of the toolchain, and also any other
location from where any executables in the makefile are located. Separate the paths with
a “;”.
57 | P a g e
Getting Started
In the next panel enable Select root directory if the project is not compressed
and enable Select archive file if it is distributed as a zipped file.
Click Finish
58 | P a g e
Getting Started
Atollic TrueSTUDIO will now automatically import the project, create a build
configuration named Debug_TrueSTUDIO (see page 61) and change the project
paths to become relative and not absolute.
The linker script is set to be the one automatically managed by Processor Expert.
Projects that Atollic TrueSTUDIO recognizes are created with Processor Expert is
marked with a small P-icon.
What is happening behind the scene is that the ProjectInfo.xml file is read and its
content used to create a new build configuration. Every time ProjectInfo.xml is
changed (often done automatically be Processor Expert), the build configuration is
updated with the new information in the file. Old source folders and includes will not be
removed.
The build configuration for the project can be forced to re-read ProjectInfo.xml
by just change the file manually.
59 | P a g e
Getting Started
It is strongly recommended that the projects created with Processor Expert is set to be
Standalone. If not, some files included in the project will be placed in the Processor Expert
installation. If Processor Expert is installed and integrated into Atollic TrueSTUDIO, the
includes for the project will be placed in the current Atollic TrueSTUDIO installation. This
might cause problem when updating Atollic TrueSTUDIO.
60 | P a g e
Getting Started
Atollic TrueSTUDIO® provides extensive GUI controls for configuration of command line
tool options using a simple point-and-click mechanism.
2. Click on the Build settings toolbar button or select Project, Build Settings….
4. Expand the C/C++ Build item in the tree in the left column. Then select the
Settings item to display the build Settings panel.
61 | P a g e
Getting Started
5. Select panels as desired and configure the command line tool options using
the GUI controls.
Advanced users may wish to enter command line options manually. This can be
done in the Miscellaneous panel for any tool.
62 | P a g e
Getting Started
6. Some project build settings are relevant for both Managed Mode projects
and Unmanaged Mode projects. For instance the selected microcontroller
or evaluation board may affect both the options to the compiler during a
Managed Mode build, and also how additional components in Atollic
TrueSTUDIO, for instance the SFR docking view, and debugger, will behave.
Project build settings relevant for both Managed Mode projects and
Unmanaged Mode projects are collected in the Target Settings panel.
The Build Settings are sometimes also referred to as the Build Configurations.
63 | P a g e
Getting Started
Changing to a different hardware target, will cause a new linker script file
(.ld) to be generated, with FLASH and RAM settings adjusted to the
memory size of the new target device.
However, libraries, header files, etc. will not be generated automatically for
the new target! These must be added manually to the project.
Furthermore, the new linker script needs to be edited manually, to include
the linker settings found in the Tool Setting, C Linker, General panel.
64 | P a g e
Getting Started
Settings done in the project will mostly only affect the current configuration. When most
of the development is done and it is time to switching to the Release configuration, there
might be a lot of settings done under the development process that is missing in the
Release configuration.
To make sure that the Release configuration contains all necessary settings, it may be
easiest to create a new Release configuration, copy the settings from the Debug
configuration, and then just change the debug information level and optimization level.
1. Select the project in the Project Explorer and right click Project, Manage Build
Configurations…
2. Delete the old Release configuration or the configuration that does not have all the used
settings
3. Click New…
6. Click OK.
Next, open up Project, Properties, and navigate to C/C++ Build, Settings, Tool Settings. In
the Debugging node, for the Assembler and C/C++ Compiler, set the debug level to none.
Then select an optimization level in the Optimization node for the C/C++ Compiler.
The build output folder will be named as the active build configuration. So when the
project is built, the .elf file will be located in the Release folder for the new Release
configuration.
SOURCE FOLDERS
A folder within a project can be recognized as a source folder if it is annotated with a small
C-icon in the Project Explorer.
65 | P a g e
Getting Started
To make Atollic TrueSTUDIO handle an existing folder as a new source folder do the
following steps:
1. Select the project and in the top menu select Project, Properties.
2. In the Properties panel open C/C++ General, Paths and Symbols and then the Source
Location tab.
66 | P a g e
Getting Started
67 | P a g e
Getting Started
INCLUDE LIBRARIES
In order to include a library into a project right-click on the project where the library will
be included; select Properties, C/C++ Build and Settings. Then select the Tool Settings-tab,
select C Linker, Libraries.
68 | P a g e
Getting Started
1. In the Libraries list add the name of the library - not the path! The name is the
filename without “lib” prefix and without the file extension (.a). It is important
not to include those parts of the name. This is a GCC convention.
If by any chance the library’s name don’t confirm to the GCC convention, the full
name to the library can be entered, preceded by a colon “:”.
2. In the Library Paths list, set the path to where the library is located. Do not
include the name of the library in the path.
The included libraries can also be found by right-clicking the project and select C/C++
General and open the Libraries-tab and the Libraries Path-tab.
After a project is referring to another project, be that a library or a normal project that
information needs to be provided to Atollic TrueSTUDIO. See Referring Project on page 88
for more information.
COMPILER OPTIMIZATION
The GNU C/C++ compiler (and hence Atollic TrueSTUDIO) have 6 levels of compiler
optimization; -O0 for no optimization up to -O3 for full optimization. There is one level for
size optimization (-Os) which is commonly required in embedded projects and another
level for speed optimization (-Ofast).
Also available is a level for turning on optimizations that won’t interfere with the debug
experience (-Og).
69 | P a g e
Getting Started
The optimization setting is per Build Configuration. Per default the Debug configuration is
optimized with –O0 and the Release configuration has -Os.
70 | P a g e
Getting Started
To define a specific optimization level on a block of code, use the optimize attribute on the
block:
However, because of the way this works also means that in order to use this feature fully it
is necessary to provide the linker tool with some extra information that usually has only
been supplied to the compiler tool. This extra information can be any optional extra flag
that you might have added to the compiler process.
In most cases however it will only be required to add the following flags to the Linker tool
Miscellaneous field
71 | P a g e
Getting Started
The optimization flag (-Os) should have the same value as the optimization flag for the
compiler, see page 68 for more information.
It is also required to change the Compiler tool settings and there add the –flto flag to the
miscellaneous field.
72 | P a g e
Getting Started
Default – This option will use the tool chain in the currently running installation of
TrueSTUDIO.
When working with a version control system in a team, the second option is
strongly recommended for a project. That way all developers will use the same
toolchain even if using different versions of Atollic TrueSTUDIO.
73 | P a g e
Getting Started
These setting are saved individually for each Project’s Build Configuration. That way it is
possible to have different Build Configurations using different toolchain versions. That way
a quick regression test can be created.
To create a new Debug Build configuration for an older version of the toolchain, do the
following:
3. Enter a good name for the new Build Configuration. Use one word, such as
OldToolChain, without white space and press OK and OK again in the Manage
Configuration panel.
74 | P a g e
Getting Started
4. In the Toolchain Version tab it is now possible to set the Default version of the tool
chain for the normal Debug Build Configuration and a Fixed TrueSTUDIO version for
the OldToolChain Build Configuration.
Figure 54 – Old Tool Chain Version for the New Build Configuration
CREATING A .HEX-FILE
To convert your program to another output format, do the following:
1. Open up Project, Properties, C/C++ Build, Settings, Tool Settings, Other, Output
format
2. Check the box Convert build output and choose a format in the dropdown menu.
75 | P a g e
Getting Started
The converted output will be located in the output directory associated with the currently
active build configuration, typically Debug/Release directory.
Other supported file formats are: Binary, S-record, S-record with symbols and Verilog Hex
Dump.
To manually create .hex-files and .bin-files, add Post-build steps in the Build Step tab:
76 | P a g e
Getting Started
The assembler file will be located in the build output directory and will be called:
FILENAME.s
77 | P a g e
Getting Started
The Build result is displayed in the Console window. At the end are the code size figures.
For example:
The values are organized according to memory sections and areas. Per default, the linker
arranges the memory into the sections text, data, bss. More information is found
in the linker script file (.ld).
The dec and hex figures express the size of the .elf file. Below the filename header
is the name of the .elf file.
78 | P a g e
Getting Started
In the top menu select Project, Properties and in the Properties panel select C/C++ Build.
Open the Behavior tab and enable Build on resource save.
REBUILD ALL
To force a Rebuild of all files included in the project, click on the Rebuild toolbar button or
select the menu command Project, Rebuild Project.
79 | P a g e
Getting Started
HEADLESS BUILD
This is intended for Managed Mode projects that are to be integrated into script-
controlled builds, such as nightly builds on build servers for continuous integration process
methods, etc. It is possible to start a build process from the operating system command
line also for Managed Mode projects. The IDE GUI is never displayed in this case, and the
user does not have to interact manually with the IDE at all.
In order to be able to run the headless build on a virtual machine server, the USB-locked or
the floating network license is needed for the server. Atollic TrueSTUDIO will only run as a
script with the headless Build, therefore there is no need for using the remote desktop
license type.
80 | P a g e
Getting Started
Option Description
-data {[uri:/]/path/to/workspace} This option is always required and selects which workspace
to use for the headless build. If the selected workspace
folder does not exist, it will be created automatically.
-import {[uri:/]/path/to/project} Optionally import a project into the workspace before the
headless build starts.
-importAll {[uri:/]/path/to/projectTreeURI} Optionally import several projects into the workspace
before the headless build starts.
-build {projname_reg_exp} Build all build configurations of the selected project. If the
project name contains wildcards (? and *), all matching
projects will be built.
-build {projname_reg_exp/configname} Build the selected project using only the selected build
configuration. If the project name contains wildcards (?
and *), all matching projects will be built.
-build all Build all configurations of all projects in the selected
workspace.
-cleanBuild {projname_reg_exp} Rebuild all build configurations of the selected project. If
the project name contains wildcards (? and *), all matching
projects will be rebuilt.
-cleanBuild {projname_reg_exp/configname} Rebuild the selected build configuration of the selected
project. If the project name contains wildcards (? and *), all
matching projects will be rebuilt.
-cleanBuild all Rebuild all build configurations of all projects in the
selected workspace.
-I {include_path} Additional include path to add to tools.
81 | P a g e
Getting Started
Example:
This command will create a temporary workspace folder buildWS for this build. It will
import all projects from the folder checkOutDir (not copy, just import to the temporary
workspace) and build all build configurations defined in each project. The result will be
stored in the folder checkOutDir. A log file will be created in the folder headless.
LOGGING
To enable project build logging, right-click on the project and select Properties. Then
select C/C++ Build, Loggings.
WORKSPACE_PATH\.metadata\.plugins\org.eclipse.cdt.ui\MyProjec
t.build.log
A global build log for all projects in a workspace can be enabled by selecting Window,
Preferences and in the dialog open C/C++, Build, Logging and Enable global build logging.
To study the properties (such as code or data size) of an object file, open the Properties
view.
To open the Properties view, press the Show View toolbar button and select the
Properties view.
82 | P a g e
Getting Started
Then select the object file in the Project Explorer view. The Property view will display a
large number of properties, including code and data sizes of the object module.
To study the properties (such as code or data size) of a linked application binary file, open
the Properties view and select the ELF file in the Project Explorer view.
83 | P a g e
Getting Started
The Property view will display a large number of properties, including code and data sizes
of the complete application.
Data is normally stored in the “data" segment and code is normally stored in the "text"
segment.
84 | P a g e
Getting Started
In the C/C++ Build, Settings select the Tool Settings tab. Each one of the different tools in
the toolchain (Assembler, Compiler, Linker and Other) has its own patter that can be
modified.
White space and other characters are significant and are copied to the created command.
But the environment variables can also be used. They are defined in Project, Properties,
C/C++ Build, and then Environment.
CREATE .LIST-FILES
To get list files with assembler information when the files in the projects are compiled the
build settings for the C/C++ compiler needs to be updated.
In the C/C++ Build, Settings select the Tool Settings tab and then C Compiler. In the Expert
settings for Command Line Pattern add -Wa,-aln=${OUTPUT}.list as shown below.
85 | P a g e
Getting Started
In the top menu select Window, Customize Perspective and in the dialog window open
the Menu Visibility tab.
Expand the Project node and enable the Build Automatically option.
Press OK, then go to the Project menu and make sure Build automatically is unchecked for
the project.
86 | P a g e
Getting Started
87 | P a g e
Getting Started
The manual can also be found from the Windows start menu when selecting Atollic,
TrueSTUDIO, Manuals, Command line Tools, Linker
This chapter will explain some of the more common problems encountered during linking.
REFERRING PROJECT
Whenever one project is using code from another project, these should be referring to
each other.
88 | P a g e
Getting Started
In the top menu select Project, Properties and select Project References. Then select and
mark the referred project.
The referred project will now be rebuilt when needed and the Indexer will also be able to
find functions from the library and open them. To do that press the Ctrl key and in the
editor, click the library-function where it is used. The source file in the library will then be
opened in an editor.
The library will also be able to create the Call hierarchy of its functions. To find it, mark the
function name and press Ctrl+Alt+H. The Call Hierarchy will then be displayed in the Call
Hierarchy view.
If a project needs to refer to a specific build of another project, select instead Project,
Properties and then C/C++ General, Paths and Symbols and open the References tab and
select the Build Configuration that the current project is referring to.
89 | P a g e
Getting Started
With this way of referring between different Build configurations, the involved project will
not be rebuilt more than necessary.
To enable linker optimization, select the Remove unused code and/or the Remove unused
data checkboxes in the Project wizard as appropriate (at project creation time).
LINKER SCRIPT
The linker (.ld) script file defines where things end up in memory.
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >FLASH
This tells the linker to put all .text, .rodata etc. sections in the FLASH region. It is possible to
define new memory regions and decide where a specific code section shall end up. Please
read the Linker manual, accessible from the Atollic TrueSTUDIO Windows start menu
entry, for details about how the linker works. Especially section 3.6 and 3.7 could be of
interest.
90 | P a g e
Getting Started
When building a Project Wizard generated project in Atollic TrueSTUDIO, a .map file is
created in the build output folder (Debug/Release). In this file can be seen exactly which
address the linker has put the code/data.
The initialization of the .data section is done in the startup code, generated by the
TrueSTUDIO project wizard. It just copies the init values of the variables to RAM.
To automatically create a new linker script, start by selecting the project to add the script
into. Right click the project and select New, Other…
1. In the dialog that then pops up select C/C++ and then Linker script.
2. Click Next.
91 | P a g e
Getting Started
3. The target must now be select properly. Here is the chance to select a new target.
The current settings can be found by right-clicking the project and selecting
Properties, C/C++ Build, Settings.
4. Click Finish.
In order to use the new script right-click the project and select Properties and in the
dialog select C/C++ Build, Settings and in the panel select the Tool Settings-tab, C Linker,
General.
The check-box Do not use standard start files gives two options to execute user-defined
code before entering main, instead of modifying the Reset-handler. Both are triggered by
the libc_init_array call in the startup code.
Option1: Constructors for objects or constructor functions are placed in a list called
.init_array. These functions are then executed one by one by the libc_init_array.
Option2: Add code to a .init section. libc_init_array will run the _init function which will
execute all instructions added to the .init section. The crti and crtn contains the start and end
of the _init function.
92 | P a g e
Getting Started
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 128K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 16K
MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K
}
Add a new area by editing the file. In this example the IP-Code region is added.
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K
IP_CODE (x) : ORIGIN = 0x08010000, LENGTH = 64K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 8K
MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K
}
Variables and functions may not be placed in the same memory region.
Place the following code a bit further down in the script, between the .data { ... } and the
.bss { ... } section:
.ip_code :
{
*(.IP_Code*);
} > IP_CODE
This tells the linker to place all sections named .IP_Code* into the IP_CODE memory region
which is specified to start at target memory address: 0x8010000.
In the C-code, tell the compiler which functions should go to this section by adding
__attribute__((section(".IP_Code"))) before the function declaration.
Example:
93 | P a g e
Getting Started
The placed_logic()-function will now be placed in the IP_CODE memory region by the
linker.
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 128K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 16K
MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K
}
A new memory region should be added by editing the file. In this example add the MYVARS
region.
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K
MYVARS (x) : ORIGIN = 0x08010000, LENGTH = 64K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 8K
MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K
}
Variables and functions may not be placed in the same memory region.
Now the memory section should be added. Place the following a bit further down in the
script, between the .data { ... } and the .bss { ... } section:
.myvars :
{
*(.myvars*);
} > MYVARS
94 | P a g e
Getting Started
This tells the linker to place all sections named .myvars* from input into the .myvars
output section in the MYVARS memory region, which is specified to start at target memory
address: 0x8010000.
A section can be called almost anything except some predefined names such as data.
To be absolutely certain that the order will stay the same even if they are spread in
multiple files, add each variable to its own section. Then map the order of the variables in
the linker script.
__attribute__((section(".myvars.VERSION_NUMBER"))) uint32_tVERSION_N
UMBER;
__attribute__((section(".myvars.CRC"))) uint32_t CRC;
__attribute__((section(".myvars.BUILD_ID"))) uint16_t BUILD_ID;
__attribute__((section(".myvars.OTHER_VAR"))) uint8_t OTHER_VAR;
And then decide the order in the linker script by adding the specially named sections like:
.myvars :
{
*(.myvars.VERSION_NUMBER)
*(.myvars.CRC)
*(.myvars.BUILD_ID)
*(.myvars*);
} > MYVARS
Then the reference in the C file might look like this using the incbin directive and the
allocatable (“a”) option on the section.
asm(".section .binary_data,\"a\";"
".incbin \"../readme.txt\";"
);
95 | P a g e
Getting Started
That section is then added in the linker script with instructions that the section should be
put in flash.
.binary_data :
{
_binary_data_start = .;
KEEP(*(.binary_data));
_binary_data_end = .;
} > FLASH
This block can then be accessed from the C code with code similar to the following:
extern int _binary_data_start;
int main(void)
{
int *bin_area = &_binary_data_start;
…
}
96 | P a g e
Getting Started
However, removing a Workspace from that list will not remove the files. Neither will
removing the files from the file system remove the workspace from this list.
In the menu select File, Export. Then in the panel select General, Preferences. Press the
Next button and in the next page enable Export All and a good filename of your choice.
Then select File, Switch Workspace and your new workspace. Atollic TrueSTUDIO will then
restart and open with the new workspace.
97 | P a g e
Getting Started
In the menu select File, Import and in the panel select General, Preferences. Press the
Next button and on the next page enable Import All and enter your file name. The
preferences will now be the same in the two workspaces.
Select the General node and then enable Show heap status. The currently used and
available Java Heap Space will then be displayed in the lower right corner of the
Workspace. The garbage collector can also be manually triggered there.
If Atollic TrueSTUDIO is started with a workspace that already is used by another instance
of the program, the following error message is displayed:
98 | P a g e
Getting Started
99 | P a g e
Getting Started
THE INDEX
In Atollic TrueSTUDIO there is an important mechanism called Indexer that creates a
database of the source and header files. That database is called the Index and is used to
provide information for all navigation and content assist in Atollic TrueSTUDIO. It includes
the information about where to find information such as where a function is located and
used, where a preprocessor symbol is located and where global variables are defined.
Try pressing CTRL and clicking on a function that is used somewhere in the code. The
editor will jump to its definition. Also hovering over it will display its comments and
documentation.
The Indexer is running in the background and keeps track on all changes in the project.
The Indexer is normally customized per Workspace, but can also be set on a per project
basis. To customize the Indexer per Workspace in the menu select Window, Preferences
and in the Preferences dialog select C/C++, Indexer.
100 | P a g e
Getting Started
To customize the Indexer setting per project right-click the project and select Properties.
In the Properties dialog select C/C++ General and then Indexer.
101 | P a g e
Getting Started
Select Enable project specific settings. It is a good idea to skip large files and files with
many hundreds of includes. This will prevent the Java heap from running out of space. If
the project is version controlled, it is also a good idea to store the settings within the
project.
From time to time the Index fails to keep track on the changes in the project. Most likely
this is due to some includes being changed or missed. Then the Index database needs to
be rebuilt. To do that right-click the project and select Index, Rebuild.
If this doesn’t solve the problem or the indexer’s database file (the .pdom-file) is corrupted,
open the workspace folder and locate the hidden directory:
.metadata\.plugins\org.eclipse.cdt.core
Delete the file: YOUR_PROJECT_NAME.pdom and restart Atollic TrueSTUDIO. The Index is
now rebuilt from scratch.
The most likely reason for a corrupted .pdom-file is that TrueSTUDIO somehow crashed
during indexing. That can happen if Atollic TrueSTUDIO runs out of Java heap space, see
Keeping Track on Java Heap Space on page 98 for more information about the Java Heap.
102 | P a g e
Getting Started
The preferences for the Scanner Discovery mechanism can be found by selecting Window
in the menu and then Preferences.
In the Preferences panel select C/C++, Build, Settings and then to the right the Discovery-
tab.
A list of the available Language Setting Providers are then displayed. A Language Setting
Provider is a specialized mechanism to discover settings. Some providers calls the tool
chain for built in compiler symbol and includes. Others scan the build output for that
information. The found entries are then stored in the workspace (shared) or for each
project.
The Atollic ARM Tools Language Settings is by default not shared between projects.
By selecting one provider that individual provider can be configured. If that provider have
found and are sharing some entries in the workspace, those entries can be removed by
pressing Clear Entries. That can be a good idea to do if the path to included files are
wrong.
Enable Allocate console in the Console View will send output to the console each time the
providers runs.
103 | P a g e
Getting Started
The project and build configuration specific settings and entries can be found by selecting
the project and then in the menu select Project, Properties and in the Properties panel for
the project select C/C++ General, Preprocessor Include Paths, Macros etc. and select the
Providers tab first.
When using a version control system it is best to enable Store entries in project setting
folder.
Do not enable the Use global provider shared between projects option! The Atollic ARM
Tools Language Settings is by default not shared between projects. Since each project has
different arguments to the tools based on the Target Settings, sharing between projects
will not give a totally accurate result.
The Entries tab displays the found entries for the different providers. At the top is the CDT
User Setting Entries. By selecting that user defined entries can be added.
When sharing a project in a version control system, it is a good idea to set the
SVN property svn:ignore on the file
%PROJECT_LOCATION%/.settings/language.settings.xml since it
includes a hash specific to each individual environment. See more in the
chapter about SVN on page 124.
104 | P a g e
Getting Started
The view is also able to display all the files included in the selected file and the name of the
folder where the files are located.
To be able to keep track on these changes and properly edit external source files in Atollic
TrueSTUDIO®, a link to the folders or to the files needs to be added to the project. To add
a link to a file, right-click on a source folder and select New, File.
In the dialog click on the Advanced button and select Link to file in the file system.
Enter the file name and Browse to the file you want to create a link to.
105 | P a g e
Getting Started
When this is done, Atollic TrueSTUDIO® will keep track of all changes in the file and rebuild
when the file is changed.
106 | P a g e
Getting Started
I/O REDIRECTION
The C runtime library includes many functions, including some that typically handle I/O.
The I/O related runtime functions include printf(), fopen(), fclose(), and many
others.
It is common practice to redirect the I/O from these functions to the actual embedded
platform, such as redirecting printf() output to an LCD display or a serial cable, or to
redirect file operations like fopen() and fclose() to some Flash file system
middleware. Atollic TrueSTUDIO® also comes with an integrated Terminal that can be used
to display redirected I/O, see page 154 for more information.
The free Atollic TrueSTUDIO® Lite do not support I/O redirection, and instead have do-
nothing stubs compiled into the C runtime library.
Atollic TrueSTUDIO® Pro and Premium do support I/O redirection. To enable I/O
redirection the file syscalls.c should be included and built into the project:
1. In the Project explorer view, Right click on the project and select New, Other...
107 | P a g e
Getting Started
4. Click Browse... and select the src folder as new file container. Also select the
Heap Implementation. There is one dynamic heap implementation that is default
and a fixed one intended for RTOS use. If the latter is selected a modification of
the script linker_script.ld in accordance with the instructions is also
needed.
108 | P a g e
Getting Started
5. Click OK.
To redirect the printf() to the target output, the _write() function needs to be
modified. Exactly how this is done depends on the hardware and library implementation.
Here is an example:
109 | P a g e
Getting Started
The compiler has an option -fPIE that enables the compiler to generate position
independent code for executable. Add this option into the tool settings for the Assembler
and C Compiler in the Miscellaneous settings in the Build Configuration.
Also use this -fPIE option for the linker. E.g. in the Miscellaneous settings the Other
options field for the C linker, the command may look like
-Wl,-cref,-u,Reset_Handler -fPIE
110 | P a g e
Getting Started
Make sure that the stack pointer is set up correctly. Normally this is done by issuing a
monitor reset command as part of the Startup-script for the debug session.
However now the start code needs to set the stack pointer instead; do this by adding the
following assembly line at the top of the Reset_Handler()-function located in the
startup file:
This will make sure that the stack pointer is initialized when the Reset_Handler()-
function runs.
Since the monitor reset command is not used any more, it needs to be removed from
the Debug Startup Script.
Do this by opening your debug configuration, by pressing the Debug Configuration button,
switch to the Startup Scripts tab.
This contains all commands that are used to launch a debug session. Try commenting
the monitor reset line out by adding a # sign in front.
111 | P a g e
Getting Started
Also in some examples the SystemInit()-function for the vector table relocation needs
to be changed.
To test that the code is started where it should be, also comment out the continue
command from the Debug Startup script. This will suspend execution on the first
instruction in the Reset_Handler(), making it possible to debug the start-up code.
112 | P a g e
Getting Started
2. Then enter the URL to the update site for the plugin. If the URL is not known,
All Available Sites can be selected.
Select the appropriate plugins. Please remember that not all ECLIPSE™ plugins
are compatible with Atollic TrueSTUDIO®.
Click the Next button.
113 | P a g e
Getting Started
4. Read all the licenses agreements and click accept if the terms are found
acceptable. Then click the Finish button.
114 | P a g e
Getting Started
3. Install the Updater plug-in using the Eclipse installation system (P2)
Download PE_DRIVER_SUITE_ECLIPSE_x.x-y.y
115 | P a g e
Getting Started
• PExDriverSuite_v10.4_eclipse
• com.freescale.eclipse3.7-4.2.updater.custom.updatesite
116 | P a g e
Getting Started
INSTALL UPDATER
Start Atollic TrueSTUDIO
Click the Add button to point out a plug-in to be installed in Atollic TrueSTUDIO
Choose Local
Choose com.freescale.eclipse3.7-4.2.updater.custom.updatesite
Click OK
Click OK
com.freescale.eclipse3.7-
4.2.updater.custom.updatesite must be installed first!
117 | P a g e
Getting Started
C HOOSE I TEMS
Select package to be installed and click Next
118 | P a g e
Getting Started
Other…
119 | P a g e
Getting Started
MISCELLANEOUS TOOLS
VERSION CONTROL
Atollic TrueSTUDIO includes a basic version-system for projects that works well for a
project with just one developer on one computer. It allows users to keep tracks on local
file history.
For more information about a local repository see Local SVN Repository below.
However if users need to collaborate, keep better track of changes and perhaps work on
many workstations, a better version control-system is needed.
Atollic TrueSTUDIO supports three such systems GIT, Concurrent Versions System (CVS)
and Subversion (SVN). The CVS is an older system that Atollic TrueSTUDIO supports for
those that already have CVS-repositories.
File revision annotations, file difference viewer and revision graph viewer
Full traceability of all lines, in all files, throughout complete project history
SUBVERSION - SVN
Subversion (SVN) is an open source version control system that was design to replace the
older CVS. It is more or less a de facto standard in the computer industry.
A free and very good online book about SVN can be found here
http://svnbook.red-bean.com/
SVN manages files, directories and the changes made to them. That way it is possible to go
back to previous version of the code or inspect what changes has been made over time. It
also operates over a network and allows the same code to be changed simultaneously on
120 | P a g e
Getting Started
many computers, even over the internet. Thus development can be done faster and with
fewer errors. If some incorrect code is entered it can just revert to the previous version.
To be able to use SVN a Subversion repository is needed. How to set up and maintain a
network repository is out of the scope of this manual. On page 124 set up off a local
repository is explained. There are also several websites such as Freepository, Google Code
and SourceForge provides free source code hosting that can be accessed with Atollic
TrueSTUDIO’s SVN-integration. A good introduction to how to set up a repository can also
be found in chapter 5 in the SVN-book and in several good tutorials on the net.
After making sure a repository exists, the next thing to do to be able to use SVN in a
project, is to enable SVN in Atollic TrueSTUDIO. In the top menu select Window,
Customize Perspective.
In the dialog that opens up select the Command Groups Availability-tab. Find SVN in the
Available command groups-column and make sure it is selected. Click OK.
Some extra items are now available in the toolbar. However they should be greyed out.
There will also be a new top-menu called SVN.
121 | P a g e
Getting Started
There are several views in Atollic TrueSTUDIO for managing SVN. They can be found by in
the top-menu select Window, Show View, Other.
The first view needed is the SVN Repositories since that where repositories are connected.
Next step is to share the project in the repository. Right-click on the project and select
Team, Share Project. In the dialog that then pops up, select SVN and click on Next. Select
the repository and then Finish.
For more information about how to use SVN, see the tutorials at
http://www.atollic.com/index.php/videotutorials
For more information about how to use SVN, see the tutorials at
http://www.atollic.com/index.php/videotutorials
122 | P a g e
Getting Started
LOCKS IN SVN
In normal cases locks is never used in SVN. SVN is very good in merging different versions
and branches of the same file. That way more than one developer can edit the same
source-file without fearing to interfere in other developers work.
However in very special cases, such as editing images and other complex file-types, SVN
can’t merge. In that case we recommend to lock the file before editing it.
Locking is easy. Just right-click on the file, select Team, Lock and enter a brief comment on
why the file is locked.
If others now want to edit the same file, they will only have a read-only version of the file
and can’t save or check it in.
To make sure a file is always locked before anyone can edit it, do the following:
123 | P a g e
Getting Started
3. Check with Team, Show Properties that the property is correctly added
That string will be replaced with a text showing the revision number of that file.
Other possible values to the svn:keywords is Date, Author, HeadURL and Id.
"$Revision:: $".
IGNORE A FILE
To ignore sharing a specific file in a repository, the property svn:ignore needs to be set
instead. It is done in the same manner as the other properties above.
When sharing a project in a version control system, it is a good idea to set the SVN
property svn:ignore on the file
124 | P a g e
Getting Started
1. Open the SVN Repositories by selecting Window, Show View, Other… and in the
panel select SVN, SVN Repositories and press OK.
125 | P a g e
Getting Started
3. In the Create Repository dialog enter the name and location for the new local
repository and make sure File System is selected.
126 | P a g e
Getting Started
5. To start version controlling a project in the repository, right click the project and
select Team, Share Project..
127 | P a g e
Getting Started
Atollic TrueSTUDIO will now be opened in an additional window. This is useful when the
workplace is equipped with two screens. It is then possible to edit and debug at the same
time. One instance of Atollic TrueSTUDIO can then be used for editing and the other for
debugging.
SHELL ACCESS
To access Windows Shell (cmd.exe) open the shell by selecting Window, Show View,
Other and in the dialog select Wicked Shell group and the Shell view.
128 | P a g e
Getting Started
Press Create New and enter a unique identifier for your new shell.
129 | P a g e
Getting Started
The new shell that can handle Japanese encoding is now selectable.
130 | P a g e
Getting Started
131 | P a g e
Getting Started
DEBUGGING
This section provides information on how to begin using Atollic TrueSTUDIO® for ARM®.
Debug Configuration
Debug Perspective
Debugging
Advanced Debugging
132 | P a g e
Debugging
Atollic TrueSTUDIO® automatically starts and stops the GDB server as required during
debugging, thus creating a seamless integration of the GDB server.
To prepare for debugging with an ST-LINK JTAG probe connected to your electronic board,
perform the following steps:
1. Verify that the RAM and FLASH configuration switches on the target board
is set to match the Atollic TrueSTUDIO® project configuration, regarding
memory. Note: Not all boards have such configuration abilities.
3. Connect the JTAG cable between the JTAG probe and the target board.
4. Connect the USB cable between the PC and the JTAG probe.
5. Make sure the target board has a proper power supply attached.
Once the steps above are performed, a debug session in Atollic TrueSTUDIO® can be
started.
133 | P a g e
Debugging
2. Click on the Debug toolbar button (the insect icon) or press the F11 key to
start the debug session.
134 | P a g e
Debugging
5. Click on the Debugger panel to display it. The panel contains information on
the JTAG probe to use, its configuration, and how to start it. Some settings
are probe-specific.
6. Open the Debug probe drop down list. Select the JTAG probe to be used
during the debug session.
135 | P a g e
Debugging
Figure 115 - Debug Configuration, Debugger Panel for the SEGGER J-Link
136 | P a g e
Debugging
10.If any other debug probe then ST-Link JTAG probe was selected in step 6,
the following Misc settings are relevant:
Atollic TrueSTUDIO® is able to automatically recognize and launch J-Link
scripts at the start of a debug session. If a script is needed to debug a wizard-
created project, the wizard will also automatically create one.
To manually select the J-Link script to be launched, please enable the Use J-
Link script file option and browse to the desired script file.
To be able to use the Live Expressions view during debugging the Live
Expression mechanism has to be enabled during startup. It is enabled by
default.
137 | P a g e
Debugging
12.The Startup Script panel contains the initialization scripts that are sent to
the GDB debugger upon debugger start. The scripts can contain any GDB or
GDB server commands that are compatible with the application, JTAG probe
and target board. The Startup Script tab is also where GDB script programs
are defined.
The Target Hardware Initialization tab is for the script used to initialize the
hardware and the Target Software Startup Scripts tab is for the scripts used
to initialize the software. In most cases the Target Hardware Initialization
script can be empty but if some hardware needs to be configured before
software can be loaded to target commands can be added here. For example
in some systems the external data/address bus and DRAM refresh control
needs to be initialized before software can be loaded.
The Debug tab contains the script used for normal debugging and the
Analyze and Unit Test tabs contain GDB scripts used by the Atollic
TrueANALYZER® and Atollic TrueVERIFIER® products. While in this tutorial,
leave the default selections unaltered.
138 | P a g e
Debugging
139 | P a g e
Debugging
Complete symbolic information is emitted by the tool chain to help the user
navigate the information in the source code, during the debug process.
After switching from the Debug to the Release build configuration, the target board can be
programmed by launching a debug session. During this process, caution must be executed
to prevent unexpected results from occurring.
This brings up the list of existing debug launch configurations. By right clicking on an
existing configuration, the options to create a new configuration, duplicate the existing, or
delete it, appears.
The easiest way to create a new configuration is to duplicate an existing one, edit the
configuration settings in the dialog box, and then rename it. In this way multiple debug
launch configurations are easily created. The user may toggle among the debug launch
configurations in the list, and launch the most suitable session for the task at hand.
If the user does not explicitly choose a debug launch configuration from the existing list,
Atollic TrueSTUDIO® launches the most recently used debug launch configuration.
Assume that a user has created a build configuration named Debug, and a debug launch
configuration that loads the ELF-file, created by the Debug build, to the target. Assume
further that the user launches a debug session to debug this ELF-file.
Following this, the user switches to the build configuration named Release, and launches a
new debug session by clicking on the debugging icon. Atollic TrueSTUDIO® will fetch the
140 | P a g e
Debugging
most recent debug launch configuration, which specifies that the ELF-file from the Debug
build configuration, and not the Release ELF-file, is to be programmed into the target.
Atollic TrueSTUDIO® has no means of automatically selecting the ELF-file associated with
the currently active build configuration (Debug or Release), when a debug session is
started. The build image used will always be the one specified in the debug launch
configuration, regardless of the active build configuration.
This behavior is different from some other development environments that automatically
reconfigure the debug launch mechanism, to use the ELF-file from the currently active
build configuration.
In Atollic TrueSTUDIO®, the user must create a debug launch configuration that explicitly
refers to the particular ELF-file that is to be loaded, when a debug session is started.
Example: The user generates a project from the Project Wizard and builds an ELF-file using
the build configuration named Debug. The debug session configuration dialog box shows
the location of the ELF-file:
To create a debug launch configuration that refers to the Release ELF-file, instead of the
Debug ELF-file, simply change Debug in the above path to Release. It is recommended to
rename the debug launch configuration to clearly mark it as a Release configuration.
To load the Release ELF-file into the target, start a debug session based on this debug
launch configuration.
If desired, other properties of the new debug launch configuration can be edited as well.
For example, setting the temporary breakpoint at the first line of main(), may be
omitted by inserting a comment on the corresponding line in the GDB initialization script.
This is done via the Debug dialog box, in the Startup Scripts, Target Software Startup
Scripts panel.
141 | P a g e
Debugging
142 | P a g e
Debugging
DEBUGGING
Once the debug session has been started, Atollic TrueSTUDIO® switches automatically to
the Debug perspective, sets a breakpoint at main(), resets the processor, and executes the
startup code until execution stops at the first executable program line inside main().
The Debug perspective is now active. The next program line to be executed is highlighted
in the source code window. A number of execution control functions are available from
the Run menu:
Alternatively, the execution control commands are available in the Debug view toolbar.
143 | P a g e
Debugging
DISASSEMBLY VIEW
A common user action, not available from the Run menu, is to switch between C/C++ level
stepping in the C/C++ source code window, and assembler level instruction stepping in the
Disassembly view.
Click on the instruction stepping button to activate assembler level instruction stepping in
the Disassembly view. Click it once more to return to C/C++ level stepping in the C/C++
source code window.
144 | P a g e
Debugging
By right-clicking in the left part of the view, the Function Offset can also be displayed.
BREAKPOINTS
A standard code breakpoint at a source code line can easily be inserted by double-clicking
in the left editor margin, or by right-clicking the mouse in the left margin of the C/C++
source code editor. A context menu will appear in the latter case.
Select the Toggle Breakpoint menu command to set or remove a breakpoint at the
corresponding source code line.
More complicated types of breakpoints, such as Watch Points and Event Breakpoints (for
PC projects) are configured in the Breakpoints view.
145 | P a g e
Debugging
CONDITIONAL BREAKPOINT
When setting a normal breakpoint the program will break each time reaching that line. If
that is not the desired behavior a condition can be set on the breakpoint that regulates if
the program should actually break or not on that breakpoint.
Set a breakpoint at a line. Right-click it and open the Breakpoint Properties... The
Breakpoint Properties can also be opened from the Breakpoints view.
Enter a condition. In the example below “g1==100” is a global variable, but the variable
can also be a local stack variable.
What happens when running now is that the gdbserver will break each time the line is
executed but gdb will test the condition and restart running if the variable g1 not is equal
to 100. This method could be used when debugging an RTOS with several tasks if the RTOS
kernel has a variable that the Breakpoint condition could be tested on to see which task is
running. The only problem with this method is that it takes some time for GDB to evaluate
the condition.
The conditions are written in C-style so you can write “g1%2==0” to get more complex
conditions.
146 | P a g e
Debugging
EXPRESSIONS
The Expressions view displays many different types of data, including global variables,
local variables and CPU core registers. The Expressions view also allows users to create
mathematical expressions that are evaluated automatically, such as (Index * 4 + Offset).
An expression is displayed in many formats simultaneously, and the view can parse
complicated data types and display complex data types like a C-language struct.
Furthermore, it is CPU core registers may be added to the view, in addition to local and
global variables.
The users may drag and drop variables from the editor into the Expressions view. This
applies to complex data types as well.
The value of variables and writeable registers may also be changed via the Expressions
view.
LIVE EXPRESSIONS
The Live Expressions view works a lot like the Expression view with the exceptions that all
the expressions are sampled live during the debug execution.
147 | P a g e
Debugging
The view displays many different types of global variables. The Expressions view also
allows users to create mathematical expressions that are evaluated automatically, such as
(Index * 4 + Offset).
An expression is displayed in many formats simultaneously, and the view can parse
complicated data types and display complex data types like a C-language struct.
Only one format of numbers is used at the same time to speed up the sampling. To change
the format, use the dropdown arrow.
The Live Expressions view requires a Segger J-Link probe and a Segger J-Link
GDBServer v4.78h or later.
To be able to use the Live Expressions view during debugging the Live
Expression mechanism has to be enabled during startup. This is by default
enabled when Segger J-Link probe is selected in the debug configuration.
Please read the Starting the Debugger section for more information.
148 | P a g e
Debugging
LOCAL VARIABLES
The Variables view auto-detects and display the value of local variables. It provides
extensive information about each variable, such as value in hex/dec/bin format. The
content of complex variable types is also displayed.
The Memory Fill dialog is opened when the toolbar button is pressed.
149 | P a g e
Debugging
The filled area is up to, but not including, the end address.
SFRS
Special Function Registers (SFRs) can be viewed, accessed and edited via the SFRs view.
The view displays the information for the current project. It will change its content if
another project is selected.
150 | P a g e
Debugging
The SFRs view can also be useful in the C/C++ Editing Perspective, however
then only the names and addresses of the registers will be displayed.
151 | P a g e
Debugging
The toolbar buttons are found at the top right corner of the view. The Base format buttons
(A) are used to change what base the registers values are displayed in.
The Configure SVD settings button (B) opens up the CMSIS-SVD Settings Properties Panel
for the current project.
Two CMSIS-SVD (System View Description) data files can be pointed out for the project. All
SVD-files must comply with the syntax as outlined in the CMSIS-SVD specification found on
ARM® website. If this requirement is not met, the SFR-view is likely not to show any
register information.
152 | P a g e
Debugging
The Device file field is typically used to for the Device file. This file should include the
information for the whole device. Other views may fetch information from the SVD-file
pointed out by this field, therefore Atollic recommends only using this field for SVD-files
containing full system description. This field is typically only changed of the
microcontroller vendor releases a new version of the SVD-files. Updated files can be
obtained from the CMSIS category on http://www.ARM.com.
The Custom file field can be used to define special function registers related to custom
hardware, in order to simplify the viewing of different register states. Another possible use
case is to create a SFR favorites’ file, containing a subset of the content in the Device file.
This subset may be frequently checked or registers. If a Custom file is pointed out a new
top-node in the SFR-view will be created containing the Custom file related register
information.
Both fields may be changed by the user and both fields may be used at the same time.
FAULT ANALYZER
The Fault Analyzer view helps developers to identify and resolve hard-to-find system faults
that occur when the CPU has been driven into a fault condition by the application
software. The fault analyzer feature interprets information extracted from the Cortex-M
nested vector interrupt controller (NVIC) in order to identify the reasons that caused the
fault.
Within the debugger, after a fault has occurred, the code line where the fault occurred will
be displayed. The user can view the reasons for the error condition. Faults are broadly
categorized into bus, usage and memory faults.
Bus faults occur when an invalid access attempt is made across the bus, either of a
peripheral register or a memory location.
Usage faults are the result of illegal instructions or other program errors.
To further aid fault analysis, an exception stack frame visualization option provides a
snapshot of the MCU register values at the time of the crash. Isolating the fault to an
153 | P a g e
Debugging
individual instruction allows the developer to reconstruct the MCU condition at the time
the faulty instruction was executed.
In the Debugger perspective the Fault Analyzer view is opened from the menu. Select the
menu command View, Fault Analyzer or use the toolbar icon Show View to open a drop
down list; then select Fault Analyzer.
TERMINAL VIEW
A terminal is included to allow I/O communication with target using Serial/SSH/Telnet
communication.
It can be located by selecting the Open View toolbar button and then select Terminal in
the dropdown list.
To start using the terminal, press button A. This will open up the Terminal Settings Dialog.
154 | P a g e
Debugging
Select what type of connection is preferred. That will most likely be Serial communication.
For more information for how to redirect the I/O to the Terminal, see the chapter about
I/O Redirection on page 107.
3. Make sure that these folders are treated as source code folders by right-clicking on
the c-file or the folder then select Resource configuration, Exclude from build… and
Deselect all.
4. Setup include paths by select in the menu Project, Build Settings, Tool Settings, C
Compiler, Directories and add all headers
5. Exclude the main.c supplied in the TrueSTUDIO example project. Also exclude the
tiny_printf.c and the syscalls.c (if available). This since RTT will override some
of these implementations.
155 | P a g e
Debugging
6. The RTT-pack comes with three different demonstration examples. This means 3
different main() implementation. Make sure only one is built. Again for these (2 of
these 3) source files use: right-click on the c-files, Resource configuration, Exclude
from build… and Select all.
7. Build and start a debug session.. Open the “Terminal”-view. Setup a connection:
Encoding: ISO-8859-1
Host: localhost
Port: 19021
Ok
156 | P a g e
Debugging
157 | P a g e
Debugging
158 | P a g e
Debugging
Then change the setting that points out where the server is stored. Select the top-menu
Window, Preferences and then open Run/Debug, Embedded C/C++ Application, Debug
Hardware, and the name of the GDB probe used. The path to the newly installed GDB
server can be entered there.
159 | P a g e
Debugging
Open a command window (cmd) in Windows and move to the folder for the installed GDB
server:
JLINK.exe
Now there should have a new icon in Windows Notification Area (by default in the lower
right corner in Windows) for Segger J-Link GDB server. Right click to open it. The Control
panel for the GDB server will then be opened.
A good idea is now to in the General tab deselect Start minimized and Always on top.
160 | P a g e
Debugging
What does not happen is if the program alters the flash contents, the Memory panel does
not reflect that.
To fix this go to the Settings tab and deselect the Allow caching of flash contents.
2. Then open the Settings tab and enter a name of a log file.
4. The GDB server should now save information in the new log file.
161 | P a g e
Debugging
Then start the GDB server manually from the command line.
162 | P a g e
Debugging
163 | P a g e
Debugging
The latest P&E GDB Server version from P&E Microcomputer Systems Inc. is available here
http://www.pemicro.com/downloads/download_file.cfm?download_id=382
When using the Freescale Freedom board, it might be necessarily to first configure the
board for it to work with the P&E GDB Server. How that is done is explained on page 170 -
Freescale Freedom Board Configuration.
LICENSING
When a debug session using the P&E GDB Server is started with Atollic TrueSTUDIO the
debug session uses a “challenge/response” protocol to license the GDB Server. So there is
no need to have any other license of the GDB Server to make it work with Atollic
TrueSTUDIO.
164 | P a g e
Debugging
When using P&E Micro USB Multilink probes, OpenSDA or Embedded OSJTAG probes
make sure that P&E Micro is selected in the Debugger tab. The actual type of probe is
selected in the configuration for the GDB Server, see the next step below.
165 | P a g e
Debugging
Info: The port number shall always be set to 7224 when connecting to current version of
GDB Server.
The Startup Scripts tab contains the GDB script that will be used when starting a Debug
session.
166 | P a g e
Debugging
2. Select the Interface to be used. E.g. Select “OpenSDA Embedded Debug – USB
Port” when using Freescale Freedom board.
Close the GDB Server GUI when configuration is ready. Two initialization files are created
by the GDB Server in the project - pe_micro_serversettings.ini and
pe_micro_projectsettings.ini
Use the Open Configuration GUI (GDB Server) button if any setting needs to be changed.
Do not use the Connect button to connect to the target. It will not work with the license
included in Atollic TrueSTUDIO.
This is done by pressing the Debug button in the Debugger tab in the Debug
Configurations dialog.
167 | P a g e
Debugging
168 | P a g e
Debugging
The GDB Server will then be started by Atollic TrueSTUDIO and the GDB server GUI pop
up.
The default Atollic TrueSTUDIO GDB script for the P&E GDB Server will load the program,
set a breakpoint at main(), and make a continue. So if everything works fine the program
shall startup and run startup code until execution stops at the first executable program
line inside main().
Note! The GDB server can be quite slow and the startup take up to one
minute. Especially if the card has the older OSBDM design for debugging.
Please be patient and wait while the server is Initializing.
The GDB Server GUI also provides some log information. Investigate this if there are some
problems.
The GDB script can be changed by updating the information in the Startup Scripts tab in
the Debug Configuration dialog
169 | P a g e
Debugging
The Freescale Quick Start Guide for FRDM-KL25Z and the Freescale FRDM-KL25Z User’s
Manual are also good to read to get information about the Freedom board.
First the OpenSDA Bootloader Mode shall be started. This is done by:
170 | P a g e
Debugging
3. Plug in a USB cable (not included) between a USB host and the OpenSDA USB
connector (labeled ―SDA‖).
A removable drive should now be visible in the host file system with a volume label of
BOOTLOADER. You are now in OpenSDA Bootloader mode.
171 | P a g e
Debugging
Download latest flash programming firmware (MSD & Debug) from the P&E Micro
webpage: http://www.pemicro.com/opensda/index.cfm
The zip-file contains a number of SDA files that can be downloaded to the Freedom board.
Next sections contain information about how to update the Flash Programmer Application
and how to download the DEBUG_APP. It is necessary to install the DEBUG_APP to the
board when the PE Micro GDB Server shall be used.
https://segger.com/opensda.html
1. Open the directory where the PEMicro OpenSDA Firmware has been unzipped.
2. Copy & paste or drag & drop the MSD Flash Programmer Application, MSD-FRDM-
KL25Z_Pemicro_vXYZ.SDA, to the BOOTLOADER drive.
3. Unplug the USB cable and plug it in again. The new OpenSDA Application should now
be running and a FRDM-KL25Z drive should be visible in the host file system.
172 | P a g e
Debugging
2. Open the directory where the PEMicro OpenSDA Firmware has been
unzipped.
3. Copy & paste or drag & drop the DEBUG_APP, DEBUG_APP_Pemicro_vXYZ.SDA, to the
BOOTLOADER drive.
4. Unplug the USB cable and plug it in again. The new OpenSDA Application should now
be running and a FRDM-KL25Z drive should be visible in the host file system.
OSBDM CONFIGURATION
Other boards from Freescale that don’t have the modern OpenSDA standard, most likely
have the older OSBDM design. OSBDM is an open source design which provides low-speed
debug communications for different Freescale processors.
Most likely the firmware is also outdated on the device. It is the necessary to download
and install the P&E Firmware Updater Utility from http://www.pemicro.com/osbdm/
To upgrade the firmware, connect the device and start updater utility.
173 | P a g e
Debugging
Press Update Firmware. The GUI will then pop up a message to switch the device to
bootloader mode. To do that unplug the device, locate the JM60 IRQ pins (also known as
J10) and insert a jumper on the pins and re-connect the device again.
After the firmware is updated, the jumpers needs to be removed again while the device is
unplugged.
174 | P a g e
Debugging
USING OPENOCD
OpenOCD is an open source gdbserver that from version 0.8.0 has support for CMSIS-DAP
and other JTAG-probes.
Atollic TrueSTUDIO has excellent support for OpenOCD. To use OpenOCD as the gdbserver
when debugging, do the following:
2. Unzip the file somewhere on disk. Then the openocd-0.8.0.exe file to run is
located in the /bin folder E.g.
E:\Development\TrueSTUDIO\V5.2.0\OpenOCD\openocd-
0.8.0\openocd-0.8.0\bin
175 | P a g e
Debugging
5. Debug example:
Update GDB Server Command Line Options with the name of the script
copied above:
-f E:\ARM_workspace\Project1\Debug\stm32f4discovery.cfg
Debug
176 | P a g e
Debugging
In Atollic TrueSTUDIO this will typically require only running one instance of Atollic
TrueSTUDIO containing one project for each microcontroller.
The default port to be used for Segger J-Link is 2331. This is presented in the Debugger tab
in the Debug Configurations dialog. The developer needs to change the port for one of the
projects to use another port, e.g. port 2341.
When the Debug Configuration has been configured for both projects so that each board is
associated to a specific probe, the user may try to debug each board individually first.
When it is confirmed that this is working it is time to debug both targets at the same time.
Proceed as follow:
1. First start to debug HW_A.
2. The developer will automatically be switched to the Debug Perspective in Atollic
TrueSTUDIO when a debug session is started. Switch to C/C++ Perspective.
3. Select the project for HW_B and start debugging this. The Debug perspective will now
open again.
4. There will be two application stacks/nodes in the debug view: One for each project
(hardware). When changing selected node in the Debug view the depending editor,
variable view etc. will be updated to present information valid to the selected
project/board.
177 | P a g e
Debugging
If Connect to remote GDB server is selected, the developer must start the GDB server
manually before starting the debug session.
To start Segger J-Link GDB server manually please follow this procedure:
1. Open a Windows Console (Command Prompt, cmd.exe)
2. Change directory to the location where the GDB server is located, normally to:
C:\Program Files (x86)\Atollic\TrueSTUDIO for ARM Pro
4.1.0\Servers\J-Link_gdbserver
3. Start the GDB server: E.g start using port 2341 with SWD interface mode:
JLinkGDBServerCL.exe -port 2341 -if SWD -select usb=123456789
(The 123456789 is serial number of dongle.)
Start another GDB server in a second command prompt, using another port number in a
similar way and let this connect to the second J-Link.
Now when both Segger J-Link GDB servers are running the developer can debug the two
projects individually or multi-target. Please note that the Debug Configurations needs to
use the same port as the GDB server is listening on and Connect to remote GDB server
shall be used.
178 | P a g e
Debugging
The ST-Link GDB-server used for debugging STM32 devices does not implement all
functionality available in the ST-Link utility. It is however possible to call ST-Link Utility
from inside the IDE, this can save a lot of time when performing various debugging related
tasks.
When certain parts of the flash need to be erased before loading binary
When you want to compare the binary file in target with the one just built with
Atollic TrueSTUDIO.
For faster loading into flash than is offered by the ST-Link GDB-server
REQUIREMENTS
St-Link Utility (Download it from http://www.st.com)
A working ST-Link
The ST-Link utility does not support elf-files. Use Intel Hex.
179 | P a g e
Debugging
4. Create a Launch Group to perform the ST-Link Utility operations before the Atollic
TrueSTUDIO debugger starts
180 | P a g e
Debugging
Press Apply
Test that the external tool just setup is working by clicking Run or Run, External Tools…,
ST-LINK_CLI
Click OK
The output name will be %PROJECT%.elf.hex. Make sure that this binary is selected
when creating the debug configuration. This will not work with an .elf-file.
181 | P a g e
Debugging
Change the name of this configuration to “… NO LOAD”, this is since GDB will not
be used to load the hex.
Open the Startup Scripts tab, comment out the “load” command load, #load. It
might also be a good idea to comment out the “monitor reset” command.
Click Apply.
Double-click on the Launch Group node to create a Launch group and give it a name.
182 | P a g e
Debugging
Click Add..
Expand Programs and select your external tool configuration, i.e. ST-LINK_CLI.
183 | P a g e
Debugging
Expand Embedded C/C++ Applications and select your debug configuration, i.e.
Project NO LOAD.
184 | P a g e
Debugging
Click Apply
This will make the launch group available in Atollic TrueSTUDIO from the Run, Run-menu
and later the Run, Debug History…
FINISHED
ST-Link Utility is now flashing the binary into the target memory and the debugger is
started as soon as the ST-Link Utility has finished.
185 | P a g e
Getting Started
Statistical profiling
186 | P a g e
Serial Wire Viewer Tracing
Please note that the SWO is just one pin and it is easy to set a configuration that produces
more data than the SWO is able to send.
Serial Wire Viewer (SWV) provides the following types of target information:
Event counters
Based on this trace data, modern debuggers can provide developers with advanced
debugger capabilities.
187 | P a g e
Serial Wire Viewer Tracing
The ITM port has 32 channels, and by writing different types of data to different ITM
channels, the debugger can interpret or visualize the data on various channels differently.
Writing a byte to the ITM port only takes one write cycle, thus taking almost no execution
time from the application logic.
188 | P a g e
Serial Wire Viewer Tracing
The GDB server must also support SWV. The ST-LINK gdbserver must be of version 1.4.0 or
later, and the SEGGER J-LINK gdbserver must be of version 4.32.A or later. Older GDB
server versions that may be installed must be upgraded to the versions included in the
Atollic TrueSTUDIO® product package in order to use SWV tracing.
To use SWV the board must support SWD. Please note that devices based on ARM Cortex-
M0 and Cortex-M0+ cores do not support SWV tracing.
189 | P a g e
Serial Wire Viewer Tracing
4. Enter the Core Clock frequency. This must correspond to the value set by
the application program to be executed.
5. Enter the desired SWO Clock frequency. The latter depends on the JTAG
Probe and must be a multiple of the Core Clock value.
190 | P a g e
Serial Wire Viewer Tracing
8. Open one of the SWV views. For first-time users, Atollic recommends the
SWV Trace log view because it will give a good view of the incoming SWV
packages and how well the tracing is working.
Thus, select the View, SWV, SWV Trace log menu command.
9. Open the SWV settings panel by clicking on the Configure Serial Wire
Viewer button in the SWV Trace log view toolbar.
191 | P a g e
Serial Wire Viewer Tracing
192 | P a g e
Serial Wire Viewer Tracing
F. ITM stimulus ports – Enable one or more of the 32 ITM ports. The
most common way to use this is to send information
193 | P a g e
Serial Wire Viewer Tracing
Atollic recommends limiting the amount of data traced. Most ARM® -based
microcontrollers reads and writes data faster than the maximum SWO-pin
throughput. Too much trace data result in data overflow, lost packages and
possibly corrupt data. For optimum performance, trace only data vital to the
task at hand.
12.Press the Start/Stop Trace button to send the SWV configuration to the
target board and start SWV trace recoding. The board will not send any SWV
194 | P a g e
Serial Wire Viewer Tracing
13.Start the target execution again by pressing the green Resume Debug
button.
14.Packages should now be arriving in the SWV Trace Log view (and possibly
other views too, dependent on trace configuration).
Collected data can be cleared by pressing the Empty SWV-Data button. All
the timers are also restarted when this button is pressed.
195 | P a g e
Serial Wire Viewer Tracing
SWV Trace Log - Lists all incoming SWV packages in a spreadsheet. Useful as a
first diagnostic for the trace quality. The data in this view can be copied to other
applications in CSV-format by selecting the rows to copy and type CTRL-C. The
copied data can be pasted into another application with the CTRL-V command.
SWV Exception Trace Log – The view has two tabs. The first is similar to the
SWV Trace Log, but is restricted to Exception events and also has additional
information about the type of event. The data can be copied and pasted into
other applications. Each row is linked to the code for the corresponding exception
handler. Double click on the event and the corresponding interrupt hander source
code is opened in the editor view.
The second tab displays statistical information about the Exception events. This
information may be of great value when optimizing the code. Hypertext links to
exception handler source code in the editor is included.
SWV Console - Prints readable text output from the target application.
Typically this is done via printf() with output redirected to ITM channel 0. Other
ITM channels can get their own console view too.
SWV Data Trace – Tracks up to four different symbols or areas in the memory.
For example, global variables can be referenced by name.
196 | P a g e
Serial Wire Viewer Tracing
SWV Data Trace Timeline Graph – A graphical display that shows the
distribution of variable values over time. Applies to the variables or memory areas
in the SWV Data Trace.
More than one SWV view may be open at the same time, for simultaneous tracking of
various events.
197 | P a g e
Serial Wire Viewer Tracing
Any graph can be saved as an image file by clicking the camera icon.
The zoom range is limited while debugging is running. More details are available
when debugging is paused.
Zoom in: Double-click on the left mouse button. Zoom out: Double-click on the
right button or use the corresponding toolbar buttons in the view.
The tooltip shows the number of packages in each bar. Except for the Trace
Timeline Graph, the content of bars with less than 50 packages is showed in a
detailed view.
The Data Trace Timeline displays distinct values for variables during execution and
has different features than the above graphs.
STATISTICAL PROFILING
This is a way to obtain information about the amount of execution time spent within
various functions. It is not based on code analysis but on statistical information regarding
the part of the code executed. This is a technical limitation of the SWV protocol.
198 | P a g e
Serial Wire Viewer Tracing
3. Push the red Start/Stop Trace button to send the configuration to the board.
4. When you start executing code in the target system, Atollic TrueSTUDIO®
starts collecting statistics about function usage via SWV.
5. Suspend (Pause) the debugging. The collected data is displayed in the view.
The longer the debugging session, the more statistics will be collected.
199 | P a g e
Serial Wire Viewer Tracing
EXCEPTION TRACING
To make it possible to trace the exceptions encountered during execution, the exception
packages needs to be enabled. Open SWV Configuration as described above.
Enable EXETRC: Trace Exception. This will generate Trace Exception packages. Disable all
other packages not needed at the moment.
EXCEPTION DATA
The exception packages are displayed in the SWV Exception Trace Log view. The view has
two tabs, the Data tab and the Statistics tab.
200 | P a g e
Serial Wire Viewer Tracing
Name Description
Index The Id for the exception package. Are shared with the
other SWV packages.
EXCEPTION STATISTICS
The exception statistics is collected whenever Exception packages are received by SWV. It
can be found in the SWV Exception Trace Log view, in the Statistics tab.
The statistics can be access by selecting the Statistics tab in the view. The available
columns are described in the table below:
201 | P a g e
Serial Wire Viewer Tracing
Name Description
% of exception time How big part of the execution time for all exceptions that
this exception type have.
% of debug time How big part of the total execution time for this debug
session that this exception type have. All the timers are
restarted when the Empty SWV-Data button is pressed.
Total runtime The total execution time in cycles for this exception type.
Avg runtime The average execution time in cycles for this exception
type.
202 | P a g e
Serial Wire Viewer Tracing
In the Project explorer, right click on the project and select New, Other...
Expand System calls.
Select "Minimal System Calls Implementation" and click next.
Click Browse... and select the src folder as new file container and click OK.
Click on Finish and verify that syscalls.c is added to the project.
3. Next step is to locate the core_cmX.h file which contains the function
ITM_SendChar(). The core_cmX.h file is included by the Device
Peripheral Access Layer Header File (i.e. stm32f4xx.h). That file in turn
needs to be included in the syscalls.c file.
If uncertain about where to find the Device Peripheral Access Layer Header
File, use the Include Browser. Drop the core file in the Include Browser view,
and check that which files are including the core_cmX.h file.
203 | P a g e
Serial Wire Viewer Tracing
Select the menu command Widows, Preferences. In the dialog select Run/Debug,
Embedded C/C++ Application and then Serial Wire Viewer.
The buffer is stored in the heap. The allocated heap is displayed by first selecting Window,
Preferences and General; then enabling “Show heap status”. The current heap and
allocated memory will be displayed in the lower, right corner.
There is an upper limit to the amount of memory Atollic TrueSTUDIO® can allocate. This
limit can be increased to store more information during a debug-session.
Proceed as follows:
204 | P a g e
Serial Wire Viewer Tracing
The Core Clock of the target is incorrectly set. It is very important to select the
right Core Clock. If the frequency of the target Core Clock is unknown, it can
sometimes be found by setting a breakpoint in a program loop and open the
Variable View, when the breakpoint is hit.
Right click and select Add Global Variables.., and select SystemCoreClock.
This is a global variable that according to the CMSIS-standard must be set to the
correct speed of the Core Clock.
For most devices that do not have libraries that follow the CMSIS-standard, the
Core Clock can be found in the startup code. It is often named SYSCLK, or a
similar abbreviation. Also note that if software dynamically change the CPU clock
speed during runtime, then SWV might stop as the clocking suddenly becomes
wrong during execution.
The SWV configuration has not been sent to the target board.
Some manufacturers, such as Energy Micro, disable SWO pin by default. In this
case, enable SWO with a function-call, such as DBG_SWOEnable().
The SWO receives too much data. Reduce the amount of data enabled for tracing.
The JTAG Probe, the GDB server, the target board, or possibly some other part,
does not support SWV.
Open the SWV configuration. Disable all tracing except PS Sampling and
Timestamps. Set the Resolution to the highest possible value.
Start tracing.
Make sure that incoming packages can be seen in the SWV Trace Log.
205 | P a g e
INSTRUCTION TRACING
This section provides information on how to do Instruction Tracing with Atollic TrueSTUDIO®
for ARM.
Enable Trace
206 | P a g e
Instruction Tracing
INSTRUCTION TRACING
Atollic TrueSTUDIO® supports instruction tracing, provided that trace-enabled hardware is
being used. Instruction tracing records the execution flow of the processor in real-time.
The recorded trace buffer can then be analyzed to locate the cause of software errors.
Instruction tracing is particularly useful when debugging problems that only occur
sporadically.
Atollic TrueSTUDIO supports instructing tracing using both the ETM and the ETB methods:
ETM tracing: ETM tracing works with many Cortex-M devices but requires using
an ETM-trace enabled JTAG probe. Atollic TrueSTUDIO supports ETM tracing
using the Segger J-Trace JTAG probe. The J-Link and ST-LINK probes cannot be
used for ETM tracing as they have no trace buffer. The trace buffer in ETM-
compatible trace probes are typically many megabytes in size.
ETB tracing: ETB tracing can only be used with Cortex devices that have this
feature enabled in the silicon. ETB tracing can be done using any of the supported
JTAG probes, including Segger J-Link, as the trace buffer is not located in the JTAG
probe but instead inside the target device. This adds to the chip cost and
therefore is not supported by all chip vendors. The on-chip ETB trace buffer is
tiny; typically 2KB or 4KB only.
Both ETM and ETB tracing records all executed machine code instructions, until the
hardware limits are reached. A trace buffer is filled very quickly even though it is highly
compressed. The compressed trace buffer in a JTAG probe with a 16MB of trace buffer
typically expands into 200MB of uncompressed machine readable data, and to 2-3GB of
human readable data. Instruction tracing thus quickly generates a huge amount of data.
ETM/ETB Trace may not work on max CPU clock speed. Please check the User
manual from the board/microcontroller manufacturer if there are any trace
clock limitations.
ENABLE TRACE
Instruction tracing (using ETM or ETB) must be enabled in the debug configuration. To
enable instruction tracing, first open the debug configuration dialog box:
207 | P a g e
Instruction Tracing
1. In the Debug probe dropdown list, select Segger J-Trace (for ETM and ETB
tracing) or Segger J-Link (ETB tracing only).
2. In the Trace systems dropdown list, select the ETM or ETB trace system.
3. Ensure the Probe buffer size setting corresponds to the JTAG probe in use (ETM
tracing only).
4. For ETM tracing, make sure the Trace Port config selection points to a file that
setup the ETM trace pins of the device in a way that works for the target board in
use. The commands in the file are sent to the target when trace recording is
started first time in a debug session. See the section below for information on
how to write a new trace port configuration file for custom designed or
unsupported boards.
208 | P a g e
Instruction Tracing
Atollic TrueSTUDIO comes with a readymade trace port configuration file for most of the
supported boards, but it is possible to edit them, or create new ones, to enable ETM
tracing on new boards. It is recommended to copy such readymade file to the Project or
some other folder on the files system if any changes are needed. Make the change in the
copied file and make sure to point to the correct file in the Trace Port Config selection in
the debug configuration.
See the example below for the Freescale Kinetis TWR-K70FN1M0 board:
if ($tracePortWidth == 1)
end
if ($tracePortWidth == 2)
209 | P a g e
Instruction Tracing
end
if ($tracePortWidth == 4)
end
To configure trace, suspend the debug session and open the Trace Log view (Select View in
the top menu and then ETM/ETB, Trace Log).
In the Trace Log view toolbar, click on the Configuration toolbar button.
210 | P a g e
Instruction Tracing
Configure the Trace Port Width dropdown list to match the number of pins used for ETM
tracing on the hardware board.
Using the Stall processor on FIFO full checkbox, select one of these two options:
Stall the processor when the ETM trace FIFO buffer becomes full. With this
setting, no trace data is lost but the timing behavior of the application can be
changed.
Do not stall the processor when the ETM trace FIFO buffer becomes full. With this
setting, the processor will always continue to run at full speed but trace data may
be lost.
Some devices support timestamps. Enabling the timestamps can be useful if timing
information is needed. It will however reduce the amount of other information available.
211 | P a g e
Instruction Tracing
There are four hardware triggers that can be set to starting and stopping the tracing on
different conditions.
To access them, open the Trace Configuration as above and select Add Trace Triggers…
212 | P a g e
Instruction Tracing
For each of the triggers 0-3, it is possible to define that the trigger shall start or stop
tracing, if its configured conditions are met. Each trigger has the following options:
Enter the address to trigger on in the Expression/Address field. This field accepts:
Typically, at least one trigger is configured to start tracing, and another trigger is
configured to stop tracing. Once the trace start and stop conditions have been configured,
click OK to save the trace trigger settings.
Right click on the ruler to the left in the editor window and select Add Trace Trigger.
213 | P a g e
Instruction Tracing
A new trigger will be created and tracing starts to be collected when execution reaches
that line of code.
From this view the triggers can easily be inactivated, activated, removed and even added.
Bear in mind that the hardware supports up to a maximum of four simultaneous Trace
Triggers.
214 | P a g e
Instruction Tracing
With trace recording enabled, start target execution. When execution is suspended, the
Trace Log view is filled with the recorded instruction trace (provided the trace start trigger
condition was fulfilled).
The Trace Log view shows detailed information on what the processor was doing up to the
point of suspending execution.
Please note the column with graphical icons that annotate the Trace Log view with
information about execution flow branches:
215 | P a g e
Instruction Tracing
At the end of the view is the End of Trace marker displayed. This is added to the Trace Log
each time the buffer is overflowed and it indicates that some trace data most likely is lost.
The other important marker is the Trace restarted marker. It indicates that the target
wasn’t able to generate all the trace information without affecting the performance of the
running application. Some data is lost.
To overcome this issue, enable Stall processor on FIFO full in the Trace Configuration.
Enabling Stall processor on FIFO full will slow down the processor in some
situation and hence affect the timing of the execution. For some real time
applications this is unacceptable.
DISPLAY OPTIONS
The Log Trace view supports several different display options:
C tracing
Assembler tracing
Use the different Display Options Toolbar Buttons to switch between the different view-
modes.
216 | P a g e
Instruction Tracing
The Function call tracing displays what function the execution is in and from where it is
called or returned from.
Using the search feature it is possible to search for certain data of particular interest. For
example, assume a system crash sometimes happens because a variable has an illegal
value. By searching the instruction trace for the address of the variable, it is possible to
understand what code modifies the value and gives it the illegal value causing a system
crash.
The trace log can be saved to either comma separated value files (*.csv) that can be
imported into Microsoft® Excel®, or to human readable ASCII text files (*.txt).
Configure the trace record range to export using the From Index and To Index fields.
As the saved trace log becomes approximately 200 times larger than its compressed size in
the JTAG probe trace buffer, the saved trace log can optionally be split to many files in
order to avoid exported trace logs which are several gigabytes in size (for example, the
16MB compressed trace buffer in Segger J-Trace expands to 2-3GB when saved to a
human readable trace log file in *.CSV or *.TXT formats).
217 | P a g e
Instruction Tracing
Select the file filename and folder to use for the export using the Browse button. In the
Save As dialog box, select the desired filename and folder, select *.CSV or *.TXT file
format, and click Save to return to the Export Trace dialog box. Click OK to start exporting
the trace log.
218 | P a g e
RTOS-Aware Debugging
RTOS-AWARE
DEBUGGING
This section provides information on how to debug Real Time Operating Systems (RTOS) with
Atollic TrueSTUDIO® for ARM.
Segger embOS
Freescale MQX
Micrium uC/OS-III
Quadros RTXC
TOPPERS/ASP
219 | P a g e
RTOS-Aware Debugging
Several different Real Time Operating Systems are supported and the current state of the
RTOS kernel and the various RTOS kernel objects can easily be inspected in a set of
dedicated views, in the Atollic TrueSTUDIO Debug perspective.
220 | P a g e
RTOS-Aware Debugging
SEGGER EMBOS
The kernel awareness features for Segger embOS in Atollic TrueSTUDIO provide the
developer with a detailed insight into the internal data structures of the embOS kernel.
During a debug session, the current state of the embOS kernel and the various embOS
kernel objects such as tasks, mailboxes, semaphores and software timers, can easily be
inspected in a set of dedicated views, in the Atollic TrueSTUDIO Debug perspective.
REQUIREMENTS
The kernel awareness features require Segger embOS version 3.80 or later.
Please note that the level of information available in the different views in
Atollic TrueSTUDIO depends on the options used when the embOS kernel was
built. This manual refers to an embOS kernel built with the debug and
profiling (DP) build options. Please note that microcontrollers based on the
ARM-cores Cortex-M0 and Cortex-M0+ do not support Serial Wire Viewer
tracing.
These views can be opened from the Show View toolbar dropdown list button.
221 | P a g e
RTOS-Aware Debugging
SYSTEM INFORMATION
The embOS System Information view displays a number of system variables available in
the embOS kernel, such as status, number of tasks, etc.
This view also provides descriptive fault information messages for any fault conditions
detected by the OS kernel.
222 | P a g e
RTOS-Aware Debugging
Name Description
OS_pCurrentTask The address (TCB) and name of the currently running task.
OS_pActiveTask The address (TCB) and name of the next running task.
embOS build The build options of the currently running embOS kernel.
In the example, debugging and profiling information (DP)
is available.
Table 4 – embOS System Variables
TASK LIST
The embOS Task List view displays detailed information regarding all available tasks in the
target system. The task list is updated automatically each time the target execution is
suspended.
There is one column for each type of task parameter, and one row for each task. If the
value of any parameter for a particular task has changed since the last time the debugger
was suspended, the corresponding row will be highlighted in yellow.
Please note that due to performance reasons, stack analysis (the Stack Info column) is
disabled by default. To enable stack analysis, use the Stack analysis toggle toolbar button
in the View toolbar:
223 | P a g e
RTOS-Aware Debugging
Name Description
Status The current status of the task. The type of object that
currently blocks a task is presented in parenthesis.
Waitable Object The address of the object the task is waiting for.
Events The event mask of the task. A value of 0x0 means that the
task is not waiting on any events.
Stack Info The amount of used stack space, the available stack space
and the stack start address. [Used/Total@Address].
Note! This feature must be enabled in the View toolbar.
Round Robin The number of remaining time slices (ticks) and the time
slice reload value, during round robin scheduling.
Table 5 – embOS Task Parameters
TIMERS
The embOS Timers view displays detailed information regarding all available software
timers in the target system. The timers view is updated automatically each time the target
execution is suspended.
224 | P a g e
RTOS-Aware Debugging
There is one column for each type of timer parameter, and one row for each timer. If the
value of any parameter for a particular timer has changed since the last time the debugger
was suspended, the corresponding row will be highlighted in yellow.
Name Description
Hook The address and name of the function that is called when
the timer expires.
RESOURCE SEMAPHORES
The embOS Resource Semaphores view displays detailed information regarding all
available resource semaphores in the target system. The view is updated automatically
each time the target execution is suspended.
There is one column for each type of semaphore parameter, and one row for each
semaphore. If the value of any parameter for a particular semaphore has changed since
the last time the debugger was suspended, the corresponding row will be highlighted in
yellow.
225 | P a g e
RTOS-Aware Debugging
Column Description
Owner The address (TCB) and name of the task currently owning
the semaphore.
Use counter The semaphore use counter. Keeps track of how many
times the semaphore has been claimed by a task.
Waiting tasks The address (TCB) and name of all tasks waiting on the
semaphore.
Table 7 – embOS Resource Semaphore Parameters
MAILBOXES
The embOS Mailboxes view displays detailed information regarding all available mailboxes
in the target system. The view is updated automatically each time the target execution is
suspended.
There is one column for each type of mailbox parameter, and one row for each mailbox. If
the value of any parameter for a particular mailbox has changed since the last time the
debugger was suspended, the corresponding row will be highlighted in yellow.
226 | P a g e
RTOS-Aware Debugging
Column Description
Waiting tasks The address (TCB) and name of all tasks waiting on the
mailbox.
Table 8 – embOS Mailbox Parameters
227 | P a g e
RTOS-Aware Debugging
REQUIREMENTS
The kernel awareness features described in this document is based on eTaskSync Versions
3.01.
228 | P a g e
RTOS-Aware Debugging
TASK LIST
The eTaskSync Task List view displays detailed information regarding all available tasks in
the target system. The task list is updated automatically each time the target execution is
suspended.
There is one column for each type of task parameter, and one row for each task. If the
value of any parameter for a particular task has changed since the last time the debugger
was suspended, the corresponding row will be highlighted in yellow.
Name Description
Time Slice The time slice. This is not always present. Only if
SYNC_TIME_SLICE_ENABLE option is set at compile time in
hcc/src/config/config_sync.h.
229 | P a g e
RTOS-Aware Debugging
The kernel awareness features for FreeRTOS in Atollic TrueSTUDIO provide the developer
with a detailed insight into the internal data structures of the FreeRTOS kernel. During a
debug session, the current state of the FreeRTOS kernel and the various FreeRTOS kernel
objects such as tasks, mailboxes, semaphores and software timers, can be easily inspected
in a set of dedicated views, in the Atollic TrueSTUDIO Debug perspective.
REQUIREMENTS
In order for the FreeRTOS Queues and the FreeRTOS Semaphores views to be able to
locate the appropriate RTOS kernel data structures, the associated kernel objects need to
be added to the FreeRTOS queue registry. Please consult the FreeRTOS reference manual
for details.
The following define fixes so GDB doesn't fail when going through the stack of
a task in FreeRTOS 7.6. The same problem might also affect earlier releases.
These views are available from the Show View toolbar dropdown list button.
230 | P a g e
RTOS-Aware Debugging
TASK LIST
The FreeRTOS Task List view displays detailed information regarding all available tasks in
the target system. The task list is updated automatically each time the target execution is
suspended.
There is one column for each type of task parameter, and one row for each task. If the
value of any parameter for a particular task has changed since the last time the debugger
was suspended, the corresponding row will be highlighted in yellow.
231 | P a g e
RTOS-Aware Debugging
Please note that due to performance reasons, stack analysis (the Min Free Stack column)
is disabled by default. To enable stack analysis, use the Stack analysis toggle toolbar
button in the View toolbar:
Name Description
Priority (Base/Actual) The task base priority and actual priority. The base priority
is the priority assigned to the task. The actual priority is a
temporary priority assigned to the task due to the priority
inheritance mechanism.
Start of Stack The address of the stack region assigned to the task.
Event Object The name of the resource that has caused the task to be
blocked.
232 | P a g e
RTOS-Aware Debugging
Name Description
Min Free Stack The stack “high watermark”. Displays the minimum
number of bytes left on the stack for a task. A value of 0
(most likely) indicates that a stack overflow has occurred.
Note! This feature must be enabled in the View toolbar.
Table 10 – FreeRTOS Task Parameters
QUEUES
The FreeRTOS Queues view displays detailed information regarding all available queues in
the target system. The queues view is updated automatically each time the target
execution is suspended.
There is one column for each type of queue parameter, and one row for each queue. If the
value of any parameter for a particular queue has changed since the last time the
debugger was suspended, the corresponding row will be highlighted in yellow.
Name Description
Max Length The maximum number of items that the queue can hold.
233 | P a g e
RTOS-Aware Debugging
Name Description
SEMAPHORES
The FreeRTOS Semaphores view displays detailed information regarding all available
synchronization objects in the target system, including:
Mutexes
Counting semaphores
Binary semaphores
Recursive semaphores
The view is updated automatically each time the target execution is suspended.
There is one column for each type of semaphore parameter, and one row for each
semaphore. If the value of any parameter for a particular semaphore has changed since
the last time the debugger was suspended, the corresponding row will be highlighted in
yellow.
Column Description
234 | P a g e
RTOS-Aware Debugging
Column Description
#Blocked tasks The number of tasks currently blocked waiting for the
object.
Table 12 – FreeRTOS Semaphore Parameters
TIMERS
The FreeRTOS Timers view displays detailed information regarding all available software
timers in the target system. The timers view is updated automatically each time the target
execution is suspended.
There is one column for each type of timer parameter, and one row for each timer. If the
value of any parameter for a particular timer has changed since the last time the debugger
was suspended, the corresponding row will be highlighted in yellow.
Name Description
235 | P a g e
RTOS-Aware Debugging
Name Description
Period The time (in ticks) between timer start and the execution
of the callback function.
236 | P a g e
RTOS-Aware Debugging
FREESCALE MQX
The kernel awareness features for MQX in Atollic TrueSTUDIO provide the developer with
a detailed insight into the task structures of the MQX kernel. During a debug session, the
current state of the tasks can be easily inspected in a dedicated view, in the Atollic
TrueSTUDIO Debug perspective.
REQUIREMENTS
The kernel awareness features described in this document is based on MQX Versions 4.0.
TASK SUMMARY
The MQX Task Summary view displays information regarding all available tasks in the task
chain which is part of kernel data. The task list is updated automatically each time the
target execution is suspended. The items in the view can be expanded to provide more
details about the tasks.
237 | P a g e
RTOS-Aware Debugging
There is one column for each type of task parameter, and one row for each task. If the
value of any parameter for a particular task has changed since the last time the debugger
was suspended, the corresponding row will be highlighted in yellow.
Name Description
State The state of the task. The currently running task has the
state Active.
TASK DETAILS
This is not a unique view, but instead each task in the MQX Task Summery view can be
expanded to display more information about that task.
238 | P a g e
RTOS-Aware Debugging
In this mode the view will display extensive information about each task.
A task’s creator is also recursively displayed with its own details. The hierarchy recursion is
never infinite – there is always a System task as an owner of some task in the hierarchy.
The System task terminates the recursion
239 | P a g e
RTOS-Aware Debugging
QUADROS RTXC
The kernel awareness features for Quadros RTXC RTOS in Atollic TrueSTUDIO provide the
developer with a detailed insight into the internal data structures of the RTXC kernel.
During a debug session, the current state of the RTXC kernel and the various RTXC kernel
objects such as tasks, semaphores, mailboxes, etc, can be easily inspected in a set of
dedicated views, in the Atollic TrueSTUDIO Debug perspective.
REQUIREMENTS
The kernel awareness features described in this document is based on RTXC Version 2.1.2.
The views can be accessed from the Show View toolbar dropdown list button.
240 | P a g e
RTOS-Aware Debugging
KERNEL INFORMATION
The RTXC Kernel Information view displays general information about the kernel.
Name Description
241 | P a g e
RTOS-Aware Debugging
There is one column for each type of task parameter, and one row for each task. If the
value of any parameter for a particular task has changed since the last time the debugger
was suspended, the corresponding row will be highlighted in yellow.
Name Description
242 | P a g e
RTOS-Aware Debugging
There is one column for each type of stack information, and one row for each task. If the
value of any parameter for a particular task has changed since the last time the debugger
was suspended, the corresponding row will be highlighted in yellow.
Name Description
243 | P a g e
RTOS-Aware Debugging
ALARMS
The RTXC Alarms view displays detailed information regarding all available alarms in the
target system. The view is updated automatically each time the target execution is
suspended.
There is one column for each type of alarm parameter, and one row for each alarm. If the
value of any parameter for a particular alarm has changed since the last time the debugger
was suspended, the corresponding row will be highlighted in yellow.
Name Description
Wait order The alarm’s wait order that can be either Priority or FIFO.
Waiter(s) The task(s) that is waiting on the alarm, if any. Only the first
5 tasks are shown.
Table 18 – RTXC Alarm Parameters
244 | P a g e
RTOS-Aware Debugging
COUNTERS
The RTXC Counters view displays detailed information regarding all available counters in
the target system. The counter information is updated automatically each time the target
execution is suspended.
There is one column for each type of parameter, and one row for each counter. If the
value of any parameter for a particular task has changed since the last time the debugger
was suspended, the corresponding row will be highlighted in yellow.
Name Description
EVENT SOURCES
The RTXC Event Sources view displays detailed information regarding all available event
sources in the target system. The event source information is updated automatically each
time the target execution is suspended.
245 | P a g e
RTOS-Aware Debugging
There is one column for each type of parameter, and one row for each event source. If the
value of any parameter for a particular event source has changed since the last time the
debugger was suspended, the corresponding row will be highlighted in yellow.
Name Description
EXCEPTION BACKTRACE
The RTXC Exception Backtrace view displays detailed backtrace information during an
exception.
Each line represents an exception that is either executing, or was preempted by the item
above it. The topmost line shows the active component, which preempted the component
listed on the second line, which in turn preempted the third, and so on.
246 | P a g e
RTOS-Aware Debugging
Name Description
EXCEPTIONS
The RTXC Exceptions view displays one line entry for each exception in the application.
Name Description
247 | P a g e
RTOS-Aware Debugging
MAILBOXES
The RTXC Mailboxes view displays detailed information regarding all available mailboxes
in the target system. The view is updated automatically each time the target execution is
suspended.
There is one column for each type of mailbox parameter, and one row for each mailbox. If
the value of any parameter for a particular mailbox has changed since the last time the
debugger was suspended, the corresponding row will be highlighted in yellow.
Name Description
Wait order The mailbox’s wait order that can be either Priority or FIFO.
Usage The total number of messages that have been placed in the
mailbox. Mailbox statistics must be enabled for displaying
this information.
Waiter(s) The task that is waiting on the mailbox, if any. Only the first
5 tasks are shown.
Table 23 – RTXC Mailbox Parameters
248 | P a g e
RTOS-Aware Debugging
MUTEXES
The RTXC Mutexes view displays detailed information regarding all available mutexes in
the target system. The view is updated automatically each time the target execution is
suspended.
There is one column for each type of mutex parameter, and one row for each mutex. If the
value of any parameter for a particular mutex has changed since the last time the
debugger was suspended, the corresponding row will be highlighted in yellow.
Name Description
Wait order The mutex’s wait order that can be either Priority or FIFO.
Waiter(s) The task(s) that is waiting on the mutex, if any. Only the first
5 tasks are shown.
249 | P a g e
RTOS-Aware Debugging
PARTITIONS
The RTXC Partitions view displays detailed information regarding all available partitions in
the target system. The view is updated automatically each time the target execution is
suspended.
There is one column for each type of parameter, and one row for each partition. If the
value of any parameter for a particular partition has changed since the last time the
debugger was suspended, the corresponding row will be highlighted in yellow.
Name Description
Wait order The partition’s wait order that can be either Priority or
FIFO.
Usage The usage count for the partition. Partition statistics must
be enabled for displaying this information.
250 | P a g e
RTOS-Aware Debugging
Name Description
Worst The low watermark for the available blocks in the partition.
Partition statistics must be enabled for displaying this
information.
PIPES
The RTXC Pipes view displays detailed information regarding all available pipes in the
target system. The view is updated automatically each time the target execution is
suspended.
There is one column for each type of pipe parameter, and one row for each pipe. If the
value of any parameter for a particular pipe has changed since the last time the debugger
was suspended, the corresponding row will be highlighted in yellow.
Name Description
251 | P a g e
RTOS-Aware Debugging
Name Description
Usage The usage count for the pipe. Pipe statistics must be
enabled for displaying this information.
QUEUES
The RTXC Queus view displays detailed information regarding all available queues in the
target system. The view is updated automatically each time the target execution is
suspended.
There is one column for each type of queue parameter, and one row for each queue. If the
value of any parameter for a particular queue has changed since the last time the
debugger was suspended, the corresponding row will be highlighted in yellow.
Name Description
Wait Order The queue’s wait order that can be either Priority or FIFO.
252 | P a g e
RTOS-Aware Debugging
Name Description
SEMAPHORES
The RTXC Semaphores view displays detailed information regarding all available
semaphores in the target system. The view is updated automatically each time the target
execution is suspended.
There is one column for each type of semaphore parameter, and one row for each
semaphore. If the value of any parameter for a particular semaphore has changed since
the last time the debugger was suspended, the corresponding row will be highlighted in
yellow.
253 | P a g e
RTOS-Aware Debugging
Name Description
Wait Order The semaphore’s wait order that can be either Priority or
FIFO.
254 | P a g e
RTOS-Aware Debugging
REQUIREMENTS
The kernel awareness features described in this document is based on ThreadX Cortex-
M4/GNU Version G5.5.5.0.
These views are available from the Show View toolbar dropdown list button.
255 | P a g e
RTOS-Aware Debugging
THREAD LIST
The ThreadX Thread List view displays detailed information regarding all available threads
in the target system. The thread list is updated automatically each time the target
execution is suspended
There is one column for each type of thread parameter, and one row for each thread. If
the value of any parameter for a particular thread has changed since the last time the
debugger was suspended, the corresponding row will be highlighted in yellow.
Please note that due to performance reasons, stack analysis (the Stack Usage column) is
disabled by default. To enable stack analysis, use the Stack analysis toggle toolbar button
in the View toolbar:
256 | P a g e
RTOS-Aware Debugging
Name Description
State The state of the current thread. The name of the object
that currently suspends a thread is presented in
parenthesis. For sleeping threads, the remaining sleep
time (ticks) is presented.
SEMAPHORES
The ThreadX Semaphores view displays detailed information regarding all available
resource semaphores in the target system. The view is updated automatically each time
the target execution is suspended.
There is one column for each type of semaphore parameter, and one row for each
semaphore. If the value of any parameter for a particular semaphore has changed since
the last time the debugger was suspended, the corresponding row will be highlighted in
yellow.
257 | P a g e
RTOS-Aware Debugging
Column Description
MUTEXES
The ThreadX Mutexes view displays detailed information regarding all available mutexes
in the target system. The view is updated automatically each time the target execution is
suspended.
There is one column for each type of mutex parameter, and one row for each mutex. If the
value of any parameter for a particular mutex has changed since the last time the
debugger was suspended, the corresponding row will be highlighted in yellow.
258 | P a g e
RTOS-Aware Debugging
Column Description
MESSAGE QUEUES
The ThreadX Message Queues view displays detailed information regarding all available
message queues in the target system. The view is updated automatically each time the
target execution is suspended.
There is one column for each type of message queue parameter, and one row for each
message queue. If the value of any parameter for a particular message queue has changed
since the last time the debugger was suspended, the corresponding row will be highlighted
in yellow.
Column Description
259 | P a g e
RTOS-Aware Debugging
Column Description
Message size The size (in 32-bit words) of each message entry.
EVENT FLAGS
The ThreadX Event Flags view displays detailed information regarding all available event
flag groups in the target system. The view is updated automatically each time the target
execution is suspended.
There is one column for each type of parameter, and one row for each event flag group. If
the value of any parameter for a particular event flag group has changed since the last
time the debugger was suspended, the corresponding row will be highlighted in yellow.
Column Description
260 | P a g e
RTOS-Aware Debugging
TIMERS
The ThreadX Timers view displays detailed information regarding all available software
timers in the target system. The timers view is updated automatically each time the target
execution is suspended.
There is one column for each type of timer parameter, and one row for each timer. If the
value of any parameter for a particular timer has changed since the last time the debugger
was suspended, the corresponding row will be highlighted in yellow.
Name Description
Functions The address and name of the function that will be called
when the timer expires.
Table 34 – ThreadX Timer Parameters
There is one column for each type of parameter, and one row for each memory block pool.
If the value of any parameter for a particular memory block pool has changed since the
last time the debugger was suspended, the corresponding row will be highlighted in
yellow.
261 | P a g e
RTOS-Aware Debugging
Column Description
There is one column for each type of parameter, and one row for each memory byte pool.
If the value of any parameter for a particular memory byte pool has changed since the last
time the debugger was suspended, the corresponding row will be highlighted in yellow.
262 | P a g e
RTOS-Aware Debugging
Column Description
263 | P a g e
RTOS-Aware Debugging
TOPPERS/ASP
The kernel awareness features for TOPPERS RTOS in Atollic TrueSTUDIO provide the
developer with a detailed insight into the internal data structures of the TOPPERS kernel.
During a debug session, the current state of the TOPPERS kernel and the various TOPPERS
kernel objects such as tasks, semaphores, mailboxes, etc, can be easily inspected in a set of
dedicated views, in the Atollic TrueSTUDIO Debug perspective.
Each view for the TOPPERS RTOS contains two tabs - one tab for the hardcoded Static
Information and one tab for the Current dynamic status.
REQUIREMENTS
The kernel awareness features described in this document is based on TOPPERS/ASP
Release 1.7.0.
They are available from the Show View toolbar dropdown list button.
264 | P a g e
RTOS-Aware Debugging
TASKS
The TOPPERS Tasks view displays detailed information regarding all available tasks in the
target system. The task list is updated automatically each time the target execution is
suspended.
There is one column for each type of task parameter, and one row for each task. If the
value of any parameter for a particular task has changed since the last time the debugger
was suspended, the corresponding row will be highlighted in yellow.
Name Description
Auto start If the Task is to auto start or not. Displays yes or No.
265 | P a g e
RTOS-Aware Debugging
Name Description
Waiting object When Status is Waiting, this column displays Delay, Sleep,
Recv DTQ, Recv PDTQ, Semaphore, EventFlag, Send DTQ,
Send PDTQ, Mailbox or Mempool
Remaining time When Status is Waiting, this column displays the remaining
time waiting or Forever.
266 | P a g e
RTOS-Aware Debugging
DATAQUEUES
The TOPPERS Dataqueues view displays detailed information regarding all available data
queues in the target system. The list is updated automatically each time the target
execution is suspended.
There is one column for each type of data queue parameter, and one row for each data
queue. If the value of any parameter for a particular data queue has changed since the last
time the debugger was suspended, the corresponding row will be highlighted in yellow.
Name Description
267 | P a g e
RTOS-Aware Debugging
Name Description
First Waiting Task (receive) When there is a waiting task of this object, displays 1st
waiting task ID. When there is no waiting task of this
object, displays blank space.
First Waiting Task (send) When there is a waiting task of this object, displays 1st
waiting task ID. When there is no waiting task of this
object, displays blank space.
Queuing Data Top When there is queuing data, display 1st queuing data
address as Hex.
Table 40 – TOPPERS Dataqueues Current Status
268 | P a g e
RTOS-Aware Debugging
EVENT FLAGS
The TOPPERS Event Flags view displays detailed information regarding all available event
flags in the target system. The list is updated automatically each time the target execution
is suspended.
There is one column for each type of event flag parameter, and one row for each event
flag. If the value of any parameter for a particular event flag has changed since the last
time the debugger was suspended, the corresponding row will be highlighted in yellow.
Name Description
269 | P a g e
RTOS-Aware Debugging
Name Description
First Waiting Task When there is a waiting task of this object, displays 1st
waiting task ID. When there is no waiting task of this
object, displays blank space.
Table 42 – TOPPERS Event Flags Current Status
MAILBOXES
The TOPPERS Mailboxes view displays detailed information regarding all available
mailboxes in the target system. The list is updated automatically each time the target
execution is suspended.
There is one column for each type of mailbox parameter, and one row for each mailbox. If
the value of any parameter for a particular mailbox has changed since the last time the
debugger was suspended, the corresponding row will be highlighted in yellow.
270 | P a g e
RTOS-Aware Debugging
Name Description
271 | P a g e
RTOS-Aware Debugging
Name Description
ID The Mailbox ID
First Waiting Task When there is a waiting task of this object, displays 1st
waiting task ID. When there is no waiting task of this
object, displays blank space.
MEMORY POOLS
The TOPPERS Memory Pools view displays detailed information regarding all available
memory pools in the target system. The list is updated automatically each time the target
execution is suspended.
There is one column for each type of memory pool parameter, and one row for each
memory pool. If the value of any parameter for a particular memory pool has changed
since the last time the debugger was suspended, the corresponding row will be highlighted
in yellow.
272 | P a g e
RTOS-Aware Debugging
Name Description
Name Description
First Waiting Task Display 1st waiting task ID when there is a waiting task
of this object.
Table 46 – TOPPERS Memory Pools Current Status
273 | P a g e
RTOS-Aware Debugging
CYCLIC HANDLERS
The TOPPERS Cyclic Handlers view displays detailed information regarding all available
cyclic handlers in the target system. The list is updated automatically each time the target
execution is suspended.
There is one column for each type of cyclic handler parameter, and one row for each cyclic
handler. If the value of any parameter for a particular cyclic handler has changed since the
last time the debugger was suspended, the corresponding row will be highlighted in
yellow.
Name Description
274 | P a g e
RTOS-Aware Debugging
Name Description
Rest time until cyclic event Display Remaining time as ms in decimal form when
Cyclic event is started.
Table 48 – TOPPERS Cyclic Handlers Current Status
ALARM HANDLERS
The TOPPERS Alarm Handlers view displays detailed information regarding all available
alarm handlers in the target system. The list is updated automatically each time the target
execution is suspended.
There is one column for each type of alarm handler parameter, and one row for each
alarm handler. If the value of any parameter for a particular alarm handler has changed
since the last time the debugger was suspended, the corresponding row will be highlighted
in yellow.
275 | P a g e
RTOS-Aware Debugging
Name Description
Name Description
276 | P a g e
RTOS-Aware Debugging
Name Description
Rest time until alarm Display Remaining time as ms in decimal form when
Alarm is started.
Table 50 – TOPPERS Alarm Handlers Current Status
277 | P a g e
RTOS-Aware Debugging
MICRIUM µC/OS-III
The kernel awareness features for Micriµm µC/OS-IIITM in Atollic TrueSTUDIO provide the
developer with a detailed insight into the internal data structures of the µC/OS-III kernel.
During a debug session, the current state of the µC/OS-III kernel and the various µC/OS-III
kernel objects such as tasks, memory partitions, message queues, semaphores and
software timers, can be easily inspected in a set of dedicated views, in the Atollic
TrueSTUDIO Debug perspective.
REQUIREMENTS
The kernel awareness features described in this document is based on µC/OS-III V3.02.00.
Please note that the level of information available in the different views in
Atollic TrueSTUDIO depends on the configuration of the µC/OS-III RTOS. If
some feature is not enabled, the views presented in this document may
contain columns presenting information such as “N/A” (Not Applicable) or “0”
instead of expected values when debugging the target system. The Micriµm
µC/OS-III Users Guide contains information on how different features can be
enabled in the operating system.
These views are available from the Show View toolbar dropdown list button.
278 | P a g e
RTOS-Aware Debugging
SYSTEM INFORMATION
The µC/OS-III System Information view displays a number of system variables available in
the µC/OS-III kernel, such as state, version, CPU usage, different counter information, etc.
279 | P a g e
RTOS-Aware Debugging
Name Description
Max Interrupt Disable Time The maximum interrupt disabled time (µs).
280 | P a g e
RTOS-Aware Debugging
Name Description
Scheduler Lock Nesting Counter The counter for the nesting level of the scheduler
lock.
Max Scheduler Lock Time The maximum amount of time the scheduler was
locked irrespective of which task did the locking
Table 51 – µC/OS-III System Variables
TASK LIST
The µC/OS-III Task List view displays detailed information regarding all available tasks in
the target system. The task list is updated automatically each time the target execution is
suspended.
There is one column for each type of task parameter, and one row for each task. If the
value of any parameter for a particular task has changed since the last time the debugger
was suspended, the corresponding row will be highlighted in yellow.
Name Description
281 | P a g e
RTOS-Aware Debugging
Name Description
Ticks Rem The amount of time (ticks) remaining for a delayed task to
become ready-to-run or for a pending task to timeout
CtxSwCtr The number of times the task has executed (switched in).
SLT The maximum amount of time (µs) the scheduler has been
(Scheduler Lock Time) locked by the task.
Task Sem Ctr The number of times the task has been signaled while the
task was not able to run.
SEMAPHORES
The µC/OS-III Semaphores view displays detailed information regarding all available
resource semaphores in the target system. The view is updated automatically each time
the target execution is suspended.
There is one column for each type of semaphore parameter, and one row for each
semaphore. If the value of any parameter for a particular semaphore has changed since
the last time the debugger was suspended, the corresponding row will be highlighted in
yellow.
282 | P a g e
RTOS-Aware Debugging
Column Description
MUTEXES
The µC/OS-III Mutexes view displays detailed information regarding all available mutexes
in the target system. The view is updated automatically each time the target execution is
suspended.
There is one column for each type of mutex parameter, and one row for each mutex. If the
value of any parameter for a particular mutex has changed since the last time the
debugger was suspended, the corresponding row will be highlighted in yellow.
283 | P a g e
RTOS-Aware Debugging
Column Description
Owner The name of the task that currently owns the mutex.
Owner Org Prio The owning task original priority (task priority may have
been raised due to priority inheritance).
Owner Nest Ctr The owning task nesting counter. Number of times the
owning task acquired the mutex.
MESSAGE QUEUES
The µC/OS-III Message Queues view displays detailed information regarding all available
message queues in the target system. The view is updated automatically each time the
target execution is suspended.
There is one column for each type of message queue parameter, and one row for each
message queue. If the value of any parameter for a particular message queue has changed
since the last time the debugger was suspended, the corresponding row will be highlighted
in yellow.
284 | P a g e
RTOS-Aware Debugging
Column Description
Pend List List of tasks pending on the queue. Highest priority tasks
are sorted first in list.
Table 55 – µC/OS-III Message Queue Parameters
EVENT FLAGS
The µC/OS-III Event Flags view displays detailed information regarding all available event
flag groups in the target system. The view is updated automatically each time the target
execution is suspended.
There is one column for each type of parameter, and one row for each event flag group. If
the value of any parameter for a particular event flag group has changed since the last
time the debugger was suspended, the corresponding row will be highlighted in yellow.
Column Description
285 | P a g e
RTOS-Aware Debugging
Column Description
Time Stamp The last time the group was posted to.
Pend List Entries The number of tasks pending on the event flag group.
Pend List List of tasks pending on the event flag group. Highest
priority tasks are sorted first in list.
Table 56 – µC/OS-III Event Flag Parameters
TIMERS
The µC/OS-III Timers view displays detailed information regarding all available software
timers in the target system. The timers view is updated automatically each time the target
execution is suspended.
There is one column for each type of timer parameter, and one row for each timer. If the
value of any parameter for a particular timer has changed since the last time the debugger
was suspended, the corresponding row will be highlighted in yellow.
Name Description
286 | P a g e
RTOS-Aware Debugging
Name Description
Delay The expiration time for one-shot timers and initial delay
for periodic timers.
Callback The address and name of function to call when the timer
expires.
Table 57 – µC/OS-III Timer Parameters
MEMORY PARTITIONS
The µC/OS-III Memory Partitions view displays detailed information regarding all available
memory partitions in the target system. The view is updated automatically each time the
target execution is suspended.
There is one column for each type of parameter, and one row for each memory partition.
If the value of any parameter for a particular memory partition has changed since the last
time the debugger was suspended, the corresponding row will be highlighted in yellow.
287 | P a g e
RTOS-Aware Debugging
Column Description
288 | P a g e
Source Code Review
289 | P a g e
Source Code Review
In order to put the concepts and terminology used in Atollic TrueSTUDIO into context, the
two flow charts below are provided.
The first flow chart shows a commonly deployed software review workflow. The second
flowchart shows the individual source code review steps available in Atollic TrueSTUDIO.
The dashed lines between the two flow charts, map the steps of one flow chart to the
corresponding steps in the other.
Figure 271 – Atollic TrueSTUDIO Support for the Code Review Workflow
290 | P a g e
Source Code Review
291 | P a g e
Source Code Review
The comments may thus be shared between reviewers using a commonly accessed version
control system. This is a big advantage, as no server-side database needs to be installed,
configured and administered to perform code reviews. The normal version control system,
such as GIT or Subversion, is used for team collaboration.
In order to perform a code review the first step is to create a review ID for this specific
code review session. Creating a review ID is typically done by a moderator, which may be a
team leader or an employee from the quality assurance department. This is a simple
operation where the user is prompted to configure the following options:
The steps to create a specific code review session can be severely simplified by taking the
time to create a project, or company standard, review template. All future reviews that are
created later can then be based on this review template. The moderator will thus only be
required to configure most of the above options once for each TrueSTUDIO workspace.
This is described in next chapter.
Review comments are stored as XML formatted files in a selectable folder within the
TrueSTUDIO project; one file for each reviewer. The overall review settings are saved as a
hidden XML formatted file in the project root folder in the workspace.
292 | P a g e
Source Code Review
CREATING A REVIEW ID
In order to create a review ID the user must access the properties for the Atollic
TrueSTUDIO project that is containing the desired work product. This is done by
performing the following steps:
2. Click on the Build Settings toolbar button or right-click on the project in the
Project Explorer view and click Properties.
4. The user may choose to add a New, or Edit or Remove an existing, review
in the dialog box.
293 | P a g e
Source Code Review
6. Give the review a Review ID, i.e. a name. It is recommended not to use
whitespaces as this will be part of the file name. Also provide a short
description for the meeting. Click Next.
7. The next step determines the work product for the meeting. Choose which
files that will be subject to this review. Use the buttons to Add and
Remove files.
294 | P a g e
Source Code Review
9. Select an author among the reviewers. The review issues identified in the
Team Phase will be assigned to the author as default. Naturally, an explicit
assignment overrides the default.
10.In this step, it is possible to configure available parameter options for the
review comments. The parameter options are:
295 | P a g e
Source Code Review
11.It is possible to set a default option for each of the above review
parameters. This will be used unless an option is chosen explicitly when a
review comment is created or modified.
12.Choose the folder name where review issue data will be saved within the
project. This folder will be stored in the root level of the corresponding
project. It is possible to put the review issue data in a subfolder, i.e.
“ProjectName/reviews/MileStone1_2013-01-02/” by using “/”
(forward slash). The previous example would be specified as:
“reviews/MileStone1_2013-01-02”
296 | P a g e
Source Code Review
13.In the final step the user can customize which information shall be shown
in the Review Table view during the three different phases; Individual,
Team, Rework. This is done by setting up filters. These filter can be toggled
on and off in the Code Review Table view during the inspection.
Individual Phase – The default filter allows the reviewers to view their
own comments only. It is recommended is to keep this filter, so that
reviewers are not biased by each other’s review comments.
Team Phase – The default filter allows the moderator and the
reviewers to view only comments which have “Resolution: Unset”.
This means that only review comments that still require a decision are
shown.
297 | P a g e
Source Code Review
Click Finish to save all settings for the specific Review ID.
14.As a final, and very important, step, make sure to commit the review
settings file which resides in the project root folder and is called
.code_review_properties to the version control system. Configuration
files are typically hidden from the rest of the project resources by using a
leading “.” (dot-character) in the filename. A file with a leading “.” in the
filename will not be shown by the Project Explorer docking view. In order
to commit this file the user must open the Navigator docking view which
also shows hidden configuration files.
Default selections
The DEFAULT review ID template can be edited from the Review panel in the Project
Properties by selecting DEFAULT and clicking Edit…
298 | P a g e
Source Code Review
The user may also choose to remove a Review ID by clicking Remove… in the Review panel
in the Project Properties. This will remove the corresponding sections from the review
settings file and all individual reviewer files containing the individual review issue data.
299 | P a g e
Source Code Review
The Code Review perspective contains a number of unique views and toolbar buttons.
300 | P a g e
Source Code Review
The Code Review perspective has a toolbar adapted for navigation of review issues. The
toolbar has the following buttons and functionality:
Individual Phase Log into the individual phase and add code
review comments
Team Phase Log into the Team Phase, and perform a code
review meeting
Rework Phase Log into the Rework Phase, and correct the
problems assigned to you at the code review
meeting
Table 60 - Code Review Toolbar Buttons
The following docking views are primarily associated to the code review perspective:
The main editor area – The editor area of the perspective is needed to review the
source code files.
The Code Review Table view – This is the list of review issues. Different set of
issues will be listed depending on selected Phase and Reviewer.
The Code Review Editor view – An editor showing the current issue being created
or modified. The editor view provides different toolbar buttons depending on the
current phase of the review.
301 | P a g e
Source Code Review
Edit the code review Edit the settings for this specific code
review
Add code review issue Adds a code review issue associated to the
code line the marker currently is on
302 | P a g e
Source Code Review
INDIVIDUAL PHASE
In order to start working in the individual phase and add review comments, the reviewer
must use their own associated reviewer ID to log into a review session. The user does this
by clicking on the toolbar button Individual Phase in the Code Review perspective.
The Review ID selection dialog will appear when the user clicks on either of the three code
review phase related toolbar buttons. Review ID must be chosen so that the associated
work product is shown to the reviewer. The user must also choose his or her name from
the Reviewer ID drop-down menu. This will make sure that all review issues found are
associated with the specified Reviewer ID.
When a user has logged into the individual phase of a certain Review ID, it is possible for
him or her to start adding review comments. This is done by reviewing the work product.
303 | P a g e
Source Code Review
The work product can be browsed by using the Go to the source code button in the Code
Review Table.
By selecting a file from the drop-down menu it will be opened in the Editor window of the
IDE. Right-click on any code line or right-click in the editor margin and a menu will be
populated containing the Add Code Review Issue… option.
When clicking Add Code Review Issue… the reviewer will be hyper-linked into the Code
Review Editor view where a new review issue is being created.
The top of the Code Review Editor view shows information about who found the review
issue, in which file and at which code line. The user may also choose to select a code block,
304 | P a g e
Source Code Review
right-click and then click Add Cod Review Issue… In this case the content of the code block
will be copied into the description field of the Review issue. The type and severity fields
are mandatory information for each review issue.
The type field identifies the type of review issue and the severity field defines the severity
level for the current issue.
After entering all information into the review issue being added, click the Save button in
the Code Review Editor view. Upon saving, the review issue will become visible in the
Code Review Table view. A review marker will also be added to the left margin of the main
editor window.
Go through the different files included in the work product and add review comments.
When an individual user has finished reviewing the work product, he/she must remember
to commit the .review file to the version control system. This enables other reviewers to
access the review issues by retrieving the files them from the version control system.
This path to the .review file was specified during the review configuration phase. By
default the file is saved in the review subfolder within the project folder.
TEAM PHASE
In this phase the team members gather in a code review meeting to discuss all the review
issues that were found by the individual reviewers. Before starting this phase it is
important that the review moderator assures that all reviewers have committed their
.review file, and subsequently updates his or her own local copy of each .review file
from the version control system. If this is not done properly, the issues from one, or more,
reviewers are not taken into account, and will not show up in the collaborative Code
Review Table view.
To start the team phase (code review meeting), click on the Team Phase toolbar button in
the Code Review perspective.
305 | P a g e
Source Code Review
The Review ID Selection dialog will appear where the user is prompted to select a Project,
a Review ID and a Reviewer ID. The Reviewer ID in this phase is typically the author of the
work product under review or the moderator hosting the meeting.
All review issues collected by all reviewers are now displayed in the Code Review Table
view (provided that the review comment files have been committed to the version control
system, and have subsequently been updated to the computer being used for the code
review meeting).
Click on any review issue in the Code Review Table view and its content will be shown in
the Code Review Editor view. If an already existing review issue is modified in this phase,
make sure to click Save, Next, or Previous button to automatically save any changes. By
double-clicking on any review issue in the Code Review Table view, the associated source
code lines are also shown in the editor area of the IDE.
Review issues can also be navigated from the Code Review Editor view by using the Next
and Previous buttons. The Go to the source code button allows jumping from the Code
Review Editor view into the source code.
The Assigned To field contains the author’s Review ID by default, but can be changed to
the Reviewer ID of any other team reviewer. When the group has reached a decision on
how to handle the review issue at hand, the Resolution field must be changed to reflect
this decision. The Annotation field allows additional information to be added.
By single-clicking on a review marker in the source code, the summary and description of
the review issues for the specific code line will be shown in a tooltip.
Review markers are also subject to the filter that is configured for the current phase of the
code review. For example, if the filter is set to show Resolution: Unset issues only, then
only review markers associated with such review issues will be shown.
306 | P a g e
Source Code Review
When all review issues have been handled in the code review meeting; a reviewer has
been assigned and a resolution has been chosen for all review comments, it is important to
remember to commit the .review files to the version control system. When this is done
all reviewers are able to access the decision outcome information from the Team Phase,
and the code review can enter the Rework Phase.
REWORK PHASE
In this phase each reviewer will work on the review issues that were assigned to him/her
at the code review meeting, in order to implement the agreed resolution. Before starting
this phase it is important that the each reviewer updates the folder containing the
.review files from the version control system. If this is not done, the reviewer will not be
able to access any assigned-to or resolution information from the code review meeting.
To start this phase click on the Rework Phase toolbar button in the Code Review
perspective.
The Review ID Selection dialog will appear where the user is prompted to select a Project
a Review ID and a Reviewer ID.
In the Code Review Table view, the user will only see the review issues that were assigned
to the reviewer that was selected in the Review ID Selection dialog when entering this
phase. The purpose of this phase is that each reviewer addresses the review issues that
were assigned to him/her respectively.
The Code Review Editor view will now contain the fields Status, Resolution and Revision.
The Status field allows the status of each review issue to be changed. The resolution fields
simply states the agreed resolution decided at the code review meeting. It can and should
not be changed in this phase. The Revision field provides the possibility to write a
comment related to the implemented resolution.
307 | P a g e
Source Code Review
Figure 297 - Code Review Editor View Content in the Rework Phase
When all fields are filled in for the Review issue at hand, the reviewer must click Save,
before the buttons Next and Previous can be used to view the next review issue to fix.
When updated statuses for all review issues have been saved, the Code Review Table view
will be empty. The reviewer must then remember to commit the .review file to the
version control system so that the moderator can verify that everything has been fixed.
ADDITIONAL SETTINGS
The Code Review Table view can also be customized temporarily without overwriting the
.code_review_properties file. This is done from the Preference settings found in the
Code Review Table view toolbar.
In this customization dialog the user may change filters that are applied on the Code
Review Table view in order to show only review issues that have a certain parameter
combination. It is also possible to tailor which columns, and thereby which parameters, are
visible in each phase.
308 | P a g e
Source Code Review
309 | P a g e
Test Automation
310 | P a g e
Static Code Analysis
INTRODUCTION
Atollic TrueSTUDIO Pro and Premium includes a professional tool for static source code
analysis that helps you to find potential bugs automatically. By using static source code
analysis, you can easily improve the quality of your software product.
The static code analysis included in Atollic TrueSTUDIO was previously sold
on a separate license called TrueINSPECTOR.
Automated static source code analysis is the process in which a software tool analyzes the
source code of an application, and automatically detects potential bugs or other types of
problems.
The tool parses the source code of the application and analyzes how the source code is
written. Static source code analysis is typically divided into two different areas:
The Atollic TrueSTUDIO static source code analysis analyses the code and generates
source code metrics. The source code is validated against a database of formal coding
standards, and coding constructs that are known to be error-prone are detected
automatically, thus reducing the number of errors. This in turn reduces
development/debug/test time, reduces development cost, and improves the quality of the
software product.
Static source code analysis runs in demo mode in Atollic TrueSTUDIO Lite.
Static source code analysis only works with managed mode projects, not
makefile mode projects.
311 | P a g e
Static Code Analysis
ensures that unsafe or unreliable coding constructs are not used, thus improving software
quality and reducing the time spent on debugging.
Developers can configure the rules to enable or disable at specific code inspection
sessions, and rule violations are directly connected to the corresponding lines in the C/C++
editor. For each violation, Atollic TrueSTUDIO gives an example of code that triggers the
violation, and provides an example of the recommended coding style that solves the
reported problem.
Additionally, Atollic TrueSTUDIO performs source code metrics on project, file and
function level too. This enables developers to view statistics on parameters like number of
lines in files, number of lines in functions, commenting level and C function code
complexity.
With a better understanding of what parts of the code are too complex, it can be rewritten
using less complex coding constructs. Avoiding complex code constructs is a good way to
improve maintainability and reducing the risk of errors, thus reducing development time
and increasing product quality.
REPORTS
Atollic TrueSTUDIO generates various types of reports that can be exported in Microsoft®
Word®, Microsoft® Excel®, HTML and PDF formats, for offline analysis or as technical proof
of compliance for management or customers. See the chapter Generate a Report on page
330.
312 | P a g e
Static Code Analysis
1. Select the project in the Project explorer, and select the File, Properties menu
command to open the Properties dialog box. Then select the Testing, Rule Setting
panel:
313 | P a g e
Static Code Analysis
2. Expand the MISRA 2004 node, and select one of the rules:
The Description field explains the purpose of the selected coding standard rule. Any rule
can be enabled or disabled as appropriate using the corresponding checkboxes. Use the
Import… and Export… buttons to store rule selection configurations in an external file.
314 | P a g e
Static Code Analysis
3. Optionally exclude files or folders from analysis, using the Testing, Exclusion,
TrueINSPECTOR panel.
Click the OK button to apply any changes made, or Cancel to exit with no changes.
315 | P a g e
Static Code Analysis
1. Switch to the Static code analysis perspective by clicking the Open Perspective
toolbar button and select the Static code analysis perspective.
2. Select the project or file to be analyzed; then press the Static code analysis
toolbar button.
If the Static Code Analysis button is grayed out, no resource that can be
analyzed has been selected. In such a case, please select a file or a project to
analyze in the Project Explorer.
316 | P a g e
Static Code Analysis
3. Atollic TrueSTUDIO starts to analyze the source code and present the analysis
results in various views. The Static code analysis perspective has several new
docking views specific to source code analysis:
317 | P a g e
Static Code Analysis
The screenshot below shows the default view layout in the static source code analysis
perspective:
318 | P a g e
Static Code Analysis
The Rule table category mode display statistics on how many times different MISRA rules
have been violated:
The Severity table category mode display statistics on how many rules of different MISRA
severity levels (Required or Advisory) have been violated:
The Source table category mode display statistics on how many MISRA violations there are
in each file:
319 | P a g e
Static Code Analysis
The Syntax Error table category mode display statistics on how many files could not be
analyzed due to syntax errors:
320 | P a g e
Static Code Analysis
recommendation for an alternative, better, coding practice. The Rule Description view is
thus a very important tool to learn and improve the coding style over time.
Select a rule in the Violation Summary view list to activate the Rule Description view:
VIOLATION VIEW
The Violation view lists the actual violations (connected to specific file:line instances)
sorted by file name:
321 | P a g e
Static Code Analysis
A hash-sign (#) before the rule name indicates that the rule is global. A global rule is a rule
that needs to be checked in more than one file to be confirmed as violated.
By using the drop-down arrow toolbar button, you can select other sorting and grouping
options, for example group by MISRA rule number instead:
322 | P a g e
Static Code Analysis
A dialog box is now displayed. Enter the name of the report(s), the desired output
directory as well as the file format.
Click on the Export button to generate the reports. Once the report(s) are exported, Atollic
TrueSTUDIO gives you the option to open the folder where the reports were generated:
Click the Open Folder button to view the folder containing the report files. Double-click to
open any of the generated reports. Atollic TrueSTUDIO selects a suitable viewer (such as
Adobe® Acrobat® Reader or Microsoft® Excel®) depending of file type.
323 | P a g e
Static Code Analysis
Code complexity is usually presented using a standard measure called the cyclomatic value
of code complexity. This measure was introduced by Thomas McCabe in 1976. It calculates
the amount of decision logic in a software block, typically a C function. It is therefore an
excellent predictor of bug probability, and can also be used to provide judgments on the
soundness and confidence for a software implementation in general.
The cyclomatic value of code complexity measures the number of independent execution
paths (the structural complexity) through a function, assigning a numerical value to the
complexity of each C function. The more iterations and conditional code a function has;
the higher its complexity level.
A complex function is likely to include more errors, and be more difficult to understand,
test and maintain. Too complex functions should be simplified by rewriting or splitting
them into several smaller functions, thus creating less error-prone functions of reduced
complexity.
324 | P a g e
Static Code Analysis
In addition to aid in decisions on rewriting and refactoring source code, code complexity
analysis can also be used to guide manual source code inspection operations. For a
number of reasons, many companies do not perform source code reviews; despite that it
is one of the most cost-effective and best ways of improving software quality quickly. But
code complexity analysis can be used to flag certain risky functions, which would benefit
from a code inspection even if most other functions are not inspected manually.
The cyclomatic complexity level also serves as the minimum number of test cases that
must be executed to cover all possible execution paths through a C function (i.e. full
branch coverage) during software testing. Therefore, code complexity analysis helps
creating or assessing the test procedures as well. And in general, it is advisable to carefully
test functions with a high complexity level.
In other words, an organization can use any complexity limit it prefers. However, they
should not accept complexity figures in excess of 10, unless they are willing to devote
additional testing efforts required by the more complex software implementation.
Regardless of the exact limit, it should be considered alarming if a function becomes more
complex than level 20.
The following, often quoted, table lists the probability of a new bug being introduced
when fixing another already existing bug:
325 | P a g e
Static Code Analysis
Finally, to aid in source code review decisions; it is good rule of thumb that at least
functions with a code complexity level of 10, or more, ought to undergo a manual source
code review.
In fact, nothing is further from the truth. No one will start to rewrite code with tens of
thousands of lines of problematic code, at the end of a project. The recommended
approach is to use this type of tool hourly or daily from the project start, to ensure a
gradual and iterative development where all code additions are checked and fixed as they
are added. Good tool support is thus of great importance.
The Code Metric view displays statistics of the source code. The default mode is to display
information at module or Build Configuration level:
326 | P a g e
Static Code Analysis
The Code Metrics will change when using different Build Configurations.
The Code Metric Value SLOC stands for Source Lines of Code. It is the number of lines with
C code. SLOC is typically used to predict the amount of effort that will be required to
develop a program, as well as to estimate programming
productivity or maintainability once the software is produced.
Click on the Metric mode toolbar button in the Code Metric view to switch to File Mode:
327 | P a g e
Static Code Analysis
The Metric dropdown list is a filtering tool to enable to select the files outside a specific
limit value. That way files with too few comments and that needs to be rewritten can
quickly be identified.
The Code Metric Value PLOC stands for Physical Lines of Code. It is the number of lines in a
file, including comment lines, excluding whitespace. SLOC stands for Statements Lines of
Code. It is the number of lines in a file containing C-statements, excluding whitespace
and/or comment lines. The file Comment Ratio is computed as:
Data in column PLOC, SLOC, Comment Ratio is only shown for files that have
been selected for analysis and for included header-files.
Click on the Metric mode toolbar button one more time to switch to Function Mode:
Atollic TrueSTUDIO now displays detailed information for each function, including code
complexity:
328 | P a g e
Static Code Analysis
Note that the cyclomatic value of code Complexity is listed for each function. It is
recommended to refactor or simplify the implementation of functions with very high
complexity values (the column can be sorted in ascending or descending order by clicking
on the column header).
The Metric dropdown list is also a very useful tool here to identify functions that need to
be rewritten.
329 | P a g e
Static Code Analysis
GENERATE A REPORT
Click on the Generate report toolbar button in the Code Metric view:
A dialog box is now displayed. Enter the name of the report(s), the desired output
directory as well as file format:
Click on the Export button to generate the reports. Once the report(s) are exported, Atollic
TrueSTUDIO gives you the option to open the folder where the reports were generated:
Click the Open Folder button to view the folder containing the report files. Double-click to
open any of the generated reports. Atollic TrueSTUDIO selects a suitable viewer (such as
Adobe® Acrobat® Reader or Microsoft® Excel®) depending of file type.
330 | P a g e
Static Code Analysis
To remove the rule violation markers, select the Violation View and press the red Remove
Violation button.
331 | P a g e
Static Code Analysis
SUMMARY
By using the static source code analysis features of Atollic TrueSTUDIO, developers get
many benefits that can improve software quality, in particular, validation against industry
best-practice coding standards and source code metrics including code complexity
measurements.
Atollic strongly recommends deploying static code analysis in any software development
your project, thus elevating software quality to a completely new level.
332 | P a g e
Test Automation
TEST AUTOMATION
This section provides information on how to use Atollic TrueVERIFIER®. Atollic TrueVERIFIER
is fully integrated into Atollic TrueSTUDIO Premium. A demo version is included in all other
Atollic TrueSTUDIO installations.
Running tests
333 | P a g e
Test Automation
INTRODUCTION
Atollic TrueSTUDIO Premium includes Atollic TrueVERIFIER, as a deeply integrated module
for professional in-target software test automation. Atollic TrueVERIFIER automates
testing of your software, and is a very powerful tool for improving the quality of your
embedded system.
Atollic TrueVERIFIER allows the user to create the test cases with or without looking in the
source code implementation.
The tests can be created before the implementation is written (manually created test
cases only, using empty function stubs), or after the source code implementation is
written (manually, or automatically generated test cases).
Atollic TrueVERIFIER automates the process of creating and running tests. Two types of
test suites can be created:
Function tests
Integration tests
For function tests, the generated test suite checks that each C function behaves as
expected. For integration tests, the generated test suite builds a more complete, real-
world type of use case, testing that several C functions works as expected when put
together into a larger scenario.
FUNCTION TESTS
For function tests, Atollic TrueVERIFIER auto-generates and auto-executes test suites that
exercise as many as possible of all potential execution paths, as the illustration below
shows:
334 | P a g e
Test Automation
In this trivial example, the source code of the function MyFunc() is analyzed, and a test
suite will be created that makes a number of function calls, one for each important
combination of input parameter values. In this case, the function has only one input
parameter, and so tests will be created for the minimum and maximum values the input
parameter data-type, along with the value 0 (and some values around it), as well as any
other parameter values that were found to modify the execution flow inside the function
(such as the value of 50 in the example above).
Please note that test cases are auto-generated only for expressions whose value can be
calculated completely by statically analyzing the code. In case an expression depends on
dynamically calculated values, for instance the return value of a function call, no test case
is generated for that expression. In such a case, a test case must be added manually.
Once the test suite(s) have been created, expected return code values and affected global
variable values can be defined, and the tests are executed automatically in the target
board and test results and achieved test coverage is uploaded and displayed in the IDE.
Calculates the test cases needed to exercise as many as possible of the potential
execution paths in each C function included in the test suite.
335 | P a g e
Test Automation
Downloads the unit tests to the target board using the same JTAG probe being
used for Atollic TrueSTUDIO debugging.
Executes the unit tests in the target board with execution-path monitoring.
When the tests are completed, test results as well as rigorous test coverage
information is uploaded and presented in Atollic TrueSTUDIO (i.e. the quality of
the test coverage is measured automatically).
In Atollic TrueVERIFIER, one or more test suites can be defined. Each test suite contains
tests for one or more C functions. Test suites are therefore a way of grouping tests for
various C functions into logical groups, such as a test suite for graphic functions, another
test suite for mathematical functions, etc.
When testing a C function, typically many test cases are needed to exercise as many as
possible of all the potential execution paths in the function. In this context, a test case can
be considered to be a function call with a defined set of input parameter values. Several
test cases for a function can thus be considered to be several function calls to that
function, using different combinations of input parameter values.
As all test cases are executed in the target board with full execution-path monitoring,
Atollic TrueVERIFIER provides a stringently defined value for the quality of the test cases
being run (in practice, how many of all the possible combinations of potential execution
paths and branch conditions have been executed by the current test suite). Atollic
TrueVERIFIER provides test coverage information for Block Coverage, the more advanced
Branch Coverage, and even Modified Condition/Decision Coverage (MC/DC).
INTEGRATION TESTS
For integration tests, Atollic TrueVERIFIER creates a more complete, real-life type of test
scenario testing that several functions perform a task as expected together.
336 | P a g e
Test Automation
Integration tests using test scenarios are created by selecting a number of functions,
rearranging their calling order, and combine them into one test that runs all the functions
in the defined order. The test scenarios can be modified manually to provide more
advanced types of scenarios, for example by wrapping function calls into if-statements and
for-loops.
CONCEPTS
Some concepts and their usage in Atollic TrueVERIFIER are outlined in the table below:
337 | P a g e
Test Automation
Term Description
Test suite A test suite contains the set of tests to be run. A test typically
drives the testing of one C function, and so a test suite tests a
set of functions. A test suite can contain one or many tests as
desired. You can define as many test suites as you like in a
project. Technically, each test suite driver is implemented in an
auto-generated C file that is located in the
<ProjectLocation>\unittest\ folder.
Test vector The set of test cases for a test. It can be considered to be the
number of function calls and their input parameter values used
to test one C function, along with the expected return codes and
affected output values for that combination of input parameter
values.
Test case One test case will drive one test of a function. As such, a test
case can be considered to be one function call with predefined
input parameter values.
Test driver The C code that drives a test. Test drivers are located in the
<ProjectLocation>\unittest\ folder.
Instrumentation C macro’s that are used to implement the test driver. The test
macro driver of a test can be instrumented with assertion macros that
check the functional behavior and determines if the result of a
test case is the expected or not.
338 | P a g e
Test Automation
Term Description
Test When test cases have been executed in the target board, each
result test case provides a test result of one of these 3 types:
Success
The function behaved as expected.
Failure
The function did not behave as expected.
Error
The test could not be executed for some reason, such as the
JTAG probe not being connected.
339 | P a g e
Test Automation
It is a good idea to not perform the actual unit testing in the same project as
the development is done in. Instead the code should be linked in to a dedicated
testing project.
That way test code and data can be separated from the development code and
data. It will also reduce the time it takes to build the test binary.
typedef struct
{
int a;
int b;
} MyValueStruct;
int a = 0;
340 | P a g e
Test Automation
else
return MyStruct->b;
}
The function MySimpleFunc() takes an integer parameter, and returns 0 or 1 dependent
on the value of the input parameter. The function MyComplexFunc() takes two input
parameters; an integer and a pointer to a complex data structure, in this case a struct
containing two integer variables. The function MyComplexFunc() also has a dependency
on a global variable, which it also modifies.
INITIAL STEPS
Before unit testing your project, make sure that your project can be built properly and that
you can debug it using the normal Atollic TrueSTUDIO debugger (i.e. compile the project,
download the resulting binary file to the target board and ensure that it is possible to
single step through a couple of source code lines).
When done, switch to the Unit Test perspective. To switch perspective, select the Open
Perspective toolbar button.
341 | P a g e
Test Automation
The code coverage instrumentation must not be applied to files that contain code that
executes before the main() function is called during the power-on-reset and boot-up
phase. The C language runtime environment is not properly initialized at this early stage.
Consequently, instrumenting this code will lead to a program crash when executing the
test in the target board.
Therefore, all files containing C code that execute before the main() function, must be
excluded from test analysis and instrumentation. However the file containing the main()
function must not be excluded, excluding this fill will lead to build errors upon test
execution.
342 | P a g e
Test Automation
It may also be desirable to exclude 3rd party libraries (such as RTOS, device drivers or other
middleware) from the tests analysis as TrueVERIFIER do not have to spend time analyzing
source code that is not likely to be tested anyway. Also please note that it is not possible
to test hardware interrupt service routines (ISR’s).
To exclude files and folders from testing, please select the project in the Project Explorer
view, right-click and select the Properties menu command.
Drill down to the Testing, Exclusion, TrueVERIFIER panel and select any files and folders to
exclude. In this example, we have excluded the device driver library that is implemented in
the Libraries and Utilities folders, as well as two C files that belong to the hardware
drivers, and may contain C code that runs before main() is called.
Exclude the relevant files and folders from your project. Close the dialog box by clicking
the OK or Cancel button.
Atollic TrueVERIFIER cannot run the tests in hardware, unless all C files that
execute code before main() are excluded.
The source file containing main() must NOT be excluded in the exclusion
filters. If the exclusion filters contain the source file implementing main(),
Atollic TrueVERIFIER will display a dialog box: “Build failed. Please check build
log”. In the build console there will also be a build error “multiple definitions
of ‘main’”.
343 | P a g e
Test Automation
A. Add unit tests. All selected C functions are grouped into one test suite. The C functions
are tested in isolation (one-by-one).
B. Add unit tests. Each selected C-function gets its own individual test suite. The C
functions are tested in isolation (one-by-one).
C. Add a unit test scenario. All selected C functions are grouped into one test suite. The C
functions are tested by calling them in the pre-defined sequence.
E. Launch Unit test (i.e., run the tests in the target board).
For the purposes of this tutorial, click on toolbar button B to create unit tests where each
function will have an individual test suite. A reminder to exclude all startup files is now
displayed. Click OK to dismiss the warning dialog box.
Atollic TrueVERIFIER now parses the source code files in the project and detects the C
functions available for testing. The currently selected project, along with available
functions for testing, is displayed in the dialog box below.
344 | P a g e
Test Automation
The Test target functions edit field can be used to filter the function name list in case the
project contains a large amount of functions. As the functions MySimpleFunc() and
MyComplexFunc() are to be tested, we type “My” in the Test Target functions edit field
to filter the list.
345 | P a g e
Test Automation
The list of functions available for testing is reduced to a more convenient size. In this
tutorial, we will auto-generate unit tests for the functions MySimpleFunc() and
MyComplexFunc(). Thus, select those functions for testing in the function list.
In addition, select the checkbox Generate test data for the selected test target functions.
This ensures the auto-generated test suites are initialized with an auto-generated set of
test cases in the test vector for each function.
346 | P a g e
Test Automation
Test data, i.e. Atollic TrueVERIFIER will parse the source code inside the selected
functions, and determine the various input parameter values that will affect the
execution flow in the function. Atollic TrueVERIFIER will then auto-generate test
cases with different combinations of parameter values, ensuring that as many
combinations of potential execution paths as possible will be tested.
Click Next to move on to the next wizard step. In this step, Atollic TrueVERIFIER will
display the input and output dependencies for each of the C functions that are to be added
for testing.
347 | P a g e
Test Automation
It is possible to drill down into complex data structures, as have been done in the
screenshot above. By selecting the corresponding checkboxes, it is possible to configure
whether checking shall be done for the detected input and output dependencies.
In the example above, Atollic TrueVERIFIER has detected that the function
MyComplexFunc() has input dependencies on both the parameter x, some members in a
complex data structure pointed to by the parameter MyStruct, as well as the global
variable a. Furthermore, checking for the return code is enabled, as are checking for the
modified value of the global variable a.
Now click the Finish button to auto-generate the new test suites according to the
configurations made. Expand the test suite tree nodes in the Unit test view and select the
test MySimpleFunc_test0. Atollic TrueVERIFIER will now look like this:
348 | P a g e
Test Automation
Figure 342 - The Unit Test Perspective with test suites added
Test drivers for each test (i.e. each C function to be tested) are auto-generated in the
unittest\ folder. The test drivers are normal C files and can be edited if needed to
accommodate for more advanced testing needs.
349 | P a g e
Test Automation
As this tutorial adds tests for the functions MySimpleFunc() and MyComplexFunc(), the
following two test driver C files have been auto-generated in the unittest folder:
MyComplexFunc_test0.c
MySimpleFunc_test0.c
As can be seen in the screenshot below, Atollic TrueVERIFIER displays the generated test
suites in the Unit test view.
Figure 344 - Test suites and tests in the Unit Test view
Selecting a test in a test suite (such as MySimpleFunc_test0) in the Unit Test view has two
effects:
The Test cases view is filled with the test vector (test case data) for the testing of
the C function tested by the selected test.
The Unit Test view provides an overview of test status and test results for each of the
functions to test. This includes the number of test cases that have been run for each
function (with success, failure or error if the test could not be run). The test status is
displayed for each test in the format of (Runs/Errors/Successes).
Errors – The number of tests that could not be executed, for example due to build
or debug errors.
In the Unit Test view there are some important toolbar buttons.
A. Synchronize unit tests. Manually trigger a re-parsing of the source code. This might
be needed if the source code has been changed outside of Atollic TrueSTUDIO.
B. Filter the view and only show tests that have not been run yet.
C. Filter the view and only show tests that have failure or error status
350 | P a g e
Test Automation
One test case equals one call to the function being tested, so each column contains the
input parameter values for the specific function call being made but that particular test
case.
The Test cases view contains the test cases (function calls) for one test (one function).
Select the desired test in the Unit Test view, and the Test cases view will be updated to
show the test cases of that particular test. The Test cases view thus display the test cases
(function calls) that has been auto-generated by Atollic TrueSTUDIO. By default, test cases
are auto-generated to test the MIN and MAX values of the data-type being used, values
around 0, and values around any other numeric constant in the source code that can be
determined to affect the execution flow.
In this case, select the test MySimpleFunc_test0 in the Unit Test view, and the Test cases
view will look like this:
The input parameter values to use during testing of this C function are auto-generated, but
can be edited manually. It is also possible to delete test cases, and add more test cases,
testing other combinations of input parameter values.
To fill in the expected return code for each test case (i.e. for each combination of input
parameter values), enter the expected return code value in the int _rMySimpleFunc row.
351 | P a g e
Test Automation
else
return 1;
}
For any value where the input parameter x is less than 25, the return code is expected to
be 0, otherwise 1 (normally this should be determined by knowing what the function is
supposed to do, not by studying the actual implementation, as the implementation may
contain errors that we want to detect using the tests).
In the screenshot below, this has been defined. But please notice a “wrong” return code
has been defined for test case #5, where the function is called with the input parameter x
being 24. For this case, the code implementation should return 0, but we have defined the
expected return code to be 1. This is done to simulate an error, where the actual return
code differs from the expected one.
In effect, we have created an error in the test vector instead of having an error in the code.
But it will show what happens when the actual return code is not equal to the expected
one.
With test suites now created for testing of two functions, and expected return code values
defined for one of the functions, we can run the test suites in the hardware board.
it is possible to use a more flexible approach than just enter a fixed expected value.
352 | P a g e
Test Automation
~ Range 50~70,
~50, 20~
& AND operator 10 & 11
Cannot be used with the OR operation ~30& 7~20
RUNNING TESTS
When running test suites and tests, it is sometimes useful to manually select which test
suites or individual tests should be executed. This is done using the checkboxes adjacent to
the test suites and tests in the Unit Test view. In the screenshot below, both test suites
and their corresponding test suites will be executed.
To start to run the tests, select the project in the Project Explorer view and then click the
Launch Unit test icon to start the test on the target board.
The first time a project is downloaded to the target board, a dialog box with launch
configuration properties is displayed – this is not displayed for projects that have
previously been run in target:
353 | P a g e
Test Automation
Select the Debugger tab and ensure that the settings for the JTAG probe to use are correct
(for example, we need to select the ST-LINK JTAG probe for the board being used in this
example).
354 | P a g e
Test Automation
Then switch to the Startup Unit Test panel, which provides the possibility to modify the
debugger initialization script to use when connecting to the hardware. For this tutorial,
make no changes unless required by a different board setup.
355 | P a g e
Test Automation
Click the OK button to start the unit test. The source code is now analyzed. Unit test
source code files are generated and built, resulting in a binary file. Finally, the binary file is
downloaded and executed on the target board.
Running large sets of test suites and tests can sometimes take a long time. Open the
Progress view to get detailed information on what Atollic TrueVERIFIER is doing:
356 | P a g e
Test Automation
Once tests are completed, the docking views in the Unit test perspective provide
information on the test results.
357 | P a g e
Test Automation
As can be seen in the screenshot below, the Test cases view show detailed information on
the test results for each test case.
More specifically, the Test cases view provides test results in the following ways:
For each test case (column), the Result row show “success”, “failure” or if the test
could not be run, “error”.
The return code row now has two values in the form x/y for each test case. The
value x is the expected value defined by the user earlier in this tutorial, and the
value y is the actual return code received when testing the function in the
hardware board.
The Diagnosis row may contain text strings printed by the test driver.
358 | P a g e
Test Automation
Test cases that failed (the actual return code did not match the expected one) are
highlighted in red color as well.
Display of the test coverage achieved by all test cases for one function
Display of the test coverage achieved by one test case for one function
Click on the Show All option in the panel to the left. The test coverage (test quality)
achieved is listed for all functions in the project:
Click on a test name (such as MySimpleFunc_test0) in the panel to the left. The test
coverage (test quality) by all test cases is displayed for the tested function:
359 | P a g e
Test Automation
Expand a test name (such as MySimpleFunc_test0) in the panel to the left, and all test
cases for that test will be listed. Select any of the test cases, and the test coverage (test
quality) achieved by that test case is displayed:
A. Show in coverage - To show the status of covered or uncovered over the source code.
B. Refresh- if the test has been executed, but the view is not updated, clicking refresh
button will help.
C. Link with editor - To show the source code on the editor through selecting specific
function.
360 | P a g e
Test Automation
Using the Coverage view, it is thus easy to analyze the achieved test coverage, and
determine if additional test cases are needed to provide better test quality.
typedef struct
{
int a;
int b;
} MyValueStruct;
int a = 0;
By selecting the MyComplexFunc_test0 in the Unit Test view, the Test cases view will
show all the auto-generated test cases for the MyComplexFunc() function.
361 | P a g e
Test Automation
By studying the Test cases view for the test MyComplexFunc_test0, it can be noticed that
there are now more input and output dependencies, compared to the test of the
MySimpleFunc() we tested earlier.
For example, Atollic TrueVERIFIER have detected that the global variable a can affect the
execution flow if it has a value around 8. It is thus listed as an input dependency and when
the function is tested, it will be tested in an environment where the global variable a will
have values around 8 too.
362 | P a g e
Test Automation
Additionally, Atollic TrueVERIFIER have detected that the function can modify the value of
the global variable a, and so it is possible to define expected output values for a too, in
addition to the return code.
363 | P a g e
Test Automation
For example, a test scenario may be to connect to a server over TCP/IP, download a file,
open it to extract information from the file, and then closing the file and the TCP/IP
channel.
Test scenarios can only include functions that are implemented in any file, but the test
driver file may need to be modified to #include necessary dependencies.
int FTP_Disconnect()
{
return 1;
}
This simplified example will show how a test scenario can be created, to test the more
real-life use-case of connecting to an FTP server, download a file, and disconnect. In other
words, an integration test will be created and executed.
364 | P a g e
Test Automation
Initially, the test scenario is empty as no functions have been selected. Click the Add
button to select what C functions should take part in the test scenario. The function
selection dialog box will then be displayed:
365 | P a g e
Test Automation
In this example, 3 functions for FTP access are selected, to create a test scenario of
connecting to an FTP server, downloading a file, and disconnecting.
Click OK to accept the function selection. The wizard now lists the selected functions,
although they are not in the correct calling sequence:
366 | P a g e
Test Automation
Select the function FTP_Readfile and click on the Up button, to position it between the
FTP_Connect and FTP_Disconnect functions. Then click Next to see the detected input and
output dependencies of all the functions in the test scenario:
367 | P a g e
Test Automation
Click Finish to generate the test scenario. The Unit test perspective now looks like this:
368 | P a g e
Test Automation
Select the test suite node in the test configuration form, and change the test suite name to
“FTP_Download_scenario”:
Then select the test node and notice the Test cases view contains the input parameter
values and return codes and output parameter values for all functions in the test scenario.
369 | P a g e
Test Automation
Figure 370 - Input and output values for all functions in the test scenario
The generated test driver file in the unittest\ folder implements the test scenario, by
transferring the input values from the Test cases view to the test driver, calling the
functions in sequence, and transferring the return codes from the test driver back to the
Test cases view.
Figure 371 - The test scenario implementation in the test driver file
The test driver can be modified as desired, to create a more advanced type of test
scenario, for example by wrapping some function calls in if-statements or for-loops, etc.
370 | P a g e
Test Automation
The test scenarios are executed in the same way as function tests, by clicking on the test
start button in the toolbar.
371 | P a g e
Test Automation
A. Add unit tests. All selected C functions are grouped into one test suite. The C functions
are tested in isolation (one-by-one).
B. Add unit tests. Each selected C-function gets its own individual test suite. The C
functions are tested in isolation (one-by-one).
C. Add a unit test scenario. All selected C functions are grouped into one test suite. The C
functions are tested by calling them in the pre-defined sequence.
To manage an existing test suite, select it in the Unit Test view and it will be highlighted in
the test configuration form in the main editor area.
372 | P a g e
Test Automation
The test suite name can be changed to the right in the form, and it is possible to enter a
description of the test suite. By right-clicking on the test suite name in the test
configuration panel, a context menu is opened where it is possible to add or import more
tests (i.e. let the test suite test more functions), as well as deleting it. The setup and
teardown options will be discussed in a subsequent section, and will not be covered here.
373 | P a g e
Test Automation
MANAGING TESTS
To edit a test, select it in the test configuration form. It is possible to define a description
of the test. A link to the C file containing the function(s) tested by this test is provided as
well.
To re-generate test cases, click on the Generate Data button. If the function being tested
has 3 parameters or more, the Pairwise Combination option generates many more test
cases. For the Flat Combination option, different permutations of parameter value
combinations are not generated. The Pairwise Combination and the Flat Combination
settings have no effect on functions with less than 3 parameters.
Using the import and export buttons, test data can be imported or exported.
374 | P a g e
Test Automation
For this function, there is only one function parameter, of type integer. Please note that
two particular values of the parameter x affect the execution flow: -10 and 65. If x is less
than -10 or greater than 65, a different execution path is taken.
Obviously it is important to test these input parameter values, as they do in fact affect the
execution flow of the function. For complete testing though, it is also of interest to test
other “corner case” values, like MAXINT, MININT, zero, and one or two values next to
these values.
For the above function, Atollic TrueVERIFIER will automatically generate unit tests with
input parameters for x as follows: -2147483648, -11, -10, -9, -1, 0, 1, 64, 65, 66 and
2147483647. This is the test vector for the function MyFunc1().
In C program syntax, unit tests with the following function calls have been auto-generated:
MyFunc1(-2147483648);
MyFunc1(-11);
MyFunc1(-10);
MyFunc1(-9);
MyFunc1(-1);
MyFunc1(0);
MyFunc1(1);
MyFunc1(64);
MyFunc1(65);
MyFunc1(66);
MyFunc1(2147483647);
Test cases are created for empty function stubs, before the implementation is
written.
More test cases are needed to improve the test coverage (test quality)
To toolbar in the Test cases view provides commands for managing the test cases. Several
of these commands only work if the column heading have been clicked, to select the full
column.
375 | P a g e
Test Automation
376 | P a g e
Test Automation
For this purpose, Atollic TrueVERIFIER provides the possibility to “hook in” setup and
teardown code, which runs before or after a test suite, as well as before or after each test,
as appropriate.
To create setup or teardown definitions, open the test configuration form by clicking on a
test suite or a test in the Unit test view. In the bottom of the test form, click on the Assist
Code tab.
The Assist Code tab shows a list of all setup and teardown code definitions. To create new
setup code or teardown code definitions, click the Add button.
377 | P a g e
Test Automation
If the source code file is not listed when browsing the Connected Source list,
the user must synchronize the project to have all latest code changes take into
consideration. Do this by clicking Synchronize unit tests button, see Figure
345.
Click Finish to complete the setup or teardown definition and return to the AssistCode tab
in the test configuration form. Press CTRL-S or click on the save toolbar button to save the
changes. New setup and teardown definitions will not be available to use for before the
AssistCode tab has been saved.
Once the setup and teardown definitions have been created, C code must be added to
them to make them useful.
ADDING CODE
Once the changes to the Assist Code tab have been saved, a file is auto-generated in the
unittest\ folder for each setup and teardown definition that has been added. The file
names are equal to the names that were defined in the Assist Code tab.
378 | P a g e
Test Automation
Double-click on any of the auto-generated setup or teardown files to open it in the C/C++
editor. Edit the setup code or teardown code as appropriate, to make them initialize and
shutdown the S/W or H/W environment as needed for different test suites or tests.
Once the setup and teardown definitions are created, and code implementations have
been added to make them useful, they can be connected to various test suites and tests to
make them initialize the environment before a test-suite or test, or make them shutdown
the environment after a test-suite or test. This is done in the SuiteList tab in the test form.
To do this, right-click on any test suite or test in the configuration tree in the SuiteList tab.
In the context menu, select Add, and choose Setup or Teardown dependent on what
action you want to add to the test suite or test.
379 | P a g e
Test Automation
This creates a setup node under the test suite node in the tree. Expand the test suite node
and select the setup node. In the right part of the test configuration form, click the Browse
button to open the setup definition selection dialog box.
Then select the desired setup or teardown definition in the list and click OK.
During a test run, the test suite or test will now execute the selected setup code or
teardown code as desired to make the appropriate initialization and shutdown steps
needed to make the test run work in its surrounding environment.
380 | P a g e
Test Automation
TEST DRIVERS
A test driver function manages the execution of a test, by feeding the input values of the
functions to be tested, and calling the functions to be tested with the appropriate test
data. It also returns the output values to the Test cases view.
Test driver functions use the #pragma cstest to specify them as being test driver
functions. Test driver functions have no input parameters and no return codes:
#pragma cstest
void test_function( void )
{
…
}
If the return type of functions to be tested is of a primitive type, the macro that checks the
return code is created automatically.
INSTRUMENTATION MACROS
Atollic TrueVERIFIER provides various macros enabling the user modify the test driver for
more advanced use.
INPUT MACROS
Input macros transfer the input values from the Test cases view to the function call in the
test driver.
381 | P a g e
Test Automation
Macro Parameters
This example shows how an input macro transfers a parameter from the Test cases view to
the function call in the test driver:
void MySimpleFunc_test0()
{
/* Do not modify CS_TEST_PARAMETER() */
CS_TEST_PARAMETER(MySimpleFunc_test0);
/* INPUT */
x = CS_INT_INPUT(int,x);
/* OUTPUT */
CS_INT_OUTPUT(_rMySimpleFunc,"_rMySimpleFunc");
}
382 | P a g e
Test Automation
Macro Parameters
This example shows a test driver that has been instrumented to make additional checking
of the behavior of the function being tested. In this case, it is considered to be an error if
the return code is not equal to 1, for test case number 4 and above. Using the test result
macros, failure detection of arbitrary complexity can be designed.
void MySimpleFunc_test0()
{
/* Do not modify CS_TEST_PARAMETER() */
CS_TEST_PARAMETER(MySimpleFunc_test0);
/* INPUT */
x = CS_INT_INPUT(int,x);
/* OUTPUT */
CS_INT_OUTPUT(_rMySimpleFunc,"_rMySimpleFunc");
}
The screenshot below shows how the Test cases view show how the test result macros
cause test case number 4 and above to fail if the return code is not equal to one. The
failure message string is displayed in the Diagnosis field too.
383 | P a g e
Test Automation
OUTPUT MACROS
Output macros transfer the actual output values (such as the return code) from the test
driver to the Test cases view.
Macro Parameters
384 | P a g e
Test Automation
This example shows how an output macro transfers the actual return code to the Test
cases view:
void MySimpleFunc_test0()
{
/* Do not modify CS_TEST_PARAMETER() */
CS_TEST_PARAMETER(MySimpleFunc_test0);
/* INPUT */
x = CS_INT_INPUT(int,x);
/* OUTPUT */
CS_INT_OUTPUT(_rMySimpleFunc,"_rMySimpleFunc");
}
OTHER MACROS
Additional macros prints text strings to the Diagnosis fields of the Test cases view, and
return the test case number currently being executed.
Macro Parameters
CS_LOG(_msg) _msg:
log message
An example of a test driver that prints the test case number in the Diagnosis field of the
Test cases view is available here:
void MySimpleFunc_test0()
{
char Str[ 256 ];
385 | P a g e
Test Automation
/* INPUT */
x = CS_INT_INPUT(int,x);
/* OUTPUT */
CS_INT_OUTPUT(_rMySimpleFunc,"_rMySimpleFunc");
}
With the test driver modification above, the Test cases view will print information in the
Diagnosis view as shown here:
386 | P a g e
Test Automation
The problem is that the syntax for a pointer to a character and the syntax for a string
variable are the same. If Atollic TrueVERIFIER detects that a function parameter or
variable to be used in a test is of type char *, it has no way of knowing if the function
want to use this as a pointer to a character, or if it wants to treat it as a zero terminated
string.
So the user must help Atollic TrueVERIFIER to resolve this ambiguity. By default, Atollic
TrueVERIFIER treats all char * parameters and variables as being a pointer to a character,
which is the literate default value. In effect, this becomes a pointer to a small integer data-
type.
To make Atollic TrueVERIFIER treat char * parameters and variables as strings, two steps
must be performed manually:
The test driver source code file must get its use of instrumentation macro’s
modified, from a pointer to character (i.e. small integer), to a string.
Once the change has been done to the test driver file, click the Synch Test toolbar
button in the Unit test view to notify Atollic TrueVERIFIER that the test driver has
been modified.
First create a test suite containing a test of the function MyStrFunc(). This function takes
a string as its second parameter, and returns the number of characters in the string:
y = strlen(str);
return y;
}
Since this function takes a char * parameter, Atollic TrueVERIFIER will by default
consider this to be a pointer to a small integer data-type. This is also reflected in the test
vector in the Test cases view; the generated test values for the char * parameter are
integer values.
387 | P a g e
Test Automation
Now open the corresponding test driver file in the unittest\ folder, and scroll to the
/* INPUT */ section of the test driver for the MyStrFunc() function.
388 | P a g e
Test Automation
To change the data-type of the char * parameter from being a pointer to a character to
become a zero-terminated string, change the last line that defines the second parameter:
/* INPUT */
x = CS_INT_INPUT(int,x);
str[0] = CS_UINT_INPUT(char,str0);
To:
/* INPUT */
x = CS_INT_INPUT(int,x);
str = CS_STR_INPUT(char[200], str);
The test driver source code should now look like this:
389 | P a g e
Test Automation
Once the test driver source code have been updated and saved according to the above
example, click on the Synch Test toolbar button in the Unit test view to let Atollic
TrueVERIFIER know it needs to update its internal data structures following the change in
the test driver.
After some processing, the Test cases view is now updated with refreshed knowledge
about the data-type of the char * parameter:
Once Atollic TrueVERIFIER has detected a parameter value is to be treated as a string data-
type, string values can be entered into the test vector input value list:
390 | P a g e
Test Automation
As the function to be tested returns the number of characters in the input parameter
string, the screenshot above also contains definitions of the expected return code for each
input value in the test vector.
After running the test, it can be seen that the actual return codes match the expected
ones, and so all test cases using string variables passed with success in this example.
391 | P a g e
Test Automation
GENERATE REPORTS
To be able to properly follow up all tests and make sure all bugs are fixed, correct and
detailed reports are vital. To create the reports, click on the Generate Unit test Report
button (C).
A dialog box will be displayed with report generation options, such as file format and
export folder location.
392 | P a g e
Test Automation
IMPORTANT NOTES
This section contains additional information related to the use of Atollic TrueVERIFIER.
PROJECT SHARING
Atollic TrueVERIFIER stores data about the test configurations in various database files in
the .csdata/ut folder, which is located in the project root folder. In order to share the
test configuration of a project amongst several users on different computers, for example
by checking-and and checking-out the project using a version control system, the
.csdata/ut folder needs to be properly managed and distributed with the project.
Therefore, make sure the .csdata/ut folder is properly checked-in and checked-out, or
otherwise included with the project, when moving a TrueVERIFIER-enabled project from
one location to another.
The different files in the .csdata/ut folder MUST be modified as an atomic operation by
one user at a time only. If this is not enforced, the test data will become corrupt and
cannot be used onwards. Therefore, make sure only one user at a time modify any of the
files in the .csdata/ut folder.
This can for example be enforced using some version control systems using a “locking
mechanism”, whereby one user “locks” the files in the folder such that no other user can
modify any of the locked files before they are unlocked by the first user. Using such a
mechanism ensures only one user at a time can modify the files in the .csdata/ut folder,
and several users can thus move around the test data to different computers, without the
risk of getting corrupt test data.
In addition to the test data files in the .csdata/ut folder, also the test drivers and
setup/teardown implementations in the unittest folder must be checked-in and
checked-out. But these files are standards C files and are thus to be managed as any other
source code file in the project.
SYNCHRONIZE TRUEVERIFIER
Atollic TrueVERIFIER automatically keeps the test database and the project source code in
synch (re-parsing and updating the test data if needed) in the following situations:
393 | P a g e
Test Automation
Manual synch is sometimes also needed when importing or updating source code from a
version control system, and sometimes when adding, editing, deleting or renaming source
code files. To manually synchronize Atollic TrueVERIFIER, press the Sync Test button in the
Unit Test view toolbar.
If the test database and source code should become corrupt and a Synch Test command
does not help, it is also possible to make a deeper reanalysis of the full project. During this
operation, all test data is recollected from the source code. To do a full reanalysis, right-
click on the project in the Project Explorer view and select Reanalysis in the context menu:
394 | P a g e
Test Automation
TEST QUALITY
MEASUREMENT
This section provides information on how to use Atollic TrueANALYZER®. Atollic
TrueANALYZER is fully integrated into Atollic TrueSTUDIO Premium. A demo version is
included in all other Atollic TrueSTUDIO installations.
395 | P a g e
Test Quality Measurement
INTRODUCTION
Atollic TrueSTUDIO Premium includes Atollic TrueANALYZER® as a module providing
advanced features for system-level test quality measurements. Test quality is measured by
analyzing how large portion of the execution paths and branch decisions in a software
product have been exercised when running one or more test cases in the target board.
Test quality is measured by performing code coverage measurement, and is sometimes
also called test coverage measurement.
TrueANALYZER performs dynamic execution flow analysis as the application runs in the
target board during test, and it provides code coverage analysis up to the level of Modified
Condition/Decision Coverage (MC/DC). This is the most stringent level of test quality
measurement, and is required for testing of safety critical systems, such as avionics and
flight control systems.
It is important to understand that code coverage analysis do not measure the quality of
the software; rather it measures the quality of the test procedures. But by performing test
quality measurement, test cases can be improved to the level they test enough, or
everything, dependent on the requirements of your project. A code coverage analysis tool
can thus be considered to be a test debugger, or a test case debugger.
For example, if a microwave oven is to be tested, one of the test cases in the test
specification may include the following steps:
With test cases that are known to be good enough, the improved test cases will in turn
detect more bugs, and offer test confidence and quality confidence as well.
396 | P a g e
Test Quality Measurement
A recent real-world example is Chrysler, who had to recall 475.000 cars in May 2013, as a
software upgrade was needed since the cars had an error that had caused 26 accidents
and 2 injuries up to that point. Imagine the cost of recalling almost half a million cars
worldwide, and the cost savings achieved if a software upgrade had not been needed.
Knowing what test quality is being achieved gives both test confidence and quality
confidence. Code coverage analysis is a powerful tool to measure and debug test cases,
such that they find more of the bugs that most likely do exist in the software – whether
you are aware of them or not. A code coverage analysis tool can find more programming
errors, which enables you to release a software product of higher quality.
Code coverage analysis finds areas in the program that may not be covered by existing test
cases, enabling you to create additional tests that cover otherwise untested parts.
It is important to realize that code coverage helps to assess the quality of the test cases,
not the quality of the actual source code. However, better test cases will lead to higher
source code quality indirectly, since a substantially larger portion of the faults will be
discovered before release.
Performing code coverage analysis by hand can be very time consuming. Atollic
TrueANALYZER automates this task.
397 | P a g e
Test Quality Measurement
BLOCK COVERAGE
This type of code coverage analysis is sometimes included in standard debuggers. Block
coverage is a very weak type of code coverage analysis. It can only verify what blocks of
code have been executed, but not under what circumstances. For example, it does not test
what alternative execution paths have been taken.
FUNCTION COVERAGE
This basic type of code coverage analysis is sometimes included in standard debuggers too.
Function coverage can only report whether or not a function has been called. It does not
disclose anything about the execution within the function, or how or why the function was
called. And it does not test all the potential ways to call the function.
398 | P a g e
Test Quality Measurement
BRANCH COVERAGE
Branch coverage is a more advanced type of code coverage analysis. Branch coverage
measures to what extent all code blocks have been exercised, and all execution paths have
been executed. In complex branch decisions, the analysis does not consider the inner
details that affect the value of the expression (i.e. the conditions that formed the branch
decision is not considered).
399 | P a g e
Test Quality Measurement
To fulfill MC/DC coverage for a code section, the following must apply:
Every condition in all decisions must take each possible outcome at least once.
Every decision must have taken each possible outcome at least once.
Safety-critical software is often required to be tested such that it fulfills MC/DC-level code
coverage analysis successfully. Testing on MC/DC level is for example required for flight
control system software and avionics software. But any software project benefits from
rigorous code coverage analysis:
Companies with a good reputation want to avoid bad reputation on the market
caused by releasing products of poor quality.
Products that are very difficult or expensive to upgrade in the field, are good
candidates for rigorous testing.
400 | P a g e
Test Quality Measurement
Note that in the MC/DC example above, the code section must be executed many times,
such that different combinations of condition values in the branch decision is taken to test
not only all different execution paths, but also all conditions that can affect the execution
path decision.
TOOL SUPPORT
Atollic TrueANALYZER is a very powerful tool for code coverage analysis. It performs the
following types of code coverage:
Block coverage
Function coverage
Branch coverage
To achieve such rigorous code coverage analysis, Atollic TrueANALYZER performs the
following tasks:
401 | P a g e
Test Quality Measurement
PREPARATIONS
Before performing a code coverage analysis session, Atollic TrueANALYZER must establish
a connection with the target board. This is commonly done using the same JTAG probe
used for ordinary debugging with Atollic TrueSTUDIO.
To prepare for code coverage analysis, using an ST-LINK or SEGGER JTAG probe connected
to your electronic board, perform the following steps:
1. Verify that the RAM/FLASH switch on the board (if available) is set in the
right mode (it must match the Atollic TrueSTUDIO project configuration).
3. Connect the JTAG cable between the JTAG dongle and the target board.
4. Connect the USB cable between the PC and the JTAG dongle.
5. Make sure that a proper power supply is connected to the target board.
Once the steps above are performed, a code coverage analysis session in Atollic
TrueANALYZER can be started.
Ensure that the project has been built without errors and that the build process
has resulted in a binary file containing the application to be analyzed.
402 | P a g e
Test Quality Measurement
Ensure that the application binary can be downloaded to the target board using
the JTAG probe and the Atollic TrueSTUDIO debugger.
Ensure that the application can be debugged on the target board using the JTAG
probe and the Atollic TrueSTUDIO debugger.
Provided that the pre-requisites outlined above are fulfilled, perform the following steps
to start a code coverage analysis session:
403 | P a g e
Test Quality Measurement
2. Select the project by clicking on the Project name (root node) in the Atollic
TrueSTUDIO Project Explorer view.
3. Exclude files (or folders with files) that should not be instrumented or
measured.
In particular, all C files that contain C code that execute before main() during
the power-on-reset and startup procedure must in most cases be excluded,
as the instrumentation do not work before the C runtime environment is
properly initialized.
Folder and files from quality measurement will not be instrumented by
Atollic TrueANALYZER. That code will then be able to keep its real-time
behavior. Also this is a good way to reduce the overhead in memory
consumption introduced by the tested code.
4. Right-click on the project root node in the Project Explorer view, and select
Properties to open the project properties dialog box. Then navigate to the
Testing > Exclusion > TrueANALYZER panel, and exclude files and folders as
appropriate. Click OK to save any changed settings.
404 | P a g e
Test Quality Measurement
405 | P a g e
Test Quality Measurement
7. Select the Debugger panel and make sure the settings are correct for your
board and JTAG probe:
406 | P a g e
Test Quality Measurement
8. Select the Startup Scripts, Target Software Startup Scripts, Analyze tab.
Enter any debugger initialization required by the target board or the JTAG
probe:
9. Click Analyze to start analysis of the source code. A copy of the source code
will be instrumented and rebuilt. This may take several minutes:
10.In the Analysis view, the text localhost:<port number> is displayed in the
project tree. This tree item is the “handle” to the target connection (JTAG
probe connection to the target board). Initially this tree item also displays
information regarding the download of the instrumented application to the
target, and other connection related information.
407 | P a g e
Test Quality Measurement
11.In the Analysis view, click on the text localhost:<port number> to select the
hardware connection to the target board. Note that the Refresh button in
the Analysis view toolbar becomes enabled:
408 | P a g e
Test Quality Measurement
12.At any time during execution of the application on the target board, click on
the Refresh button. This refreshes the code coverage analysis data in Atollic
TrueANALYZER (i.e. updated test quality measurements are uploaded and
displayed).
The Coverage view shows an overall summary of the complete application,
as well as the analysis results for each C function.
By clicking on a function name, the corresponding source code file is opened
and the function implementation is displayed in the editor. The source code
lines that have been executed are highlighted with color coding:
409 | P a g e
Test Quality Measurement
13.Interact with the target board (for example by pressing buttons, sending
communication packages, or activating various sensors) as desired, to
simulate various use cases as part of the test procedures.
14.To obtain the latest analysis results, simply click the Refresh button at any
point in time. This procedure effectively displays information about how
good the test quality is after running a test case, but it does not display
where or why the test coverage did not become better.
15.For each C function, it is possible to analyze where the test cases do not
reach better test coverage, and why. This is done in the MC/DC view.
Figure 406 - Using the MC/DC view to understand why the test coverage is not better
410 | P a g e
Test Quality Measurement
The MC/DC view lists all branch decisions in the selected function, such as
all if-statements, switch-statements etc. Expand a branch decision to view
its conditions. The Covered column display if each of the conditions in the
branch decision fulfill MC/DC coverage or not.
With a specific branch decision selected in the MC/DC view, the truth table
of the fulfilled conditions is displayed in the bottom of the view. Using this
truth table, it is easy to detect which conditions are not fulfilled, to achieve
better test coverage in a branch decision of a C function.
Using the Coverage and MC/DC views, it is thus possible to understand both
what test coverage (test quality) is achieved by the test procedures, as well
as where and why the test cases do not provide better test coverage.
16.To terminate the code coverage analysis session, first make sure the
localhost:<port number> text is selected in the Analysis view. Then click the
Terminate button in the toolbar:
411 | P a g e
Test Quality Measurement
17.Switch to the C/C++ perspective using the Window, Close Perspective menu
command.
412 | P a g e
Test Quality Measurement
GENERATE A CSV-FILE
The test coverage result can be exported as a CSV-file that later can be inspected in an
external program, such as Microsoft Excel. Click on the Export CSV-file toolbar button in
the Coverage view:
413 | P a g e
Test Quality Measurement
As fractions of seconds is typically not enough to test and debug the quality of real-world
test procedures (as system tests typically involves users pushing buttons, stepper motors
move mechanics, and pumps pour water into washing machines, interaction with other
systems is required, etc.), a different approach is needed.
For this reason, Atollic TrueANALYZER uses instrumentation instead of instruction trace
recordings. This enables unlimited execution time, since the time of execution does not at
all affect the amount of data that is recorded.
On the other hand, the instrumentation uses some memory resources in the target board:
In general, the need of RAM memory in the target board equals to the sum of the
cyclomatic value of code complexity + 1 of all functions being instrumented. So if
the application has two functions; one function with code complexity level 12,
and the other function having a code complexity level of 7, then the total RAM
usage will be (12+1) + (7+1) = 21 bytes. Branch decisions with multiple conditions
also add one byte of RAM usage for each condition.
In general, the need of Flash memory in the target board scales with the total
sum of the cyclomatic value of code complexity of all functions in the application
being analyzed, although the exact number of bytes being used depends on many
factors, including compiler version and optimization level.
In case the instrumented application becomes too large to fit in the target board, it is
possible to exclude files, and folders of files, from instrumentation, thus only
instrumenting parts of the system.
414 | P a g e