Safety-certified tools Tools for Automotive Applications C-STAT Static analysis C-RUN Runtime analysis Debugging and trace probes Build tools for Linux
This Technical Note shows a few examples of how a CRC16 checksum can be added in applications made with IAR Embedded Workbench.
This Technical Note applies to IAR Embedded Workbench products that use the IAR XLINK Linker. For products using the IAR ILINK Linker, see Technical Note 11927.
Generally speaking: "All bytes in the application that must be downloaded to the target, will be part of the checksum calculation."
The simplest way of get knowledge about this is to turn on "checksum calculation" + "map file" in the options for IAR XLINK Linker. Then look at the end of the .map file to see which ranges in which memory that will be included in the checksum calculation.
Please note that DATA will normaly not be included in the checksum calculation, but that XDATA (and some other segment types) can be included besides the CODE segment type. If other segment types (than CODE) are included, then you can exclude those segment types. (The example for IAR Embedded Workbench for ARM has the -J option set up in such a way that XDATA is not included in the checksum calculation.)
The supplied examples show how to use the CRC16 checksum calculation. In the C source of the application you need to add the actual generic C source to calculate the same checksum value as IAR XLINK Linker produces. There are two variants of the calculation:
You can use these options either in your linker command file (filename .XCL) or in the IAR Embedded Workbench IDE.
In IAR Embedded Workbench, you set up calculation of the checksum in the Project > Options > Linker (XLINK) > Processing. The options that corresponds to the examples are Fill unused code memory (command line option H); Fill pattern (any pattern); Generate checksum (command line option J); size = 2 bytes; CRC16; Complement = as is; Bit order = MSB first.
From command line (or in the .xcl file) you use the -J and -H linker options for calculating the checksum. Note that you must use the -H filler byte option to be able to use -J.
There are some requirements that you have to fulfil to make this work.
These examples include the actual generic C source to calculate the same checksum value as IAR XLINK Linker produces in its CRC calculation. The examples also contain IAR Embedded Workbench settings for IAR XLINK Linker and a modified .xcl file for placing the CHECKSUM segment at a proper place in memory.
There is more information about the checksums in XMAN.HTM and XLINK.PDF which can be found in your installation. You can also download these files in the related support link "Latest version of IAR XLINK Linker".
Mr. Ross N. Williams at Rocksoft in Australia have written, what he calls: A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS and this document can be down loaded from the link CRC explained by Mr. Ross N. Williams.
All product names are trademarks or registered trademarks of their respective owners.