硬汉嵌入式论坛

 找回密码
 立即注册
查看: 437|回复: 2
收起左侧

[IAR] IAR编译器的.ICF文件,如何扩展NXP的RAM

[复制链接]

8

主题

26

回帖

55

积分

初级会员

积分
55
发表于 2023-5-30 20:44:18 | 显示全部楼层 |阅读模式
IAR编译器的.ICF文件,如何扩展NXP的RAM。


        Error[Lp011]: section placement failed                       



                    unable to allocate space for sections/blocks with a total estimated minimum size of 0xf40a bytes (max align 0x4) in <[0x2000'0000-0x2000'ebff]> (total uncommitted space 0xec00).                       

如下是 .ICf文件内容

/*
** ###################################################################
**     Processor:           S32K146 with 128 KB SRAM
**     Compiler:            IAR ANSI C/C++ Compiler for ARM
**
**     Abstract:
**         Linker file for the IAR ANSI C/C++ Compiler for ARM
**
**     Copyright (c) 2015-2016 Freescale Semiconductor, Inc.
**     Copyright 2017 NXP
**     All rights reserved.
**
**     THIS SOFTWARE IS PROVIDED BY NXP "AS IS" AND ANY EXPRESSED OR
**     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
**     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
**     IN NO EVENT SHALL NXP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
**     INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
**     (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
**     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
**     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
**     STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
**     IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
**     THE POSSIBILITY OF SUCH DAMAGE.
**
**     http:                 www.nxp.com
**     mail:                 support@nxp.com
**
** ###################################################################
*/

/* If symbol __flash_vector_table__=1 is defined at link time
* the interrupt vector will not be copied to RAM.
* Warning: Using the interrupt vector from FLASH will not allow
* INT_SYS_InstallHandler because the section is Read Only.
*/
define symbol __ram_vector_table_size__ =  isdefinedsymbol(__flash_vector_table__) ? 0 : 0x00000400;
define symbol __ram_vector_table_offset__ =  isdefinedsymbol(__flash_vector_table__) ? 0 : 0x000003FF;

/* Flash */
define symbol m_interrupts_start       = 0x00008000;
define symbol m_interrupts_end         = 0x000083FF;

define symbol m_flash_config_start     = 0x00008400;
define symbol m_flash_config_end       = 0x0000840F;

define symbol m_text_start             = 0x00008410;
/* 0x00FFFFF---> 0x00083FFFu */
define symbol m_text_end               = 0x00083FFF;

/* SRAM_L */
define symbol m_interrupts_ram_start   = 0x1FFF0000;
define symbol m_interrupts_ram_end     = 0x1FFF0000 + __ram_vector_table_offset__;

define symbol m_data_start             = m_interrupts_ram_start + __ram_vector_table_size__;
define symbol m_data_end               = 0x1FFFFFFF;

/* SRAM_U */
define symbol m_data_2_start             = 0x20000000;
define symbol m_data_2_end               = 0x2000EFFF;

/* Sizes */
if (isdefinedsymbol(__stack_size__)) {
  define symbol __size_cstack__        = __stack_size__;
} else {
  define symbol __size_cstack__        = 0x00000400;
}

if (isdefinedsymbol(__heap_size__)) {
  define symbol __size_heap__          = __heap_size__;
} else {
  define symbol __size_heap__          = 0x00000400;
}

define exported symbol __VECTOR_TABLE          = m_interrupts_start;
define exported symbol __VECTOR_RAM            = isdefinedsymbol(__flash_vector_table__) ? m_interrupts_start : m_interrupts_ram_start;
define exported symbol __RAM_VECTOR_TABLE_SIZE = __ram_vector_table_size__;

define exported symbol __RAM_START             = m_interrupts_ram_start;
define exported symbol __RAM_END               = m_data_2_end;

define memory mem with size = 4G;
define region m_flash_config_region   = mem:[from m_flash_config_start to m_flash_config_end];
define region TEXT_region             = mem:[from m_interrupts_start to m_interrupts_end]
                                      | mem:[from m_text_start to m_text_end];
