cancel
Showing results for 
Search instead for 
Did you mean: 

Generated binary file size in STM32L4

AP_040
Senior

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.

65 REPLIES 65
AP_040
Senior

@Community member​  Is there any resource where I can find all those symbol list which we will use in startup file like"_limit_flash"?

The linker generates a .MAP file, I'd expect it to appear in there.

I generated it as a means to demonstrate how one uses linker scripts, the file itself reflects the use of several similar concepts in defining and placing the statics which are copied into RAM by the startup code. I'm not using GNU/GCC on a daily basis, but I can usually get things to work with a little trial and error and reviewing available documentation.

Most of this stuff should come from an understanding of Compilers, Assemblers, Linker and Loaders..

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
AP_040
Senior

I am not too much expertise in all these concept but I will try my best to understand it.

Yes, it is available in .map file but it will generate once the compilation done.

So, before all that we have to know the symbols which will useful to add in the startup(.s) and linker(.ld) file. Where it is present? Is it in the GCC-IDE(Atollic TrueStudio) installation files?

AP_040
Senior

@Community member​  Here one problem is found. When my binary size is greater then 65KB it will not give me the proper size. In every case, when I am checking the binary size and read, it is giving me the first two byte is 0x0802 every time and last two bytes is size.

Attached snapshot of example, my binary size is 119468 bytes(0x1D2AC). When I am read from ST-LINK it is showing 0x0802D2AC.

Why it is added 0x0802 in every binary? Can you please provide me the solution for this?

AP_040
Senior

Can someone have an idea about this?

AP_040
Senior

@Community member​  Can you provide the feedback on this? We specify the "_limit_flash" as ".word" in startup file. So, Why it is store the 0x0802 (two bytes) every time in flash instead of storing the 4 bytes length of binary?

It is storing the end address, or limit, of the firmware image, for the length you'll clearly need to deference it from the base address of the image.

You can probably use existing symbols to do the math, the base of the vector table for instance.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
AP_040
Senior

@Community member​ I tried it with de referencing it. But not got the success. Please help me to do this. How it is end address storing? 0x0802 is not an address of any location.

All your other vector addresses are in the 0x08020000+ range, it is within the FLASH memory region.

/* 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_size = _limit_flash - g_pfnVectors; /* compute length based on beginning and ending points */

 } >FLASH

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
AP_040
Senior

@Community member​  As per your given above solution, I added "_flash_size = _limit_flash - g_pfnVectors;" this specific line into linker file but still it is not working. Is it require to configure some other things which I have missed? What should require to do here?