📜 ⬆️ ⬇️

Configuring VSCODE for ARM development using the example of the stm32f429i-disco debug board


Hello!


Today we will consider setting up a convenient and beautiful development environment for a microcontroller programmer using a set of completely free development tools.


All steps are checked on a virtual machine with freshly installed Ubuntu 16.04 xenial desktop x64.


It is understood that you already have the source of any project.


All settings relating to a specific hardware (in my case, this is the STM32F429 controller and the STM32F429DISCO devboard) need to be replaced with their own. The same goes for the ways.


If ready, then go


Install curl


sudo apt-get install curl 

Vscode installation


 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 install apt-transport-https sudo apt-get update sudo apt-get install code # or code-insiders 

Install arm-none-eabi toolchain


 sudo apt-get install gcc-arm-none-eabi sudo apt-get install gdb-arm-none-eabi 

Install openocd


 sudo apt-get install openocd 

Run and configure vscode


To run vscode, call the code command in the terminal.
Go to the Extensions section (Ctrl + Shift + X) .
We are looking for and install the following plugins:


  1. Cortex-Debug by marus25.
  2. C / C ++ from Microsoft.

Open the folder with the project through the menu File / Open Folder .
Go to the Debug section (Ctrl + Shift + D) .


At the top in the drop-down line we see the text No configurations .


Click on the gear next to it, drop down a menu with a proposal to create a configuration for debug, select Cortex-Debug .


In the project directory, a hidden .vscode folder is created , in which a file with launch.json debug configurations is created .


If this file does not open itself, open it with your hands: go to the Explorer section (Ctrl + Shift + E) and select this file in the tree.


Configuring the configuration for openocd:


 "configurations": [ { "name": "openocd", "request": "launch", "type": "cortex-debug", "cwd": "${workspaceRoot}", "servertype": "openocd", "executable": "build/lol.elf", "svdFile": "STM32F429.svd", "configFiles": [ "/usr/share/openocd/scripts/board/stm32f429discovery.cfg" ] } ] 

The last three properties: the location of the elf file, the location of the svd file, the path to the configuration for openocd, are customizable.


We save the launch.json file and go back to the Debug section, we see that our configuration appears in the drop-down menu.


Next, go back to the Explorer section and in the .vscode directory add a new file named settings.json , open it, write the following there:


 { "cortex-debug.armToolchainPath": "/usr/bin", "cortex-debug.openocdPath": "/usr/bin/openocd" } 

Next, add another c_cpp_properties.json file to .vscode , open it and write the following there:


 { "configurations": [ { "name": "vscode_stm32_c_cpp_properties", "compilerPath": "/usr/bin/arm-none-eabi-gcc", "includePath": [ "${workspaceRoot}/Inc/", "${workspaceRoot}/Drivers/CMSIS/Include/", "${workspaceRoot}/Drivers/CMSIS/Device/ST/STM32F4xx/Include/" ], "defines": [ "STM32F429xx" ], "cStandard": "c11", "cppStandard": "c++17", "intelliSenseMode": "gcc-x64" } ], "version": 4 } 

By pressing F5, you can start debugging (do not forget to build a project before this so that the elf file is in the right place).




Source: https://habr.com/ru/post/437760/