Skip to content

Building and Debugging from the Embedded Workbench

Felipe Torrezan edited this page Feb 28, 2024 · 7 revisions

Introduction

CMake projects can be built and debugged directly from the IAR Embedded Workbench IDE version 9.3 or later, shipped with IAR products starting from the IAR Embedded Workbench for Arm 9.50.1, released on December 7, 2023.

Helpful Resources

Description

For using CMake projects with the IDE you will need CMake version 3.20 or later. It has to be installed separately, before launching the IDE.

The IDE does not require a toolchain file. This is automatically handled by the IDE.

Procedure

Creating a new CMake project from the IDE

  • Choose ProjectCreate New Project in the main menu.
  • Choose the CMake for Arm "Tool chain".
  • Finally choose the desired "Project template" (e.g., CMake).

image

  • Save the project file as <project-name>.ewp.
  • Save the workspace as <workspace-name>.eww.

Notice that the CMake template project comes with a main.c source and a CMakeLists.txt project:

image

  • Choose a build configuration containing debug information:

image

  • Build and Debug the project with the IAR C-SPY Simulator (ProjectDownload and Debug (CTRL + D)).

image

Opening an existing CMake project from the IDE

The Tutorial project from the cmake-tutorial repository will be used:

  • Choose ProjectCreate New Project in the main menu.
  • Choose the CMake for Arm "Tool chain".
  • Choose Import CMakeLists.txt.

image

  • Nagivate to an existing project's top-level CMakeLists.txt (e.g., /path/to/cmake-tutorial/tutorial/CMakeLists.txt) and Open it.

image

  • Save the project file as tutorial.ewp.

  • Make sure a build configuration containing debug information is selected:

image

  • Build and Debug the project with the IAR C-SPY Simulator (ProjectDownload and Debug (CTRL + D)).
  • Save the workspace as tutorial.eww.

image

Analyzing the project with the IAR C-STAT

IAR C-STAT is a code quality analysis add-on that can be enabled for the IAR Embedded Workbench or for the IAR Build Tools.

  • Terminate the debugging session (DebugStop Debugging (CTRL + SHIFT + D)).
  • Right-click on the project name and choose Options....
  • In the project options, under Static Analysis, choose Select C-STAT Checks.

image

  • Enable MISRAC2012 and close the window by clicking OK.
  • Click OK once more to close the Options for node "tutorial" window.

image

  • Right-click on the project name and choose C-STAT Static AnalysisAnalyze project.

image

The C-STAT Messages window will show up with a list of detected MISRA C violations this project contains. Double clicking on each message will take the code editor to the offending line:

image

  • Select any of the messages and hit F1 for online help with the full description for the violation:

image

Tweaking CMake tool configurations

You can find a new options page dedicated to the CMake configuration details, under ProjectOptionsCMake/CMSIS-ToolboxCMake:

image

The "Override tools in env" frame allows to set CC, CXX and ASM to use earlier versions of the IAR C/C++ Compiler but with the current IDE and its Debugger.

Summary

Starting from IAR Embedded Workbench for Arm version 9.50.1, it is possible to build, analyze and debug CMake projects directly from the IDE.

Clone this wiki locally