mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
spi_flash: fix the corruption of ROM after calling bootloader_execute_flash_command
The user register, especially dummy related ones, needs to be restored, otherwise the ROM function will not work.
Introduced in dd40123129
This commit is contained in:
parent
1c69e063d2
commit
606955382e
@ -287,6 +287,9 @@ IRAM_ATTR static uint32_t bootloader_flash_execute_command_common(
|
|||||||
assert(mosi_len <= 32);
|
assert(mosi_len <= 32);
|
||||||
assert(miso_len <= 32);
|
assert(miso_len <= 32);
|
||||||
uint32_t old_ctrl_reg = SPIFLASH.ctrl.val;
|
uint32_t old_ctrl_reg = SPIFLASH.ctrl.val;
|
||||||
|
uint32_t old_user_reg = SPIFLASH.user.val;
|
||||||
|
uint32_t old_user1_reg = SPIFLASH.user1.val;
|
||||||
|
|
||||||
SPIFLASH.ctrl.val = SPI_WP_REG_M; // keep WP high while idle, otherwise leave DIO mode
|
SPIFLASH.ctrl.val = SPI_WP_REG_M; // keep WP high while idle, otherwise leave DIO mode
|
||||||
//command phase
|
//command phase
|
||||||
SPIFLASH.user.usr_command = 1;
|
SPIFLASH.user.usr_command = 1;
|
||||||
@ -317,6 +320,8 @@ IRAM_ATTR static uint32_t bootloader_flash_execute_command_common(
|
|||||||
while(SPIFLASH.cmd.usr != 0)
|
while(SPIFLASH.cmd.usr != 0)
|
||||||
{ }
|
{ }
|
||||||
SPIFLASH.ctrl.val = old_ctrl_reg;
|
SPIFLASH.ctrl.val = old_ctrl_reg;
|
||||||
|
SPIFLASH.user.val = old_user_reg;
|
||||||
|
SPIFLASH.user1.val = old_user1_reg;
|
||||||
|
|
||||||
uint32_t ret = SPIFLASH.data_buf[0];
|
uint32_t ret = SPIFLASH.data_buf[0];
|
||||||
if (miso_len < 32) {
|
if (miso_len < 32) {
|
||||||
|
Loading…
Reference in New Issue
Block a user