adafruit / uf2-samdx1

MSC bootloader (based on UF2) for SAMD21
Other
210 stars 182 forks source link

Triggering Bootloader from User Code #98

Closed zjwhitehead closed 4 years ago

zjwhitehead commented 4 years ago

I'm looking for a way to boot the Feather M0 into the UF2 bootloader without pressing the reset button twice. I know how to reset the device through the watchdog but that just creates a reboot loop without entering the bootloader.

How can I trigger a reboot into bootloader either from a) setting a fuse and rebooting? b) customize the bootloader to detect a button/pin being held on boot c) different way other than using the reset button

ladyada commented 4 years ago

you can set the 'magic memory location' and then jump to address 0 (or WDT reset or however)

https://github.com/adafruit/CircuitPlaygroundFirmata/blob/e13918e8ea65ceee263e72caa3748790a073a24b/CircuitPlaygroundFirmata_Express_CodeOrg/CircuitPlaygroundFirmata_Express_CodeOrg.ino#L1442

tannewt commented 4 years ago

Here is where we do it in CircuitPython: https://github.com/adafruit/circuitpython/blob/master/ports/atmel-samd/common-hal/microcontroller/__init__.c#L66