From 3a4435e7a6198706f5c9cfc3b7214d27bb4b6791 Mon Sep 17 00:00:00 2001 From: yelvlab Date: Tue, 30 Jun 2026 11:50:42 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=B7=BB=E5=8A=A0=20Bootloader=20Flash?= =?UTF-8?q?=20=E5=81=8F=E7=A7=BB=E9=85=8D=E7=BD=AE=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index dfdb2e7..f1ec269 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ - [快速开始](#快速开始) - [工程结构](#工程结构) - [板级配置](#板级配置) +- [Flash 偏移配置(配合 Bootloader)](#flash-偏移配置配合-bootloader) - [工具链准备](#工具链准备) - [使用说明](#使用说明) - [时钟配置说明](#时钟配置说明) @@ -142,6 +143,32 @@ --- +## Flash 偏移配置(配合 Bootloader) + +如果固件需要通过 Bootloader 启动(Bootloader 占用 Flash 前部区域),需修改两处: + +**1. 链接脚本** — `LD/gd32e23x_flash.ld` 第 15 行: +```c +// 默认:从 Flash 起始运行 +FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 16K + +// 配合 Bootloader:前 8KB 留给 Bootloader,App 从 0x08002000 开始 +FLASH (rx) : ORIGIN = 0x08002000, LENGTH = 8K +``` + +**2. 向量表偏移** — `Src/system_gd32e23x.c` 第 44 行: +```c +// 默认 +#define VECT_TAB_OFFSET (uint32_t)0x00 + +// 配合 Bootloader(值 = Flash 偏移量,不含 0x0800 前缀) +#define VECT_TAB_OFFSET (uint32_t)0x2000 +``` + +> ⚠️ 两个偏移值必须对应修改:`LD` 中的 `ORIGIN` 减去 `0x08000000` 应等于 `VECT_TAB_OFFSET`。 + +--- + ## 工具链准备 ### 1. ARM GCC 工具链