8
8
#include < esp_ota_ops.h>
9
9
#include " esphome/components/md5/md5.h"
10
10
11
+ #if ESP_IDF_VERSION_MAJOR >= 5
12
+ #include < spi_flash_mmap.h>
13
+ #endif
14
+
11
15
namespace esphome {
12
16
namespace ota {
13
17
@@ -16,9 +20,28 @@ OTAResponseTypes IDFOTABackend::begin(size_t image_size) {
16
20
if (this ->partition_ == nullptr ) {
17
21
return OTA_RESPONSE_ERROR_NO_UPDATE_PARTITION;
18
22
}
19
- esp_task_wdt_init (15 , false ); // The following function takes longer than the 5 seconds timeout of WDT
23
+
24
+ // The following function takes longer than the 5 seconds timeout of WDT
25
+ #if ESP_IDF_VERSION_MAJOR >= 5
26
+ esp_task_wdt_config_t wdtc;
27
+ wdtc.timeout_ms = 15000 ;
28
+ wdtc.idle_core_mask = 0 ;
29
+ wdtc.trigger_panic = false ;
30
+ esp_task_wdt_reconfigure (&wdtc);
31
+ #else
32
+ esp_task_wdt_init (15 , false );
33
+ #endif
34
+
20
35
esp_err_t err = esp_ota_begin (this ->partition_ , image_size, &this ->update_handle_ );
21
- esp_task_wdt_init (CONFIG_ESP_TASK_WDT_TIMEOUT_S, false ); // Set the WDT back to the configured timeout
36
+
37
+ // Set the WDT back to the configured timeout
38
+ #if ESP_IDF_VERSION_MAJOR >= 5
39
+ wdtc.timeout_ms = CONFIG_ESP_TASK_WDT_TIMEOUT_S;
40
+ esp_task_wdt_reconfigure (&wdtc);
41
+ #else
42
+ esp_task_wdt_init (CONFIG_ESP_TASK_WDT_TIMEOUT_S, false );
43
+ #endif
44
+
22
45
if (err != ESP_OK) {
23
46
esp_ota_abort (this ->update_handle_ );
24
47
this ->update_handle_ = 0 ;
0 commit comments