8000 stm32: Use a separate symbol name for the bootloader state pointer. · DucRP/micropython@2c01537 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2c01537

Browse files
projectgusdpgeorge
authored andcommitted
stm32: Use a separate symbol name for the bootloader state pointer.
Prerequisite for enabling Link Time Optimisation. The _bl_state address is the same as _estack, but _estack is referred to as a uint32_t elsewhere in the code. LTO doesn't like it when the same symbol has two different types. Signed-off-by: Angus Gratton <gus@projectgus.com>
1 parent 5b66d08 commit 2c01537

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

ports/stm32/boards/common_bss_heap_stack.ld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@
2626
. = . + _minimum_stack_size;
2727
. = ALIGN(4);
2828
} >RAM
29+
30+
/* _bl_state symbol is used by MICROPY_HW_ENTER_BOOTLOADER_VIA_RESET, this is
31+
the end of stack address but is accessed as a different type. */
32+
_bl_state = _estack;

ports/stm32/powerctrl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
// Location in RAM of bootloader state (just after the top of the stack).
7979
// STM32H7 has ECC and writes to RAM must be 64-bit so they are fully committed
8080
// to actual SRAM before a system reset occurs.
81-
#define BL_STATE_PTR ((uint64_t *)&_estack)
81+
#define BL_STATE_PTR ((uint64_t *)&_bl_state)
8282
#define BL_STATE_KEY (0x5a5)
8383
#define BL_STATE_KEY_MASK (0xfff)
8484
#define BL_STATE_KEY_SHIFT (32)
@@ -87,7 +87,7 @@
8787
#define BL_STATE_GET_REG(s) ((s) & 0xffffffff)
8888
#define BL_STATE_GET_KEY(s) (((s) >> BL_STATE_KEY_SHIFT) & BL_STATE_KEY_MASK)
8989
#define BL_STATE_GET_ADDR(s) (((s) >> BL_STATE_KEY_SHIFT) & ~BL_STATE_KEY_MASK)
90-
extern uint64_t _estack[];
90+
extern uint64_t _bl_state[];
9191
#endif
9292

9393
static inline void powerctrl_disable_hsi_if_unused(void) {

0 commit comments

Comments
 (0)
0