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

>> Is it require to configure some other things which I have missed?

Are you using the _flash_size symbol?

.endof          0x080086fc        0x0
                0x080086fc                _limit_flash = .
                0x000086fc                _flash_size = (_limit_flash - g_pfnVectors)
...
  .word	UsageFault_Handler
  .word	_flash_size /* symbol you define in .ld linker script */
  .word	0
  .word	0
...
 

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

0690X000009YO8cQAG.png@Community member​ Yes, I have already used _flash_size symbol in the startup file.

.word I2C4_EV_IRQHandler

.word I2C4_ER_IRQHandler

.word _limit_flash /* symbol you define in .ld linker script */

.word  _flash_size /* symbol you define in .ld linker script */

In the linker file, symbol is used as per your suggestion. But not working.

If that doesn't work try

  .word  _limit_flash - g_pfnVectors /* compute size */

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

Yes, Finally it is working. Thanks for such an amazing support.

0690X000009YO8hQAG.png

YHass.14
Senior

Hello,

@Community member​: If you use the Flash size for calculating and checking Flash CRC: can you please advise how to do it?

Thanks in advance.

Yacob Hassidim.

Expand to end answers on this thread.

https://community.st.com/s/question/0D50X00009Xkhp1SAB/flash-crc-integrity

But basically uses C 101 File-IO functions like fopen,fread, etc to read and navigate the binary data. If you have the size recorded at a fixed location in the image you could use that, but would swear objcopy can just output .BIN or .HEX, the former being size appropriately for the data contained in the .ELF

I've got tools that can work with .HEX or .ELF directly, but I'd really like to get paid for that amount of effort.

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

Hi @Community member​  I am not using the flash size to calculate the checking Flash CRC. In fact, I am using for the firmware update purpose but if you want to use it for the flash CRC calculation, you can do it.

Instead of CRC, I am using my MD5 tool to append the whole binary checksum at the end of the binary. It is used at when we build the firmware so no need to do it extra effort after the binary is generated.

For what purpose you would like to use CRC?

Hello @Community member​,

Thank you for your reply.

How can I use objcopy to calculate CRC and save it in a known address?

Sincerely,

Yacob Hassidim.

Hello @Community member​,

Thank you for your reply.

I want to use CRC because my controller (STM32F439BGT6) has CRC hardware unit (32 bit).

I want to use the CRC unit to check the CRC of the image in run time.

IELFTOOL (of IAR) has an option to calculate CRC of a range (or multiple ranges) and save the CRC in a saved address.

The whole process that I plan is as following:

A) Saving the following addresses by linker:

  1. Size of the code and data (read only)
  2. Place holder for CRC

B) Build the image by CubeIDE (compile and link)

C) Post build by IELFTOOL (or other tool) to calculate the CRC and save it in the saved address by the linker

D) Using the CRC unit In run time and check the CRC.

Can you please advise me how do you append the CRC at the end of the binary (including to save the size of the code/data)?

May be I can use it for my purpose.

Sincerely,

Yacob Hassidim.

Hi @Community member​ I already mentioned that to append the whole binary MD5 hash checksum (instead of CRC) at last, I am using list of commands in a makefile to do it. MD5 hash check sum is more accurate because it is using 16bytes checksum.