Whether youβre a professional developer or an embedded hobbyist, STM32 microcontrollers offer immense flexibility, power efficiency, and ecosystem support. Before diving into firmware development, setting up your STM32 development environment correctly is critical. This blog focuses only on setting up the environment, not project creation. We’ll discuss IDEs, drivers, tools, OS-specific settings, and useful optional additions.
β What You’ll Set Up:
STM32CubeIDE | Main integrated development environment |
ST-Link Drivers | Interface for debugging and flashing firmware |
STM32CubeMX | MCU configuration GUI (comes integrated with STM32CubeIDE) |
GNU ARM Toolchain | Compiles your C/C++ code to ARM binaries |
USB/UART Drivers | Interface for serial communication (e.g., CH340, CP210x) |
Optional: OpenOCD, PlatformIO, or CLI-based development | For advanced/alternative workflows |
π» Supported Operating Systems:
- Windows 10/11 (64-bit)
- Ubuntu/Linux (18.04+ recommended)
- macOS (Catalina and later)
π§± 1. Install STM32CubeIDE (Official IDE)
STM32CubeIDE is ST’s official IDE built on Eclipse and includes:
- STM32CubeMX (graphical config tool)
- GCC-based toolchain
- Integrated ST-Link debugging
- Peripheral code generator
π Download:
π https://www.st.com/en/development-tools/stm32cubeide.html
π¦ Installation Steps:
Windows:
- Download
.exe
the installer. - Run the installer with Administrator privileges.
- It automatically installs STM32CubeMX and ST-Link USB drivers.
- On first run, it may prompt for updatesβaccept them.
π§ Linux (Ubuntu):
sudo apt update
sudo apt install libusb-1.0-0
chmod +x en.st-stm32cubeide_*.sh
./en.st-stm32cubeide_*.sh
Creates shortcut in applications menu.
If not, run manually:
/opt/st/stm32cubeide/stm32cubeide
π macOS:
- Download .dmg file.
- Drag and drop STM32CubeIDE to Applications.
- macOS may block it initially. Go to System Preferences > Security & Privacy > Allow Anyway.
π 2. Install ST-Link USB Drivers
ST-Link is the USB-to-debug interface built into most STM32 development boards (Nucleo, Discovery, etc.).
πͺ Windows:
- Comes bundled with STM32CubeIDE.
- If needed separately:
π STSW-LINK009
π§ Linux:
Create a udev rule:
sudo nano /etc/udev/rules.d/49-stlinkv2.rules
Paste:
SUBSYSTEM=="usb", ATTR{idVendor}=="0483", ATTR{idProduct}=="3748", MODE="0666", GROUP="plugdev"
Then:
sudo udevadm control --reload-rules
sudo udevadm trigger
π Verify:
Connect board β run:
lsusb
You should see something like: Bus 001 Device 005: ID 0483:3748 STMicroelectronics ST-LINK/V2
π 3. Install GNU ARM Toolchain (If Working Outside CubeIDE)
If you use Makefiles or CMake or want lightweight development, install this separately.
π§° Toolchain:
π https://developer.arm.com/downloads/-/gnu-rm
Windows:
- Add the
bin/
folder (e.g.,C:\Program Files (x86)\GNU Arm Embedded Toolchain\X.X\bin
) to your PATH.
Linux/macOS:
sudo tar -xjf gcc-arm-none-eabi-*.tar.bz2 -C /opt
echo 'export PATH=$PATH:/opt/gcc-arm-none-eabi-X/bin' >> ~/.bashrc
source ~/.bashrc
π Verify:
arm-none-eabi-gcc --version
π§ͺ 4. Install USB to UART Drivers (Optional but Useful)
Some STM32 boards (especially Blue Pill) use USB-to-Serial ICs for UART output/debugging.
Common Drivers:
- CH340:
https://sparks.gogo.co.nz/ch340.html - CP210x:
https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers - FTDI FT232:
https://ftdichip.com/drivers/
Verify on Linux:
dmesg | grep tty
Linux alternative:
st-info --probe # from stlink utilities
π§© 6. Optional Tools for Advanced Users
STM32CubeProgrammer | Flash/debug STM32 without IDE |
OpenOCD | Open-source debugger interface |
stlink CLI tools | Lightweight debug/flash tools |
PlatformIO (VS Code) | Cross-platform embedded development |
π§° STM32CubeProgrammer:
π https://www.st.com/en/development-tools/stm32cubeprog.html
π§° stlink-tools (Linux CLI):
sudo apt install stlink-tools
st-info --probe
st-flash write my_firmware.bin 0x8000000
π§° PlatformIO:
pip install platformio
platformio init --board nucleo_f103rb
platformio run
platformio run --target upload
π Suggested Folder Layout for Bare-Metal Projects
project-root/
β
βββ Makefile or CMakeLists.txt
βββ src/
β βββ main.c
βββ inc/
β βββ main.h
βββ startup/
β βββ startup_stm32f103xb.s
βββ linker/
β βββ stm32f103xb.ld
βββ drivers/
β βββ hal/
β βββ cmsis/
βββ build/
With this setup complete, your machine is now STM32-ready. You can use STM32CubeIDE, VS Code + PlatformIO, or makefile-based development environments depending on your comfort level.