force structure to address in IAR

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

force structure to address in IAR

1,970件の閲覧回数
ryanlush
Contributor IV

I have a C structure I am trying to force to a specific address like so

#pragma location = ".app_info"
__root struct
{
    uint32_t major;
    uint32_t minor;
    uint32_t eeprom_init;
    uint32_t reserved;
}const version = {MAJOR_REVISION, MINOR_REVISION, (uint32_t)EEPROM_Init, 0x00000000};

And here is my linker script

/*###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__ = 0x00006000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00006000 ;
define symbol __ICFEDIT_region_ROM_end__   = 0x000FFFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x1FFF0000;
define symbol __ICFEDIT_region_RAM_end__   = 0x2002FFF0;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0;
define symbol __ICFEDIT_size_heap__   = 0;
/**** End of ICF editor section. ###ICF###*/

define symbol app_info_start           = 0x00006020;
define symbol app_info_end               = 0x0000602F;

define exported symbol __INTERNAL_FLASH_BASE    = 0x00000000;
define exported symbol __INTERNAL_FLASH_SIZE    = 0x00100000;
define exported symbol __INTERNAL_SRAM_BASE     = 0x1FFF0000;
define exported symbol __INTERNAL_SRAM_SIZE     = 0x00040000;
define exported symbol __SRAM_POOL              = 0x1FFF0000;

define exported symbol __INTERNAL_FLEXNVM_BASE = 0;
define exported symbol __INTERNAL_FLEXNVM_SIZE = 0;

define exported symbol __VECTOR_TABLE_ROM_START = 0x00000000;
define exported symbol __VECTOR_TABLE_RAM_START = __ICFEDIT_region_RAM_start__;

define exported symbol __DEFAULT_PROCESSOR_NUMBER = 1;
define exported symbol __DEFAULT_INTERRUPT_STACK_SIZE = 1024;

/* mem_init writes a storeblock_struct at the end of kernel data, max size 32 bytes, so use 0x100 offset */
define exported symbol __BOOT_STACK_ADDRESS = __ICFEDIT_region_RAM_end__ - 0x100;


define exported symbol __KERNEL_DATA_END = __ICFEDIT_region_RAM_end__;

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 KERNEL_DATA with alignment = 8 { section .kernel_data };

define exported symbol __FLASHX_SECT_SIZE = 0x1000;
define exported symbol __FLASHX_END_ADDR = __INTERNAL_FLASH_BASE + __INTERNAL_FLASH_SIZE;

define block CFMPROTROM with size = 20 { section .cfmconfig };
define block FLASHX_POOL with alignment = __FLASHX_SECT_SIZE { section .flashx };
define block TEXTSECTION with alignment = 4 { section .text };
keep { section .cfmconfig };
keep { section .flashx };

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

place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec, block CFMPROTROM };
place in ROM_region { first block TEXTSECTION, readonly,  last block FLASHX_POOL };

place at address mem:__ICFEDIT_region_RAM_start__ { readwrite section .vectors_ram };

/* each block/segment must be in one line (association to region) because I need kernel data start after other datas */
place in RAM_region   { readwrite, last block KERNEL_DATA };

place at address mem: app_info_start     { section .app_info };

but when I compile I get an error from the linker

Error[Lp011]: section placement failed
            unable to complete "place at" directives with a total estimated minimum size of 0x424 bytes in  
<[0x00006000-0x0000601f], [0x00006020-0x000fffff]> (total space 0xfa000).
            Needed:
            [0x00006000-0x0000601f]: 0x414 min, align 0x4 (size:    0x20)
            [0x00006020-0x000fffff]:  0x10 min, align 0x4 (size: 0xf9fe0)
Error[Lp015]: section placement failure: overcommitted content in [0x00006000-0x0000601f]

Can anyone tell me what I'm doing wrong? This has worked for me in the past.

0 件の賞賛
返信
2 返答(返信)

1,564件の閲覧回数
dereksnell
NXP Employee
NXP Employee

Hi Ryan,

I haven't looked through the details you've shared.  But when I want to put data at a specific location in flash, I use the interrupt vector table as an example.  Every project has a vector table, and you can use it as a reference to see how to setup the linker file, and syntax needed in the source code to force your data where you want it.

Best regards

0 件の賞賛
返信

1,564件の閲覧回数
ryanlush
Contributor IV

As far as I can tell, that's what I'm doing.

0 件の賞賛
返信