# auto_build **Repository Path**: wenhuafeng/auto_build ## Basic Information - **Project Name**: auto_build - **Description**: 这是一个基于Python的自动化构建与烧录工具,支持多种编译工具链和烧录器,用于嵌入式系统项目的快速开发和部署。 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-07-27 - **Last Updated**: 2026-04-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 自动构建与烧录工具 ## 项目简介 这是一个基于Python的自动化构建与烧录工具,支持多种编译工具链和烧录器,用于嵌入式系统项目的快速开发和部署。 ## 功能特性 ### 构建功能 - 支持多种编译工具链:MDK (Keil)、IAR Embedded Workbench、GCC (CMake) - 支持Bootloader和应用程序的独立编译 - 自动生成带版本信息的固件文件(包含软件版本、编译日期和CRC校验) - 支持增量编译和全量编译(clean模式) - 自动复制构建产物到指定输出目录 - 支持Bootloader和应用程序固件合并 ### 烧录功能 - 支持多种烧录器:J-Link、DAP-Link、ST-Link - 支持独立烧录Bootloader、应用程序或合并固件 - 自动选择最新版本的固件文件进行烧录 - 支持烧录完成后的自动复位 ### 配置管理 - 集中化的配置文件管理(build_config.json) - 支持多种芯片型号扩展 - 灵活的项目路径配置 - 统一的输出目录结构 ## 安装要求 ### 系统要求 - Windows操作系统 - Python 3.6及以上版本 ### 依赖工具 根据需要使用的编译工具和烧录器,需要安装对应的软件: #### 编译工具 - **MDK (Keil)**: 需安装Keil uVision并确保UV4.exe在系统路径中 - **IAR**: 需安装IAR Embedded Workbench并确保IarBuild.exe在系统路径中 - **GCC**: 需安装ARM GCC工具链和CMake #### 烧录工具 - **J-Link**: 需安装J-Link软件包 - **DAP-Link**: 支持OpenOCD或PyOCD - **ST-Link**: 需安装ST-Link Utility ## 配置文件说明 配置文件 `build_config.json` 包含了项目的所有配置信息: ### 配置结构 ```json { "common": { /* 通用配置 */ }, "chips": { /* 芯片型号配置 */ }, "compilers": { /* 编译工具配置 */ }, "programmers": { /* 烧录器配置 */ } } ``` ### 主要配置项 #### common(通用配置) - `app_*_project_file`: 应用程序项目文件路径 - `app_*_output_dir`: 应用程序编译输出目录 - `boot_*_project_file`: Bootloader项目文件路径 - `boot_*_output_dir`: Bootloader编译输出目录 - `output_build_log`: 构建日志文件名 - `output_target`: 固件输出目录 #### chips(芯片配置) 包含所有支持的芯片型号及其配置,如设备名称、系列等。 #### compilers(编译工具配置) 定义了支持的编译工具路径。 #### programmers(烧录器配置) 定义了支持的烧录器路径和参数。 ## 使用说明 ### 查看支持的芯片型号 ```bash python build.py -c ? ``` ### 构建命令格式 ```bash python build.py build -c <芯片型号> -t <编译工具> [--boot] [--clean] ``` ### 烧录命令格式 ```bash python build.py program -c <芯片型号> -p <烧录器> [--boot] [--app] [--boot_add_app] ``` ## 命令参数详解 ### 构建命令参数 | 参数 | 说明 | 可选值 | |------|------|--------| | `-c, --chip` | 指定芯片型号 | 查看支持列表 `python build.py -c ?` | | `-t, --tool` | 指定编译工具 | `mdk`, `iar`, `gcc` | | `--boot` | 编译Bootloader | 无 | | `--clean` | 执行全量编译 | 无 | ### 烧录命令参数 | 参数 | 说明 | 可选值 | |------|------|--------| | `-c, --chip` | 指定芯片型号 | 查看支持列表 `python build.py -c ?` | | `-p, --programmer` | 指定烧录器 | `j-link`, `dap-link`, `st-link` | | `--boot` | 烧录Bootloader | 无 | | `--app` | 烧录应用程序 | 无 | | `--boot_add_app` | 烧录合并固件 | 无 | ## 示例 ### 构建示例 ```bash # 使用MDK编译应用程序(增量编译) python build.py build -c stm32f103c8t6 -t mdk # 使用MDK全量编译应用程序 python build.py build -c stm32f103c8t6 -t mdk --clean # 使用MDK编译Bootloader python build.py build -c stm32f103c8t6 -t mdk --boot --clean # 使用IAR编译应用程序 python build.py build -c stm32f103c8t6 -t iar # 使用GCC编译应用程序 python build.py build -c stm32f103c8t6 -t gcc ``` ### 烧录示例 ```bash # 使用J-Link烧录应用程序 python build.py program -c stm32f103c8t6 -p j-link --app # 使用J-Link烧录Bootloader python build.py program -c stm32f103c8t6 -p j-link --boot # 使用J-Link烧录合并固件 python build.py program -c stm32f103c8t6 -p j-link --boot_add_app # 使用DAP-Link烧录应用程序 python build.py program -c stm32f103c8t6 -p dap-link --app # 使用ST-Link烧录应用程序 python build.py program -c stm32f103c8t6 -p st-link --app ``` ## 支持的工具列表 ### 编译工具 - MDK (Keil uVision) - IAR Embedded Workbench - GCC (ARM GCC + CMake) ### 烧录器 - J-Link - DAP-Link - ST-Link ## 项目结构 ``` auto_build/ ├── build.py # 主程序脚本 ├── build_config.json # 配置文件 ├── readme.md # 项目文档 └── user/ └── output/ # 构建产物输出目录 ``` ## 扩展支持 ### 添加新芯片 1. 在 `build_config.json` 的 `chips` 部分添加新的芯片配置 2. 确保项目目录结构符合配置文件中的路径定义 ### 配置新的编译工具 在 `build_config.json` 的 `compilers` 部分添加新的编译工具配置 ### 配置新的烧录器 在 `build_config.json` 的 `programmers` 部分添加新的烧录器配置 ## 日志 构建和烧录过程会生成日志文件: - `build.log`: 主程序日志 - `build_log.log`: 编译工具生成的构建日志(在项目目录下) ## 注意事项 1. 确保所有依赖工具都已正确安装并添加到系统路径 2. 首次使用前请检查配置文件中的路径是否正确 3. 烧录前请确保目标设备已正确连接 4. 全量编译(--clean)会删除所有中间文件,编译时间较长 ## 许可证 MIT License Copyright (c) [2026] [wenhuafeng] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.