Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ The bootloader can be built to look for arbitrary patterns, but the default for

The bootloader currently looks for `0x544F` in RTC backup register 1 and `0x4F42` in RTC backup register 0 (together they spell "BOOT" in ASCII).

You can also use a button to stay in bootloader while booting. It's configured using `HAVE_BUTTON` define. If your button has a debounce capacitor, you can use `BUTTON_SAMPLE_DELAY_CYCLES` define to specify how many cycles to wait before sampling the I/O pin, by default it is approximately 20ms in a 72Mhz MCU.

### WebUSB
This bootloader implements the draft [WebUSB](https://wicg.github.io/webusb/) specification, which allows web pages to access the bootloader (after presenting the user with a device picker dialog).

Expand Down
4 changes: 4 additions & 0 deletions src/stm32f103/generic/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
#define HAVE_BUTTON 0
#endif

#ifndef BUTTON_SAMPLE_DELAY_CYCLES
#define BUTTON_SAMPLE_DELAY_CYCLES 1440000
#endif

#ifndef HAVE_USB_PULLUP_CONTROL
#define HAVE_USB_PULLUP_CONTROL 0
#endif
Expand Down
5 changes: 5 additions & 0 deletions src/stm32f103/target_stm32f103.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ bool target_get_force_bootloader(void) {
backup_write(BKP0, 0);

#if HAVE_BUTTON
/* Wait sometime in case the button has some debounce capacitor */
int i;
for (i = 0; i < BUTTON_SAMPLE_DELAY_CYCLES; i++) {
__asm__("nop");
}
/* Check if the user button is held down */
if (BUTTON_ACTIVE_HIGH) {
if (gpio_get(BUTTON_GPIO_PORT, BUTTON_GPIO_PIN)) {
Expand Down