Yup, it's the same algorithm.
Conclusion: FullComp firmwares have a second checksum in the BCL header at position 0x04. Algorithm is the same one as for Novatek firmware images.
Updated algorithm:
Attachment: checksum calculator for win32 and linux64
Usage:
./checksum filename
./checksum filename [start val] (for non standard checksum start values)
It will automatically detect FullComp firmwares and skip 0x04 for calculation, as well as NonComp (skips 0x6e in this case)
Conclusion: FullComp firmwares have a second checksum in the BCL header at position 0x04. Algorithm is the same one as for Novatek firmware images.
Updated algorithm:
Code:
uint16_t calc_checksum(uint16_t data[], uint32_t length, uint32_t skip_at, uint16_t startval) {
uint32_t pos = 0;
uint16_t checksum = 0;
while(pos < length) {
if(pos * 2 == skip_at) {
checksum += pos;
} else {
checksum += pos + data[pos];
}
pos++;
}
return startval + (~checksum & 0xFFFF) + 1;
}
Attachment: checksum calculator for win32 and linux64
Usage:
./checksum filename
./checksum filename [start val] (for non standard checksum start values)
It will automatically detect FullComp firmwares and skip 0x04 for calculation, as well as NonComp (skips 0x6e in this case)