Skip to content

A simple example on how to use the IAR Build Tools with Visual Studio Code on Ubuntu Linux

License

Notifications You must be signed in to change notification settings

felipe-iar/iar-vscode-cmake-ubuntu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IAR + VSCode + CMake on Ubuntu

This mini-guide provides the essentials for quickly setting up a "hello world" project for an Arm Cortex-M4 target built with the IAR Build Tools for Arm (BXARM) using CMake on Visual Studio Code on an Ubuntu Desktop. In the end we will debug it using the IAR C-SPY Debugger.

Warning

The information provided in this repository is subject to change without notice and does not represent a commitment on any part of IAR. While the information contained herein might be useful as reference, IAR assumes no responsibility for any errors or omissions.

Required software

Below you will find the software and their versions used in this guide. Newer versions might work with little or no modification(s).

Software Version Link
Ubuntu Desktop 22.04.4 link
IAR Build Tools for Arm 9.50.2 link
Microsoft Visual Studio Code 1.87.2 link
IAR C-SPY Debug Extension 1.30.4 link
Microsoft C/C++ Extension Pack 1.3.0 link
CMake 3.29.0-rc3 link
Ninja 1.10 link

Installing the software

This guide assumes a functional Ubuntu Linux Desktop already in place as starting point.

IAR Build Tools

IAR customers can login into IAR MyPages then use the download links provided from the following page:

  • IAR Build Tools for Arm 9.50.2
    • Download installer for Ubuntu (/Debian) (filename: bxarm-9.50.2.deb).
    • SHA256 checksum for Ubuntu installer (filename: bxarm-9.50.2.deb.sha256).
    • Device support package (Ubuntu) (filename: bxarm-cspy-device-support-9.50.2.deb).
  • And finally install the required packages:
cd ~/Downloads
sha256sum --check bxarm-9.50.2.sha256 
sudo apt install ./bxarm-*.deb

Tip

Follow the Command Line User Guide for setting up your license. If you encounter problems with your license, reach out to IAR Support.

Microsoft Visual Studio Code

Install VSCode:

sudo apt update
sudo apt install -y curl git apt-transport-https
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
sudo apt-get update
sudo apt-get install -y code
code
  • Select you trust the repository's folder. Optionally you can "Trust the authors of all files in the parent folder <folder-name>":

image

  • Use the "Welcome" wizard to set up Visual Studio Code (or skip it with "Mark Done" if you are ok with its defaults).

The "Welcome" window offers many options to start, including "Walkthroughs - Learn the Fundamentals":

image

  • Choose "Clone Git Repository..."
  • Type: https://github.com/felipe-iar/iar-vscode-cmake-ubuntu.git.
  • Click Select as Repository Destination to clone it to your home folder.
  • Open the cloned repository.

Tip

Optionally you can use the aforementioned repository as a template to create your own. For more information refer to Creating a repository from a template.

  • VSCode will offer to "Install the recommended extensions from Microsoft and IAR for this repository". Click Install:

image

Once the extensions are downloaded, you will see them in the Extensions panel:

image

Install CMake

  • Press CtrlShift` to open a bash terminal inside VSCode.
  • For installing the latest CMake follow the instructions provided at https://apt.kitware.com.

Tip

Alternatively, for installing the distribution-provided version, use sudo apt install cmake.

Install Ninja

sudo apt update
sudo apt install -y ninja-build
ninja --version

Building the project

  • Invoke the palette (CTRLSHIFTP).
    • Perform CMake: Configure.
    • Select BXARM from the drop-down list.

image

  • Invoke the palette
    • Perform CMake: Build.

Output:

[main] Building folder: iar-vscode-cmake-ubuntu 
[build] Starting build
[proc] Executing command: /usr/bin/cmake --build /home/felipeto/iar-vscode-cmake-ubuntu/build --config Debug --target all --
[build] [1/2  50% :: 0.039] Building C object CMakeFiles/hello.dir/main.o
[build] [2/2 100% :: 0.101] Linking C executable hello.elf
[driver] Build completed: 00:00:00.144
[build] Build finished with exit code 0

Debugging the project

Once the executable was built:

  • Select the Run & Debug panel (CTRLSHIFTD).
  • Select which configuration to use in the drop-down selector (defaults to IAR C-SPY Simulator)

image

  • In main.c, click on the left curb of the line which increments the counter (++counter;) to set a breakpoint.
  • Go to RunStart Debugging (F5) to start the debugging session.

image

Note

The IAR C-SPY I-jet launch configuration comes ready for the STM32F4-Discovery board as an example. For customization, refer to the IAR C-SPY Debug extension documentation.

About

A simple example on how to use the IAR Build Tools with Visual Studio Code on Ubuntu Linux

Resources

License

Stars

Watchers

Forks