A clean, no-nonsense STM32 project setup using PlatformIO, STM32Cube HAL, and FreeRTOS. Because life's too short for bad embedded setups.
- STM32F103C8
- PlatformIO
- STM32Cube HAL
- FreeRTOS
You'll need:
- VS Code
- PlatformIO extension
- ST-Link V2 (or compatible programmer)
- A sense of whismy and adventure
# if you are on linux you might need this to give permissions to use the USB ports for flashing
sudo usermod -a -G dialout $USER
# Then logout/logingit clone git@github.com:CPRT/embedded-smartPDB.git
cd embedded-smartPDB
code .VS Code will bug you about installing extensions. Click "Install All"
pio runIf it compiles, you're golden.
# Upload to board
pio run -t upload
# Watch serial output (optional)
pio device monitor.
├── include/ # Your headers go here
│ ├── FreeRTOSConfig.h # RTOS configuration
│ └── main.h # Main header
├── src/ # Your code lives here
│ ├── main.c # Entry point
│ └── freertos.c # RTOS tasks
├── lib/ # Local libraries
│
├── platformio.ini # Project config
└── .vscode/ # VS Code goodies
pio run
# Or in VS Code: Ctrl+Shift+Bpio run -t uploadpio run -t clean && pio runpio device monitor
# Exit with Ctrl+Cpio checkarm-none-eabi-size -A -d .pio/build/bluepill_f103c8/firmware.elfIn src/freertos.c:
void MyTask(void *pvParameters) {
while(1) {
// Do stuff
vTaskDelay(pdMS_TO_TICKS(1000)); // Delay 1 second
}
}
// In main()
xTaskCreate(MyTask, "MyTask", 128, NULL, 1, NULL);
vTaskStartScheduler();Got an ST-Link? Time to debug properly.
# In VS Code: F5
# Or: Run → Start DebuggingUses the config in .vscode/launch.json (ST-Link by default).
# Terminal 1: Start OpenOCD
openocd -f interface/stlink.cfg -f target/stm32f1x.cfg
# Terminal 2: GDB
arm-none-eabi-gdb .pio/build/bluepill_f103c8/firmware.elf
(gdb) target remote :3333
(gdb) monitor reset halt
(gdb) load
(gdb) continue# List all tasks
pio run --list-targets
# Verbose build
pio run -v
# Clean everything
rm -rf .pio
# Check library dependencies
pio lib list- Don't break the build
- Test your changes
- Update this README if you add something cool
- Keep commits atomic and meaningful