Skip to main content
lorenzo meneghello_2
Associate III
November 18, 2020
Question

Add CRC value to axe file

  • November 18, 2020
  • 2 replies
  • 1205 views

Hi all,

I'm trying to add the STM CRC32 to the hex or axf file, after this I need to convert it to .bin file because I've a Bootloader and I want to check the CRC32 to see if there's a valid image stored. I'm using srec_cat but doesn't work.

Thanks.

This topic has been closed for replies.

2 replies

TDK
Super User
November 18, 2020

Consider adding more details to your question. Taking the CRC of a sequence of bytes should be doable. What about it doesn't work? Note that adding a CRC to a .BIN file will now change the CRC of the BIN file, so you must be careful in how it is calculated.

"If you feel a post has answered your question, please click ""Accept as Solution""."
lorenzo meneghello_2
Associate III
November 19, 2020

I use srec_cat to generate the CRC from the .hex file through this command ".\App.hex -intel -crop 0x08004000 0x0801F7FC -crc32-b-e 0x0801F7FC -o .\App_CRC.bin -binary " the file .bin generated contain the CRC but all other byte is zero. I've the Bootloader from 0x8000000 to 0x8003FFF and the application from 0x8004000 to 0x801F800 so I wanted to put the CRC value 4 byte before the end of section so at address 0x801F7FC. MSipo's answer is also interesting.

MSipo
Senior II
November 18, 2020

You could add a 4 byte space after the vector table and later insert the CRC there using a specially written program. And then the bootloader can get the CRC from that address. And the CRC function will of cause skip those 4 bytes when calculating the checksum.

 DCD DMA2_Channel5_IRQHandler ; DMA2 Channel 5
 DCD 0 ; Reserved
 DCD COMP_ACQ_IRQHandler ; Comparator Channel Acquisition 
 DCD 0 ; Placeholder for the CRC
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Default interrupt handlers.
;;
 THUMB
 
 PUBWEAK Reset_Handler
 SECTION .text:CODE:REORDER:NOROOT(2)
Reset_Handler
 LDR R0, =SystemInit
 BLX R0
 LDR R0, =__iar_program_start
 BX R0