From de0f514432b26f0acae2fc9a7ec2b969ee25cbb1 Mon Sep 17 00:00:00 2001 From: kieranc Date: Wed, 10 Mar 2021 15:31:57 +0100 Subject: [PATCH 1/2] Add check if the button is held for the whole 5 seconds If the button is held down to reboot the watch and not released after the reboot, the device can enter recovery mode unintentionally. This check aims to ignore the button if it is held for the entirety of the 5 second delay, implying it was held before the device started to boot and should be ignored. --- libs/pinetime_boot/src/pinetime_boot.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/pinetime_boot/src/pinetime_boot.c b/libs/pinetime_boot/src/pinetime_boot.c index 0bad594..7efb001 100644 --- a/libs/pinetime_boot/src/pinetime_boot.c +++ b/libs/pinetime_boot/src/pinetime_boot.c @@ -93,6 +93,10 @@ void pinetime_boot_init(void) { console_printf("Waited 5 seconds (%d)\n", (int)button_samples); console_flush(); // Check whether button is pressed and held. Sample count must high enough to avoid accidental rollbacks. + if(button_samples == (3000 * 64 * 5)) { + console_printf("Button held for 5 seconds - ignoring\n"); console_flush(); + } + if(button_samples > (3000 * 64 * 4)) { console_printf("Restoring factory firmware\n"); console_flush(); restore_factory(); From db8491ae9ca5476910248371ab0e3fd248455c19 Mon Sep 17 00:00:00 2001 From: kieranc Date: Wed, 10 Mar 2021 16:03:46 +0100 Subject: [PATCH 2/2] Update pinetime_boot.c --- libs/pinetime_boot/src/pinetime_boot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/pinetime_boot/src/pinetime_boot.c b/libs/pinetime_boot/src/pinetime_boot.c index 7efb001..fc4d6c3 100644 --- a/libs/pinetime_boot/src/pinetime_boot.c +++ b/libs/pinetime_boot/src/pinetime_boot.c @@ -97,7 +97,7 @@ void pinetime_boot_init(void) { console_printf("Button held for 5 seconds - ignoring\n"); console_flush(); } - if(button_samples > (3000 * 64 * 4)) { + if(button_samples > (3000 * 64 * 4) && (button_samples < (3000 * 64 * 5)) { console_printf("Restoring factory firmware\n"); console_flush(); restore_factory(); }