Guidelines for Using Keil Studio for VS Code

<rawat.s>
6 min readSep 1, 2023

--

.

In this blog, I will demonstrate how to use the VS Code IDE on Linux Ubuntu 22.04 LTS together with the “Keil Studio for VS Code” extension pack. For additional details regarding the Keil MDK v6 Community Edition, please refer to the following website: https://www.keil.arm.com/community/.

URL: https://www.keil.arm.com/community/
URL: https://www.keil.arm.com/community/

As you can see from the screenshot of the Keil-Arm Software website, there are three types or options of software that you can use, namely (1) the Keil Studio for VS Code, (2) the Keil Studio Cloud (online), and (3) Keil uVision IDE.

As mentioned earlier, I will focus on the VS Code IDE and the Keil Studio extension pack. I am assuming that the VS Code IDE is already installed on the Linux machine; therefore, I will omit the installation steps for the VS Code IDE.

Additional information about the Keil Studio Pack can be found on the following website: https://marketplace.visualstudio.com/items?itemName=Arm.keil-studio-pack.

You can also access the Arm Keil Studio Visual Studio Code Extensions — User Guide (First Release: 13 July 2023) at this link: https://developer.arm.com/documentation/102497/1-7/.

The installation process for the Keil Studio Pack extension is straightforward. Simply follow these steps:

  • Click on the “Extension” icon in the VS Code IDE.
  • Search for “Keil Studio Pack.”
  • Click the “Install” button to initiate the installation.

The Keil Studio Pack in Visual Studio Code desktop includes:

  • Arm CMSIS csolution
  • Arm Device Manager
  • Arm Embedded Debugger
  • Arm Remote Build
  • Arm Virtual Hardware

In the next step, we will create a new project in the VS Code IDE. The recommended approach is to import an example project provided by the Arm Keil website. Follow these steps:

  • Open your web browser to https://www.keil.arm.com/.
  • Click on the “Hardware” menu.
  • Search for “Boards.”
  • For the demonstration, I will use the STMicroelectronics STM32F407VGTx Discovery Board as the target board.
STM32F4-Discovery Board

After selecting the board, you will see a list of available examples. For this demonstration, let’s choose the CMSIS-RTOS Blinky example. The next step is to obtain or export the zip file of the project and then open it in Keil Studio for VS Code.

To extract the downloaded .zip file, choose the destination directory for your project.

Open the folder containing the CMSIS-RTOS Blinky project in the VS Code IDE. The Keil uVision project files will be automatically converted to the so-called Arm CMSIS csolution files.

Next, take a look at the project’s files and subdirectories, and open the main.c file. Now you can click the Build or Build (clean) button to start the project build process.

After successfully building the project, connect the STM32 board to your computer using a USB cable. Depending on your setup, you may need to upgrade the ST-Link/v2 firmware for the target board. If you are using Linux, you might also need to install the UDEV rules file to grant access to the ST-Link/v2 device without requiring root permissions.

The onboard ST-Link/v2 programmer/debugger on the board should be detected automatically.

To start the RUN or DEBUG session, simply click on the corresponding button. Afterward, ensure that the ST-Link device is recognized and select the CMSIS pack for the target device, in this case, the STM32F407VGTx.

Selecting he Keil::STM32F4xx_DFP (Device File Pack)

Next, click on one or more lines within the main.c source code to set breakpoints before initiating the DEBUG process. The binary file will be automatically downloaded to the target device, and the program will execute the startup code, pausing at the first statement of the main function when a breakpoint is encountered.

You can also resume the execution of the program on the target device or unselect or deactivate the existing breakpoints.

Summary

This guide outlines the steps for working with the Keil Studio for VS Code extension and an STM32 board on a Linux machine. The process begins with selecting a board and importing an example project from the Arm Keil website. After unzipping the project files and opening them in VS Code, you can build the project. Then, connect your STM32 board via USB and potentially upgrade the ST-Link/v2 firmware. To start a RUN or DEBUG session, click the corresponding button and select the CMSIS pack for your target device. You can set breakpoints in your code, and the binary file will be downloaded to the target device. Finally, you can resume program execution or deactivate breakpoints as needed.

Extra: Upgrading the firmware of the onboard STLink/v2 programmer

You have to download the zip file: en.stsw-link007-v3–13–4.zip from the STMicroelectronic website.

Next, run the following commands in the Linux bash shell.

$ unzip en.stsw-link007-v3-13-4.zip
$ cd stsw-link007/AllPlatforms
$ sudo bash ./StlinkRulesFilesForLinux/st-stlink-udev-rules-1.0.3-2-linux-noarch.sh
$ lsusb -d "0483:3748"
Bus 001 Device 017: ID 0483:3748 STMicroelectronics ST-LINK/V2
$ sudo udevadm control --reload-rules && sudo udevadm trigger

Start the STLink Upgrade Tool:

$ java -jar STLinkUpgrade.jar

Note:

  • A Java runtime is required on your Linux machine.
  • When upgrading the firmware of the ST-Link, you may need to ensure that the ST-Link is in “update mode.” This step is crucial to successfully update the firmware on the ST-Link/v2 device.

--

--