From 00cfcde3857cd95fbe62bb554448d8c824aa575b Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Sat, 16 Jan 2021 17:40:01 +1100 Subject: [PATCH] bootloader: Fix "skip validate on exit deep sleep" when "Use RTC fast memory as heap" is enabled RTC region used to store boot partition needs to remain reserved in the app. --- .../src/bootloader_common_loader.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/components/bootloader_support/src/bootloader_common_loader.c b/components/bootloader_support/src/bootloader_common_loader.c index 272035d597..3e8ddcf89d 100644 --- a/components/bootloader_support/src/bootloader_common_loader.c +++ b/components/bootloader_support/src/bootloader_common_loader.c @@ -30,6 +30,7 @@ #include "soc/gpio_periph.h" #include "soc/rtc.h" #include "soc/efuse_reg.h" +#include "soc/soc_memory_layout.h" #include "hal/gpio_ll.h" #include "esp_image_format.h" #include "bootloader_sha.h" @@ -138,7 +139,18 @@ esp_err_t bootloader_common_get_partition_description(const esp_partition_pos_t #if defined( CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP ) || defined( CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC ) -rtc_retain_mem_t *const rtc_retain_mem = (rtc_retain_mem_t *)(SOC_RTC_DRAM_HIGH - sizeof(rtc_retain_mem_t)); +#define RTC_RETAIN_MEM_ADDR (SOC_RTC_DATA_HIGH - sizeof(rtc_retain_mem_t)) + +rtc_retain_mem_t *const rtc_retain_mem = (rtc_retain_mem_t *)RTC_RETAIN_MEM_ADDR; + +#if !IS_BOOTLOADER_BUILD +/* The app needs to be told this memory is reserved, important if configured to use RTC memory as heap. + + Note that keeping this macro here only works when other symbols in this file are referenced by the app, as + this feature is otherwise 100% part of the bootloader. However this seems to happen in all apps. + */ +SOC_RESERVE_MEMORY_REGION(RTC_RETAIN_MEM_ADDR, RTC_RETAIN_MEM_ADDR + sizeof(rtc_retain_mem_t), rtc_retain_mem); +#endif static bool check_rtc_retain_mem(void) {