define region DATA_region             = mem:[from m_data_start to m_data_end];
define region DATA_region_2           = mem:[from m_data_2_start to m_data_2_end-__size_cstack__];
define region CSTACK_region           = mem:[from m_data_2_end-__size_cstack__+1 to m_data_2_end];
define region m_interrupts_ram_region = mem:[from m_interrupts_ram_start to m_interrupts_ram_end];


define block CSTACK    with alignment = 8, size = __size_cstack__   { };
define block HEAP      with alignment = 8, size = __size_heap__     { };
define block RW        { readwrite };
define block ZI        { zi };

/* Custom Section Block that can be used to place data at absolute address. */
/* Use __attribute__((section (".customSection"))) to place data here. */
define block customSectionBlock { section .customSection };

define block __CODE_ROM   { section .textrw_init };
define block __CODE_RAM   { section .textrw  };

initialize manually       { section .textrw };
initialize manually       { section .bss };
initialize manually       { section .customSection };
initialize manually       { section .data };
initialize manually       { section __DLIB_PERTHREAD };
do not initialize         { section .noinit, section .bss, section .data, section __DLIB_PERTHREAD, section .customSection };

place at address mem: m_interrupts_start    { readonly section .intvec };
place in m_flash_config_region              { section FlashConfig };
place in TEXT_region                        { readonly };
place in TEXT_region                        { block __CODE_ROM };
place in DATA_region                        { block RW };
place in DATA_region                        { block __CODE_RAM };
place in DATA_region_2                      { first block customSectionBlock };
place in DATA_region_2                      { block ZI };
place in DATA_region_2                      { last block HEAP };
place in CSTACK_region                      { block CSTACK };
place in m_interrupts_ram_region            { section m_interrupts_ram };



回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106997
QQ
发表于 2023-5-30 21:17:56 | 显示全部楼层
还有额外的RAM空间可以使用吗,如果有的话设置下即可,比如我这里扩展了个SDRAM
https://www.armbbs.cn/forum.php? ... 697&highlight=SDRAM


[C] 纯文本查看 复制代码
/*###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__       = 0x081FFFFF;
define symbol __ICFEDIT_region_RAM_start__     = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__       = 0x2001FFFF;
define symbol __ICFEDIT_region_ITCMRAM_start__ = 0x00000000;
define symbol __ICFEDIT_region_ITCMRAM_end__   = 0x0000FFFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0x1000;
define symbol __ICFEDIT_size_heap__   = 0x800;
/**** 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 region ITCMRAM_region  = mem:[from __ICFEDIT_region_ITCMRAM_start__ to __ICFEDIT_region_ITCMRAM_end__];
define region RAM_D1_region  = mem:[from 0x24000000 to 0x24080000];
define region RAM_D2_region  = mem:[from 0x30000000 to 0x30048000];
define region RAM_D3_region  = mem:[from 0x38000000 to 0x38010000];
define region SDRAM_region  = mem:[from 0xC0000000 to 0xC2000000];

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 };
place in RAM_D1_region {section .RAM_D1};
place in RAM_D2_region {section .RAM_D2};
place in RAM_D3_region {section .RAM_D3};
place in SDRAM_region {section .RAM_SDRAM};

do not initialize  { section .RAM_SDRAM };

回复

使用道具 举报

8

主题

26

回帖

55

积分

初级会员

积分
55
 楼主| 发表于 2023-5-31 09:57:24 | 显示全部楼层
eric2013 发表于 2023-5-30 21:17
还有额外的RAM空间可以使用吗,如果有的话设置下即可,比如我这里扩展了个SDRAM
https://www.armbbs.cn/fo ...

应该是我表述有问题。
我程序了定义了一块大内存。编译发现RAM不够了。
昨天晚上解决了。
define symbol m_data_start             = m_interrupts_ram_start + __ram_vector_table_size__;
define symbol m_data_end               = 0x1FFFFFFF - v_REGION2_ADD;

/* SRAM_U */
define symbol m_data_2_start           = 0x20000000 - v_REGION2_ADD;
define symbol m_data_2_end             = 0x2000EFFF;

将REGION2区域  扩大即可。
place in DATA_region_2                      { first block customSectionBlock };
这个区域存放用户自定义数据。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2024-5-13 17:32 , Processed in 0.243309 second(s), 26 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表