flash_encryption: added wdt feed during encryption process to avoid undesired reset.
This commit is contained in:
parent
7635dce502
commit
b3d8847406
|
@ -180,8 +180,7 @@ menu "Bootloader config"
|
||||||
config BOOTLOADER_WDT_TIME_MS
|
config BOOTLOADER_WDT_TIME_MS
|
||||||
int "Timeout for RTC watchdog (ms)"
|
int "Timeout for RTC watchdog (ms)"
|
||||||
depends on BOOTLOADER_WDT_ENABLE
|
depends on BOOTLOADER_WDT_ENABLE
|
||||||
default 9000 if IDF_TARGET_ESP32
|
default 9000
|
||||||
default 40000 if IDF_TARGET_ESP32S2
|
|
||||||
range 0 120000
|
range 0 120000
|
||||||
help
|
help
|
||||||
Verify that this parameter is correct and more then the execution time.
|
Verify that this parameter is correct and more then the execution time.
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "esp32s2/rom/efuse.h"
|
#include "esp32s2/rom/efuse.h"
|
||||||
#include "esp_efuse.h"
|
#include "esp_efuse.h"
|
||||||
#include "esp_efuse_table.h"
|
#include "esp_efuse_table.h"
|
||||||
|
#include "hal/wdt_hal.h"
|
||||||
|
|
||||||
static const char *TAG = "flash_encrypt";
|
static const char *TAG = "flash_encrypt";
|
||||||
|
|
||||||
|
@ -324,7 +325,13 @@ esp_err_t esp_flash_encrypt_region(uint32_t src_addr, size_t data_length)
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wdt_hal_context_t rtc_wdt_ctx = {.inst = WDT_RWDT, .rwdt_dev = &RTCCNTL};
|
||||||
for (size_t i = 0; i < data_length; i += FLASH_SECTOR_SIZE) {
|
for (size_t i = 0; i < data_length; i += FLASH_SECTOR_SIZE) {
|
||||||
|
|
||||||
|
wdt_hal_write_protect_disable(&rtc_wdt_ctx);
|
||||||
|
wdt_hal_feed(&rtc_wdt_ctx);
|
||||||
|
wdt_hal_write_protect_enable(&rtc_wdt_ctx);
|
||||||
|
|
||||||
uint32_t sec_start = i + src_addr;
|
uint32_t sec_start = i + src_addr;
|
||||||
err = bootloader_flash_read(sec_start, buf, FLASH_SECTOR_SIZE, false);
|
err = bootloader_flash_read(sec_start, buf, FLASH_SECTOR_SIZE, false);
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
|
|
Loading…
Reference in a new issue