mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
ota: fix ota with flash encryption
This commit is contained in:
parent
63e4510e9e
commit
2333667cb5
@ -32,6 +32,7 @@ static inline void IRAM_ATTR spi_flash_guard_end(void)
|
||||
}
|
||||
}
|
||||
|
||||
extern void IRAM_ATTR flash_rom_init(void);
|
||||
esp_rom_spiflash_result_t IRAM_ATTR spi_flash_write_encrypted_chip(size_t dest_addr, const void *src, size_t size)
|
||||
{
|
||||
const uint8_t *ssrc = (const uint8_t *)src;
|
||||
@ -73,6 +74,7 @@ esp_rom_spiflash_result_t IRAM_ATTR spi_flash_write_encrypted_chip(size_t dest_a
|
||||
}
|
||||
|
||||
spi_flash_guard_start();
|
||||
flash_rom_init();
|
||||
rc = esp_rom_spiflash_write_encrypted(row_addr, (uint32_t *)encrypt_buf, 32);
|
||||
spi_flash_guard_end();
|
||||
if (rc != ESP_ROM_SPIFLASH_RESULT_OK) {
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "hal/spi_flash_hal.h"
|
||||
#include "esp_flash.h"
|
||||
|
||||
extern void IRAM_ATTR flash_rom_init(void);
|
||||
esp_rom_spiflash_result_t IRAM_ATTR spi_flash_write_encrypted_chip(size_t dest_addr, const void *src, size_t size)
|
||||
{
|
||||
const spi_flash_guard_funcs_t *ops = spi_flash_guard_get();
|
||||
@ -59,6 +60,7 @@ esp_rom_spiflash_result_t IRAM_ATTR spi_flash_write_encrypted_chip(size_t dest_a
|
||||
if (ops && ops->start) {
|
||||
ops->start();
|
||||
}
|
||||
flash_rom_init();
|
||||
rc = SPI_Encrypt_Write(dest_addr, src, size);
|
||||
if (ops && ops->end) {
|
||||
ops->end();
|
||||
|
@ -461,13 +461,13 @@ out:
|
||||
}
|
||||
#endif // CONFIG_SPI_FLASH_USE_LEGACY_IMPL
|
||||
|
||||
#if !CONFIG_SPI_FLASH_USE_LEGACY_IMPL
|
||||
#ifndef CONFIG_SPI_FLASH_USE_LEGACY_IMPL
|
||||
extern void spi_common_set_dummy_output(esp_rom_spiflash_read_mode_t mode);
|
||||
extern void spi_dummy_len_fix(uint8_t spi, uint8_t freqdiv);
|
||||
static void IRAM_ATTR flash_rom_init(void)
|
||||
extern uint8_t g_rom_spiflash_dummy_len_plus[];
|
||||
void IRAM_ATTR flash_rom_init(void)
|
||||
{
|
||||
uint32_t freqdiv = 0;
|
||||
esp_rom_spiflash_read_mode_t read_mode;
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
uint32_t dummy_bit = 0;
|
||||
@ -492,6 +492,8 @@ static void IRAM_ATTR flash_rom_init(void)
|
||||
freqdiv = 4;
|
||||
#endif
|
||||
|
||||
#if !CONFIG_IDF_TARGET_ESP32S2BETA && !CONFIG_IDF_TARGET_ESP32
|
||||
esp_rom_spiflash_read_mode_t read_mode;
|
||||
#if CONFIG_ESPTOOLPY_FLASHMODE_QIO
|
||||
read_mode = ESP_ROM_SPIFLASH_QIO_MODE;
|
||||
#elif CONFIG_ESPTOOLPY_FLASHMODE_QOUT
|
||||
@ -501,6 +503,7 @@ static void IRAM_ATTR flash_rom_init(void)
|
||||
#elif CONFIG_ESPTOOLPY_FLASHMODE_DOUT
|
||||
read_mode = ESP_ROM_SPIFLASH_DOUT_MODE;
|
||||
#endif
|
||||
#endif //!CONFIG_IDF_TARGET_ESP32S2BETA && !CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
g_rom_spiflash_dummy_len_plus[1] = dummy_bit;
|
||||
@ -508,14 +511,13 @@ static void IRAM_ATTR flash_rom_init(void)
|
||||
spi_dummy_len_fix(1, freqdiv);
|
||||
#endif //CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
#if !CONFIG_IDF_TARGET_ESP32S2 && !CONFIG_IDF_TARGET_ESP32
|
||||
#if !CONFIG_IDF_TARGET_ESP32S2BETA && !CONFIG_IDF_TARGET_ESP32
|
||||
spi_common_set_dummy_output(read_mode);
|
||||
#endif //!CONFIG_IDF_TARGET_ESP32S2
|
||||
esp_rom_spiflash_config_readmode(read_mode);
|
||||
#endif //!CONFIG_IDF_TARGET_ESP32S2BETA
|
||||
esp_rom_spiflash_config_clk(freqdiv, 1);
|
||||
}
|
||||
#else
|
||||
static void IRAM_ATTR flash_rom_init(void)
|
||||
void IRAM_ATTR flash_rom_init(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -524,7 +526,6 @@ static void IRAM_ATTR flash_rom_init(void)
|
||||
esp_err_t IRAM_ATTR spi_flash_write_encrypted(size_t dest_addr, const void *src, size_t size)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
flash_rom_init();
|
||||
CHECK_WRITE_ADDRESS(dest_addr, size);
|
||||
if ((dest_addr % 16) != 0) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
@ -768,7 +769,6 @@ out:
|
||||
|
||||
esp_err_t IRAM_ATTR spi_flash_read_encrypted(size_t src, void *dstv, size_t size)
|
||||
{
|
||||
flash_rom_init();
|
||||
if (src + size > g_rom_flashchip.chip_size) {
|
||||
return ESP_ERR_INVALID_SIZE;
|
||||
}
|
||||
|
@ -411,7 +411,7 @@ UT_020:
|
||||
- psram
|
||||
|
||||
UT_021:
|
||||
extends: .unit_test_32_template
|
||||
extends: .unit_test_template
|
||||
parallel: 2
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
|
Loading…
x
Reference in New Issue
Block a user