Stm32 Development Workflow logo

Stm32 Development Workflow

Community
EricSun787
stm32-development-workflow

STM32通用程序开发完整流程,基于STM32CubeCLT命令行工具链。涵盖工具链安装、 HAL库配置、项目构建、固件编译和ST-Link烧录。适用于STM32F1/F4/H7等系列, 解决编译错误、链接错误、烧录失败等常见问题。

Overview

PublisherEricSun787
Repositorystm32-development-workflow
Skill namestm32-development-workflow
Stars
29
Forks
2
Bundled files
1
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by EricSun787 on GitHub. Read the source before you install it.

Installation

Install the Stm32 Development Workflow AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/EricSun787/stm32-development-workflow/tree/main
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/EricSun787/stm32-development-workflow.git \
  .claude/skills/stm32-development-workflow
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Stm32 Development Workflow in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Stm32 Development Workflow on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Stm32 Development Workflow is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

STM32 通用程序开发流程

概述

基于STM32CubeCLT命令行工具链的完整STM32开发流程,无需依赖Keil或STM32CubeIDE。

开发环境准备

1. 安装STM32CubeCLT

从ST官网下载并安装STM32CubeCLT,包含:

  • arm-none-eabi-gcc 编译器
  • STM32CubeProgrammer (烧录工具)
  • ST-Link驱动

典型安装路径:C:\ST\STM32CubeCLT_1.21.0

2. 获取HAL库

从GitHub下载STM32Cube固件包:

bash
# STM32CubeF4示例
git clone https://github.com/STMicroelectronics/STM32CubeF4.git

# 或从ST官网下载完整固件包

固件包目录结构:

STM32Cube_FW_F4_V1.28.0/
├── Drivers/
│   ├── STM32F4xx_HAL_Driver/    # HAL库源文件
│   ├── CMSIS/                    # CMSIS核心文件
│   └── BSP/                      # 板级支持包
├── Projects/                     # 示例项目
└── Utilities/                    # 工具

项目目录结构

my-stm32-project/
├── Core/
│   ├── Inc/                      # 核心头文件
│   │   └── main.h
│   └── Src/                      # 核心源文件
│       └── main.c
├── Drivers/
│   ├── STM32F4xx_HAL_Driver/     # HAL库
│   │   ├── Inc/                  # HAL头文件
│   │   │   └── stm32f4xx_hal_conf.h  # 关键配置文件
│   │   └── Src/                  # HAL源文件
│   ├── CMSIS/                    # CMSIS
│   │   ├── Core/                 # CMSIS核心
│   │   └── Device/ST/STM32F4xx/  # 设备特定文件
│   │       ├── Include/          # 启动文件
│   │       └── Source/Templates/
│   │           ├── gcc/          # GCC启动文件
│   │           │   └── startup_stm32f429xx.s
│   │           └── system_stm32f4xx.c
│   └── BSP/                      # 板级支持包(可选)
├── build/                        # 构建输出
└── build.sh                      # 构建脚本

HAL库配置

关键配置文件 stm32f4xx_hal_conf.h

启用需要的HAL模块:

c
#define HAL_MODULE_ENABLED
#define HAL_GPIO_MODULE_ENABLED
#define HAL_RCC_MODULE_ENABLED
#define HAL_FLASH_MODULE_ENABLED
#define HAL_PWR_MODULE_ENABLED
#define HAL_CORTEX_MODULE_ENABLED

// 根据外设需求启用
#define HAL_DMA_MODULE_ENABLED
#define HAL_UART_MODULE_ENABLED
#define HAL_TIM_MODULE_ENABLED
#define HAL_I2C_MODULE_ENABLED
#define HAL_SPI_MODULE_ENABLED
#define HAL_ADC_MODULE_ENABLED
// ... etc

时钟配置(HSE_VALUE必须与硬件匹配):

c
#if !defined (HSE_VALUE)
  #define HSE_VALUE  8000000U  // 8MHz for STM32F429I-DISCO
#endif

构建脚本 build.sh

bash
#!/bin/bash

TOOLCHAIN="/c/ST/STM32CubeCLT_1.21.0/GNU-tools-for-STM32/bin"
CC="${TOOLCHAIN}/arm-none-eabi-gcc"
AS="${TOOLCHAIN}/arm-none-eabi-gcc -x assembler-with-cpp"
LD="${TOOLCHAIN}/arm-none-eabi-gcc"
CP="${TOOLCHAIN}/arm-none-eabi-objcopy"
SZ="${TOOLCHAIN}/arm-none-eabi-size"

PROJECT_DIR="/path/to/project"
BUILD_DIR="${PROJECT_DIR}/build"

# MCU配置
MCU="-mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard"
DEFS="-DUSE_HAL_DRIVER -DSTM32F429xx"
INCLUDES="-I${PROJECT_DIR}/Core/Inc \
          -I${PROJECT_DIR}/Drivers/STM32F4xx_HAL_Driver/Inc \
          -I${PROJECT_DIR}/Drivers/CMSIS/Device/ST/STM32F4xx/Include \
          -I${PROJECT_DIR}/Drivers/CMSIS/Include"

