cancel
Showing results for 
Search instead for 
Did you mean: 

I am struggling trying to locate a library header in a specific address. Header has a limited size Error is: ld.exe: DiscoL496_07.elf section `CLIENT_HDR' will not fit in region `CLIENT_ROM' ld.exe: region `CLIENT_ROM' overflowed by 269730352 bytes

DBara.3
Associate II

The structure of the code is:

  • A library called "clientManiobra.a" to be placed in "CLIENT_ROM" memory region. Library requires to place a struct constant in the very first position in "CLIENT_ROM" memory
  • The above library to be linked with main application.

Application's memory map ("memory_map.ld"):

/* Common memory definition */
MEMORY
{
	SHARED_RAM (xrw)	: ORIGIN = 0x20000000,		LENGTH = 256
	RAM        (xrw)	: ORIGIN = 0x20000100, 		LENGTH = 320K - LENGTH(SHARED_RAM)
	BOOT_FLASH (rx)		: ORIGIN = 0x08000000,		LENGTH = 32K
	SLOT1_ROM  (rx) 	: ORIGIN = 0x08008000,   	LENGTH = 360k
	SLOT2_ROM  (rx)		: ORIGIN = 0x08062000,		LENGTH = 360k
	CLIENT_ROM (rx)		: ORIGIN = 0x080BC000,		LENGTH = 240k
	SHARED_CFG (rx)		: ORIGIN = 0x080F8000,		LENGTH = 32k
}
 
/* SHARED_RAM is memory to pass messages between firmwares. Needs to hold data while MCU is not unpowered */
SECTIONS
{
    .SHARED_RAM(NOLOAD) : {
        KEEP(*(.SHARED_RAM))
    } > SHARED_RAM
}
 
__sharedram_start__	= ORIGIN(SHARED_RAM);
__sharedram_size__	= LENGTH(SHARED_RAM);
__bootrom_start__	= ORIGIN(BOOT_FLASH);
__bootrom_size__	= LENGTH(BOOT_FLASH);
__slot1rom_start__	= ORIGIN(SLOT1_ROM);
__slot1rom_size__	= LENGTH(SLOT1_ROM);
__slot2rom_start__	= ORIGIN(SLOT2_ROM);
__slot2rom_size__	= LENGTH(SLOT2_ROM);
__clientrom_start__ = ORIGIN(CLIENT_ROM);
__clientrom_size__	= LENGTH(CLIENT_ROM);
 
/* offset to be used for locating the image header from start image address */
__fw_header_offset = 0x200;
 
/* offset to be used for locating firmware code (".text") after image header */
__fw_codestart_offset = 0x30;
 
/* bootloader configuration, stored at the last page of SHARED_CFG section */
__bootloader_cfg_addr = 0x080FF800;

Application's Flash linker scatter file:

INCLUDE memory_map.ld
 
/* Entry Point */
ENTRY(Reset_Handler)
 
/* Highest address of the user mode stack */
_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
 
