RT-Thread论坛
直播中

王桂兰

8年用户 1273经验值
私信 关注
[问答]

env生成的gd32H759IM MDK5工程,出现烧写错误怎么解决?

icf文件修改了flash和ram大小

  • /*-Editor annotation file-*/
  • /* IcfEditorFile="$TOOLKIT_DIR$configideIcfEditorcortex_v1_0.xml" */
  • /*-Specials-*/
  • define symbol __ICFEDIT_intvec_start__ = 0x08000000;
  • /*-Memory Regions-*/
  • define symbol __ICFEDIT_region_ROM_start__ = 0x08000000;
  • define symbol __ICFEDIT_region_ROM_end__   = 0x083BFFFF;
  • define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
  • define symbol __ICFEDIT_region_RAM_end__   = 0x2007FFFF;
  • /*-Sizes-*/
  • define symbol __ICFEDIT_size_cstack__ = 0x2000;
  • define symbol __ICFEDIT_size_heap__   = 0x2000;
  • /**** End of ICF editor section. ###ICF###*/

  • export symbol __ICFEDIT_region_RAM_end__;

  • define symbol __region_RAM1_start__ = 0x10000000;
  • define symbol __region_RAM1_end__   = 0x1000FFFF;

  • define memory mem with size = 4G;
  • define region ROM_region   = mem:[from __ICFEDIT_region_ROM_start__   to __ICFEDIT_region_ROM_end__];
  • define region RAM_region   = mem:[from __ICFEDIT_region_RAM_start__   to __ICFEDIT_region_RAM_end__];
  • define region RAM1_region  = mem:[from __region_RAM1_start__   to __region_RAM1_end__];

  • define block CSTACK    with alignment = 8, size = __ICFEDIT_size_cstack__   { };
  • define block HEAP      with alignment = 8, size = __ICFEDIT_size_heap__     { };

  • initialize by copy { readwrite };
  • do not initialize  { section .noinit };

  • keep { section FSymTab };
  • keep { section VSymTab };
  • keep { section .rti_fn* };
  • place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };

  • place in ROM_region   { readonly };
  • place in RAM_region   { readwrite,
  •                         block CSTACK, block HEAP };
  • place in RAM1_region  { section .sram };



  • /* memory map */
  • MEMORY
  • {
  •   CODE (rx)       : ORIGIN = 0x08000000, LENGTH = 3840k
  •   DATA (xrw)      : ORIGIN = 0x24000000, LENGTH = 1M
  •   ITCMRAM(xrw)    : ORIGIN = 0x00000000, LENGTH = 512K
  •   DTCMRAM(xrw)    : ORIGIN = 0x20000000, LENGTH = 512K
  • }

  • ENTRY(Reset_Handler)
  • _system_stack_size = 0x200;

  • SECTIONS
  • {
  •     .text :
  •     {
  •         . = ALIGN(4);
  •         _stext = .;
  •         KEEP(*(.isr_vector))            /* Startup code */
  •         . = ALIGN(4);
  •         *(.text)                        /* remaining code */
  •         *(.text.*)                      /* remaining code */
  •         *(.rodata)                      /* read-only data (constants) */
  •         *(.rodata*)
  •         *(.glue_7)
  •         *(.glue_7t)
  •         *(.gnu.linkonce.t*)

  •         /* section information for finsh shell */
  •         . = ALIGN(4);
  •         __fsymtab_start = .;
  •         KEEP(*(FSymTab))
  •         __fsymtab_end = .;
  •         . = ALIGN(4);
  •         __vsymtab_start = .;
  •         KEEP(*(VSymTab))
  •         __vsymtab_end = .;
  •         . = ALIGN(4);

  •         /* section information for initial. */
  •         . = ALIGN(4);
  •         __rt_init_start = .;
  •         KEEP(*(SORT(.rti_fn*)))
  •         __rt_init_end = .;
  •         . = ALIGN(4);

  •         . = ALIGN(4);
  •         _etext = .;
  •     } > CODE = 0

  •     /* .ARM.exidx is sorted, so has to go in its own output section.  */
  •     __exidx_start = .;
  •     .ARM.exidx :
  •     {
  •         *(.ARM.exidx* .gnu.linkonce.armexidx.*)

  •         /* This is used by the startup in order to initialize the .data secion */
  •         _sidata = .;
  •     } > CODE
  •     __exidx_end = .;

  •     /* .data section which is used for initialized data */

  •     .data : AT (_sidata)
  •     {
  •         . = ALIGN(4);
  •         /* This is used by the startup in order to initialize the .data secion */
  •         _sdata = . ;

  •         *(.data)
  •         *(.data.*)
  •         *(.gnu.linkonce.d*)

  •         . = ALIGN(4);
  •         /* This is used by the startup in order to initialize the .data secion */
  •         _edata = . ;
  •     } >DATA

  •     .stack :
  •     {
  •         . = . + _system_stack_size;
  •         . = ALIGN(4);
  •         _estack = .;
  •     } >DATA

  •     __bss_start = .;
  •     .bss :
  •     {
  •         . = ALIGN(4);
  •         /* This is used by the startup in order to initialize the .bss secion */
  •         _sbss = .;

  •         *(.bss)
  •         *(.bss.*)
  •         *(COMMON)

  •         . = ALIGN(4);
  •         /* This is used by the startup in order to initialize the .bss secion */
  •         _ebss = . ;

  •         *(.bss.init)
  •     } > DATA
  •     __bss_end = .;

  •     _end = .;

  •   _sitcmram = LOADADDR(.itcmram);

  •   .itcmram :
  •   {
  •     . = ALIGN(4);
  •     _sitcmram = .;       /* create a global symbol at itcmram start */
  •     *(.itcmram)
  •     *(.itcmram*)

  •     . = ALIGN(4);
  •     _eitcmram = .;       /* create a global symbol at itcmram end */
  •   } >ITCMRAM AT> CODE

  •   _sdtcmram = LOADADDR(.dtcmram);

  •   .dtcmram :
  •   {
  •     . = ALIGN(4);
  •     _sdtcmram = .;       /* create a global symbol at dtcmram start */
  •     *(.dtcmram)
  •     *(.dtcmram*)

  •     . = ALIGN(4);
  •     _edtcmram = .;       /* create a global symbol at dtcmram end */
  •   } >DTCMRAM AT> CODE

  •     /* Stabs debugging sections.  */
  •     .stab          0 : { *(.stab) }
  •     .stabstr       0 : { *(.stabstr) }
  •     .stab.excl     0 : { *(.stab.excl) }
  •     .stab.exclstr  0 : { *(.stab.exclstr) }
  •     .stab.index    0 : { *(.stab.index) }
  •     .stab.indexstr 0 : { *(.stab.indexstr) }
  •     .comment       0 : { *(.comment) }
  •     /* DWARF debug sections.
  •      * Symbols in the DWARF debugging sections are relative to the beginning
  •      * of the section so we begin them at 0.  */
  •     /* DWARF 1 */
  •     .debug          0 : { *(.debug) }
  •     .line           0 : { *(.line) }
  •     /* GNU DWARF 1 extensions */
  •     .debug_srcinfo  0 : { *(.debug_srcinfo) }
  •     .debug_sfnames  0 : { *(.debug_sfnames) }
  •     /* DWARF 1.1 and DWARF 2 */
  •     .debug_aranges  0 : { *(.debug_aranges) }
  •     .debug_pubnames 0 : { *(.debug_pubnames) }
  •     /* DWARF 2 */
  •     .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
  •     .debug_abbrev   0 : { *(.debug_abbrev) }
  •     .debug_line     0 : { *(.debug_line) }
  •     .debug_frame    0 : { *(.debug_frame) }
  •     .debug_str      0 : { *(.debug_str) }
  •     .debug_loc      0 : { *(.debug_loc) }
  •     .debug_macinfo  0 : { *(.debug_macinfo) }
  •     /* SGI/MIPS DWARF 2 extensions */
  •     .debug_weaknames 0 : { *(.debug_weaknames) }
  •     .debug_funcnames 0 : { *(.debug_funcnames) }
  •     .debug_typenames 0 : { *(.debug_typenames) }
  •     .debug_varnames  0 : { *(.debug_varnames) }
  • }

  • /* input sections */
  • GROUP(libgcc.a libc.a libm.a libnosys.a)



