cancel
Showing results for 
Search instead for 
Did you mean: 

sha256sum different for hex file generated from STM32CubeIDE and STM32CubeCLT

SBhon.1
Associate III

Hi,

I am working on automating the build process of the ST firmware and for that I was looking for CLI tools which can be used for the same. I found that STM32CubeCLT is a toolset extracted from STM32CubeIDE, so I was trying out the toolset to check if it fulfils my needs. For development purposes we use STM32CubeIDE.

To check if same hex file is generated, I built the firmware to generate the hex files using the STM32CubeIDE and STM32CubeCLT and calculated the sha2556sum hash of both the files. It turns out that both the hex files return different hash values.

Is there any specific reason for this? I checked the commands executed by both the IDE and the CLI tool and the commands are same as far as I can tell. Note that I did clean build both the times(i.e. for CLI and IDE).

Also I have noticed that there is no user manual/reference document for the STM32CubeCLT toolset except for the quick start guide. So I used the command mentioned in the quick start guide to build firmware using CLI.

 

Regards,

Sahil

1 ACCEPTED SOLUTION

Accepted Solutions
SBhon.1
Associate III

Hi all,

I found the issue why I was getting different hash value for the hex file generated from ST CLI and IDE.

When I tested initially, I had STM32CubeIDE v1.10.1 and STM32CubeCLT v1.16.0 installed on my system. Turns out these two versions had different compilers so because of that it was actually generating somewhat different hex files(STM32CubeCLT were little bit smaller in size compared to STM32CubeIDE).

Now I updated my STM32CubeIDE to latest version that is 1.16.0 and now both the methods generate same hex file and I am getting same hash value.

 

Regards,

Sahil

View solution in original post

5 REPLIES 5
Peter BENSCH
ST Employee

Well, if a single bit of the two HEX files is different, you will get a completely different SHA256. Even if, for example, the two tools create HEX files with different record lengths, which would result in an identical binary, you will inevitably have a different SHA256 value.

Instead of comparing HEX files via SHA256, you could convert the HEX to BIN and compare them binary.

Regards
/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Andrew Neil
Evangelist III

Do they both use the exact same GCC version?

Hi Peter,

I checked with the Bin file also. Same problem. It generates two different hash values.

I have also noticed that generated files have different sizes.

Built from IDE:

...
Finished building target: timer_test.elf
 
arm-none-eabi-size   timer_test.elf 
arm-none-eabi-objdump -h -S  timer_test.elf  > "timer_test.list"
arm-none-eabi-objcopy  -O ihex  timer_test.elf  "timer_test.hex"
arm-none-eabi-objcopy  -O binary  timer_test.elf  "timer_test.bin"
   text	   data	    bss	    dec	    hex	filename
  18864	     20	   1836	  20720	   50f0	timer_test.elf
Finished building: default.size.stdout
Finished building: timer_test.bin
Finished building: timer_test.hex

 Built from CLI:

...
Finished building target: timer_test.elf
 
arm-none-eabi-size  timer_test.elf 
arm-none-eabi-objdump -h -S timer_test.elf  > "timer_test.list"
arm-none-eabi-objcopy  -O ihex timer_test.elf  "timer_test.hex"
arm-none-eabi-objcopy  -O binary timer_test.elf  "timer_test.bin"
   text	   data	    bss	    dec	    hex	filename
  18856	     20	   1836	  20712	   50e8	timer_test.elf
Finished building: default.size.stdout
 
Finished building: timer_test.bin
Finished building: timer_test.hex

Any specific reasons for happening this?

I can share you a sample project if you want for reference.

Regards,

Sahil.

They're different sizes, so the hash will be different.

Open them in STM32CubeProgrammer and examine what is different. Likely it's something trivial.

You can compare the actual compiler and linker build statements used in each case to determine why this is happening.

If you feel a post has answered your question, please click "Accept as Solution".
SBhon.1
Associate III

Hi all,

I found the issue why I was getting different hash value for the hex file generated from ST CLI and IDE.

When I tested initially, I had STM32CubeIDE v1.10.1 and STM32CubeCLT v1.16.0 installed on my system. Turns out these two versions had different compilers so because of that it was actually generating somewhat different hex files(STM32CubeCLT were little bit smaller in size compared to STM32CubeIDE).

Now I updated my STM32CubeIDE to latest version that is 1.16.0 and now both the methods generate same hex file and I am getting same hash value.

 

Regards,

Sahil