Merge branch 'feature/deep_sleep_fast_wake' into 'master'

bootloader: Reduce the time spent in image validation when waking from deep sleep

See merge request espressif/esp-idf!5140
This commit is contained in:
Angus Gratton
2019-08-28 08:54:28 +08:00
17 changed files with 393 additions and 79 deletions

View File

@@ -219,6 +219,53 @@ menu "Bootloader config"
It allow to test anti-rollback implemention without permanent write eFuse bits.
In partition table should be exist this partition `emul_efuse, data, 5, , 0x2000`.
config BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP
bool "Skip image validation when exiting deep sleep"
depends on (SECURE_BOOT_ENABLED && SECURE_BOOT_INSECURE) || !SECURE_BOOT_ENABLED
default n
help
This option disables the normal validation of an image coming out of
deep sleep (checksums, SHA256, and signature). This is a trade-off
between wakeup performance from deep sleep, and image integrity checks.
Only enable this if you know what you are doing. It should not be used
in conjunction with using deep_sleep() entry and changing the active OTA
partition as this would skip the validation upon first load of the new
OTA partition.
config BOOTLOADER_RESERVE_RTC_SIZE
hex
default 0x10 if BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP || BOOTLOADER_CUSTOM_RESERVE_RTC
default 0
help
Reserve RTC FAST memory for Skip image validation. This option in bytes.
This option reserves an area in the RTC FAST memory (access only PRO_CPU).
Used to save the addresses of the selected application.
When a wakeup occurs (from Deep sleep), the bootloader retrieves it and
loads the application without validation.
config BOOTLOADER_CUSTOM_RESERVE_RTC
bool "Reserve RTC FAST memory for custom purposes"
default n
help
This option allows the customer to place data in the RTC FAST memory,
this area remains valid when rebooted, except for power loss.
This memory is located at a fixed address and is available
for both the bootloader and the application.
(The application and bootoloader must be compiled with the same option).
The RTC FAST memory has access only through PRO_CPU.
config BOOTLOADER_CUSTOM_RESERVE_RTC_SIZE
hex "Size in bytes for custom purposes"
range 0 0x10
default 0
depends on BOOTLOADER_CUSTOM_RESERVE_RTC
help
This option reserves in RTC FAST memory the area for custom purposes.
If you want to create your own bootloader and save more information
in this area of memory, you can increase it. It must be a multiple of 4 bytes.
This area (rtc_retain_mem_t) is reserved and has access from the bootloader and an application.
endmenu # Bootloader

View File

@@ -41,6 +41,14 @@ void __attribute__((noreturn)) call_start_cpu0(void)
bootloader_reset();
}
#ifdef CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP
// If this boot is a wake up from the deep sleep then go to the short way,
// try to load the application which worked before deep sleep.
// It skips a lot of checks due to it was done before (while first boot).
bootloader_utility_load_boot_image_from_deep_sleep();
// If it is not successful try to load an application as usual.
#endif
// 2. Select the number of boot partition
bootloader_state_t bs = { 0 };
int boot_index = select_partition_number(&bs);