2019-06-12 04:11 AM
Is there any specific address location in generated binary file so we can know the size of that binary file?
Using this, in the firmware to read the size of binary file from that location and use it in our application.
Solved! Go to Solution.
2019-07-03 09:08 PM
If that doesn't work try
.word _limit_flash - g_pfnVectors /* compute size */
2019-06-12 04:36 AM
One typically has linker symbols, and you can refer to them within the code. For fixed location stuff people typically refer to the symbol via an empty/unused vector in the vector table at the front of the image.
2019-06-12 04:37 AM
@Community member
Yes, can you give example for this?
2019-06-12 04:43 AM
Not from my phone.
These aren't complicated concepts.
In the GNU tools the symbols are often defined in the linker script, see .LD and .MAP files. In Keil there are $$Limit$$ type symbols.
2019-06-12 04:54 AM
@Community member
If some constant value needs to be defined it will be okay but how can I store the binary size? How to calculate the size of .bin file?
Please provide some example to do it?
Which symbol is for Atollic TrueStudio?
2019-06-12 05:14 AM
I accept PayPal and Amazon Gift cards
https://community.st.com/s/question/0D70X000006Srs3SAC/end-of-program
extern uint32_t Load$$LR$$LR_IROM1$$Limit;
printf("Limit %08X\n", (uint32_t)&Load$$LR$$LR_IROM1$$Limit);
extern uint32_t Load$$LR$$LR_IROM1$$Length;
printf("Length %08X\n", (uint32_t)&Load$$LR$$LR_IROM1$$Length);
; In your starup.s file, could be placed at known offset in vector table
IMPORT ||Load$$LR$$LR_IROM1$$Length||
DCD ||Load$$LR$$LR_IROM1$$Length||
In GNU define a variable marking the end of text+code sections
Equivalent to
_etext = .; /* define a global symbols at end of code */
but including the initialization by placing beyond that.
2019-06-12 05:24 AM
2019-06-12 05:25 AM
2019-06-12 06:15 AM
Yeah, because that's for Keil, something like this? Perhaps review how your tools function
startup.s
...
g_pfnVectors:
.word _estack
.word Reset_Handler
.word NMI_Handler
.word HardFault_Handler
.word MemManage_Handler
.word BusFault_Handler
.word UsageFault_Handler
.word _limit_flash /* symbol you define in .ld linker script */
.word 0
.word 0
.word 0
.word SVC_Handler
.word DebugMon_Handler
.word 0
...
script.ld
...
/* User_heap_stack section, used to check that there is enough RAM left */
._user_heap_stack :
{
. = ALIGN(4);
PROVIDE ( end = . );
PROVIDE ( _end = . );
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(4);
} >RAM
/* End section */
. = ALIGN(4);
.endof :
{
/* This is used by the startup in order to find the end */
_limit_flash = .; /* define a global symbol at the end of flash */
} >FLASH
/* Remove information from the standard libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
...
2019-06-12 08:14 PM
Thanks, @Community member
Now, I am able to get the size of binary from the specific location. But when we load binary into the MCU, it is not working.
So, I put the ".word _limit_flash" at last in the startup file then location of the size is changed and load .bin file into the MCU, it is working.