我这边使用rtthread env 生成的gd32H759IM MDK5工程,出现GD32H7 的烧写算法(Flash Algorithm),导致部分地址空间无法被擦除或编程,但是用gd32官方裸机例程烧写是正常运行的,这个时候要考虑什么问题


回帖(1)

dplion5

2025-9-17 17:45:16

针对GD32H759IM在MDK5工程中的烧写错误问题,结合您提供的icf文件(实际MDK应使用.sct分散加载文件),以下是系统性的解决方案:


核心问题分析




  1. Flash/RAM配置不匹配



    • 您的icf文件设置:

      • Flash: 0x08000000 - 0x083BFFFF(3840KB)

      • RAM: 0x20000000 - 0x2007FFFF(512KB)


    • GD32H759IM实际规格:

      • Flash:3072KB(0x300000) → 结束地址应为 0x082FFFFF

      • RAM:512KB(正确)


    • 问题:Flash结束地址超出物理范围(0x083BFFFF > 0x082FFFFF)




  2. 工具链混淆



    • .icf是IAR的链接脚本,MDK需修改.sct文件或Target配置






解决方案(MDK5环境)


步骤1:修正Target内存配置



  1. 打开 Options for TargetTarget 选项卡

  2. 修改以下参数:

    • IROM1(Flash):

      • Start: 0x08000000

      • Size: 0x300000(3072KB)


    • IRAM1(RAM):

      • Start: 0x20000000

      • Size: 0x80000(512KB)
        MDK Target配置示意图




