
..\..\..\..\..\middleware\safety_iec60730b\tools\crc\crc_hex.bat
-..\..\..\..\boards\<YOUR_BOARD>\demo_apps\safety_iec60730b\mdk\debug\safety_iec60730b.hex
-..\..\..\..\boards\<YOUR_BOARD>\demo_apps\safety_iec60730b\mdk\debug\safety_iec60730b_crc.hex
-..\..\..\..\tools\srecord\srec_cat.exe -CRC32
"<YOUR_BOARD>" is the name of your SDK development board, e.g. "frdmk22f".
The first line is the path from the project root path (IDE project file) to the
crc_hex.bat
file. The other lines are the parameters for
the
crc_hex.bat
file.
The
crc-hex.bat
file has three mandatory parameters and one optional parameter:
• The first paramater is the path from the
crc-hex.bat
file to your application's
*.hex
file (
safety_iec60730b.hex
). It is the input
for the calculation.
• The second parameter is the path for the generated output file. This file (with the specified name) is stored as a result of
the script (
safety_iec60730b_crc.hex
) with the calculated CRC.
• The third parameter is the path from the
crc-hex.bat
file to the
srec_cat.exe
file.
• The fourth parameters is optional. When it is filled with"-CRC32", the result will be CRC32. Otherwise, the CRC16
calculation happens.
A dedicated structure in the input
*.hex
file is used to define the area where the CRC will be calculated. All necessary information
for the CRC will be read by the
crc-hex.bat
file from this structure.
Information table in the *.hex file
It is necessary to add a dedicated marker structure to the memory
*.hex
file to use the presented
crc-hex.bat
file.
The presented
crc-hex.bat
file parses the last 16 bytes from the input
*.hex
file to the found information table.
This information table must have a dedicated structure and it must be placed at the end of the input
*.hex
file.
The structure of the information table is as follows:
/* The safety-related FLASH CRC value. */
fs_crc_t c_sfsCRC =
{
.ui16Start = 0xA55AU,
.ui32FlashStart = (uint32_t)__ROM_start__,
.ui32FlashEnd = (uint32_t)&Load$$ER_IROM3$$Limit,
.ui32CRC = (uint32_t)FS_CFG_FLASH_TST_CRC,
.ui16End = 0x5AA5U
};
• 0x5AA5 - the start/end marker for the information table
• ui32FlashStart - the start address for the CRC calculation
• ui32FlashEnd - the end address for the CRC calculation
• ui32CRC - the seed value
This table must be placed at the end of the
*.hex
file. This can be assured by a linker script. The linker script depends on the IDE
used. The exact description for the supported IDE is in the following chapter.
Post-build CRC calculation
LPC CM0 Safety Example , Rev. 3, 07/2021
NXP Semiconductors
17