diff --git "a/bsp/stm32/docs/STM32\347\263\273\345\210\227BSP\345\210\266\344\275\234\346\225\231\347\250\213.md" "b/bsp/stm32/docs/STM32\347\263\273\345\210\227BSP\345\210\266\344\275\234\346\225\231\347\250\213.md" index d809ff3e303b178b10de83af5adf4a55509b09d2..c326193f540d4d414ea1927177e8f9a5d97fc74c 100644 --- "a/bsp/stm32/docs/STM32\347\263\273\345\210\227BSP\345\210\266\344\275\234\346\225\231\347\250\213.md" +++ "b/bsp/stm32/docs/STM32\347\263\273\345\210\227BSP\345\210\266\344\275\234\346\225\231\347\250\213.md" @@ -69,8 +69,10 @@ BSP 的制作过程分为如下五个步骤: | 工程模板 | 说明 | | ------- | ---- | +| libraries/templates/stm32f0xx | F0 系列 BSP 模板 | | libraries/templates/stm32f10x | F1 系列 BSP 模板 | | libraries/templates/stm32f4xx | F4 系列 BSP 模板 | +| libraries/templates/stm32f7xx | F7 系列 BSP 模板 | | libraries/templates/stm32l4xx | L4 系列 BSP 模板 | 本次示例所用的 F1 系列 BSP 模板文件夹结构如下所示: @@ -157,9 +159,25 @@ BSP 的制作过程分为如下五个步骤: ![需要修改的链接脚本](./figures/linker_scripts.png) -修改这些文件需要用户掌握链接脚本语法,根据相应的芯片进行修改。 +下面以 MDK 使用的链接脚本 link.sct 为例,演示如何修改链接脚本: + +![linkscripts_change](figures/linkscripts_change.png) + +本次制作 BSP 使用的芯片为 STM32F103RB,FLASH 为 128k,因此修改 LR_IROM1 和 ER_IROM1 的参数为 0x00020000。RAM 的大小为20k, 因此修改 RW_IRAM1 的参数为 0x00005000。这样的修改方式在一般的应用下就够用了,后续如果有特殊要求,则需要按照链接脚本的语法来根据需求修改。 + +其他两个链接脚本的文件分别为 iar 使用的 link.icf 和 gcc 编译器使用的 link.lds,修改的方式也是类似的,如下图所示: + +- link.icf 修改内容 + + ![link_icf](figures/link_icf.png) + +- link.lds 修改内容 + + ![link_lds](figures/link_lds.png) + #### 3.4.2 修改构建脚本 + **SConscript** 脚本决定 MDK/IAR 工程的生成以及编译过程中要添加文件。 在这一步中需要修改芯片型号以及芯片启动文件的地址,修改内容如下图所示: diff --git "a/bsp/stm32/docs/STM32\347\263\273\345\210\227\351\251\261\345\212\250\344\273\213\347\273\215.md" "b/bsp/stm32/docs/STM32\347\263\273\345\210\227\351\251\261\345\212\250\344\273\213\347\273\215.md" index 3fd19df57d07eb31e0cb8e92ad210e244ca1b23b..44e69cdf46eb139d468e5b81dd968647d7abde5d 100644 --- "a/bsp/stm32/docs/STM32\347\263\273\345\210\227\351\251\261\345\212\250\344\273\213\347\273\215.md" +++ "b/bsp/stm32/docs/STM32\347\263\273\345\210\227\351\251\261\345\212\250\344\273\213\347\273\215.md" @@ -60,6 +60,4 @@ ### 2.4 驱动示例代码 -// TODO 添加驱动示例代码相关的介绍,考虑如何使用这些驱动示例代码,如果暂时没有,这一小结可以先删去 - 在 RT-Thread 的 `examples\test` 目录下,有 RT-Thread 提供的基于不同外设驱动的示例代码。在 env 工具中开启 BSP 中要测试的驱动,并将 `examples\test` 中对应的驱动框架测试文件加入工程,即可快速测试 BSP 中提供的驱动。 \ No newline at end of file diff --git a/bsp/stm32/docs/figures/Peripheral.png b/bsp/stm32/docs/figures/Peripheral.png index 1185515990aae4514894d024922056e6efad4a79..759fe3e8a9896ebf2f08161cf48085f3144ffabc 100644 Binary files a/bsp/stm32/docs/figures/Peripheral.png and b/bsp/stm32/docs/figures/Peripheral.png differ diff --git a/bsp/stm32/docs/figures/link_icf.png b/bsp/stm32/docs/figures/link_icf.png new file mode 100644 index 0000000000000000000000000000000000000000..bd5c982e1fc4df41b47030aec3804abbde5e9f9f Binary files /dev/null and b/bsp/stm32/docs/figures/link_icf.png differ diff --git a/bsp/stm32/docs/figures/link_lds.png b/bsp/stm32/docs/figures/link_lds.png new file mode 100644 index 0000000000000000000000000000000000000000..203c67e2df7519dec9c9c6c2c83f4d567d90ac86 Binary files /dev/null and b/bsp/stm32/docs/figures/link_lds.png differ diff --git a/bsp/stm32/docs/figures/linkscripts_change.png b/bsp/stm32/docs/figures/linkscripts_change.png new file mode 100644 index 0000000000000000000000000000000000000000..522980503d56e88fb7bba103b036c3c5d6e8c134 Binary files /dev/null and b/bsp/stm32/docs/figures/linkscripts_change.png differ