renesas-ra/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:
iabdalkader 2022-06-07 19:13:08 +02:00 committed by Damien George
parent f522aabab2
commit c5d26ee5e7
3 changed files with 9 additions and 1 deletions

View File

@ -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

View File

@ -47,6 +47,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 "storage.h" #include "storage.h"
#include "pin.h" #include "pin.h"
@ -182,13 +183,15 @@ 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_STORAGE #if MICROPY_HW_ENABLE_STORAGE
storage_flush(); storage_flush();
#endif #endif
__disable_irq(); __disable_irq();
MICROPY_BOARD_ENTER_BOOTLOADER(n_args, args);
#if MICROPY_HW_USES_BOOTLOADER #if MICROPY_HW_USES_BOOTLOADER
// ToDo: need to review how to implement // ToDo: need to review how to implement

View File

@ -49,6 +49,7 @@ void machine_deinit(void);
void machine_pin_init(void); void machine_pin_init(void);
void machine_pin_deinit(void); void machine_pin_deinit(void);
void machine_i2s_init0(void); void machine_i2s_init0(void);
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);