本帖最后由 袁胜富 于 2026-5-8 23:27 编辑
一、概述
图1
G32R430 支持从不同的存储区启动,用户通过配置 Option Bytes 的 BOOTADDR[15:0]位段进行
选择。
若从 BootLoader 启动,用户可使用串口接口重新编程用户 Flash。在嵌入式 BootLoader 模式
下,用户可以选择通过以下任意一组串行接口重新编程 Flash:
⚫ USART1(默认接口)(PB6/PB9)
⚫ USART2(PD5/PD9)
由图1知道,G32R430的启动地址需要对BOOTADDR[15:0]位进行配置,配置0x4000从flash 0x8000000开始启动;配置0x0080从系统的存储器启动,在此配置下可以使用官方的工具GeehyProg_SetUp_V1.0.6_Chinese通过USART1或USART2进行串口在线升级程序。
图2
由图2可知配置0x4000需要配置BOOTADDR[7:0]:0x00,nBOOTADDR[7:0]:0xFF;BOOT_ADDR[15:8]:0x40,nBOOT_ADDR[15:8]:0xBF;
由图2可知配置0x0080需要配置BOOTADDR[7:0]:0x80,nBOOTADDR[7:0]:0x7F;BOOT_ADDR[15:8]:0x00,nBOOT_ADDR[15:8]:0xFF;
二、代码
- //
- // G32R430 Option Bytes Configuration
- //
- // Address range: 0x1FFF0000 ~ 0x1FFF000B
- // Each field is 1 byte (8 bits).
- //
- // Below example sets:
- // - RDP to Level0: 0xAA (nRDP: 0x55)
- // - USER to 0x03 => SW IWDG = 1, SW WWDG = 1, WLOCK enable = 0
- // (nUSER = 0xFC)
- // - WLOCK = 0xFF => disable all write protections
- // (nWLOCK = 0x00)
- // - BOOTADDR = 0x4000 (boot from 0x08000000, for demonstration)
- // (nBOOTADDR = 0xBFFF)
- // - You can adjust these settings based on your application needs.
- //
- .section .ARM.__at_0x1FFF0000
- /* 0x0000: RDP, nRDP */
- .byte 0xAA /* RDP: 0xAA => Level0 (no protection) */
- .byte 0x55 /* nRDP: 0x55 => complement of RDP */
- /* 0x0002: USER, nUSER */
- .byte 0x03 /* USER: [2]=0 => WLOCK Disable,
- [1]=1 => SW WWDG ,
- [0]=1 => SW IWDG */
- .byte 0xFC /* nUSER: complement of 0x07 */
- /* 0x0004: WLOCK, nWLOCK */
- .byte 0xFF /* WLOCK: 0xFF => all sectors unprotected (bit=1 => write protection OFF) */
- .byte 0x00 /* nWLOCK: complement of 0xFF */
- /* 0x0006: Reserved */
- .byte 0x00
- .byte 0xFF
- /*4000 */
- /* 0x0008: BOOTADDR[7:0], nBOOTADDR[7:0] */
- .byte 0x00 /* BOOTADDR[7:0] */
- .byte 0xFF /* nBOOTADDR[7:0] */
- /* 0x000A: BOOTADDR[15:8], nBOOTADDR[15:8] */
- .byte 0x40 /* BOOTADDR[15:8] */
- .byte 0xBF /* nBOOTADDR[15:8] */
- /* End of file */
三、测试
修改g32r430_opt.s下载程序
打开GeehyProg_SetUp_V1.0.6_Chinese
连接成功
$K\ARM\ARMCLANG\bin\fromelf.exe --bin --output ./Output/@L.bin !L或$K\ARM\ARMCLANG\bin\fromelf.exe --bin --output @L.bin !L生成bin文件
|