This is a bit of the chicken and egg thing. If you want a embed the code checksum in a code module to report the checksum, is there a way of doing this? It's a bit like being your own grandfather, I think.
I'm not thinking anything too fancy, like a CRC, but rather a simple modulo N addition, maybe N being 2^16.
I keep thinking of using a placeholder, but that doesn't seem to work out in any useful way. Even if you try to anticipate the impact of adding the checksum, that only gives you a different checksum, that you then need to anticipate further... ad infinitum.
I'm not thinking of coding any special checksum generator that excludes the checksum data. That would be too messy. Just use the existing tools to checksum the file.
I keep thinking there is a different way of looking at this to achieve the result I want...
Maybe I can prove it is impossible. Assume the file checksums to X when the checksum data is zero. The goal would then be to include the checksum data value Y in the file, that would change X to Y. Given the properties of the module N checksum, this would appear to be impossible for the general case, unless... Add another data value, called, checksum normalizer. This data value checksums with the original checksum to give the result zero. Then, when these two values are added to the file, the resulting checksum does not change.
This might be inordinately hard for a CRC, but a simple checksum would not be an issue, I think. At least, this could work in software, where data can be included in an image file as itself. In a device like an FPGA, it might not be included in the bit stream file so directly... but that might depend on where in the device it is inserted. Memory might have data that is stored as itself. I'll need to look into that.
- Get 1,000 miles of free Supercharging
- Tesla referral code - https://ts.la/richard11209