The -mchecksum=specs
option will calculate a hash
value (for example checksum or CRC) over the address range specified and stores the result
in the hex file at the indicated destination address. The general form of this option is as
follows.
-mchecksum=start-end@destination[,specifications]
The following specifications are appended as a comma-separated list to this option.
Argument | Description |
---|---|
width=n |
Selects the width of the hash result in bytes for non-Fletcher algorithms, or in bits for SHA algorithms. A negative width will store the result in little-endian byte order; positive widths in big-endian order. Result widths from one to four bytes are permitted, or 256 bits for SHA algorithms. |
offset=nnnn |
Specifies an initial value or offset added to the checksum. |
algorithm=n |
Selects one of the hash algorithms implemented in Hexmate. The selectable algorithms are described in Table 2. |
polynomial=nn |
Selects the polynomial value when using CRC algorithms |
code=nn |
Specifies a hexadecimal code that will trail
each byte in the result. This can allow each byte of the result to be embedded
within an instruction, for example code=34 will embed the
result in a retlw instruction on Mid-range devices. |
revword=n |
Read data in reverse byte order from
n -byte wide words. Currently this value can be 0
or 2. A value of 0 disables the reverse-read feature. |
The start
, end
and
destination
attributes are, by default, hexadecimal
constants. The addresses defining the input range are typically made multiples of the
algorithm width. If this is not the case, zero bytes will pad any missing input word
locations.
If an accompanying --fill
option (Fill Option) has not been specified, unused
locations within the specified address range will be automatically filled with 0xFFF for
baseline devices, 0x3FFF for mid-range devices, or 0xFFFF for PIC18 devices. This is to
remove any unknown values from the calculations and ensure the accuracy of the result.
For example:
-mchecksum=800-fff@20,width=1,algorithm=2
will calculate a 1-byte checksum from address 0x800 to 0xfff and store this at address 0x20. A 16-bit addition algorithm will be used. Table 2 shows the available algorithms and Hash Functions describes these in detail.
Selector | Algorithm description |
---|---|
-5 |
Reflected cyclic redundancy check (CRC) |
-4 |
Subtraction of 32 bit values from initial value |
-3 |
Subtraction of 24 bit values from initial value |
-2 |
Subtraction of 16 bit values from initial value |
-1 |
Subtraction of 8 bit values from initial value |
1 |
Addition of 8 bit values from initial value |
2 |
Addition of 16 bit values from initial value |
3 |
Addition of 24 bit values from initial value |
4 |
Addition of 32 bit values from initial value |
5 |
Cyclic redundancy check (CRC) |
7 |
Fletcher’s checksum (8 bit calculation, 2-byte result width) |
8 |
Fletcher’s checksum (16 bit calculation, 4-byte result width) |
10 |
SHA-2 (currently only SHA256 is supported) |
The hash calculations are performed by the Hexmate application. The information in this driver option is passed to the Hexmate application when it is executed.