STM32
STM32 — Ubuntu / Linux Setup
Install STM32CubeIDE on Ubuntu (or any Debian-based Linux). Linux requires an extra step to configure udev rules so you can access the ST-LINK programmer without sudo.
Prerequisites
- Ubuntu 22.04 or 24.04 (64-bit)
sudoaccess- A free st.com account
Step 1 — Install Required Dependencies
sudo apt update
sudo apt install -y \
libusb-1.0-0 \
libusb-dev \
libc6:i386 \
libncurses5 \
libstdc++6:i386 \
unzip
Step 2 — Download STM32CubeIDE
- Go to st.com/en/development-tools/stm32cubeide.html
- Click Get Software → log in with your ST account
- Download "STM32CubeIDE-Lnx" (the
.shinstaller)
Step 3 — Run the Installer
# Navigate to your Downloads directory
cd ~/Downloads
# Make the installer executable
chmod +x st-stm32cubeide-*.sh
# Run the installer (do NOT use sudo here)
./st-stm32cubeide-*.sh
The installer will ask:
- Installation path: Accept the default (
~/st/stm32cubeide_1.xx.x) or choose a custom path - Create desktop shortcut: Yes
- Install for all users: No (install for current user only)
Step 4 — Configure udev Rules (CRITICAL)
Without udev rules, you'll get "Permission denied" when trying to flash or debug via ST-LINK.
The installer places udev rules in:
~/st/stm32cubeide_1.xx.x/plugins/com.st.stm32cube.ide.mcu.externaltools.stlink.*.linux64/tools/
Install the udev rules:
# Find the udev rules directory
STLINK_DIR=$(find ~/st -name "stlink_udev_rules" -type d 2>/dev/null | head -1)
# Copy all udev rules
sudo cp $STLINK_DIR/*.rules /etc/udev/rules.d/
# OR copy manually (adjust path to your version)
sudo cp ~/st/stm32cubeide_*/plugins/com.st.stm32cube.ide.mcu.externaltools.stlink*/tools/udev_rules/*.rules /etc/udev/rules.d/
Reload udev and add yourself to the plugdev group:
sudo udevadm control --reload-rules
sudo udevadm trigger
sudo usermod -aG plugdev $USER
Log out and log back in
The group change only takes effect after you log out and back in. After doing so, connect your NUCLEO board — it should be recognized without sudo.
Step 5 — Launch STM32CubeIDE
# Launch from terminal
~/st/stm32cubeide_1.xx.x/stm32cubeide &
# Or use the desktop shortcut if you created one during installation
On first launch:
- Select a workspace directory (e.g.,
~/STM32CubeIDE/workspace) - Click Launch
Step 6 — Verify ST-LINK Detection
Connect your NUCLEO board or ST-LINK probe via USB.
# Verify the device is recognized
lsusb | grep -i "ST "
# Expected: Bus XXX Device XXX: ID 0483:374b STMicroelectronics ST-LINK/V2.1
# Check it's accessible without sudo
ls -la /dev/bus/usb/*/*
# ST-LINK device should be readable by plugdev group
In STM32CubeIDE: go to Help → ST-LINK Upgrade — if your board appears in the list, it's working correctly.
Step 7 — Create and Flash a Blink Project
Follow the same project creation steps as the Windows guide:
- File → New → STM32 Project
- Select your board (e.g.,
NUCLEO-F446RE) - Name it
hello_blink - In the
while(1)loop ofmain.c:
1while (1)2{3 HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);4 HAL_Delay(500);5}- Build with
Ctrl+B - Flash with
F11(Debug) or use Run → Run for release flash
Step 8 — Serial Monitor on Linux
For serial output from USART2 (connected to ST-LINK VCP on NUCLEO):
# The NUCLEO's virtual COM port appears as /dev/ttyACM0
# Install minicom or use any serial terminal
sudo apt install -y minicom
# Open serial terminal at 115200 baud
minicom -D /dev/ttyACM0 -b 115200
Alternatively, use the Serial Monitor extension in VS Code.
Troubleshooting
libusb_open() failed: LIBUSB_ERROR_ACCESS
This means udev rules are not installed or not applied. Retry Step 4 and verify you've logged out and back in.
STM32CubeIDE won't launch
Check if OpenJDK is installed:
java -version
STM32CubeIDE bundles its own JRE. If you see issues, try launching with:
~/st/stm32cubeide_*/stm32cubeide -vm ~/st/stm32cubeide_*/jre/bin/java
libncurses5 not found
# Ubuntu 24.04 may need this
sudo apt install libncurses5-dev libncurses5

