8000 stm32: Support custom reset to bootloader via board config define. · micropython/micropython@74e3a51 · GitHub
[go: up one dir, main page]

Skip to content

Commit 74e3a51

Browse files
committed
stm32: Support custom reset to bootloader via board config define.
1 parent fd0ab4e commit 74e3a51

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

ports/stm32/boards/ARDUINO_PORTENTA_H7/mpconfigboard.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,22 @@ typedef unsigned int mp_uint_t; // must be pointer size
2727
#define MICROPY_HW_ENABLE_TIMER (1)
2828
#define MICROPY_HW_ENABLE_SDCARD (1)
2929
#define MICROPY_HW_ENABLE_MMCARD (0)
30+
31+
// Flash storage config
3032
#define MICROPY_HW_SPIFLASH_ENABLE_CACHE (1)
3133
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0)
3234

35+
// Using a custom bootloader
36+
#define MICROPY_HW_ENTER_BOOTLOADER_VIA_RESET (0)
37+
3338
#define MICROPY_BOARD_STARTUP PORTENTA_board_startup
3439
void PORTENTA_board_startup(void);
3540

3641
#define MICROPY_BOARD_EARLY_INIT PORTENTA_board_early_init
3742
void PORTENTA_board_early_init(void);
3843

3944
#define MICROPY_RESET_TO_BOOTLOADER PORTENTA_reboot_to_bootloader
40-
void PORTENTA_reboot_to_bootloader(void);
45+
void PORTENTA_reboot_to_bootloader(void) __attribute__((noreturn));
4146

4247
void PORTENTA_board_low_power(int mode);
4348
#define MICROPY_BOARD_LEAVE_STOP PORTENTA_board_low_power(0);

ports/stm32/powerctrl.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ NORETURN void powerctrl_mcu_reset(void) {
107107
NVIC_SystemReset();
108108
}
109109

110+
#if MICROPY_HW_ENTER_BOOTLOADER_VIA_RESET || !defined(MICROPY_RESET_TO_BOOTLOADER)
110111
NORETURN static __attribute__((naked)) void branch_to_bootloader(uint32_t r0, uint32_t bl_addr) {
111112
__asm volatile (
112113
"ldr r2, [r1, #0]\n" // get address of stack pointer
@@ -116,9 +117,14 @@ NORETURN static __attribute__((naked)) void branch_to_bootloader(uint32_t r0, ui
116117
);
117118
MP_UNREACHABLE;
118119
}
120+
#endif
119121

120122
NORETURN void powerctrl_enter_bootloader(uint32_t r0, uint32_t bl_addr) {
121-
#if MICROPY_HW_ENTER_BOOTLOADER_VIA_RESET
123+
#if defined(MICROPY_RESET_TO_BOOTLOADER)
124+
125+
MICROPY_RESET_TO_BOOTLOADER();
126+
127+
#elif MICROPY_HW_ENTER_BOOTLOADER_VIA_RESET
122128

123129
// Enter the bootloader via a reset, so everything is reset (including WDT).
124130
// Upon reset powerctrl_check_enter_bootloader() will jump to the bootloader.

0 commit comments

Comments
 (0)
0