Skip to content

Commit 39f30ae

Browse files
committed
Fix 1200 baud reset.
Fixes adafruit#494
1 parent ec1d29f commit 39f30ae

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

atmel-samd/common-hal/microcontroller/__init__.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,14 @@ void common_hal_mcu_enable_interrupts(void) {
5555
}
5656

5757
extern uint32_t _ezero;
58-
extern uint32_t _srelocate;
5958

6059
void 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

atmel-samd/mphalport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ volatile bool reset_on_disconnect = false;
6262

6363
void 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
}

atmel-samd/reset.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
}

atmel-samd/reset.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ extern uint32_t _bootloader_dbl_tap;
3333

3434
void reset_to_bootloader(void);
3535
void reset(void);
36+
bool bootloader_available(void);
3637

3738
#endif // MICROPY_INCLUDED_ATMEL_SAMD_RESET_H

0 commit comments

Comments
 (0)