microsoft / uf2-samdx1

USB Mass Storage bootloader (based on UF2) for SAMD21 and SAMD51
Other
251 stars 309 forks source link

Single Button Press into Bootloader #38

Closed brendanvanbreda closed 6 years ago

brendanvanbreda commented 6 years ago

I am attempting to build a custom binary release for a custom board, with reference about the reset procedure.

When looking through uf2.h

// If enabled, bootloader will start on power-on and every reset. A second reset
// will start the app. This only happens if the app says it wants that (see SINGLE_RESET() below).
// If disabled here or by the app, the bootloader will only start with double-click of the reset
// button.
#define USE_SINGLE_RESET 1

If this value is set to 0, should the expected result be that the bootloader will become active on a single reset ?

As when working in maker.makecode with the Arduino Zero it makes use of a single reset to enable the bootloader. In comparison to when converting a .bin file from Arduino to a .UF2 it would still require a second reset. This occures between uploads of the UF2 file from the different sources.

mmoskal commented 6 years ago

To get single-reset behavior on Arduino-generated binaries you will need to set USE_SINGLE_RESET to 1, and also modify:

#define SINGLE_RESET() (*((uint32_t *)0x20B4) == 0x87eeb07c)

to

#define SINGLE_RESET() 1

Let me know if it didn't work!

brendanvanbreda commented 6 years ago

Awesome thanx @mmoskal worked as expected.

TamojitSaha commented 5 years ago

Is it possible to have a key combination to enter into bootloader mode?

mmoskal commented 5 years ago

You could probably quite easily modify the bootloader to support that - just configure the pin as input with a pull up (or pulldown, depending on how your button is wired) and return at the beginning of check_start_application() when your button is pressed.