Hi,
I'm using compiler version 6 and building M55 image for FVP SSE-300-MPS3.
I would like to get section actual size using the are arm linker auto generated variables and use it in c code.
Image$$section_name$$Length;Image$$section_name$$Base;image$$section_name$$Limit;
I'm using ARM scatter file below but can't get the correct info.
here is sample scatter file with 3 regions.
dtcm.bin 0x20000000 0x00060000 { ; Any R/W and/or zero initialised data .ANY(+RW +ZI) } ;----------------------------------------------------- ; 32 kiB of stack space within the DTCM region. See ; `dtcm.bin` for the first section. Note: by virtue of ; being part of DTCM, this region is only accessible ; from Cortex-M55. We use the last DTCM bank ;----------------------------------------------------- ARM_LIB_STACK 0x20060000 EMPTY ALIGN 8 0x00008000 {}
c main code part.
extern unsigned int Image$$ARM_LIB_STACK$$Length; extern unsigned int Image$$ARM_LIB_STACK$$Base; extern unsigned int Image$$ARM_LIB_STACK$$Limit; extern unsigned int Image$$dtcm$$Length; extern unsigned int Image$$dtcm$$Base; extern unsigned int Image$$dtcm$$Limit; extern unsigned int Image$$dtcm_ZI$$Length; extern unsigned int Image$$dtcm_ZI$$Base; extern unsigned int Image$$dtcm_ZI$$Limit; int main(int argc, char **argv) { printf("The ARM_LIB_STACK section Length 0x%x Base 0x%x Limit 0x%x \n", Image$$ARM_LIB_STACK$$Length, (unsigned int)&Image$$ARM_LIB_STACK$$Base, (unsigned int)Image$$ARM_LIB_STACK$$Limit); printf("The dtcm section Length 0x%x Base 0x%x Limit 0x%x \n", Image$$dtcm$$Length, (unsigned int)&Image$$dtcm$$Base, (unsigned int)Image$$dtcm$$Limit); printf("The dtcm_ZI section Length 0x%x Base 0x%x Limit 0x%x \n", Image$$dtcm_ZI$$Length, (unsigned int)&Image$$dtcm_ZI$$Base, (unsigned int)Image$$dtcm_ZI$$Limit); }
The map file out put indicates the following:
Execution Region ARM_LIB_STACK (Exec base: 0x20060000, Load base: 0x00003b98, Size: 0x00008000, Max: 0x00008000, ABSOLUTE)
Execution Region dtcm (Exec base: 0x20000000, Load base: 0x00003b80, Size: 0x00000014, Max: 0xffffffff, ABSOLUTE)
Execution Region dtcm_ZI (Exec base: 0x20000014, Load base: 0x00003b94, Size: 0x00008b10, Max: 0xffffffff, ABSOLUTE)
The output of the my code is as follw:
The ARM_LIB_STACK section Length 0x20068000 Base 0x20060000 Limit 0xdfdfdfcf The dtcm section Length 0x1ddd Base 0x20000000 Limit 0x0 The dtcm_ZI section Length 0x20068000 Base 0x20000014 Limit 0x0
Any idea how can I get the actual size of the regions? e.g. for dtcm_ZI size
Hello,
These symbols are passed as addresses, and show should be treated as pointers (even $$LENGTH symbols, as these are calculated as differences of addresses).
For example, changing the printf statements to print `%p` data returns expected values:
printf("The dtcm section Length 0x%p Base 0x%p Limit 0x%p \n", &Image$$dtcm$$Length, &Image$$dtcm$$Base, &Image$$dtcm$$Limit);
Outputs:
The dtcm section Length 0x00000010 Base 0x30000000 Limit 0x30000010
The code you posted doesn't match the scatter file - you can use $$ZI$$Length and similar for these:
extern unsigned int Image$$dtcm$$ZI$$Length; extern unsigned int Image$$dtcm$$ZI$$Base; extern unsigned int Image$$dtcm$$ZI$$Limit;
Hi Ronan,
Thanks for your reply, you are correct, I copied the wrong scatter file part.
this is the correct one:
;----------------------------------------------------- ; 384kiB of 512kiB DTCM is used for any other RW or ZI ; data. Note: this region is internal to the Cortex-M ; CPU. ;----------------------------------------------------- dtcm 0x20000000 { ; Any R/W and/or zero initialised data .ANY(+RW) } dtcm_ZI +0 { .ANY(+ZI) } ;----------------------------------------------------- ; 32 kiB of stack space within the DTCM region. See ; `dtcm.bin` for the first section. Note: by virtue of ; being part of DTCM, this region is only accessible ; from Cortex-M55. We use the last DTCM bank ;----------------------------------------------------- ARM_LIB_STACK 0x20060000 EMPTY ALIGN 8 0x00008000 {}
and the code with the changes for the pointers:
extern unsigned int Image$$ARM_LIB_STACK$$Length; extern unsigned int Image$$ARM_LIB_STACK$$Base; extern unsigned int Image$$ARM_LIB_STACK$$Limit; extern unsigned int Image$$dtcm$$Length; extern unsigned int Image$$dtcm$$Base; extern unsigned int Image$$dtcm$$Limit; extern unsigned int Image$$dtcm_ZI$$Length; extern unsigned int Image$$dtcm_ZI$$Base; extern unsigned int Image$$dtcm_ZI$$Limit; int main(int argc, char **argv) { printf("The ARM_LIB_STACK section Length 0x%p Base 0x%p Limit 0x%p \n", &Image$$ARM_LIB_STACK$$Length, &Image$$ARM_LIB_STACK$$Base, &Image$$ARM_LIB_STACK$$Limit); printf("The dtcm section Length 0x%p Base 0x%p Limit 0x%p \n", &Image$$dtcm$$Length, &Image$$dtcm$$Base, &Image$$dtcm$$Limit); printf("The dtcm_ZI section Length 0x%p Base 0x%p Limit 0x%p \n", &Image$$dtcm_ZI$$Length, &Image$$dtcm_ZI$$Base, &Image$$dtcm_ZI$$Limit); }
This is output for the above code:
The ARM_LIB_STACK section Length 0x00000000 Base 0x20060000 Limit 0x20060000 The dtcm section Length 0x00000c9c Base 0x20000000 Limit 0x20000c9c The dtcm_ZI section Length 0x00000000 Base 0x20000ca0 Limit 0x20000ca0
The output is good for the ARM_LIB_STACK and dtcm but not the length for the dtcm_ZI - do I miss something?
You need to use (note the extra "$$ZI"):
Image$$dtcm_ZI$$ZI$$Length Image$$dtcm_ZI$$ZI$$Base Image$$dtcm_ZI$$ZI$$Limit
Thanks Ronan - it is working.