From ecce6797a02196a417f96e7031a7ff5ca8c06dbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Sat, 23 Jul 2022 13:03:21 +0200 Subject: [PATCH] dfu: exit DFU mode if firmware is valid --- examples/device/dfu_freertos/src/main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/examples/device/dfu_freertos/src/main.c b/examples/device/dfu_freertos/src/main.c index 2711ee106..78d760f69 100644 --- a/examples/device/dfu_freertos/src/main.c +++ b/examples/device/dfu_freertos/src/main.c @@ -98,6 +98,16 @@ esp_ota_handle_t ota_handle = 0; int main(void) { board_init(); + const esp_partition_t *next = esp_ota_get_next_update_partition(NULL); + esp_app_desc_t next_desc; + esp_ota_get_partition_description(next, &next_desc); + + if (ESP_APP_DESC_MAGIC_WORD == next_desc.magic_word) { + ESP_LOGI(TAG, "boot set to valid app"); + esp_ota_set_boot_partition(next); + } else { + ESP_LOGI(TAG, "no valid app"); + } // soft timer for blinky blinky_tm = xTimerCreateStatic(NULL, pdMS_TO_TICKS(BLINK_NOT_MOUNTED), true, NULL, led_blinky_cb, &blinky_tmdef);