File tree 4 files changed +8
-3
lines changed
common-hal/microcontroller
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) {
55
55
}
56
56
57
57
extern uint32_t _ezero ;
58
- extern uint32_t _srelocate ;
59
58
60
59
void common_hal_mcu_on_next_reset (mcu_runmode_t runmode ) {
61
60
// Set up the defaults.
62
61
_bootloader_dbl_tap = DBL_TAP_MAGIC ;
63
62
_ezero = CIRCUITPY_CANARY_WORD ;
64
63
65
64
if (runmode == RUNMODE_BOOTLOADER ) {
66
- if (& _bootloader_dbl_tap < & _srelocate ) {
65
+ if (! bootloader_available () ) {
67
66
mp_raise_ValueError ("Cannot reset into bootloader because no bootloader is present." );
68
67
}
69
68
// 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;
62
62
63
63
void usb_dtr_notify (uint8_t port , bool set ) {
64
64
mp_cdc_enabled = set ;
65
- if (!set && reset_on_disconnect && _bootloader_dbl_tap != 0 ) {
65
+ if (!set && reset_on_disconnect && bootloader_available () ) {
66
66
reset_to_bootloader ();
67
67
}
68
68
}
Original file line number Diff line number Diff line change @@ -38,3 +38,8 @@ void reset_to_bootloader(void) {
38
38
_bootloader_dbl_tap = DBL_TAP_MAGIC ;
39
39
reset ();
40
40
}
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;
33
33
34
34
void reset_to_bootloader (void );
35
35
void reset (void );
36
+ bool bootloader_available (void );
36
37
37
38
#endif // MICROPY_INCLUDED_ATMEL_SAMD_RESET_H
You can’t perform that action at this time.
0 commit comments