File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change 2828
2929#define ESP_PARTITION_HASH_LEN 32 /* SHA-256 digest length */
3030#define IS_FIELD_SET (rev_full ) (((rev_full) != 65535) && ((rev_full) != 0))
31+ #define ALIGN_UP (num , align ) (((num) + ((align) - 1)) & ~((align) - 1))
3132
3233static const char * TAG = "boot_comm" ;
3334
@@ -264,7 +265,10 @@ rtc_retain_mem_t* bootloader_common_get_rtc_retain_mem(void)
264265#if ESP_ROM_HAS_LP_ROM
265266 #define RTC_RETAIN_MEM_ADDR (SOC_RTC_DRAM_LOW)
266267#else
267- #define RTC_RETAIN_MEM_ADDR (SOC_RTC_DRAM_HIGH - sizeof(rtc_retain_mem_t))
268+ /* Since the structure containing the retain_mem_t is aligned on 8 by the linker, make sure we align this
269+ * structure size here too */
270+ #define RETAIN_MEM_SIZE ALIGN_UP(sizeof(rtc_retain_mem_t), 8)
271+ #define RTC_RETAIN_MEM_ADDR (SOC_RTC_DRAM_HIGH - RETAIN_MEM_SIZE)
268272#endif //ESP_ROM_HAS_LP_ROM
269273 static rtc_retain_mem_t * const s_bootloader_retain_mem = (rtc_retain_mem_t * )RTC_RETAIN_MEM_ADDR ;
270274 return s_bootloader_retain_mem ;
Original file line number Diff line number Diff line change 66
77#include "sdkconfig.h"
88
9+ #define ALIGN_UP(SIZE, AL) (((SIZE) + (AL - 1)) & ~(AL - 1))
10+
911/* CPU instruction prefetch padding size for flash mmap scenario */
1012#define _esp_flash_mmap_prefetch_pad_size 16
1113
4547
4648#if CONFIG_SOC_RTC_MEM_SUPPORTED
4749 #if CONFIG_BOOTLOADER_RESERVE_RTC_MEM
50+ /**
51+ * The ESP_BOOTLOADER_RESERVE_RTC size must have the same alignment of RTC_TIMER_RESERVE_RTC, else
52+ * the segment will overflow at link time because not enough bytes are allocated for the RTC segment.
53+ */
4854 #ifdef CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC
49- #define ESP_BOOTLOADER_RESERVE_RTC (CONFIG_BOOTLOADER_RESERVE_RTC_SIZE + CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC_SIZE)
55+ #define ESP_BOOTLOADER_RESERVE_RTC ALIGN_UP (CONFIG_BOOTLOADER_RESERVE_RTC_SIZE + CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC_SIZE, 8 )
5056 #else
51- #define ESP_BOOTLOADER_RESERVE_RTC (CONFIG_BOOTLOADER_RESERVE_RTC_SIZE)
57+ #define ESP_BOOTLOADER_RESERVE_RTC ALIGN_UP (CONFIG_BOOTLOADER_RESERVE_RTC_SIZE, 8 )
5258 #endif // not CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC
5359 #else
5460 #define ESP_BOOTLOADER_RESERVE_RTC 0
You can’t perform that action at this time.
0 commit comments