For working with STM32, general steps are:

1) Create based project with STM32CudeMX: config GPIO, Clocks, Midware, ... and select toolchain/IDE to generate: EWARM, MDK-ARM, STM32CudeIde, Makefile

2) Open chosen IDE to work with

In this article, I will guide you steps to develop STM32 under your favorite VSCode environment in Windows/Linux/Macos platforms.

Install VSCode plugin

In VSCode, search for plugin stm32-for-vscode

stm32-for-vscode

Install toolchains

Install toolchains in Windows

1) Install choco package manager. You can follow Chocolatey official guidance

2) Install latestARM GNU Toolchain and make:

choco install gcc-arm-embedded
choco install openocd
choco install make

Validate those tools are installed:

arm-none-eabi-gcc --version
arm-none-eabi-gcc.exe (GNU Arm Embedded Toolchain 10.3-2021.10) 10.3.1 20210824 (release)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

openocd --version
Open On-Chip Debugger 0.12.0 (2023-01-14-23:37)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html

make --version
GNU Make 4.4.1
Built for Windows32
Copyright (C) 1988-2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Install toolchains in Linux/Macos

Just look at your package management and install package gcc-arm-embedded and openocd

Archlinux based:

sudo pacman -Syu
sudo pacman -S arm-none-eabi-gcc
sudo pacman -S openocd

Debian based Linux:

sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
sudo apt update
sudo apt-get install gcc-arm-embedded
sudo apt-get install openocd

MacOS:

brew install --cask gcc-arm-embedded
brew install open-ocd

Usage

1) In STM32CudeMX, in Project Manager select Toolchain/IDE as Makefile and generate Code

2) Open project with VSCode and open left menu STM32 for VScode - this plugin should recognize all tools automatically and you can build/flash/debug on the target board without any issue.

Debug with VSCode:

Advantage of this VScode plugin - it looks for toolchain/debug tool and also STM32CudeMX settings and generate:

  • VSCode tasks: compile/debug under subfolder .vscode
  • Generate openocd.cfg configuration under the main project folder