cancel
Showing results for 
Search instead for 
Did you mean: 

Need support to have STM32F769 Hardware 32BIT CRC generation and same value should be generated by STM CUBE IDE POST COMPILATION 32BIT CRC for BINARY file .

BareMetalExpert
Associate III

Need support to have STM32F769 Hardware 32BIT CRC generation and same value should be generated by STM CUBE IDE POST COMPILATION 32BIT CRC for BINARY file .

So a quick background is once the project is compiled and binary is generated we use SREC_CAT post binary build so we get the Binary + 32 BIT CRC .

currently we are using 32BIT Sofware CRC generated in Firmware to compare with what IDE generates .

Same SREC_CAT generated 32BIT CRC for BINARY should match with STM IN-BUILT HARDWARE 32BIT PHY generated 32 BIT Binary .

http://srecord.sourceforge.net/man/man1/srec_cat.html

2 REPLIES 2
BareMetalExpert
Associate III

Previous Posts on same topic are all based on 32BIT Software based CRC Calculation

kalvacherla.chandrashekhar (Community Member) asked a question.

October 29, 2019 at 12:49 AM

Actions for this Feed Item

IDE script to generate crc at post compilation process

https://stackoverflow.com/questions/24150030/storing-crc-into-an-axf-elf-file

—CHECKSUM=0-FF@100,offset=0xFFFF,algorithm=5,width=-2,polynomial=0x1021

arm-none-eabi-size "${BuildArtifactFileName}"

arm-none-eabi-objcopy -O binary "${BuildArtifactFileName}" "${BuildArtifactFileBaseName}.bin"

checksum -p ${TargetChip} -d "${BuildArtifactFileBaseName}.bin"

../util/srec_cat "${BuildArtifactFileBaseName}.bin" -binary -crop 0 0x3FFFC -fill 0xFF 0x00000 0x3FFFC -crc32-b-e 0x3FFFC -o "${BuildArtifactFileBaseName}.crc.bin" -binary

echo ""

echo "CRC32:"

../util/srec_cat "${BuildArtifactFileBaseName}.crc.bin" -binary -crop 0x3FFFC 0x40000 -o - -hex-dump

similar to above mentioned

I required to embed CRC32 into the .bin file or .hex file generated during compilation process .

does the GCC compiler or the IDE system workbench based on eclipse has any inbuilt compiler libraries that generate CRC during compilation and embed it in the .hex or .bin file .

Thanks for providing the step by step guide , and this works to generate the required 32bit CRC for the file .

I Modified to generate .bin CRC as we required .bin

# srec cat command file: srec crc dump_to_file.txt _ _ _ 

#Input File 

Companion_Upgradable_BootLoader.bin -Binary 

#CRC Algorithm at given address 

-STM32 0x0009F800 

#Produce output 

-o Companion_Upgradable_BootLoader_output.bin -Binary 

The CRC generator configuration also I have gone through the following documents and it works

http://srecord.sourceforge.net/man/man1/srec_cat.html

http://srecord.sourceforge.net/srecord-1.64.pdf

They mention

The CRC used is documented in “RM0041, STM32F100xx reference manual�?, page 46, chapter

“CRC Calculation Unit�?, which can be found at

http://www.st.com/internet/mcu/product/216844.jsp

CRC main features

• Uses CRC-32 (Ethernet) polynomial: 0x4C11DB7

– X32 + X26 + X23 + X22 + X16 + X12 + X11 + X10 +X8 + X7 + X5 + X4 + X2+ X + 1

• Single input/output 32-bit data register

• CRC computation done in 4 AHB clock cycles (HCLK)

• General-purpose 8-bit register (can be used for temporary storage)

Hi ,

We are following the process from last 24 months to generate 32-Bit CRC , Though It is long and Cumbersome process to generate 32-Bit CRC of the compilation completed and Linking completed .bin file .

TI Code composer studio gives a better CRC generation method embedded into the IDE itself but not any of the STM tools provide this .

We are using this method of generating .bin file CRC POST-BUILD COMPLETION process.

The output file is .bin file with no 0x00's at the end of the file this will cause to generate wrong crc make all the unused ending characters are filled with 0xFF in the linker script and use the following method mentioned by Ethan Huang.

Also follow below my reply in this thread to get more details of how to generate 32-Bit CRC for a Binary file .

Ethan HUANG (ST Employee)

2 years ago

I'm afraid that there is no "inbuild compiler libraries that generate CRC during compilation and embed it in the .hex or .bin file". I made an example based on srecord in the following link:

https://github.com/ethanhuanginst/STM32CubeIDE-Workshop-2019/tree/master/hands-on/06_F746-DISCO-CRC

Key messages in the README.md:

  1. External tool srecord is used.
  2. Because of an bug of sequence between post-build and elf generation in early version (v1.0.0), I used a batch file (checksum.bat) to workaround it. This bug had been fixed from v1.0.2 so a more straightforward approach could be used as shown in the attached PDF.

Sorry that I'm lazy of making complete document to cover those steps in CubeIDE v1.1.0, so please refer to two separate material (README in Github and attached PDF). Hope these help.

  •  

Like

Reply

  •  

kalvacherla.chandrashekhar (Community Member)

2 years ago

Actions for this Feed Item Comment

Thanks for providing the step by step guide , and this works to generate the required 32bit CRC for the file .

I Modified to generate .bin CRC as we required .bin

# srec cat command file: srec crc dump_to_file.txt _ _ _ 

#Input File 

Companion_Upgradable_BootLoader.bin -Binary 

#CRC Algorithm at given address 

-STM32 0x0009F800 

#Produce output 

-o Companion_Upgradable_BootLoader_output.bin -Binary 

The CRC generator configuration also I have gone through the following documents and it works

http://srecord.sourceforge.net/man/man1/srec_cat.html

http://srecord.sourceforge.net/srecord-1.64.pdf

They mention

The CRC used is documented in “RM0041, STM32F100xx reference manual�?, page 46, chapter

“CRC Calculation Unit�?, which can be found at

http://www.st.com/internet/mcu/product/216844.jsp

CRC main features

• Uses CRC-32 (Ethernet) polynomial: 0x4C11DB7

– X32 + X26 + X23 + X22 + X16 + X12 + X11 + X10 +X8 + X7 + X5 + X4 + X2+ X + 1

• Single input/output 32-bit data register

• CRC computation done in 4 AHB clock cycles (HCLK)

• General-purpose 8-bit register (can be used for temporary storage)

Perhaps look at examples using the HW CRC

STM32Cube_FW_F7_V1.15.0\Projects\STM32F769I-Discovery\Examples\CRC\CRC_Example\Src\main.c

The BUFFER_SIZE here is a 32-bit Word Count, not a Byte Count

If you run the CRC computation over it's own remainder it will compute to zero

 uwCRCValue = HAL_CRC_Calculate(&CrcHandle, (uint32_t *)aDataBuffer, BUFFER_SIZE);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..