Skip to content

Commit

Permalink
Rework bootloader entry to be off by default, allow opting-in.
Browse files Browse the repository at this point in the history
  • Loading branch information
tzarc committed Apr 12, 2020
1 parent a370c5b commit d29fd61
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/platformdev_chibios_earlyinit.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The function `early_hardware_init_pre` is the earliest possible code that can be

This is executed before RAM gets cleared, and before clocks or GPIOs are configured; any delays or preparation using GPIOs is not likely to work at this point. After executing this function, RAM on the MCU may be zero'ed. Assigning values to variables during execution of this function may be overwritten.

As such, if you wish to override this API consider limiting use to writing to low-level registers. The default implementation of this function is to do nothing.
As such, if you wish to override this API consider limiting use to writing to low-level registers. The default implementation of this function can be configured to jump to bootloader if a `RESET` key was pressed, by ensuring `#define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE` is in the keyboard's `config.h` file.

To implement your own version of this function, in your keyboard's source files:

Expand Down
9 changes: 7 additions & 2 deletions tmk_core/protocol/chibios/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
#include "debug.h"
#include "printf.h"

#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
// Change this to be TRUE once we've migrated keyboards to the new init system
# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP FALSE
#endif

#ifdef SLEEP_LED_ENABLE
# include "sleep_led.h"
#endif
Expand Down Expand Up @@ -104,10 +109,10 @@ void midi_ep_task(void);
/* Early initialisation
*/
__attribute__((weak)) void early_hardware_init_pre(void) {
#if defined(ENABLE_STM32_BOOTLOADER_ADDRESS) && defined(STM32_BOOTLOADER_ADDRESS) // remove the FALSE when we've migrated all existing __early_init invocations
#if EARLY_INIT_PERFORM_BOOTLOADER_JUMP
void enter_bootloader_mode_if_requested(void);
enter_bootloader_mode_if_requested();
#endif
#endif // EARLY_INIT_PERFORM_BOOTLOADER_JUMP
}

__attribute__((weak)) void early_hardware_init_post(void) {}
Expand Down

0 comments on commit d29fd61

Please sign in to comment.