From d1a447f6c06cd7318f2fb2abe5c3bbb3edd8e5e6 Mon Sep 17 00:00:00 2001 From: Marek Matej Date: Thu, 27 Apr 2023 16:20:30 +0200 Subject: [PATCH] bootloader_support: fix register backup By storing the 'user2' register during the early init we fix the flash access issue, which occurs in the Zephyr/MCUboot ports for ESP32. Signed-off-by: Marek Matej --- .../bootloader_support/bootloader_flash/src/bootloader_flash.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/bootloader_support/bootloader_flash/src/bootloader_flash.c b/components/bootloader_support/bootloader_flash/src/bootloader_flash.c index b6eaf62945..9458d3dfb9 100644 --- a/components/bootloader_support/bootloader_flash/src/bootloader_flash.c +++ b/components/bootloader_support/bootloader_flash/src/bootloader_flash.c @@ -553,6 +553,7 @@ IRAM_ATTR uint32_t bootloader_flash_execute_command_common( uint32_t old_ctrl_reg = SPIFLASH.ctrl.val; uint32_t old_user_reg = SPIFLASH.user.val; uint32_t old_user1_reg = SPIFLASH.user1.val; + uint32_t old_user2_reg = SPIFLASH.user2.val; #if CONFIG_IDF_TARGET_ESP32 SPIFLASH.ctrl.val = SPI_WP_REG_M; // keep WP high while idle, otherwise leave DIO mode #else @@ -599,6 +600,7 @@ IRAM_ATTR uint32_t bootloader_flash_execute_command_common( SPIFLASH.ctrl.val = old_ctrl_reg; SPIFLASH.user.val = old_user_reg; SPIFLASH.user1.val = old_user1_reg; + SPIFLASH.user2.val = old_user2_reg; uint32_t ret = SPIFLASH.data_buf[0]; if (miso_len < 32) {