Skip to content

Commit ddb9f5d

Browse files
author
Jiang Jiang Jian
committed
Merge branch 'fix/fix_mspi_write_stuck_after_reset_v5.5' into 'release/v5.5'
fix(esp_system): fix mspi write stuck after cpu/digital reset on c5/c61 (v5.5) See merge request espressif/esp-idf!43732
2 parents b1e3248 + 83acb84 commit ddb9f5d

File tree

11 files changed

+73
-1
lines changed

11 files changed

+73
-1
lines changed

components/bootloader_support/src/esp32c5/bootloader_esp32c5.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "hal/lpwdt_ll.h"
4444
#include "hal/regi2c_ctrl_ll.h"
4545
#include "hal/brownout_ll.h"
46+
#include "hal/axi_icm_ll.h"
4647

4748
static const char *TAG = "boot.esp32c5";
4849

@@ -85,6 +86,9 @@ static void bootloader_super_wdt_auto_feed(void)
8586

8687
static inline void bootloader_hardware_init(void)
8788
{
89+
// Clear bit reset_event_bypass to ensure that the system bus is also reset during a core reset (WDT),
90+
// preventing bus freezing caused by an incorrect MSPI core reset in ROM.
91+
axi_icm_ll_reset_with_core_reset(true);
8892
_regi2c_ctrl_ll_master_enable_clock(true); // keep ana i2c mst clock always enabled in bootloader
8993
regi2c_ctrl_ll_master_force_enable_clock(true); // TODO: IDF-8667 Remove this?
9094
regi2c_ctrl_ll_master_configure_clock();

components/bootloader_support/src/esp32c61/bootloader_esp32c61.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "hal/lpwdt_ll.h"
4545
#include "hal/regi2c_ctrl_ll.h"
4646
#include "hal/brownout_ll.h"
47+
#include "hal/axi_icm_ll.h"
4748

4849
static const char *TAG = "boot.esp32c61";
4950

@@ -86,6 +87,9 @@ static void bootloader_super_wdt_auto_feed(void)
8687

8788
static inline void bootloader_hardware_init(void)
8889
{
90+
// Clear bit reset_event_bypass to ensure that the system bus is also reset during a core reset (WDT),
91+
// preventing bus freezing caused by an incorrect MSPI core reset in ROM.
92+
axi_icm_ll_reset_with_core_reset(true);
8993
_regi2c_ctrl_ll_master_enable_clock(true); // keep ana i2c mst clock always enabled in bootloader
9094
regi2c_ctrl_ll_master_force_enable_clock(true); // TODO: IDF-9274 Remove this?
9195
regi2c_ctrl_ll_master_configure_clock();

components/esp_system/port/soc/esp32c5/system_internal.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ void esp_system_reset_modules_on_exit(void)
4848
modem_lpcon_ll_reset_all(&MODEM_LPCON);
4949
#endif
5050
// Set Peripheral clk rst
51+
SET_PERI_REG_MASK(PCR_MSPI_CLK_CONF_REG, PCR_MSPI_AXI_RST_EN); // Must reset mspi AXI before reset mspi core.
5152
SET_PERI_REG_MASK(PCR_MSPI_CONF_REG, PCR_MSPI_RST_EN);
5253
SET_PERI_REG_MASK(PCR_UART0_CONF_REG, PCR_UART0_RST_EN);
5354
SET_PERI_REG_MASK(PCR_UART1_CONF_REG, PCR_UART1_RST_EN);
@@ -59,9 +60,11 @@ void esp_system_reset_modules_on_exit(void)
5960
SET_PERI_REG_MASK(PCR_SDIO_SLAVE_CONF_REG, PCR_SDIO_SLAVE_RST_EN);
6061
//ETM may directly control the GPIO or other peripherals even after CPU reset. Reset to stop these control.
6162
SET_PERI_REG_MASK(PCR_ETM_CONF_REG, PCR_ETM_RST_EN);
63+
SET_PERI_REG_MASK(PCR_REGDMA_CONF_REG, PCR_REGDMA_RST_EN);
6264

6365
// Clear Peripheral clk rst
6466
CLEAR_PERI_REG_MASK(PCR_MSPI_CONF_REG, PCR_MSPI_RST_EN);
67+
CLEAR_PERI_REG_MASK(PCR_MSPI_CLK_CONF_REG, PCR_MSPI_AXI_RST_EN); // Must release mspi core reset before mspi AXI.
6568
CLEAR_PERI_REG_MASK(PCR_UART0_CONF_REG, PCR_UART0_RST_EN);
6669
CLEAR_PERI_REG_MASK(PCR_UART1_CONF_REG, PCR_UART1_RST_EN);
6770
CLEAR_PERI_REG_MASK(PCR_SYSTIMER_CONF_REG, PCR_SYSTIMER_RST_EN);
@@ -70,6 +73,7 @@ void esp_system_reset_modules_on_exit(void)
7073
CLEAR_PERI_REG_MASK(PCR_PWM_CONF_REG, PCR_PWM_RST_EN);
7174
CLEAR_PERI_REG_MASK(PCR_SDIO_SLAVE_CONF_REG, PCR_SDIO_SLAVE_RST_EN);
7275
CLEAR_PERI_REG_MASK(PCR_ETM_CONF_REG, PCR_ETM_RST_EN);
76+
CLEAR_PERI_REG_MASK(PCR_REGDMA_CONF_REG, PCR_REGDMA_RST_EN);
7377

7478
// Reset crypto peripherals. This ensures a clean state for the crypto peripherals after a CPU restart
7579
// and hence avoiding any possibility with crypto failure in ROM security workflows.

components/esp_system/port/soc/esp32c6/system_internal.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ void esp_system_reset_modules_on_exit(void)
5353
SET_PERI_REG_MASK(PCR_PWM_CONF_REG, PCR_PWM_RST_EN);
5454
//ETM may directly control the GPIO or other peripherals even after CPU reset. Reset to stop these control.
5555
SET_PERI_REG_MASK(PCR_ETM_CONF_REG, PCR_ETM_RST_EN);
56+
SET_PERI_REG_MASK(PCR_REGDMA_CONF_REG, PCR_REGDMA_RST_EN);
5657

5758
// Clear Peripheral clk rst
5859
CLEAR_PERI_REG_MASK(PCR_MSPI_CONF_REG, PCR_MSPI_RST_EN);
@@ -79,6 +80,7 @@ void esp_system_reset_modules_on_exit(void)
7980
CLEAR_PERI_REG_MASK(PCR_HMAC_CONF_REG, PCR_HMAC_RST_EN);
8081
CLEAR_PERI_REG_MASK(PCR_RSA_CONF_REG, PCR_RSA_RST_EN);
8182
CLEAR_PERI_REG_MASK(PCR_SHA_CONF_REG, PCR_SHA_RST_EN);
83+
CLEAR_PERI_REG_MASK(PCR_REGDMA_CONF_REG, PCR_REGDMA_RST_EN);
8284

8385
// UART's sclk is controlled in the PCR register and does not reset with the UART module. The ROM missed enabling
8486
// it when initializing the ROM UART. If it is not turned on, it will trigger LP_WDT in the ROM.

components/esp_system/port/soc/esp32c61/system_internal.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ void esp_system_reset_modules_on_exit(void)
4848
#endif
4949

5050
// Set Peripheral clk rst
51+
SET_PERI_REG_MASK(PCR_MSPI_CLK_CONF_REG, PCR_MSPI_AXI_RST_EN); // Must reset mspi AXI before reset mspi core.
5152
SET_PERI_REG_MASK(PCR_MSPI_CONF_REG, PCR_MSPI_RST_EN);
5253
SET_PERI_REG_MASK(PCR_UART0_CONF_REG, PCR_UART0_RST_EN);
5354
SET_PERI_REG_MASK(PCR_UART1_CONF_REG, PCR_UART1_RST_EN);
@@ -58,8 +59,10 @@ void esp_system_reset_modules_on_exit(void)
5859
SET_PERI_REG_MASK(PCR_SDIO_SLAVE_CONF_REG, PCR_SDIO_SLAVE_RST_EN);
5960
//ETM may directly control the GPIO or other peripherals even after CPU reset. Reset to stop these control.
6061
SET_PERI_REG_MASK(PCR_ETM_CONF_REG, PCR_ETM_RST_EN);
62+
SET_PERI_REG_MASK(PCR_REGDMA_CONF_REG, PCR_REGDMA_RST_EN);
6163

6264
// Clear Peripheral clk rst
65+
CLEAR_PERI_REG_MASK(PCR_MSPI_CLK_CONF_REG, PCR_MSPI_AXI_RST_EN); // Must release mspi core reset before mspi AXI.
6366
CLEAR_PERI_REG_MASK(PCR_MSPI_CONF_REG, PCR_MSPI_RST_EN);
6467
CLEAR_PERI_REG_MASK(PCR_UART0_CONF_REG, PCR_UART0_RST_EN);
6568
CLEAR_PERI_REG_MASK(PCR_UART1_CONF_REG, PCR_UART1_RST_EN);
@@ -68,6 +71,7 @@ void esp_system_reset_modules_on_exit(void)
6871
CLEAR_PERI_REG_MASK(PCR_MODEM_CONF_REG, PCR_MODEM_RST_EN);
6972
CLEAR_PERI_REG_MASK(PCR_SDIO_SLAVE_CONF_REG, PCR_SDIO_SLAVE_RST_EN);
7073
CLEAR_PERI_REG_MASK(PCR_ETM_CONF_REG, PCR_ETM_RST_EN);
74+
CLEAR_PERI_REG_MASK(PCR_REGDMA_CONF_REG, PCR_REGDMA_RST_EN);
7175

7276
// Reset crypto peripherals. This ensures a clean state for the crypto peripherals after a CPU restart
7377
// and hence avoiding any possibility with crypto failure in ROM security workflows.

components/esp_system/port/soc/esp32h2/system_internal.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ void esp_system_reset_modules_on_exit(void)
5050
SET_PERI_REG_MASK(PCR_PWM_CONF_REG, PCR_PWM_RST_EN);
5151
//ETM may directly control the GPIO or other peripherals even after CPU reset. Reset to stop these control.
5252
SET_PERI_REG_MASK(PCR_ETM_CONF_REG, PCR_ETM_RST_EN);
53+
SET_PERI_REG_MASK(PCR_REGDMA_CONF_REG, PCR_REGDMA_RST_EN);
5354

5455
// Clear Peripheral clk rst
5556
CLEAR_PERI_REG_MASK(PCR_MSPI_CONF_REG, PCR_MSPI_RST_EN);
@@ -60,6 +61,7 @@ void esp_system_reset_modules_on_exit(void)
6061
CLEAR_PERI_REG_MASK(PCR_MODEM_CONF_REG, PCR_MODEM_RST_EN);
6162
CLEAR_PERI_REG_MASK(PCR_PWM_CONF_REG, PCR_PWM_RST_EN);
6263
CLEAR_PERI_REG_MASK(PCR_ETM_CONF_REG, PCR_ETM_RST_EN);
64+
CLEAR_PERI_REG_MASK(PCR_REGDMA_CONF_REG, PCR_REGDMA_RST_EN);
6365

6466
// Reset crypto peripherals. This ensures a clean state for the crypto peripherals after a CPU restart
6567
// and hence avoiding any possibility with crypto failure in ROM security workflows.

components/esp_system/port/soc/esp32h21/system_internal.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ void esp_system_reset_modules_on_exit(void)
5050
SET_PERI_REG_MASK(PCR_PWM_CONF_REG, PCR_PWM_RST_EN);
5151
//ETM may directly control the GPIO or other peripherals even after CPU reset. Reset to stop these control.
5252
SET_PERI_REG_MASK(PCR_ETM_CONF_REG, PCR_ETM_RST_EN);
53+
SET_PERI_REG_MASK(PCR_REGDMA_CONF_REG, PCR_REGDMA_RST_EN);
5354

5455
// Clear Peripheral clk rst
5556
CLEAR_PERI_REG_MASK(PCR_MSPI_CONF_REG, PCR_MSPI_RST_EN);
@@ -60,6 +61,7 @@ void esp_system_reset_modules_on_exit(void)
6061
CLEAR_PERI_REG_MASK(PCR_MODEM_CONF_REG, PCR_MODEM_RST_EN);
6162
CLEAR_PERI_REG_MASK(PCR_PWM_CONF_REG, PCR_PWM_RST_EN);
6263
CLEAR_PERI_REG_MASK(PCR_ETM_CONF_REG, PCR_ETM_RST_EN);
64+
CLEAR_PERI_REG_MASK(PCR_REGDMA_CONF_REG, PCR_REGDMA_RST_EN);
6365

6466
// Reset crypto peripherals. This ensures a clean state for the crypto peripherals after a CPU restart
6567
// and hence avoiding any possibility with crypto failure in ROM security workflows.

components/esp_system/port/soc/esp32h4/system_internal.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ void esp_system_reset_modules_on_exit(void)
3535
}
3636

3737
// Set Peripheral clk rst
38+
SET_PERI_REG_MASK(PCR_MSPI_CLK_CONF_REG, PCR_MSPI_AXI_RST_EN); // Must reset mspi AXI before reset mspi core.
3839
SET_PERI_REG_MASK(PCR_MSPI_CONF_REG, PCR_MSPI_RST_EN);
3940
SET_PERI_REG_MASK(PCR_UART0_CONF_REG, PCR_UART0_RST_EN);
4041
SET_PERI_REG_MASK(PCR_UART1_CONF_REG, PCR_UART1_RST_EN);
@@ -45,9 +46,11 @@ void esp_system_reset_modules_on_exit(void)
4546
SET_PERI_REG_MASK(PCR_PWM1_CONF_REG, PCR_PWM1_RST_EN);
4647
//ETM may directly control the GPIO or other peripherals even after CPU reset. Reset to stop these control.
4748
SET_PERI_REG_MASK(PCR_ETM_CONF_REG, PCR_ETM_RST_EN);
49+
SET_PERI_REG_MASK(PCR_REGDMA_CONF_REG, PCR_REGDMA_RST_EN);
4850

4951
// Clear Peripheral clk rst
5052
CLEAR_PERI_REG_MASK(PCR_MSPI_CONF_REG, PCR_MSPI_RST_EN);
53+
CLEAR_PERI_REG_MASK(PCR_MSPI_CLK_CONF_REG, PCR_MSPI_AXI_RST_EN); // Must release mspi core reset before mspi AXI.
5154
CLEAR_PERI_REG_MASK(PCR_UART0_CONF_REG, PCR_UART0_RST_EN);
5255
CLEAR_PERI_REG_MASK(PCR_UART1_CONF_REG, PCR_UART1_RST_EN);
5356
CLEAR_PERI_REG_MASK(PCR_SYSTIMER_CONF_REG, PCR_SYSTIMER_RST_EN);
@@ -56,6 +59,7 @@ void esp_system_reset_modules_on_exit(void)
5659
CLEAR_PERI_REG_MASK(PCR_PWM0_CONF_REG, PCR_PWM0_RST_EN);
5760
CLEAR_PERI_REG_MASK(PCR_PWM1_CONF_REG, PCR_PWM1_RST_EN);
5861
CLEAR_PERI_REG_MASK(PCR_ETM_CONF_REG, PCR_ETM_RST_EN);
62+
CLEAR_PERI_REG_MASK(PCR_REGDMA_CONF_REG, PCR_REGDMA_RST_EN);
5963

6064
// Reset crypto peripherals. This ensures a clean state for the crypto peripherals after a CPU restart
6165
// and hence avoiding any possibility with crypto failure in ROM security workflows.

components/hal/esp32c5/include/hal/axi_icm_ll.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77

88
#include <stddef.h>
99
#include <stdint.h>
10+
#include <stdbool.h>
1011
#include "hal/assert.h"
1112
#include "soc/hp_system_struct.h"
13+
#include "soc/pcr_struct.h"
1214

1315
#ifdef __cplusplus
1416
extern "C" {
@@ -36,6 +38,15 @@ static inline void axi_icm_ll_set_cache_arbiter_prio(uint8_t priority)
3638
HP_SYSTEM.axi_mst_pri.cache_priority = priority;
3739
}
3840

41+
/**
42+
* @brief Reset system bus with soc core reset.
43+
* @param reset_with_core_reset True to reset system bus with soc core reset.
44+
*/
45+
static inline void axi_icm_ll_reset_with_core_reset(bool reset_with_core_reset)
46+
{
47+
PCR.reset_event_bypass.reset_event_bypass = !reset_with_core_reset;
48+
}
49+
3950
#ifdef __cplusplus
4051
}
4152
#endif

components/hal/esp32c61/include/hal/axi_icm_ll.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77

88
#include <stddef.h>
99
#include <stdint.h>
10+
#include <stdbool.h>
1011
#include "hal/assert.h"
1112
#include "soc/hp_system_struct.h"
13+
#include "soc/pcr_struct.h"
1214

1315
#ifdef __cplusplus
1416
extern "C" {
@@ -36,6 +38,15 @@ static inline void axi_icm_ll_set_cache_arbiter_prio(uint8_t priority)
3638
HP_SYSTEM.system_axi_mst_pri.system_cache_priority = priority;
3739
}
3840

41+
/**
42+
* @brief Reset system bus with soc core reset.
43+
* @param reset_with_core_reset True to reset system bus with soc core reset.
44+
*/
45+
static inline void axi_icm_ll_reset_with_core_reset(bool reset_with_core_reset)
46+
{
47+
PCR.reset_event_bypass.reset_event_bypass = !reset_with_core_reset;
48+
}
49+
3950
#ifdef __cplusplus
4051
}
4152
#endif

0 commit comments

Comments
 (0)