bootloader_support: Adds API to detect Factory reset has happened

Closes https://github.com/espressif/esp-idf/issues/10753
This commit is contained in:
KonstantinKondrashov
2023-03-18 04:07:52 +08:00
parent 017f55862d
commit efbafb873b
15 changed files with 124 additions and 32 deletions
+8
View File
@@ -86,6 +86,14 @@ In addition, the following configuration options control the reset condition:
- :ref:`CONFIG_BOOTLOADER_FACTORY_RESET_PIN_LEVEL` - configure whether a factory reset should trigger on a high or low level of the GPIO. If the GPIO has an internal pullup then this is enabled before the pin is sampled, consult the {IDF_TARGET_NAME} datasheet for details on pin internal pullups.
.. only:: SOC_RTC_FAST_MEM_SUPPORTED
Sometimes an application needs to know if the Factory Reset has occurred. For this purpose, there is a function :cpp:func:`bootloader_common_get_rtc_retain_mem_factory_reset_state`, which returns its status, after reading the status is reset to false. This feature reserves some RTC FAST memory (the same size as the :ref:`CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP` feature).
.. only:: not SOC_RTC_FAST_MEM_SUPPORTED
Sometimes an application needs to know if the Factory Reset has occurred. The {IDF_TARGET_NAME} chip does not have RTC FAST memory, so there is no API to detect it. Instead, there is a workaround: you need an NVS partition that will be erased by bootloader while Factory Reset (add this partition to :ref:`CONFIG_BOOTLOADER_DATA_FACTORY_RESET`). In this NVS partition, create a "factory_reset_state" token that will be increased in the application. If the "factory_reset_state" is 0 then the factory reset has occurred.
.. _bootloader_boot_from_test_firmware:
Boot from Test Firmware