edc17 / med17 eeprom checksum
All eeprom divided to blocks with 0x80 size
offsets:
0x00 - block id (half word)
0x02 - CS1 (half word)
0x04 - block revision
0x08 - data
0x7C - CS2 (word)
Half word - 16 bit
Word - 32 bit
And list Block id from EDC17 eeprom:
1,8,9,A,B,C,1A,1B,1C,1D,1E,1F,2A,2B,2C
2D,2E,2F,3A,3B,3C,3D,3D,3E,3F,17,18,19
20,21,22,23,24,25,26,27,28,29,30,31,32
33,34,35,36,37,38,39,40,41,42,43,44,45
46,47,48,49,CC00
In TriCore asm another look at it
Size given in asm mnemonic.
Like this:
ld.hu d15, [a12]2
extr.u d2, d2, #0, #0x10
jne16 d15, d2, loc_8013AD6A ; Bad CRC
Algorithm for CS1:
data from - 0x04
leight - 0x7C
CS calculated with Tricore internal CRC32 and low half word - CS1
Inicial value - block id
unsigned long crc_buffer(unsigned long crc, const unsigned long *p, unsigned long sz)
{
const unsigned long poly = 0xEDB88320;
unsigned long tmp1, tmp2;
while(sz--)
{
tmp1 = 0;
tmp2 = crc & poly;
for(int i = 0; i <=31; i++ )
tmp1 ^= ((tmp2 >> i) & 1);
crc = *p++ ^ ((crc << 1) | tmp1) ;
}
return crc;
}
All eeprom divided to blocks with 0x80 size
offsets:
0x00 - block id (half word)
0x02 - CS1 (half word)
0x04 - block revision
0x08 - data
0x7C - CS2 (word)
Half word - 16 bit
Word - 32 bit
And list Block id from EDC17 eeprom:
1,8,9,A,B,C,1A,1B,1C,1D,1E,1F,2A,2B,2C
2D,2E,2F,3A,3B,3C,3D,3D,3E,3F,17,18,19
20,21,22,23,24,25,26,27,28,29,30,31,32
33,34,35,36,37,38,39,40,41,42,43,44,45
46,47,48,49,CC00
In TriCore asm another look at it
Size given in asm mnemonic.
Like this:
ld.hu d15, [a12]2
extr.u d2, d2, #0, #0x10
jne16 d15, d2, loc_8013AD6A ; Bad CRC
Algorithm for CS1:
data from - 0x04
leight - 0x7C
CS calculated with Tricore internal CRC32 and low half word - CS1
Inicial value - block id
unsigned long crc_buffer(unsigned long crc, const unsigned long *p, unsigned long sz)
{
const unsigned long poly = 0xEDB88320;
unsigned long tmp1, tmp2;
while(sz--)
{
tmp1 = 0;
tmp2 = crc & poly;
for(int i = 0; i <=31; i++ )
tmp1 ^= ((tmp2 >> i) & 1);
crc = *p++ ^ ((crc << 1) | tmp1) ;
}
return crc;
}