
-..\..\..\..\boards\<YOUR_BOARD>\demo_apps\safety_iec60730b\mdk\debug\dev_safety_iec60730b_crc.hex
-..\..\..\..\tools\srecord\srec_cat.exe
The meaning of this afterbuild command is described in
Postbuild in IEC60730B safety example
The product of the postbuild operation with the
crc-hex.bat
file is the
<your_project_name>_crc.hex
edited file, which must be
loaded to the target. The best way to do this is to create a debug initialization file.
5.1.2.2 Debug initialization settings
By default, the uVision Keil IDE downloads the output file specified in "Options->output". Due to this, it is necessary to create an
alternative debug initialization file. In our case, a
*.hex
file with an added CRC is dedicated for the download to the target.
In the uVision Keil IDE, it is necessary to select the following options:
• "Options ->Debug->Initialization file" - fill it with the "safety_debug.ini" pattern.
• "Options->Utilities->Init File" - fill it with the "safety_debug.ini" pattern.
Use a text editor to create the
safety_debug.ini
file. Create an empty file, save it with the
*.ini
extension, and copy the following
command into the file: "LOAD .\debug\<YOUR_PROJECT>_crc.hex INCREMENTAL".
This command loads the
<YOUR_PROJECT>_crc.hex
file from the
.\debug\
relative path and this address is relative to the project
file (
<YOUR_PROJECT>.uvprojx
in the presented case). It means that the file is in the
debug
folder.
It is necessary to save this file to the project root path (to the folder with
<YOUR_PROJECT>.uvprojx
in the presented case).
After these IDE settings, the IDE calls the
crc-hex.bat
file after the build and it uses the alternative hex file
<YOUR_PROJECT>_crc.hex
as the source for programming during the download.
5.1.2.3 Linker settings for information table
The
crc-hex.bat
postbuild file expects the information table at the end of the
*.hex
file. For this purpose, it is good to define your
own section in the linker. In the uVision Keil IDE, it can be the following:
LR_IROM3 m_fs_flash_crc_start __size_flash_crc__{
; Safety-flash CRC region
ER_CRC (m_fs_flash_crc_start) FIXED (__size_flash_crc__)
{
*(.flshcrc)
}
}
Where "m_fs_flash_crc_start" and "__size_flash_crc__" are the user-defined address. This address must be at the end of the flash.
After defining this section in the ROM, a correct structure must be defined in the C language:
/* The safety-related FLASH CRC value. */
fs_crc_t c_sfsCRC __attribute__((used, section(".flshcrc"))) =
{
.ui16Start = 0xA55AU,
Post-build CRC calculation
i.MX8M Safety Example , Rev. 3, 07/2021
NXP Semiconductors
16