Add a CRC32 over progmem and ESP.checkFlashCRC by earlephilhower · Pull Request #6566 · esp8266/Arduino

@earlephilhower

Automatically embed a CRC32 of the program memory (including bootloader
but excluding any filesystems) in all images in unused space in the
bootloader block.

Add a call, ESP.checkFlashCRC() which returns false if the calculated
CRC doesn't match the one stored in the image (i.e. flash corruption).

Fixes esp8266#4165

d-a-v

Show CRC checking catch a 1-bit error in program code by corrupting a
large array, and then return it to clean and verify the CRC matches once
again.

Add comments to the CRC check routine

Clean up pylint complaints on crc32bin.py

@earlephilhower

@earlephilhower

@earlephilhower

@earlephilhower

@earlephilhower

@earlephilhower

Add an assertion in the eboot linker file to guarantee that we have at
least 8 bytes of unused space at the end of the boot sector to patch in
the CRC.  If not, the eboot link will fail.

@earlephilhower

@earlephilhower

@earlephilhower

@earlephilhower

Per discussion with @d-a-v.

When the CRC check fails, you could *try* to do certain things (but may
not succeed since there is known flash corruption at that point).  List
a few ideas for application authors.

mcspr

@earlephilhower

Per discussion w/@mcspr, combine the CRC calculation with the binary
generation, removing the additional build step.

@earlephilhower

@earlephilhower

mcspr

@ghost ghost mentioned this pull request

Oct 9, 2020