void mgos_upd_boot_revert() {
  int boot_cfg_idx = g_boot_cfg_idx;
  struct boot_cfg *cfg = &g_boot_cfg;
  if (!cfg->flags & BOOT_F_FIRST_BOOT) return;
  LOG(LL_ERROR, ("Config %d is bad, reverting", boot_cfg_idx));
  /* Tombstone the current config. */
  cfg->seq = BOOT_CFG_TOMBSTONE_SEQ;
  write_boot_cfg(cfg, boot_cfg_idx);
  mgos_system_restart();
}
Exemple #2
0
static void esp_mgos_init(void) {
  enum mgos_init_result result = esp_mgos_init2();
  bool success = (result == MGOS_INIT_OK);
#ifdef MGOS_HAVE_OTA_COMMON
  mgos_ota_boot_finish(success, mgos_ota_is_first_boot());
#endif
  if (!success) {
    LOG(LL_ERROR, ("Init failed: %d", result));
    /* Arbitrary delay to make potential reboot loop less tight. */
    mgos_usleep(500000);
    mgos_system_restart();
  }
}