From 8849d6acfa21fb2f93707225a9473b92e1e768ae Mon Sep 17 00:00:00 2001 From: KonstantinKondrashov Date: Wed, 31 Jul 2019 22:31:58 +0800 Subject: [PATCH 1/2] bootloader: Factory reset not for deep sleep Closes: https://github.com/espressif/esp-idf/issues/3800 Closes: IDFGH-1536 --- components/bootloader/subproject/main/bootloader_start.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/bootloader/subproject/main/bootloader_start.c b/components/bootloader/subproject/main/bootloader_start.c index 6f7edc42ee..a6d88aba15 100644 --- a/components/bootloader/subproject/main/bootloader_start.c +++ b/components/bootloader/subproject/main/bootloader_start.c @@ -24,6 +24,7 @@ #include "bootloader_common.h" #include "sdkconfig.h" #include "esp_image_format.h" +#include "rom/rtc.h" static const char* TAG = "boot"; @@ -74,7 +75,8 @@ static int selected_boot_partition(const bootloader_state_t *bs) int boot_index = bootloader_utility_get_selected_boot_partition(bs); if (boot_index == INVALID_INDEX) { return boot_index; // Unrecoverable failure (not due to corrupt ota data or bad partition contents) - } else { + } + if (rtc_get_reset_reason(0) != DEEPSLEEP_RESET) { // Factory firmware. #ifdef CONFIG_BOOTLOADER_FACTORY_RESET if (bootloader_common_check_long_hold_gpio(CONFIG_BOOTLOADER_NUM_PIN_FACTORY_RESET, CONFIG_BOOTLOADER_HOLD_TIME_GPIO) == 1) { From ca3df7de7f6e2e8ec8bc0db058b5f4d49ecbcb33 Mon Sep 17 00:00:00 2001 From: KonstantinKondrashov Date: Wed, 31 Jul 2019 22:35:23 +0800 Subject: [PATCH 2/2] app_update: Fix UTs for FACTORY_RESET and APP_TEST --- components/app_update/test/test_switch_ota.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/app_update/test/test_switch_ota.c b/components/app_update/test/test_switch_ota.c index d34015635b..7fc828f268 100644 --- a/components/app_update/test/test_switch_ota.c +++ b/components/app_update/test/test_switch_ota.c @@ -443,7 +443,7 @@ static void test_flow4(void) // 2 Stage: run factory -> check it -> copy factory to OTA0 -> reboot --//-- // 3 Stage: run OTA0 -> check it -> set_pin_factory_reset -> reboot --//-- // 4 Stage: run factory -> check it -> erase OTA_DATA for next tests -> PASS -TEST_CASE_MULTIPLE_STAGES("Switching between factory, OTA0, sets pin_factory_reset, factory", "[app_update][timeout=90][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow4, test_flow4, test_flow4); +TEST_CASE_MULTIPLE_STAGES("Switching between factory, OTA0, sets pin_factory_reset, factory", "[app_update][timeout=90][ignore][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow4, test_flow4, test_flow4); #endif #ifdef CONFIG_BOOTLOADER_APP_TEST @@ -486,7 +486,7 @@ static void test_flow5(void) // 2 Stage: run factory -> check it -> copy factory to Test and set pin_test_app -> reboot --//-- // 3 Stage: run test -> check it -> reset pin_test_app -> reboot --//-- // 4 Stage: run factory -> check it -> erase OTA_DATA for next tests -> PASS -TEST_CASE_MULTIPLE_STAGES("Switching between factory, test, factory", "[app_update][timeout=90][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow5, test_flow5, test_flow5); +TEST_CASE_MULTIPLE_STAGES("Switching between factory, test, factory", "[app_update][timeout=90][ignore][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow5, test_flow5, test_flow5); #endif static const esp_partition_t* app_update(void)