File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -6687,6 +6687,9 @@ static struct mg_flash s_mg_flash_stm32h7 = {
6687
6687
#define FLASH_OPTSR_PRG 0x20
6688
6688
#define FLASH_SIZE_REG 0x1ff1e880
6689
6689
6690
+ #define STM_DBGMCU_IDCODE 0x5C001000
6691
+ #define STM_DEV_ID (MG_REG(STM_DBGMCU_IDCODE) & (MG_BIT(12) - 1))
6692
+
6690
6693
MG_IRAM static bool is_dualbank(void) {
6691
6694
return (s_mg_flash_stm32h7.size < 2 * 1024 * 1024) ? false : true;
6692
6695
}
@@ -6773,6 +6776,12 @@ MG_IRAM static bool mg_stm32h7_swap(void) {
6773
6776
flash_clear_err(bank);
6774
6777
// printf("OPTSR_PRG 1 %#lx\n", FLASH->OPTSR_PRG);
6775
6778
MG_SET_BITS(MG_REG(bank + FLASH_OPTSR_PRG), MG_BIT(31), desired);
6779
+ if (STM_DEV_ID == 0x450) {
6780
+ // H745/H755 and H747/H757 are running on dual core
6781
+ // Disable CM4 to prevent the old and the new firmwares from booting
6782
+ // simultaneously on each core.
6783
+ MG_SET_BITS(MG_REG(bank + FLASH_OPTSR_PRG), MG_BIT(22), 0);
6784
+ }
6776
6785
// printf("OPTSR_PRG 2 %#lx\n", FLASH->OPTSR_PRG);
6777
6786
MG_REG(bank + FLASH_OPTCR) |= MG_BIT(1); // OPTSTART
6778
6787
while ((MG_REG(bank + FLASH_OPTSR_CUR) & MG_BIT(31)) != desired) (void) 0;
Original file line number Diff line number Diff line change @@ -35,6 +35,9 @@ static struct mg_flash s_mg_flash_stm32h7 = {
35
35
#define FLASH_OPTSR_PRG 0x20
36
36
#define FLASH_SIZE_REG 0x1ff1e880
37
37
38
+ #define STM_DBGMCU_IDCODE 0x5C001000
39
+ #define STM_DEV_ID (MG_REG(STM_DBGMCU_IDCODE) & (MG_BIT(12) - 1))
40
+
38
41
MG_IRAM static bool is_dualbank (void ) {
39
42
return (s_mg_flash_stm32h7 .size < 2 * 1024 * 1024 ) ? false : true;
40
43
}
@@ -121,6 +124,12 @@ MG_IRAM static bool mg_stm32h7_swap(void) {
121
124
flash_clear_err (bank );
122
125
// printf("OPTSR_PRG 1 %#lx\n", FLASH->OPTSR_PRG);
123
126
MG_SET_BITS (MG_REG (bank + FLASH_OPTSR_PRG ), MG_BIT (31 ), desired );
127
+ if (STM_DEV_ID == 0x450 ) {
128
+ // H745/H755 and H747/H757 are running on dual core
129
+ // Disable CM4 to prevent the old and the new firmwares from booting
130
+ // simultaneously on each core.
131
+ MG_SET_BITS (MG_REG (bank + FLASH_OPTSR_PRG ), MG_BIT (22 ), 0 );
132
+ }
124
133
// printf("OPTSR_PRG 2 %#lx\n", FLASH->OPTSR_PRG);
125
134
MG_REG (bank + FLASH_OPTCR ) |= MG_BIT (1 ); // OPTSTART
126
135
while ((MG_REG (bank + FLASH_OPTSR_CUR ) & MG_BIT (31 )) != desired ) (void ) 0 ;
You can’t perform that action at this time.
0 commit comments