[bootloader] Consider app safe after 3 Luos_loop execution instead of timing.
@@ -37,10 +37,6 @@ service_t *detection_service;
luos_stats_t luos_stats;
general_stats_t general_stats;
-bool launch_boot_flag = true;
-bool boot_run = false;
-uint32_t boot_start_date = 0;
-
/*******************************************************************************
* Function
******************************************************************************/
@@ -89,17 +85,15 @@ void Luos_Loop(void)
msg_t *returned_msg = NULL;
#ifdef WITH_BOOTLOADER
- if (launch_boot_flag)
+ // After 3 Luos_Loop, consider this application as safe and write a flag to let the booloader know it can jump to the application safely.
+ static uint8_t loop_count = 0;
+ if (loop_count < 3)
{
- launch_boot_flag = false;
- boot_start_date = LuosHAL_GetSystick();
- boot_run = true;
- }
-
- if (((LuosHAL_GetSystick() - boot_start_date) > BOOT_TIMEOUT) && boot_run)
+ loop_count++;
+ if (loop_count == 3)
{
LuosHAL_SetMode((uint8_t)JUMP_TO_APP_MODE);
- boot_run = false;
+ }
}
#endif
