Skip to content

Repository files navigation

STM32 CMake 模板工程 (GCC)

这是一个基于 CMake 和 arm-none-eabi-gcc 工具链的 STM32F103 模板工程。

目录结构

  • .vscode/: VS Code 配置文件(调试、IntelliSense 等)。
  • Start/: 启动文件、CMSIS 核心文件及中断向量表。
  • Library/: STM32 标准外设库文件 (StdPeriph)。
  • User/: 用户代码目录(包含 main.cstm32f10x_it.c)。
  • CMakeLists.txt: 项目构建脚本。
  • arm-none-eabi-gcc.cmake: 交叉编译工具链定义。
  • stm32_flash.ld: 链接脚本(定义内存布局)。

快速开始

1. 环境准备

确保已安装以下工具:

2. 构建项目

在项目根目录下运行:

# 创建并进入构建目录
mkdir build
cd build

# 配置项目
cmake -G Ninja ..

# 执行编译
ninja

编译完成后,会在 build 目录下生成 .elf, .hex.bin 文件。

注意事项

  • 芯片型号: 当前配置为 STM32F103C8T6 (中容量/MD)。如果更换芯片,请修改 CMakeLists.txt 中的宏定义(如 STM32F10X_HD)以及链接脚本 stm32_flash.ld
  • 标准库: 工程使用了 USE_STDPERIPH_DRIVER

About

My Stm32 Template Project--CMake

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages