samd: Support entering bootloader via USB CDC 1200bps touch.

This commit is contained in:
robert-hh 2022-12-11 15:33:16 +01:00 committed by Damien George
parent e69313f89c
commit 17ab2f671b
4 changed files with 7 additions and 3 deletions

View File

@ -117,6 +117,7 @@ SHARED_SRC_C += \
shared/runtime/stdout_helpers.c \
shared/runtime/sys_stdio_mphal.c \
shared/timeutils/timeutils.c \
shared/tinyusb/mp_cdc_common.c \
ASF4_SRC_C += $(addprefix lib/asf4/$(MCU_SERIES_LOWER)/,\
hal/src/hal_atomic.c \

View File

@ -74,15 +74,14 @@ STATIC mp_obj_t machine_reset(void) {
}
MP_DEFINE_CONST_FUN_OBJ_0(machine_reset_obj, machine_reset);
STATIC mp_obj_t machine_bootloader(void) {
NORETURN mp_obj_t machine_bootloader(size_t n_args, const mp_obj_t *args) {
*DBL_TAP_ADDR = DBL_TAP_MAGIC_LOADER;
#ifdef DBL_TAP_ADDR_ALT
*DBL_TAP_ADDR_ALT = DBL_TAP_MAGIC_LOADER;
#endif
NVIC_SystemReset();
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_0(machine_bootloader_obj, machine_bootloader);
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_bootloader_obj, 0, 1, machine_bootloader);
STATIC mp_obj_t machine_freq(size_t n_args, const mp_obj_t *args) {
if (n_args == 0) {

View File

@ -41,4 +41,6 @@ extern const mp_obj_type_t machine_wdt_type;
extern const mp_obj_type_t machine_rtc_type;
#endif
NORETURN mp_obj_t machine_bootloader(size_t n_args, const mp_obj_t *args);
#endif // MICROPY_INCLUDED_SAMD_MODMACHINE_H

View File

@ -58,7 +58,9 @@
#define MICROPY_PY_BUILTINS_HELP_TEXT samd_help_text
#define MICROPY_PY_BUILTINS_HELP_MODULES (1)
#define MICROPY_ENABLE_SCHEDULER (1)
#define MICROPY_SCHEDULER_STATIC_NODES (1)
#define MICROPY_MODULE_WEAK_LINKS (1)
#define MICROPY_HW_USB_CDC_1200BPS_TOUCH (1)
// Control over Python builtins
#define MICROPY_PY_BUILTINS_BYTES_HEX (1)