From fe6f5aaa70a0d3a21c7ce542258e5c849c3b4687 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 4 Apr 2018 19:21:54 -0500 Subject: [PATCH 1/2] atmel-samd: reset: reset() was always entering bootloader mode .. set the dbl_tap word to a different special value unless RUNMODE_BOOTLOADER was selected --- ports/atmel-samd/common-hal/microcontroller/__init__.c | 2 +- ports/atmel-samd/reset.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ports/atmel-samd/common-hal/microcontroller/__init__.c b/ports/atmel-samd/common-hal/microcontroller/__init__.c index 614fac870b..5839ed5131 100644 --- a/ports/atmel-samd/common-hal/microcontroller/__init__.c +++ b/ports/atmel-samd/common-hal/microcontroller/__init__.c @@ -55,7 +55,7 @@ extern uint32_t _ezero; void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) { // Set up the defaults. - _bootloader_dbl_tap = DBL_TAP_MAGIC; + _bootloader_dbl_tap = DBL_TAP_MAGIC_QUICK_BOOT; _ezero = CIRCUITPY_CANARY_WORD; if (runmode == RUNMODE_BOOTLOADER) { diff --git a/ports/atmel-samd/reset.h b/ports/atmel-samd/reset.h index ea955c655d..b589d26111 100644 --- a/ports/atmel-samd/reset.h +++ b/ports/atmel-samd/reset.h @@ -31,6 +31,7 @@ // Copied from inc/uf2.h in https://github.com/Microsoft/uf2-samd21 #define DBL_TAP_MAGIC 0xf01669ef // Randomly selected, adjusted to have first and last bit set +#define DBL_TAP_MAGIC_QUICK_BOOT 0xf02669ef extern uint32_t _bootloader_dbl_tap; From 92853e611db7e60073631b8f117ccec32106fa6a Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 4 Apr 2018 19:22:17 -0500 Subject: [PATCH 2/2] RunMode: Fix repr(RunMode.BOOTLOADER) --- shared-bindings/microcontroller/RunMode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/microcontroller/RunMode.c b/shared-bindings/microcontroller/RunMode.c index b27a3c0909..7c3f84fcac 100644 --- a/shared-bindings/microcontroller/RunMode.c +++ b/shared-bindings/microcontroller/RunMode.c @@ -76,7 +76,7 @@ STATIC void mcu_runmode_print(const mp_print_t *print, mp_obj_t self_in, mp_prin runmode = MP_QSTR_SAFE_MODE; } else if (MP_OBJ_TO_PTR(self_in) == MP_ROM_PTR(&mcu_runmode_bootloader_obj)) { - runmode = MP_QSTR_SAFE_MODE; + runmode = MP_QSTR_BOOTLOADER; } mp_printf(print, "%q.%q.%q", MP_QSTR_microcontroller, MP_QSTR_RunMode, runmode);