From ce580fa8c627f49b551091291e3db7610ad0314f Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 4 May 2022 22:04:48 -0400 Subject: [PATCH] canboot_main: Make entry via double reset a config option Signed-off-by: Kevin O'Connor --- src/Kconfig | 4 ++++ src/canboot_main.c | 22 +++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/Kconfig b/src/Kconfig index 00c8a0c..8fecb9f 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -16,6 +16,10 @@ config CANBUS_FREQUENCY int "CAN bus speed" default 500000 +config ENABLE_DOUBLE_RESET + bool "Support bootloader entry on rapid double click of reset button" + default y + config ENABLE_LED bool "Enable Status LED" default n diff --git a/src/canboot_main.c b/src/canboot_main.c index 8054469..d623be2 100644 --- a/src/canboot_main.c +++ b/src/canboot_main.c @@ -219,6 +219,20 @@ check_application_code(void) return 0; } +// Check for a bootloader request via double tap of reset button +static void +check_double_reset(void) +{ + if (!CONFIG_ENABLE_DOUBLE_RESET) + return; + // set request signature and delay for two seconds. This enters the bootloader if + // the reset button is double clicked + set_bootup_code(REQUEST_SIG); + udelay(2000000); + set_bootup_code(0); + // No reset, read the key back out to clear it +} + /**************************************************************** * Startup @@ -255,13 +269,7 @@ canboot_main(void) set_bootup_code(0); enter_bootloader(); } - - // set request signature and delay for two seconds. This enters the bootloader if - // the reset button is double clicked - set_bootup_code(REQUEST_SIG); - udelay(2000000); - set_bootup_code(0); - // No reset, read the key back out to clear it + check_double_reset(); // jump to app jump_to_application();