maxqian888/agentpack-gui/stm32-c
Claude Code and agent skill by maxqian888/agentpack-gui
- community
Checking that the SKILL.md file is still in the repository.
Use when developing firmware for STM32 microcontrollers in C — setting up an arm-none-eabi toolchain with CMake or Makefile, working with STM32CubeMX/HAL/LL drivers, configuring linker scripts and startup files, flashing/debugging via OpenOCD/ST-Link/J-Link, handling clocks, GPIO, interrupts/NVIC, timers, UART/SPI/I2C, and DMA. Triggers on STM32, embedded C, bare-metal, HAL, CubeMX, STM32CubeCLT, STM32CubeProgrammer, arm-none-eabi, OpenOCD, ST-Link, SWO/ITM, .ld linker script, NVIC, register.
Install
npx vskill@latest install maxqian888/agentpack-gui/stm32-cSKILL.md
STM32 Bare-metal / HAL Firmware in C
Guidance for STM32 (Cortex-M) firmware. Default to arm-none-eabi-gcc + CMake, STM32CubeMX-generated HAL as a starting point, OpenOCD for flash/debug.
Fastest setup: install STM32CubeCLT — ST's cross-platform command-line bundle that ships arm-none-eabi-gcc/gdb, CMake, Ninja, STM32CubeProgrammer (STM32_Programmer_CLI), the ST-LINK GDB server, and OpenOCD together, so you don't assemble the toolchain by hand. STM32CubeMX (6.10+) can generate a ready CMake project, not just a Makefile.
Toolchain
- arm-none-eabi-gcc (Arm GNU Toolchain) —
arm-none-eabi-gcc,-objcopy,-size,-gdb. - CMake ≥ 3.21 + Ninja, or the Makefile CubeMX emits.
- OpenOCD (or STM32CubeProgrammer / ST-Link CLI / J-Link) for programming.
- A board with ST-Link (e.g. Nucleo/Discovery) or a standalone ST-Link/J-Link probe.
CMake toolchain file (cmake/arm-none-eabi.cmake)
Configure with: cmake --preset debug where the preset sets CMAKE_TOOLCHAIN_FILE to this file and passes -DCMAKE_BUILD_TYPE=Debug. If you let CubeMX generate the project (6.15+), it emits cmake/gcc-arm-none-eabi.cmake, CMakeLists.txt, and CMakePresets.json — and selects the toolchain file in CMakePresets, not in CMakeLists.txt (a common "compiler is your host gcc" build break if you configure without the preset).
Match -mcpu/-mfpu/-mfloat-abi to the exact part (e.g. M0/M0+ have no FPU → -mcpu=cortex-m0plus -mfloat-abi=soft, drop -mfpu).
Build essentials
A firmware target needs: your sources + HAL/CMSIS, the startup\_\*.s assembly, the linker script (.ld), and system_stm32xxxx.c. Produce a binary/hex:
arm-none-eabi-size shows flash (text+data) and RAM (data+bss) usage — check it fits the part.
Flash & debug with OpenOCD
HAL vs LL vs registers
- HAL: portable, fast to start (CubeMX generates init). Heavier, some abstraction cost.
- LL (Low-Layer): thin register wrappers — good middle ground for performance-sensitive paths.
- Direct registers (CMSIS):
GPIOA->ODR |= (1<<5);— smallest/fastest, but you own clock-enable and config. Always enable the peripheral clock first (RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;).
Interrupts / NVIC
- Handler names must match the vector table in
startup_*.s(e.g.TIM2_IRQHandler,USART2_IRQHandler). - Enable in NVIC (
HAL_NVIC_EnableIRQ/NVIC_EnableIRQ) and the peripheral's interrupt enable bit. - Keep ISRs short; clear the pending flag; defer work to the main loop. Mark shared state
volatile.
Common pitfalls
- Hard fault on boot → wrong clock config, stack not in valid RAM (check
.ld), or FPU used without enabling it; verifySystemInit/clock setup. - Code builds but won't run → linker script / startup file don't match the part; flash origin/length wrong; vector table not at the expected address.
- Float/`-mfpu` mismatch → all objects + libs must share the same float ABI, or you get link errors / silent corruption.
- Peripheral "dead" → forgot to enable its RCC clock, or wrong AF (alternate function) mux on the GPIO.
- OpenOCD "init mode failed" / "target not halted" → wrong target cfg, low SWD speed needed, or board not powered/connected; try
reset halt. - `-specs=nosys.specs` stubs out syscalls —
printfwon't appear unless you retarget_writeto UART/SWO/semihosting. SWO/ITM (ITM_SendChar) is the fastest path, but ITM is absent on Cortex-M0/M0+ — use UART or OpenOCD semihosting there. - CubeMX project builds with the wrong (host) compiler → you configured without the preset; on 6.15+ the toolchain file is selected in
CMakePresets.json, so always usecmake --preset <name>. - Verify by flashing to real hardware and observing behavior (LED/UART/debugger), not by reading source alone.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingsrc-tauri/assets/skills/stm32-c/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/maxqian888/agentpack-gui/stm32-c)