Tool/software:
I want to generate a CRC using armhex.exe for TI Hercules TMS570LC4357 and that CRC needs to be updated into 'C' file but CRC should not be changed when this CRC is updated into that 'C' file
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.
Tool/software:
I want to generate a CRC using armhex.exe for TI Hercules TMS570LC4357 and that CRC needs to be updated into 'C' file but CRC should not be changed when this CRC is updated into that 'C' file
Are you sure armhex.exe can calculate a CRC? I don't think it can. You can use the linker to generate a CRC:
In any case, is the 'C' file compiled into the program which is then CRC checked? If so, I don't think that will work. When you copy the CRC back in to the 'C' file then recompile, the CRC will change and you go around in circles.
You could do that but what is the point of putting the build-time CRC into a C file? Is it to access the build-time CRC value at run-time?
Reading between the lines, you want to calculate a CRC of your application at build time, store it somewhere, then have the application re-calculate the CRC at run-time and compare it with the build time CRC. Is that correct?
If so, you need to store the CRC outside of your application program at a fixed address. You can refer to the fixed address with a pointer or you can have a linker symbol associated with it. Then in your application CRC checker, you refer to the linker symbol as if it were a pointer.
Here's an example:
So your application CRC checker accesses the CRC by pointer to address 0x0.
Hi Vijay,
*Using the CRC Module on Hercules-Based Microcontrollers (ti.com)
Please refer above application notes, here clearly explained how to generate the CRC using linker command file and they also given direct example code for TMS570LC4357.
I want to give some overview on this to you.
Here the CRC will be calculated for each required sector in the code.
For example:
The below line generates the CRC for the .const section and it will store the corresponding generated CRC into the _my_crc_table structure as a record.
.const : {} palign=8, fill=0xffffffff, crc_table(_my_crc_table, algorithm=TMS570_CRC64_ISO)
And what you can do in the code is that you can extern this _my_crc_table structure, and you can use CRC module in controller to calculate the CRC in your code and then you can compare your calculated CRC with the linker generated CRC record in the _my_crc_table.
Here is the way of accessing the _my_crc_table CRC records in your code:
You can also verify the map file to understand the generated CRC by the linker:
For example, if you verify the above example:
Here i am generating the CRC records for 4 sections (.intvecs, .text, .const and .cinit), and as you can see my generated CRC table was stored right after the last section i.e. .cinit (0x000089d8 + 0x00000228 = 0x00008c00).
For more understanding refer the attached application notes and CRC module section in TRM.
--
Thanks & regards,
Jagadish.