AT32F403A 移植之IAR icf的优化配置

  之前项目是使用STM32MCU的,现在受到了限制后,逐步采用国产芯片来替代,再开发过程中,掉了不少的坑。其中之一的情况是国产MCU的flash执行速度不一致。

替换的芯片是AT32F403A,此芯片的FLASH 是1024KB,其前256KB的执行效率比后面的768KB的执行速度高很多。这样的话 有必要把实时性要求较高的代码编译到前256KB,把实时性要求低的代码排在后面。IDE是IAR.

这里研究出了两种方法

方法1 :

   把1024KB 分为前256KB和后面的768KB,hw.o编译存放在前面的256KB, 但是其他代码只好存在768KB的分区,能够满足分区的需求,但是无法充分利用前256的空间提高效率。

/*###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__   = 0x0803FFFF;
define symbol __ICFEDIT_region_BROM_start__ = 0x08040000;
define symbol __ICFEDIT_region_BROM_end__   = 0x080FFFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__   = 0x20017FFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0x8000;
define symbol __ICFEDIT_size_heap__   = 0x8000;
/**** 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 BROM_region   = mem:[from __ICFEDIT_region_BROM_start__   to __ICFEDIT_region_BROM_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__     { };
define block FAST	   {readonly code object hw.a};

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

place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };

place in ROM_region   { block FAST};
place in BROM_region  { readonly};
place in RAM_region   { readwrite,
                        block CSTACK, block HEAP };

方法2 :

   把1024KB划分成一块,再把需要优先的代码,挪到前面的256KB区域,指定的hw.o会自动编译到前面的区域,同时其他代码会尽量往前靠,能够尽量提高效率

 

/*###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__   = 0x20017FFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0x8000;
define symbol __ICFEDIT_size_heap__   = 0x8000;
/**** 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__];

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 in RAM_region   { readwrite,
                        block CSTACK, block HEAP };
						
/* USER CMD CODE area */
define symbol __ICFEDIT_region_USER_start__    = 0x08000000;
define symbol __ICFEDIT_region_USER_end__      = 0x0803FFFF;

define region USER_CMD_CODE_region   = mem:[from __ICFEDIT_region_USER_start__   to __ICFEDIT_region_USER_end__];

place in USER_CMD_CODE_region   { ro object hw.o}; 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值