在 IAR 中:在安装目录 IAR Systems\Embedded Workbench\arm\config\linker\ArteryTek 下找到相应 MCU型号的分散加载描述文件*.ICF,复制到 project 路径下,按下图方式启用*.icf 文件。
如果是要放在 Flash 零等待区指定地址,根据需要在零等待区分配一段 region,增加下面红色字体的部分,即可将 my_code.c 内的代码都放入该零等待区内(ZWROM_CODE_region):
- /*###ICF### Section handled by ICF editor, don't touch! ****/
- /*-Editor annotation file-*/
- /* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_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__ = 0x080FFFFF;
- /* ZMROM CODE area */
- define symbol __ICFEDIT_region_ZWROM_CODE_start__ = 0x08010000;
- define symbol __ICFEDIT_region_ZWROM_CODE_end__ = 0x0801FFFF;
- define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
- define symbol __ICFEDIT_region_RAM_end__ = 0x20017FFF;
- /*-Sizes-*/
- define symbol __ICFEDIT_size_cstack__ = 0x1000;
- define symbol __ICFEDIT_size_heap__ = 0x1000;
- /**** End of ICF editor section. ###ICF###*/
- define memory mem with size = 4G;
- /* Reserved 0x08010000 ~ 0x0801FFFF as ZWROM CODE area */
- define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to
- __ICFEDIT_region_ROM_end__];
- -mem:[from
- __ICFEDIT_region_ZWROM_CODE_start__ to __ICFEDIT_region_ZWROM_CODE_end__];
- define region ZWROM_CODE_region = -mem:[from __ICFEDIT_region_ZWROM_CODE_start__
- to __ICFEDIT_region_ZWROM_CODE_end__];
- define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to
- __ICFEDIT_region_RAM_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 };
- place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
- place in ROM_region { readonly };
- /* Place Code in ZWROM CODE */
- place in ZWROM_CODE_region {ro object my_code.o};
- place in RAM_region { readwrite,
- block CSTACK, block HEAP };
如果有多个.c 文件需要放入零等待区,place in ZWROM_CODE_region 可以如下书写:
- /* Place Code in ZWROM CODE */
- place in ZWROM_CODE_region {ro object my_code1.o, ro object my_code2.o, ro object
- my_code2.o};
如果是要放在 SRAM 指定地址,以 SRAM 扩大到 224KB 为例,根据需要在零等待区分配一段 region,增加下面红色框线内的部方式分,即可将 my_code.c 内的代码都放入该零等待区内(RAM_CODE_region)
- /*###ICF### Section handled by ICF editor, don't touch! ****/
- /*-Editor annotation file-*/
- /* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_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__ = 0x080FFFFF;
- define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
- define symbol __ICFEDIT_region_RAM_end__ = 0x20037FFF;
- define symbol __ICFEDIT_region_RAM_CODE_start__ = 0x20037000;
- define symbol __ICFEDIT_region_RAM_CODE_end__ = 0x20037FFF;
- /*-Sizes-*/
- define symbol __ICFEDIT_size_cstack__ = 0x1000;
- define symbol __ICFEDIT_size_heap__ = 0x1000;
- /**** End of ICF editor section. ###ICF###*/
- define memory mem with size = 4G;
- define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to
- __ICFEDIT_region_ROM_end__];
- /* Reserved 0x20037000 ~ 0x20037FFF as ZWROM CODE area */
- define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to
- __ICFEDIT_region_RAM_end__];
- -mem:[from
- __ICFEDIT_region_RAM_CODE_start__ to __ICFEDIT_region_RAM_CODE_end__];
- define region RAM_CODE_region = mem:[from __ICFEDIT_region_RAM_start__ to
- __ICFEDIT_region_RAM_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 };
- place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
- place in ROM_region { readonly };
- /* Place Code in RAM CODE */
- place in RAM_CODE_region {ro object my_code.o};
- place in RAM_region { readwrite,
- block CSTACK, block HEAP };
如果有多个.c 文件需要放入零等待区,place in ZWROM_CODE_region 可以如下书写:
- /* Place Code in RAM CODE */
- place in RAM_CODE_region {ro object my_code1.o, ro object my_code2.o, ro object my_code2.o};
|