为了能运行使用外部的RAM(SMARTARM2200提供的是8M BYTE的PSRAM),就需要修改linker文件,相当于ADS中的分散加载文件.
以LPC2220_flash.icf为模板,创建一个LPC2220_XRAM.icf进行修改:
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$/config/ide/IcfEditor/a_v1_0.xml" */
/*-Specials-*/
/*中断向量起始位置,0x80000000就是flash的0地址*/
define symbol __ICFEDIT_intvec_start__ = 0x80000000;
/*-Memory Regions-*/
/*flash地址范围,2MB*/
define symbol __ICFEDIT_region_ROM_start__ = 0x80000044;
define symbol __ICFEDIT_region_ROM_end__ = 0x80200000;
/*内部RAM地址范围,64KB*/
define symbol __ICFEDIT_region_RAM_start__ = 0x40000040;
define symbol __ICFEDIT_region_RAM_end__ = 0x40007FDF;
/*外部RAM地址范围,8MB*/
define symbol __ICFEDIT_region_XRAM_start__ = 0x81000000;
define symbol __ICFEDIT_region_XRAM_end__ = 0x817FFFFF;
/*-Sizes-*/
/*异常堆栈及堆大小*/
define symbol __ICFEDIT_size_cstack__ = 0x100;
define symbol __ICFEDIT_size_svcstack__ = 0x40;
define symbol __ICFEDIT_size_irqstack__ = 0x100;
define symbol __ICFEDIT_size_fiqstack__ = 0x100;
define symbol __ICFEDIT_size_undstack__ = 0x40;
define symbol __ICFEDIT_size_abtstack__ = 0x40;
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__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
/*添加XRAM_region定义*/
define region XRAM_region = mem:[from __ICFEDIT_region_XRAM_start__ to __ICFEDIT_region_XRAM_end__];
define symbol __region_USB_DMA_RAM_start__= 0x7FD00000;
define symbol __region_USB_DMA_RAM_end__ = 0x7FD01FFF;
define region USB_DMA_RAM_region= mem:[from __region_USB_DMA_RAM_start__ to __region_USB_DMA_RAM_end__];
/*实际定义堆栈堆*/
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block SVC_STACK with alignment = 8, size = __ICFEDIT_size_svcstack__ { };
define block IRQ_STACK with alignment = 8, size = __ICFEDIT_size_irqstack__ { };
define block FIQ_STACK with alignment = 8, size = __ICFEDIT_size_fiqstack__ { };
define block UND_STACK with alignment = 8, size = __ICFEDIT_size_undstack__ { };
define block ABT_STACK with alignment = 8, size = __ICFEDIT_size_abtstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite }; /*复制readwrite段到RAM中*/
do not initialize { section .noinit };
do not initialize { section DMA_RAM };
/*代码数据存放位置*/
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly }; /*.rodata and .data_init */
place in RAM_region {block CSTACK, block SVC_STACK, block IRQ_STACK, block FIQ_STACK, block UND_STACK, block ABT_STACK };
/*把readwrite段(.data,.bss,.noinit)和堆定义到外部RAM*/
place in XRAM_region {readwrite, block HEAP };
place in USB_DMA_RAM_region
{ section DMA_RAM };
最后一步就是设置工程属性:
更加详细内容请参考EWARM_DevelopmentGuide.ENU.pdf中的Linking using ILINK和Linking your application两章.