stm32/modmachine: Allow boards to provide custom bootloader code.
And expose the machine_bootloader() C function so it can be used elsewhere.
This commit is contained in:
committed by
Damien George
parent
921dd94676
commit
0adf0dd3d7
@@ -37,6 +37,10 @@
|
|||||||
#define MICROPY_BOARD_STARTUP powerctrl_check_enter_bootloader
|
#define MICROPY_BOARD_STARTUP powerctrl_check_enter_bootloader
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef MICROPY_BOARD_ENTER_BOOTLOADER
|
||||||
|
#define MICROPY_BOARD_ENTER_BOOTLOADER(nargs, args)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef MICROPY_BOARD_EARLY_INIT
|
#ifndef MICROPY_BOARD_EARLY_INIT
|
||||||
#define MICROPY_BOARD_EARLY_INIT()
|
#define MICROPY_BOARD_EARLY_INIT()
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ void PORTENTA_board_startup(void);
|
|||||||
#define MICROPY_BOARD_EARLY_INIT PORTENTA_board_early_init
|
#define MICROPY_BOARD_EARLY_INIT PORTENTA_board_early_init
|
||||||
void PORTENTA_board_early_init(void);
|
void PORTENTA_board_early_init(void);
|
||||||
|
|
||||||
#define MICROPY_BOARD_ENTER_BOOTLOADER PORTENTA_board_enter_bootloader
|
#define MICROPY_BOARD_ENTER_BOOTLOADER(nargs, args) PORTENTA_board_enter_bootloader()
|
||||||
void PORTENTA_board_enter_bootloader(void);
|
void PORTENTA_board_enter_bootloader(void);
|
||||||
|
|
||||||
void PORTENTA_board_low_power(int mode);
|
void PORTENTA_board_low_power(int mode);
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
#include "gccollect.h"
|
#include "gccollect.h"
|
||||||
#include "irq.h"
|
#include "irq.h"
|
||||||
#include "powerctrl.h"
|
#include "powerctrl.h"
|
||||||
|
#include "boardctrl.h"
|
||||||
#include "pybthread.h"
|
#include "pybthread.h"
|
||||||
#include "rng.h"
|
#include "rng.h"
|
||||||
#include "storage.h"
|
#include "storage.h"
|
||||||
@@ -270,7 +271,7 @@ STATIC mp_obj_t machine_soft_reset(void) {
|
|||||||
MP_DEFINE_CONST_FUN_OBJ_0(machine_soft_reset_obj, machine_soft_reset);
|
MP_DEFINE_CONST_FUN_OBJ_0(machine_soft_reset_obj, machine_soft_reset);
|
||||||
|
|
||||||
// Activate the bootloader without BOOT* pins.
|
// Activate the bootloader without BOOT* pins.
|
||||||
STATIC NORETURN mp_obj_t machine_bootloader(size_t n_args, const mp_obj_t *args) {
|
NORETURN mp_obj_t machine_bootloader(size_t n_args, const mp_obj_t *args) {
|
||||||
#if MICROPY_HW_ENABLE_USB
|
#if MICROPY_HW_ENABLE_USB
|
||||||
pyb_usb_dev_deinit();
|
pyb_usb_dev_deinit();
|
||||||
#endif
|
#endif
|
||||||
@@ -280,6 +281,8 @@ STATIC NORETURN mp_obj_t machine_bootloader(size_t n_args, const mp_obj_t *args)
|
|||||||
|
|
||||||
__disable_irq();
|
__disable_irq();
|
||||||
|
|
||||||
|
MICROPY_BOARD_ENTER_BOOTLOADER(n_args, args);
|
||||||
|
|
||||||
#if MICROPY_HW_USES_BOOTLOADER
|
#if MICROPY_HW_USES_BOOTLOADER
|
||||||
if (n_args == 0 || !mp_obj_is_true(args[0])) {
|
if (n_args == 0 || !mp_obj_is_true(args[0])) {
|
||||||
// By default, with no args given, we enter the custom bootloader (mboot)
|
// By default, with no args given, we enter the custom bootloader (mboot)
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ extern const mp_obj_type_t machine_i2s_type;
|
|||||||
void machine_init(void);
|
void machine_init(void);
|
||||||
void machine_deinit(void);
|
void machine_deinit(void);
|
||||||
void machine_i2s_init0();
|
void machine_i2s_init0();
|
||||||
|
NORETURN mp_obj_t machine_bootloader(size_t n_args, const mp_obj_t *args);
|
||||||
|
|
||||||
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(machine_info_obj);
|
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(machine_info_obj);
|
||||||
MP_DECLARE_CONST_FUN_OBJ_0(machine_unique_id_obj);
|
MP_DECLARE_CONST_FUN_OBJ_0(machine_unique_id_obj);
|
||||||
|
|||||||
Reference in New Issue
Block a user