Skip to content

Commit b7457e0

Browse files
committed
Rework workaround for STM32H7 DTCM retention issue
1 parent c5afd1a commit b7457e0

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

Bootloader/Adapters/Src/system_adapter.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@
3535
#include "main.h"
3636
#include "system_adapter.h"
3737

38+
#include "binary_update.h"
39+
40+
extern __attribute__ ((section(".restart_info")))
41+
volatile bootInfo_S boot_info;
42+
3843
void
3944
SystemAdapter_reset(void) {
45+
46+
boot_info.end = 0xFF; // Resolve known issue with STM32H7 MCUs. Memory must be written before reset to ensure data retention.
4047
HAL_NVIC_SystemReset();
4148
}

Bootloader/Inc/binary_update.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141

4242
#pragma pack(push, 1)
4343
typedef struct bootInfo {
44-
uint32_t jump_address; //!< Address for BL to jump
45-
bool skip_bl_loop; //!< Flag to skip BL loop
46-
uint8_t end; // FIXME: added here because after restart something is messing up with data in the structure and if there is an extra byte at the end it messes only with it
44+
uint32_t jump_address; //!< Address for BL to jump
45+
bool skip_bl_loop; //!< Flag to skip BL loop
46+
uint8_t end; //!< MCUs like the STM32H7 have issues preserving certain data unless an additional byte is written before reset.
4747
} bootInfo_S;
4848
#pragma pack(pop)
4949

Bootloader/Src/binary_update.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,6 @@ BinaryUpdate_finish(void) {
250250
break;
251251
}
252252

253-
boot_info.end = 0xFF;
254-
255253
return success;
256254
}
257255

0 commit comments

Comments
 (0)