_Min_Heap_Size = 0x200 ; /* required amount of heap */
_Min_Stack_Size = 0x400 ; /* required amount of stack */
 
 
/* Sections */
SECTIONS
{
  /* The Vector table into SLOT1_ROM Rom type memory */
  .isr_vector : {
    . = ALIGN(4);
    KEEP(*(.isr_vector)) 	/* Startup code */
    . = ALIGN(4);
  } > SLOT1_ROM
 
 
  /* The application image header */
  .image_hdr : ALIGN(4) {
  	FILL(0xFF)
  	
  	. = ORIGIN(SLOT1_ROM) + __fw_header_offset;
	KEEP (*(.image_hdr))
  } > SLOT1_ROM
  
 
  /* The clientManiobra library image header */
  CLIENT_HDR : ALIGN(4) {
  	FILL(0xFF)
  	
  	. = __clientrom_start__;
  	KEEP (*(CLIENT_HDR))
  } > CLIENT_ROM
 
 
   /* The Client Library program code and other data into "CLIENT_ROM" slot in flash */
  .text2 :
  {
	FILL(0xFF)
	. = __clientrom_start__ + __fw_header_offset + __fw_codestart_offset;
	. = ALIGN(4);
	
	*clientManiobra.a:* (.text .text*)           /* .text sections from Client Library (code) */
  } > CLIENT_ROM
 
 
  /* The program code and other data into "FLASH" Rom type memory */
  .text : {
  	FILL(0xFF)
  	. = ORIGIN(SLOT1_ROM) + __fw_header_offset + __fw_codestart_offset;
    . = ALIGN(4);
    		           										/* Before was: 		*(.text) 	*/
    		          										/* Before was: 		*(.text*) 	*/
 
    *(EXCLUDE_FILE (*clientManiobra.a) .text .text*)		/* .text sections (code) 		*/
 
 	*(.glue_7)
	*(.glue_7t)
    *(.eh_frame)									/* exception handling tables	*/
 
    KEEP (*(.init))
    KEEP (*(.fini))
 
    . = ALIGN(4);
    _etext = .;        /* define a global symbols at end of code */
  } > SLOT1_ROM
 
... (continues)...

Withing "clientManiobra" library code, the following code snippets are implemented:

  • Structure definition:
typedef struct __attribute__((packed)) {
	uint32_t						magicWord;
	uint16_t 						imageFormatVersion;
	uint32_t 						crc;
	uint32_t 						data_size;
	uint8_t 						imageType;	
	uint16_t						clientFamily;
	uint8_t 						clientVersion;
	f_init_TypeDef 					func_init;		          /* callbacks  */
	f_checkEndOfMsgCallback_TypeDef	func_EndOfMsgCbk;
	f_getCmdTypeDef					func_getCmd;
	f_getErrorTypeDef				func_getError;
	f_getRspTypeDef					func_getRsp;
	f_getUrcTypeDef					func_getUrc;
	f_extractElemTypeDef			func_extractElem;
	f_analyzeCmdTypeDef				func_analyzeCmd;
	f_analyzeParamTypeDef			func_analyzeParam;
	f_terminateCmdTypedef			func_terminateCmd;
	uint32_t 						reserved;	
} client_image_hdr_t;
  • In above structure definition every "func_xxxx" type is a function signature typedef. As example:
typedef void (*f_init_TypeDef)(uart_parser_context_t *p_upCtxt);
  • Code snippet creating the constant variable holding the structure content to be placed at the very beginning of "CLIENT_ROM" memory region:
/* Global variables of clientManiobra */
 
static const client_image_hdr_t client_hdr __attribute__((section("CLIENT_HDR"))) = {
		.magicWord			= CLIENT_IMAGE_MAGIC,
		.imageFormatVersion	= CLIENT_IMAGE_CURRENT_VERSION,
		.crc				= 0,				/* to be parsed in post-processing */
		.data_size			= 0x0000,	/* to be parsed in post-processing */
		.imageType			= IMAGE_TYPE_CLIENT_LIBRARY,
		.clientFamily		= CLIENT_FAMILY_ORONA_ARCA,
		.clientVersion		= CLIENT_ORONA_FW_VERSION,
		.func_init			= &libInit,
		.func_EndOfMsgCbk	= &lib_checkEndOfMsgCallback,
		.func_getCmd		= &lib_getCmd,
		.func_getError		= &lib_getError,
		.func_getRsp		= &lib_getRsp,
		.func_getUrc		= &lib_getUrc,
		.func_extractElem	= &lib_extractElem,
		.func_analyzeCmd	= &lib_analyzeCmd,
		.func_analyzeParam	= &lib_analyzeParam,
		.func_terminateCmd	= &lib_terminateCmd,
		.reserved			= 0
};

All compiles perfect but linking is raising error.

It's already 3 days reviewing where may I be mistaken but no progress. Any help/suggestion will be highly appreciated.

Pol

1 ACCEPTED SOLUTION

Accepted Solutions
MM..1
Chief III

How big is your .a file?

View solution in original post

5 REPLIES 5
DBara.3
Associate II

Sorry missed to add a snapshot in map generated file. Apparently linker is allocating every piece where it should but only weird thing is around the size of the "client_hdr" structure (equal to its position?)

MM..1
Chief III

How big is your .a file?

DBara.3
Associate II

upps, 1.303KB !! :frowning_face_with_open_mouth:

I was only focused on the header piece and didn't put attention on the overall library size...

Thanks for your feedback !!! I need to focus on the library size it is amazing big and it shoudn't...

Pol

from screen part .text 0x37b3C (222k OK) , but part .text2 is chaos...

DBara.3
Associate II

I was able to fix clientManiobra.a size, now it is 45KB

Nevertheless the error still is reproducing....

make -j8 all 
arm-none-eabi-gcc -o "Datalogger_DiscoL496_07.elf" @"objects.list"   -mcpu=cortex-m4 -T"D:\LiftEye\devices\firmwares\ST\Datalogger_DiscoL496_07\STM32L496AGIX_FLASH.ld" --specs=nosys.specs -Wl,-Map="Datalogger_DiscoL496_07.map" -Wl,--gc-sections -static -L"D:\LiftEye\devices\firmwares\ST\Datalogger_DiscoL496_07" -L"D:\LiftEye\devices\firmwares\ST\libOronaArca\Debug" --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -Wl,--start-group -lc -lm -Wl,--end-group
c:\st\stm32cubeide_1.0.1\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_2.0.0.202105311346\tools\arm-none-eabi\bin\ld.exe: Datalogger_DiscoL496_07.elf section `CLIENT_HDR' will not fit in region `CLIENT_ROM'
c:\st\stm32cubeide_1.0.1\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_2.0.0.202105311346\tools\arm-none-eabi\bin\ld.exe: region `CLIENT_ROM' overflowed by 269730352 bytes
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:84: Datalogger_DiscoL496_07.elf] Error 1
"make -j8 all" terminated with exit code 2. Build might be incomplete.
 
18:44:50 Build Failed. 3 errors, 0 warnings. (took 2s.621ms)

Having a look at generated .map file:

.SHARED_RAM
 *(.SHARED_RAM)
                0x0000000020000000                __sharedram_start__ = ORIGIN (SHARED_RAM)
                0x0000000000000100                __sharedram_size__ = LENGTH (SHARED_RAM)
                0x0000000008000000                __bootrom_start__ = ORIGIN (BOOT_FLASH)
                0x0000000000008000                __bootrom_size__ = LENGTH (BOOT_FLASH)
                0x0000000008008000                __slot1rom_start__ = ORIGIN (SLOT1_ROM)
                0x000000000005a000                __slot1rom_size__ = LENGTH (SLOT1_ROM)
                0x0000000008062000                __slot2rom_start__ = ORIGIN (SLOT2_ROM)
                0x000000000005a000                __slot2rom_size__ = LENGTH (SLOT2_ROM)
                0x00000000080bc000                __clientrom_start__ = ORIGIN (CLIENT_ROM)
                0x000000000003c000                __clientrom_size__ = LENGTH (CLIENT_ROM)
                0x0000000000000200                __fw_header_offset = 0x200
                0x0000000000000030                __fw_codestart_offset = 0x30
                0x00000000080ff800                __bootloader_cfg_addr = 0x80ff800
                0x0000000020050000                _estack = (ORIGIN (RAM) + LENGTH (RAM))
                0x0000000000000200                _Min_Heap_Size = 0x200
                0x0000000000000400                _Min_Stack_Size = 0x400
 
.isr_vector     0x0000000008008000      0x1ac
                0x0000000008008000                . = ALIGN (0x4)
 *(.isr_vector)
 .isr_vector    0x0000000008008000      0x1ac ./Core/Startup/startup_stm32l496agix.o
                0x0000000008008000                g_pfnVectors
                0x00000000080081ac                . = ALIGN (0x4)
 
.image_hdr      0x00000000080081ac       0x70
 FILL mask 0xff
                0x0000000008008200                . = (ORIGIN (SLOT1_ROM) + __fw_header_offset)
 *fill*         0x00000000080081ac       0x54 ff
 *(.image_hdr)
 .image_hdr     0x0000000008008200       0x1c ./App/Device_Core/app_device_logic.o
 
CLIENT_HDR      0x00000000080bc000  0x80bc000
 FILL mask 0xff
                0x00000000080bc000                . = __clientrom_start__
 *fill*         0x00000000080bc000  0x80bc000 ff
 *(CLIENT_HDR)
 
.text2          0x0000000010178000  0x80bc230
 FILL mask 0xff
                0x00000000080bc230                . = ((__clientrom_start__ + __fw_header_offset) + __fw_codestart_offset)
 *fill*         0x0000000010178000  0x80bc230 ff
                0x0000000018234230                . = ALIGN (0x4)
 *clientManiobra.a:*(.text .text*)
 
.text           0x0000000008008220    0x37b3c
 FILL mask 0xff
                0x0000000008008230                . = ((ORIGIN (SLOT1_ROM) + __fw_header_offset) + __fw_codestart_offset)
 *fill*         0x0000000008008220       0x10 ff
                0x0000000008008230                . = ALIGN (0x4)
 *(EXCLUDE_FILE(*clientManiobra.a) .text .text*)
 .text          0x0000000008008230       0x40 c:/st/stm32cubeide_1.0.1/stm32cubeide/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_2.0.0.202105311346/tools/bin/../lib/gcc/arm-none-eabi/9.3.1/thumb/v7e-m+fp/hard/crtbegin.o
 .text.AT_init  0x0000000008008270      0x130 ./App/Cellular/Cellular_Core/AT_Core/at_core.o
                0x0000000008008270                AT_init
 .text.AT_open  0x00000000080083a0      0x210 ./App/Cellular/Cellular_Core/AT_Core/at_core.o
                0x00000000080083a0                AT_open
 .text.AT_open_channel
                0x00000000080085b0      0x1b4 ./App/Cellular/Cellular_Core/AT_Core/at_core.o
                0x00000000080085b0                AT_open_channel
 
... etc....

In row 34, the provided size in the map file for section CLIENT_HDR is 0x80bc000 !!

Any hints will be very much appreciated.