步骤2:更新分散加载文件(.sct)



  1. 检查工程中的 .sct 文件(通常在Objects文件夹)

  2. 修改为GD32H759IM官方定义:
    LR_ROM1 0x08000000 0x00300000 { ; 3072KB Flash
    ER_ROM1 0x08000000 0x00300000 { *.o (RESET, +First) }
    RW_RAM1 0x20000000 0x00080000 { ; 512KB RAM
       *.o (RAM)
    }
    }


步骤3:配置Flash烧录算法



  1. 打开 Options for TargetUtilitiesSettings

  2. Flash Download 标签页:

    • 确保选择 GD32H7xx FMC Flash 3MB

    • 检查编程地址范围:0x08000000 - 0x082FFFFF
      Flash算法配置



步骤4:检查硬件连接



  1. 确认调试器(J-Link/ST-Link/DAP-Link)接线正确:

    • SWDIOSWCLKGND3.3V 连接可靠

    • 避免长线(建议<15cm)


  2. 测量板级电压:

    • 核心电压:1.2V ±5%

    • VDD:3.3V ±10%



步骤5:工程全局清理



  1. 执行菜单操作:

    • ProjectClean Targets

    • ProjectRebuild All





关键点解释



  • 结束地址计算
    实际结束地址 = 起始地址 + 大小 - 1
              = 0x08000000 + 0x300000 - 1
              = 0x082FFFFF  // 正确范围

  • 为何0x083BFFFF错误
    0x083BFFFF - 0x08000000 = 0x3C0000 (3,932,160B = 3840KB) 
    > 芯片实际3072KB



⚠️ 注意:若工程中有自定义.icf文件(来自IAR),需移除并改用MDK的.sct配置。GD32H7系列需使用最新PACK包(官网下载)。



完成以上步骤后重新烧录,问题应已解决。如果仍有错误,请提供具体的错误提示信息进一步分析。

举报

更多回帖

发帖
×
20
完善资料,
赚取积分