An important part of the update process is checking the version of the received files and their integrity.You can do this using such algorithms as MD5, CRC32 and so forth.For example, a small-size bootloader is copied to the CPU internal memory, performs initialization of external memory and copies the second-level loader to the external RAM.
The U-Boot loader implements a built-in function of checking the integrity of the loaded Linux kernel image (controlled by the verify variable), which helps check its integrity even before the OS starts and (using hush scripts) identify alternative sources for booting the software (old firmware or TFTP, Line Parsing).In addition to the typical parameters necessary to run the operating system (the location of the kernel image in the ROM, the name of the section containing the root filesystem and so on), environment variables can store the failed boot count and restore the system to the previous software after reaching a certain threshold (Figure 3). Software Update Algorithm with the Possibility of Restoring to the Previous Firmware for a small ROM capacity, the Linux kernel and applications, as well as the necessary libraries, should be copied to RAM.After that, you can erase and rewrite Flash memory.Memory is overwritten using flash_eraseall (for erasing the memory) and nandwrite (for writing images to the NAND memory), which are included in the mtd-utils package.
When update files are received and checked, you can start the process of writing them to the system ROM.
Finally, the system launches custom applications stored in the last section of the Flash memory.