5 CRCSCAN
A Cyclic Redundancy Check (CRC) creates a checksum for a block of data, enabling error detection of the data block. The Relevant Devices feature the CRCSCAN peripheral, which can check a Flash section and compare it to a checksum stored at the end of the section. If the Flash section is accidentally changed, i.e., because of corruption or an unintended write, the CRCSCAN will detect this and signal to the CPU that Flash has been corrupted.
In a bootloader application, CRCSCAN can be used to verify the application image before starting execution. This to make sure that corrupted software is not executed, which could have catastrophic consequences. If the check fails, the bootloader can either choose not to start the application, it can do a firmware update, or it can signal the error to an external system.
CRCSCAN can be run at start-up, or specific intervals controlled by the application. When running at start-up, the Flash is checked for errors before any instruction is executed. This allows the integrity of the application to be verified before execution. CRCSCAN on start-up is configured using fuses.
When CRCSCAN is controlled by the application, it can be started by register access. When started, the CPU is halted while the check is being done, as CRCSCAN has priority access to Flash, thus blocking the CPU.
For more information, refer to the CRCSCAN on tinyAVR® 0- and 1-series and megaAVR® 0-series application note.