2019-08-01 04:42 AM
Hello,
I want to calculate the CRC (32 bit) of image at post build and insert it in a known location in the image.
In order to do it I should perform the following steps:
a) Definition of placeholder in linker script file
b) Post build steps:
b.1) Calculation of image CRC (32 bit)
b.2) Insert it into the placeholder
The reason of 32 bit is to use the STM32 HW CRC calculation for checking the CRC.
The post build steps can be performed by IELFTOOL.
Can anyone help?
Yacob Hassidim.
2019-08-01 04:49 AM
srecord is one of the tools which can be used for this purpose.
JW
2019-08-01 05:07 AM
Hello,
JW: Can you please detail?
Yacob Hassidim.
2019-08-01 06:20 AM
Ok, so what's the problem here? You've described the steps
Doesn't IELFTOOL provide documentation for the command line expectations?
Does CubeIDE provide for a method to run scripts, or add lines to the makefile?
If you convert to a binary you could presumably write your own tools to read the file and add the CRC to the end. I've posted examples.
You can embedded image size data via linker symbols so the STM32 side code knows where the end of the code and copied statics falls.
https://community.st.com/s/question/0D50X0000Awa25qSQA/generated-binary-file-size-in-stm32l4
2019-08-01 07:46 AM
@Community member: Thanks for the link. It helped me.
I should try your suggestions from the link.
Yacob Hassidim.
2019-08-12 02:02 AM
Hi Yacob,
Here is a step-by-step for your reference:
https://github.com/ethanhuanginst/STM32CubeIDE-Workshop-2019/tree/master/hands-on/06_F746-DISCO-CRC
Please note that this step-by-step is made for STM32CubeIDE v.1.0.0 which has bug of the order of post-build so an workaround (using a batch file checksum.bat in post-build command) is used. This bug has been fixed after STM32CubeIDE v1.0.2 so we can simply use the following without using the batch file:
Regards,
Ethan
2019-08-12 03:27 AM
Interesting, a custom switch for srec-cat (--STM32).
But adding it to the PATH... Does CubeIDE provide a built-in variable for the toolkit binary path, like other Eclipse based environments?
-- pa
2019-08-18 12:59 AM
Hello @Ethan HUANG
Thank you for your answer.
How can I calculate the CRC of actual code, i.e. end of the range will not be constant "0x08007FFC" but as actual end of the code?
Sincerely,
Yacob Hassidim.
2019-08-18 02:05 AM
> How can I calculate the CRC of actual code, i.e. end of the range will not be constant "0x08007FFC" but as actual end of the code?
srec_cat without the -fill switch will do exactly this. The problem is then, where to put the checksum, as srec_cat requires an address.
Play with srec_cat to understand how it works. Read the srecord manual; I know that it's not written very well and it's not an easy reading.
Or, as Clive said above, write your own program to add the checksum - it will then work exactly as you want.
JW
2019-08-18 02:25 AM
Hello @Community member
Thank you for your advice.
Yacob Hassidim.