void goto_shell(const char *str)
{
printf("%s \r\n", str);
start_shell();
}
void goto_boot_from_app(void)
void update_from_backup(int size);
void main()
{
boot_cnt++;
if (boot_cnt >= (3 + 2))
goto_shell("Exceeded the maximum number of boot count.");
if (app_has_data && (!update_flag) && (boot_cnt <= 3))
goto_boot_from_app(Boot APP normally ...);
if (!backup_has_data)
goto_shell("Backup has no data.");
if (backup_crc_store != backup_crc_cal)
goto_shell("Backup crc error.");
if (app_crc_store == backup_crc_store)
goto_boot_from_app(APP and backup are same, so we do not uodate. Boot APP ...);
update_cnt++;
rt = update_from_backup(backup_size);
if (rt != SUCCESS)
reset();
goto_boot_from_app(Upate APP from backup success. Boot APP ...);
}