From 5b9b5d9636f8ca00dd55c1382adc7918c8b7f7f0 Mon Sep 17 00:00:00 2001 From: Mahavir Jain Date: Tue, 23 Jun 2020 16:03:08 +0530 Subject: [PATCH] spi_flash: esp32: fix regression in encrypted flash write In commit 309376f51ae01bf0dcfa45d5b00a71657c3df7b2, it seems like regression was added to use ROM level API for disabling flash write protection. This started random firmware crashes (on specific modules) with exception `IllegalInstruction` during encrypted flash writes. Fix here removes relevant ROM API call, since disabling flash write protection is already ensured by caller of this API. Closes https://github.com/espressif/esp-idf/issues/5467 --- components/spi_flash/esp32/flash_ops_esp32.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/components/spi_flash/esp32/flash_ops_esp32.c b/components/spi_flash/esp32/flash_ops_esp32.c index f3605cf7cf..e23e1aa540 100644 --- a/components/spi_flash/esp32/flash_ops_esp32.c +++ b/components/spi_flash/esp32/flash_ops_esp32.c @@ -35,15 +35,11 @@ static inline void IRAM_ATTR spi_flash_guard_end(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; - esp_rom_spiflash_result_t rc; + esp_rom_spiflash_result_t rc = ESP_ROM_SPIFLASH_RESULT_OK; assert((dest_addr % 16) == 0); assert((size % 16) == 0); - rc = esp_rom_spiflash_unlock(); - if (rc != ESP_ROM_SPIFLASH_RESULT_OK) { - return rc; - } /* esp_rom_spiflash_write_encrypted encrypts data in RAM as it writes, so copy to a temporary buffer - 32 bytes at a time.