STM32
STM32 — Windows Setup
Install STM32CubeIDE on Windows — the official all-in-one IDE from STMicroelectronics. Everything you need (compiler, debugger, peripheral configurator) is bundled in one installer.
Prerequisites
- Windows 10 or 11 (64-bit)
- At least 4 GB of free disk space (8 GB recommended)
- A free account on st.com (required to download the installer)
- Administrator privileges for installation
Step 1 — Download STM32CubeIDE
- Go to st.com/en/development-tools/stm32cubeide.html
- Scroll down and click "Get Software"
- If prompted, log in with your ST account (free registration)
- Under "STM32CubeIDE-Win", click Download
- Run the downloaded
.exeinstaller
Step 2 — Run the Installer
- Double-click the downloaded
st-stm32cubeide-*.exe - Accept the license agreement
- Choose installation path (default
C:\ST\STM32CubeIDE_1.xx.xis fine) - Select components to install:
- ✅ STM32CubeIDE (required)
- ✅ ST-LINK server (required for debugging)
- ✅ SEGGER J-Link (optional — only if you have a J-Link probe)
- Click Install
Installation takes 5–15 minutes
STM32CubeIDE is a large download (>1 GB). The actual installation after download takes another 5–10 minutes. Do not close the installer window.
Step 3 — Install ST-LINK Drivers
The installer should install ST-LINK USB drivers automatically. Verify by connecting your NUCLEO or ST-LINK to USB:
- Open Device Manager (
Win + X→ Device Manager) - Expand Universal Serial Bus devices
- You should see "STMicroelectronics STLink Virtual COM Port" and "STM32 STLink"
If not listed, manually install drivers:
- Open STM32CubeIDE → Help → ST-LINK Upgrade
- Or download STSW-LINK009 from st.com directly
Step 4 — Launch STM32CubeIDE
- Open STM32CubeIDE from the Start Menu
- On first launch, select a workspace directory (where your projects will be stored)
- Example:
C:\Users\<you>\STM32CubeIDE\workspace
- Example:
- Click Launch
Step 5 — Create Your First Project (NUCLEO Board)
Let's create a simple LED blink project using the HAL library.
5.1 — New STM32 Project
- Go to File → New → STM32 Project
- In the Board Selector tab:
- Search for your board (e.g.,
NUCLEO-F446RE) - Select it from the list
- Click Next
- Search for your board (e.g.,
- Set Project Name:
hello_blink - Select Targeted Language:
C - Click Finish
STM32CubeMX will open with your board's pin configuration pre-set.
5.2 — Configure the LED Pin (CubeMX)
For NUCLEO-F446RE, the onboard LED is on PA5 (already configured as GPIO_Output by default).
Click Generate Code (the gear icon or Project → Generate Code) to create the HAL-based project.
5.3 — Write the Blink Code
Open Core/Src/main.c. Inside the while(1) loop in main(), add:
1/* USER CODE BEGIN WHILE */2while (1)3{4 HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5); // Toggle the LED on PA55 HAL_Delay(500); // Wait 500ms6 /* USER CODE END WHILE */78 /* USER CODE BEGIN 3 */9}10/* USER CODE END 3 */Always write code inside USER CODE sections
STM32CubeMX regenerates code when you modify pin/clock settings. Any code outside the /* USER CODE BEGIN */ ... /* USER CODE END */ blocks will be deleted on regeneration.
5.4 — Build the Project
Press Ctrl+B or go to Project → Build All.
Expected output in the Console:
Finished building: hello_blink.elf
5.5 — Flash and Debug
- Connect your NUCLEO board via USB
- Click the Debug button (bug icon) or press
F11 - STM32CubeIDE will flash the binary and halt at
main() - Press
F8(Resume) to run the program - The LED on your NUCLEO board should blink at 1 Hz!
To stop debugging: Press Ctrl+F2 or click the red stop button.
Step 6 — Serial Output (Optional)
To print debug messages over UART:
- In CubeMX, enable USART2 (on PA2/PA3 — connected to ST-LINK on NUCLEO boards)
- Regenerate code
- Add
printfredirect by adding tomain.c:
1// Redirect printf to USART22int _write(int file, char *ptr, int len)3{4 HAL_UART_Transmit(&huart2, (uint8_t *)ptr, len, HAL_MAX_DELAY);5 return len;6}Now open Window → Show View → Console and use the serial terminal at 115200 baud.
Troubleshooting
ST-LINK not detected
- Check Device Manager for the ST-LINK entry
- Try unplugging and replugging the USB cable
- Use the shorter CN1 USB port on NUCLEO boards (not the Arduino shield connectors)
- Run Help → ST-LINK Upgrade inside STM32CubeIDE
No source available for "main()" during debug
This means the binary was flashed but source mapping is wrong. Make sure you built in Debug configuration, not Release.
Workspace locked error on startup
Another instance of CubeIDE may be running. Close all instances and relaunch.

