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 08:53 PM
>> 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
...
2019-07-03 09:03 PM
@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.
2019-07-03 09:08 PM
If that doesn't work try
.word _limit_flash - g_pfnVectors /* compute size */
2019-07-03 09:17 PM
Yes, Finally it is working. Thanks for such an amazing support.
2019-08-01 07:38 AM
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.
2019-08-01 08:52 AM
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.
2019-08-01 07:47 PM
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?
2019-08-03 11:08 PM
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.
2019-08-03 11:28 PM
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:
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.
2019-08-04 09:40 PM
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.