machine.bootloader
Posted: Wed Apr 07, 2021 9:35 am
Hello, everyone! I want to enter the bootloader to run machine.bootloader() and keep the pb1 pin is high, but the setting is no invalid, as follow code:
How to solve this issue. Thanks!
Code: Select all
STATIC NORETURN mp_obj_t machine_bootloader(size_t n_args, const mp_obj_t *args) {
#if MICROPY_HW_ENABLE_USB
pyb_usb_dev_deinit();
#endif
#if MICROPY_HW_ENABLE_STORAGE
storage_flush();
#endif
__disable_irq();
#if MICROPY_HW_USES_BOOTLOADER
if (n_args == 0 || !mp_obj_is_true(args[0])) {
// By default, with no args given, we enter the custom bootloader (mboot)
[b][u]mp_hal_pin_write(pin_B1, 1);[/u][/b]
powerctrl_enter_bootloader(0x70ad0000, 0x08000000);
}
if (n_args == 1 && mp_obj_is_str_or_bytes(args[0])) {
// With a string/bytes given, pass its data to the custom bootloader
size_t len;
const char *data = mp_obj_str_get_data(args[0], &len);
void *mboot_region = (void *)*((volatile uint32_t *)0x08000000);
memmove(mboot_region, data, len);
powerctrl_enter_bootloader(0x70ad0080, 0x08000000);
}
#endif
#if defined(STM32F7) || defined(STM32H7)
powerctrl_enter_bootloader(0, 0x1ff00000);
#else
powerctrl_enter_bootloader(0, 0x00000000);
#endif
while (1) {
;
}