This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP432E401Y: SHA256 for .bin is different than .txt executable

Part Number: MSP432E401Y
Other Parts Discussed in Thread: UNIFLASH

Hi forum!

We have an executable that is protected by calculating a SHA256.  This is done at runtime in the executable, and reported to another device that we are connected to.

Unfortunately, it appears that when I build and download to a target using Code Composer Studio (Version: 10.4.0.00006), the .bin file has a different SHA256 reported than if I download a TI-TXT (.txt) file using the MSP432 bootloader via Ethernet (BOOTP/TFTP).  Both executables work, but perhaps there is some fill value or another switch that needs to be turned on in the conversion to TI-TXT?

Here is how the build completes at present:

Building target: "cvrPIM_nortos_ccs.out"
Invoking: Arm Linker
Flags: -mv7M4 --code_state=16 --float_support=FPv4SPD16 -me --advice:power=none --define=DeviceFamily_MSP432E4 --define=__MSP432E401Y__ -g --diag_warning=225 --diag_warning=255 --diag_wrap=off --display_error_number --gen_func_subsections=on --section_sizes=on -z -m"cvrPIM_nortos_ccs.map" --heap_size=65536 --stack_size=32768 -i"C:/Users/swhitney/OneDrive - Full Spectrum Software LLC/CVR/CRV_PIM/cvrPIM_nortos_ccs/lwip/src/include/lwip/priv" -i"C:/ti/simplelink_msp432e4_sdk_4_20_00_12/source" -i"C:/ti/ccs1040/ccs/tools/compiler/ti-cgt-arm_20.2.5.LTS/lib" --define=DEBUG_WOLFSSL --diag_wrap=off --display_error_number --warn_sections --xml_link_info="cvrPIM_nortos_ccs_linkInfo.xml" --rom_model
"C:/ti/ccs1040/ccs/tools/compiler/ti-cgt-arm_20.2.5.LTS/bin/armcl" -@"ccsLinker.opt" -o "cvrPIM_nortos_ccs.out"
<Linking>
FILE: cvrPIM_nortos_ccs.out
CODE size (bytes): 324642
CONST size (bytes): 22248
DATA size (bytes): 241002

Finished building target: "cvrPIM_nortos_ccs.out"

Building secondary target: "cvrPIM_nortos_ccs.txt"
Invoking: Arm Hex Utility
"C:/ti/ccs1040/ccs/tools/compiler/ti-cgt-arm_20.2.5.LTS/bin/armhex" --diag_wrap=off --ti_txt -o "cvrPIM_nortos_ccs.txt" "cvrPIM_nortos_ccs.out"
Translating to TI-TXT format...
"cvrPIM_nortos_ccs.out" .intvecs ==> .intvecs
"cvrPIM_nortos_ccs.out" .text ==> .text
"cvrPIM_nortos_ccs.out" .const ==> .const
"cvrPIM_nortos_ccs.out" .cinit ==> .cinit
Finished building secondary target: "cvrPIM_nortos_ccs.txt"

"C:/ti/ccs1040/ccs/utils/tiobj2bin/tiobj2bin.bat" "cvrPIM_nortos_ccs.out" "cvrPIM_nortos_ccs.bin" "C:/ti/ccs1040/ccs/tools/compiler/ti-cgt-arm_20.2.5.LTS/bin/armofd.exe" "C:/ti/ccs1040/ccs/tools/compiler/ti-cgt-arm_20.2.5.LTS/bin/armhex.exe" "C:/ti/ccs1040/ccs/utils/tiobj2bin/mkhex4bin.exe"
certutil.exe -hashfile "cvrPIM_nortos_ccs.bin" SHA256
SHA256 hash of cvrPIM_nortos_ccs.bin:
a2b517c881b7c5948c9c989960f7917ce1fc35b8762def4da3786d45fe472587
CertUtil: -hashfile command completed successfully.

**** Build Finished ****

After running from Debug in Code Composer Studio, the executable outputs the calculated SHA256:

[INFO] SHA256: a2b517c881b7c5948c9c989960f7917ce1fc35b8762def4da3786d45fe472587

This exactly matches the SHA256 calculated on the .bin file using Windows "certutil" utility.

However, if I download the TI-TXT .txt file generated by the "armhex" utility (e.g. via the MSP432 Bootloader BOOTP/TFTP or the TI UniFlash utility), the following SHA256 is reported:

[INFO] SHA256: 2511116a16e8bbee448a1433bb0060e126ef022f65938d181e188842cdf2a9b1

Has anyone run into this?  Is there some additional switch/parameter needed to make sure that the .txt output matches the value from the .bin output?

Your help is sincerely appreciated.  Thanks!

--Scott

  • Scott,

    I am not sure how the SHA256 is being calculated by the application but I have a theory as to what is happening.  A binary file and a txt file are not the same.  The program that is in them is the same.  A binary file has no address information, the txt file does.  Take a look at this article https://software-dl.ti.com/ccs/esd/documents/sdto_cgt_an_introduction_to_binary_files.html. The important section is the part that discusses holes.  Basically binary files are contiguous, and txt files are not.

    What is the state of the memory before the txt file is programmed?  Is the memory all zeros?  If not then those holes are going to have different values when programming the binary file vs the txt file.  For the binary file the values are 0, for the txt file they would be whatever they were before programming. That would result in a different SHA256.

    Regards,

    John