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

Hello @Community member​ 

Thank you for your answer.

Can you please send your makefile, linker file (*.ld) and the code that checks the MD5?

I appreciate your help.

Yacob Hassidim.

@Community member​ 

"http://www.fourmilab.ch/md5/"

from the above link you can download the md5.zip and in that you can found the md5.exe.

So, in a makefile after generating the .bin, you have to set the two command below to calculate and append the checksum at the end of binary file.

$(BUILD_DIR)/$(TARGET).bin: $(BUILD_DIR)/$(TARGET).elf

   $(info Generating binary ...)

   $(CP) -S -O binary $< $@

$(info Generating MD5 ...)

   $(APP_BASE)/Source/md5.exe -opreamble_with_md5.bin $(TARGET).bin

cat $(TARGET).bin preamble_with_md5.bin >> $(TARGET)_md5.bin

Check the $(TARGET)_md5.bin file and its included with md5 hash checksum at the end.

Hello @Community member​ 

Thank you for your fast response.

Do you check the MD5 of the image in run time?

If so, can you please send the code that points to the following addresses:

a) start of the bin file

b) end of the bin file

c) size of the bin file

e) MD5 value

Sincerely,

Yacob Hassidim.

Hi @Community member​ 

Yes, I am also checking the md5 at run time.

Are you able to append the 16bytes of checksum? Please confirm it.

As per the size concern, you have to add symbol in .s and .ld file. Your bin size is available at 0x08000194.

At start of your code, read that size and by using that size read the binary from the flash upto that size and calculate md5 of that data.

To calculate md5 you have to add md5.c and md5.h files into your project which is available in downloaded md5.zip. Read 16-16 bytes of data from the flash to calculate md5. After calculating just compare it to saved md5 which is available at last of binary.

If you still have any doubt, tell me.

Hello @Community member​ 

Thank you for your explanation.

I didn't try to append yet and will try later.

I tried to use CubeIDE to create .bin file and it created a huge file (size of 3 Gbytes!). The size of elf file is about 4.3 Mbytes.

What is the tool you used to create .bin file? (I am running under Windows)

By the way 'cat' is Linux command and I am working under Windows, so I should use 'echo', 'type' or 'copy' commands instead of 'cat'.

Regarding with start address of the Flash: is it 0x0800,0000?

Regarding with 'saved MD5 at last of binary', is the start address of it: (0x0800,0000 + (content of 0x0800,0194)) ?

Sincerely,

Yacob Hassidim.

@Community member​ 

What is the tool you used to create .bin file?

Atollic Truestudio

Use mysys to build your project so "cat" command will work "https://www.msys2.org/".

is it 0x0800,0000? Yes

is the start address of it: (0x0800,0000 + (content of 0x0800,0194)) ?

Yes, You can check your binary with Hex Editor to get the better idea.

Hello @Community member​ 

Thanks again.

Regarding the .bin file:

I also use Atollic Truestudion (this is integrated into CubeIDE).

Is it normal that size of *.bin file is about 3 Gbytes?

Sincerely,

Yacob Hassidim.

@Community member​ 

Is it normal that size of *.bin file is about 3 Gbytes?

It is abnormal for me that how the .bin size is 3GB? It is in terms of KB. Which project you tried to build? Is it example project from the STM32F4 package?

Hello @Community member​ 

This is my project that I started in IAR and converted to CubeIDE (Atollic).

Do you have any idea what can be the problem?

@Community member​ 

I suggest to try with one of the example form STM32F4 package like UART,Flash,I2C,ADC etc... and try to build it. The generated binary size should be in KB. If still problem arise, I don't know why this is happening because which way you are converting your IAR project to CubeIDE in that may be something is missing.

Instead of IAR project try to convert Truestudio or SW4STM32 project into CubeIDE, I think it will work. You still not answered that which project you are working? Is it from example or it is your original application?

If you do not want to waste time to convert the project, it is better to install and work in Truestudio or SW4STM32.