File tree Expand file tree Collapse file tree 4 files changed +8
-3
lines changed
common-hal/microcontroller Expand file tree Collapse file tree 4 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -55,15 +55,14 @@ void common_hal_mcu_enable_interrupts(void) {
5555}
5656
5757extern uint32_t _ezero ;
58- extern uint32_t _srelocate ;
5958
6059void common_hal_mcu_on_next_reset (mcu_runmode_t runmode ) {
6160 // Set up the defaults.
6261 _bootloader_dbl_tap = DBL_TAP_MAGIC ;
6362 _ezero = CIRCUITPY_CANARY_WORD ;
6463
6564 if (runmode == RUNMODE_BOOTLOADER ) {
66- if (& _bootloader_dbl_tap < & _srelocate ) {
65+ if (! bootloader_available () ) {
6766 mp_raise_ValueError ("Cannot reset into bootloader because no bootloader is present." );
6867 }
6968 // Pretend to be the first of the two reset presses needed to enter the
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ volatile bool reset_on_disconnect = false;
6262
6363void usb_dtr_notify (uint8_t port , bool set ) {
6464 mp_cdc_enabled = set ;
65- if (!set && reset_on_disconnect && _bootloader_dbl_tap != 0 ) {
65+ if (!set && reset_on_disconnect && bootloader_available () ) {
6666 reset_to_bootloader ();
6767 }
6868}
Original file line number Diff line number Diff line change @@ -38,3 +38,8 @@ void reset_to_bootloader(void) {
3838 _bootloader_dbl_tap = DBL_TAP_MAGIC ;
3939 reset ();
4040}
41+
42+ extern uint32_t _srelocate ;
43+ bool bootloader_available (void ) {
44+ return & _bootloader_dbl_tap >= & _srelocate ;
45+ }
Original file line number Diff line number Diff line change @@ -33,5 +33,6 @@ extern uint32_t _bootloader_dbl_tap;
3333
3434void reset_to_bootloader (void );
3535void reset (void );
36+ bool bootloader_available (void );
3637
3738#endif // MICROPY_INCLUDED_ATMEL_SAMD_RESET_H
You can’t perform that action at this time.
0 commit comments