CFLAGS="${MCU} ${DEFS} ${INCLUDES} -O2 -Wall -fdata-sections -ffunction-sections"
ASFLAGS="${MCU} ${DEFS} ${INCLUDES} -Wall"

# 链接器脚本路径
LDSCRIPT="${PROJECT_DIR}/Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/linker/STM32F429ZITx_FLASH.ld"
LDFLAGS="${MCU} -specs=nano.specs -T${LDSCRIPT} -lc -lm -lnosys -Wl,--gc-sections"

# 源文件列表
HAL_SRCS=(
    "${PROJECT_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c"
    "${PROJECT_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c"
    "${PROJECT_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c"
    "${PROJECT_DIR}/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c"
    # ... 添加需要的HAL模块
)

CORE_SRCS=(
    "${PROJECT_DIR}/Core/Src/main.c"
    "${PROJECT_DIR}/Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c"
)

ASM_SRCS=(
    "${PROJECT_DIR}/Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f429xx.s"
)

# 编译函数
compile_c() {
    local src=$1
    local obj="${BUILD_DIR}/$(basename ${src%.c}.o)"
    echo "  CC ${src}"
    ${CC} -c ${CFLAGS} -o ${obj} ${src}
    echo "${obj}"
}

compile_asm() {
    local src=$1
    local obj="${BUILD_DIR}/$(basename ${src%.s}.o)"
    echo "  AS ${src}"
    ${AS} -c ${ASFLAGS} -o ${obj} ${src}
    echo "${obj}"
}

# 主构建流程
echo "Building project..."
mkdir -p ${BUILD_DIR}

OBJECTS=""

# 编译HAL文件
for src in "${HAL_SRCS[@]}"; do
    obj=$(compile_c "${src}")
    OBJECTS="${OBJECTS} ${obj}"
done

# 编译核心文件
for src in "${CORE_SRCS[@]}"; do
    obj=$(compile_c "${src}")
    OBJECTS="${OBJECTS} ${obj}"
done

# 编译启动文件
for src in "${ASM_SRCS[@]}"; do
    obj=$(compile_asm "${src}")
    OBJECTS="${OBJECTS} ${obj}"
done

# 链接
echo "Linking..."
${LD} ${OBJECTS} ${LDFLAGS} -o ${BUILD_DIR}/project.elf

# 生成HEX/BIN
${CP} -O ihex ${BUILD_DIR}/project.elf ${BUILD_DIR}/project.hex
${CP} -O binary -S ${BUILD_DIR}/project.elf ${BUILD_DIR}/project.bin

# 显示大小
${SZ} ${BUILD_DIR}/project.elf

echo "Build complete!"

烧录流程

1. 检查ST-Link连接

bash
STM32_Programmer_CLI.exe -l stlink

2. 升级ST-Link固件(如需要)

bash
# 如果提示"Old ST-Link firmware version"
cd C:\ST\STM32CubeCLT_1.21.0
java -jar STLink-gdb-server/bin/STLinkUpgrade.jar -sn [序列号]

3. 烧录固件

bash
# 烧录HEX文件
STM32_Programmer_CLI.exe \
    -c port=SWD sn=[序列号] \
    -w build/project.hex 0x08000000 \
    -v -rst

参数说明:

  • -c port=SWD: 使用SWD接口
  • -w: 写入文件
  • -v: 验证
  • -rst: 复位运行

常见编译错误及解决

错误原因解决
unknown type name 'DMA2D_HandleTypeDef'HAL模块未启用在hal_conf.h中定义#define HAL_DMA2D_MODULE_ENABLED
undefined reference to 'SystemCoreClock'缺少system文件添加system_stm32f4xx.c到编译
undefined reference to 'FMC_SDRAM_Init'缺少LL库添加stm32f4xx_ll_fmc.c到编译
multiple definition of 'Font8'字体重复定义检查是否重复包含字体源文件
cannot open linker script file链接器脚本路径错误检查LDSCRIPT路径

调试技巧

1. 验证HAL配置

c
// 在main()中添加检查
#if !defined(HSE_VALUE)
  #error "HSE_VALUE not defined!"
#endif

2. 使用LED指示程序状态

c
// 初始化LED
BSP_LED_Init(LED3);

// 在关键位置闪烁
while (1) {
    BSP_LED_Toggle(LED3);
    HAL_Delay(500);
}

3. 检查时钟配置

c
// 打印系统时钟频率(需要串口)
printf("System Clock: %lu Hz\n", HAL_RCC_GetSysClockFreq());

参考资源

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Stm32 Development Workflow AI skill do?

STM32通用程序开发完整流程,基于STM32CubeCLT命令行工具链。涵盖工具链安装、 HAL库配置、项目构建、固件编译和ST-Link烧录。适用于STM32F1/F4/H7等系列, 解决编译错误、链接错误、烧录失败等常见问题。

Why use Stm32 Development Workflow on TypingMind?

Because you install it once and use it with any model. Stm32 Development Workflow is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Stm32 Development Workflow in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/EricSun787/stm32-development-workflow/tree/main. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Stm32 Development Workflow?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Stm32 Development Workflow?

As many as you like. As long as a model supports skills, you can use Stm32 Development Workflow with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Stm32 Development Workflow AI skill free?

It is published on GitHub by EricSun787. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