esp32[c3|c6|h2]: Fix RTC data placement

RTC data was not being correctly placed on RTC's memory data due to
linker issues. Also, the image's RTC memory segment was not being
properly parsed by the bootloader.
This commit is contained in:
Tiago Medicci Serrano 2024-04-02 16:36:04 -03:00 committed by Xiang Xiao
parent 0040dcf858
commit 65bd548521
5 changed files with 59 additions and 16 deletions

View File

@ -95,7 +95,7 @@ endif
ESP_HAL_3RDPARTY_REPO = esp-hal-3rdparty
ifndef ESP_HAL_3RDPARTY_VERSION
ESP_HAL_3RDPARTY_VERSION = 09219a0103984369f56482f2a2fd92b26512e381
ESP_HAL_3RDPARTY_VERSION = 54aca80daef2002b0169e67bcde36f19f59cf6cf
endif
ifndef ESP_HAL_3RDPARTY_URL

View File

@ -24,6 +24,7 @@
#include <nuttx/config.h>
#include <stdbool.h>
#include <stdint.h>
#include <nuttx/arch.h>
@ -90,15 +91,39 @@
EXTMEM_ICACHE_SHUT_DBUS_M)
# define CHECKSUM_ALIGN 16
# define IS_PADD(addr) (addr == 0)
# define IS_DRAM(addr) (addr >= SOC_DRAM_LOW && addr < SOC_DRAM_HIGH)
# define IS_IRAM(addr) (addr >= SOC_IRAM_LOW && addr < SOC_IRAM_HIGH)
# define IS_IROM(addr) (addr >= SOC_IROM_LOW && addr < SOC_IROM_HIGH)
# define IS_DROM(addr) (addr >= SOC_DROM_LOW && addr < SOC_DROM_HIGH)
# define IS_PADD(addr) ((addr) == 0)
# define IS_DRAM(addr) ((addr) >= SOC_DRAM_LOW && (addr) < SOC_DRAM_HIGH)
# define IS_IRAM(addr) ((addr) >= SOC_IRAM_LOW && (addr) < SOC_IRAM_HIGH)
# define IS_IROM(addr) ((addr) >= SOC_IROM_LOW && (addr) < SOC_IROM_HIGH)
# define IS_DROM(addr) ((addr) >= SOC_DROM_LOW && (addr) < SOC_DROM_HIGH)
# define IS_SRAM(addr) (IS_IRAM(addr) || IS_DRAM(addr))
# define IS_MMAP(addr) (IS_IROM(addr) || IS_DROM(addr))
# define IS_NONE(addr) (!IS_IROM(addr) && !IS_DROM(addr) \
&& !IS_IRAM(addr) && !IS_DRAM(addr) && !IS_PADD(addr))
# ifdef SOC_RTC_FAST_MEM_SUPPORTED
# define IS_RTC_FAST_IRAM(addr) \
((addr) >= SOC_RTC_IRAM_LOW \
&& (addr) < SOC_RTC_IRAM_HIGH)
# define IS_RTC_FAST_DRAM(addr) \
((addr) >= SOC_RTC_DRAM_LOW \
&& (addr) < SOC_RTC_DRAM_HIGH)
# else
# define IS_RTC_FAST_IRAM(addr) false
# define IS_RTC_FAST_DRAM(addr) false
# endif
# ifdef SOC_RTC_SLOW_MEM_SUPPORTED
# define IS_RTC_SLOW_DRAM(addr) \
((addr) >= SOC_RTC_DATA_LOW \
&& (addr) < SOC_RTC_DATA_HIGH)
# else
# define IS_RTC_SLOW_DRAM(addr) false
# endif
# define IS_NONE(addr) (!IS_IROM(addr) \
&& !IS_DROM(addr) \
&& !IS_IRAM(addr) \
&& !IS_DRAM(addr) \
&& !IS_RTC_FAST_IRAM(addr) \
&& !IS_RTC_FAST_DRAM(addr) \
&& !IS_RTC_SLOW_DRAM(addr) \
&& !IS_PADD(addr))
# define IS_MAPPING(addr) IS_IROM(addr) || IS_DROM(addr)
#endif
@ -262,15 +287,27 @@ static int map_rom_segments(uint32_t app_drom_start, uint32_t app_drom_vaddr,
break;
}
if (IS_RTC_FAST_IRAM(segment_hdr.load_addr) ||
IS_RTC_FAST_DRAM(segment_hdr.load_addr) ||
IS_RTC_SLOW_DRAM(segment_hdr.load_addr))
{
/* RTC segment is loaded by ROM bootloader */
ram_segments++;
}
ets_printf("%s: lma 0x%08x vma 0x%08lx len 0x%-6lx (%lu)\n",
IS_NONE(segment_hdr.load_addr) ? "???" :
IS_MMAP(segment_hdr.load_addr) ?
IS_IROM(segment_hdr.load_addr) ? "imap" : "dmap" :
IS_PADD(segment_hdr.load_addr) ? "padd" :
IS_DRAM(segment_hdr.load_addr) ? "dram" : "iram",
offset + sizeof(esp_image_segment_header_t),
segment_hdr.load_addr, segment_hdr.data_len,
segment_hdr.data_len);
IS_NONE(segment_hdr.load_addr) ? "???" :
IS_RTC_FAST_IRAM(segment_hdr.load_addr) ||
IS_RTC_FAST_DRAM(segment_hdr.load_addr) ||
IS_RTC_SLOW_DRAM(segment_hdr.load_addr) ? "rtc" :
IS_MMAP(segment_hdr.load_addr) ?
IS_IROM(segment_hdr.load_addr) ? "imap" : "dmap" :
IS_PADD(segment_hdr.load_addr) ? "padd" :
IS_DRAM(segment_hdr.load_addr) ? "dram" : "iram",
offset + sizeof(esp_image_segment_header_t),
segment_hdr.load_addr, segment_hdr.data_len,
segment_hdr.data_len);
/* Fix drom and irom produced be the linker, as this
* is later invalidated by the elf2image command.

View File

@ -372,7 +372,9 @@ SECTIONS
.rtc.data :
{
*(.rtc.data)
*(.rtc.data.*)
*(.rtc.rodata)
*(.rtc.rodata.*)
} >rtc_iram_seg
/* This section holds RTC data that should have fixed addresses.

View File

@ -384,7 +384,9 @@ SECTIONS
.rtc.data :
{
*(.rtc.data)
*(.rtc.data.*)
*(.rtc.rodata)
*(.rtc.rodata.*)
} >rtc_iram_seg
/* This section holds RTC data that should have fixed addresses.

View File

@ -384,7 +384,9 @@ SECTIONS
.rtc.data :
{
*(.rtc.data)
*(.rtc.data.*)
*(.rtc.rodata)
*(.rtc.rodata.*)
} >rtc_iram_seg
/* This section holds RTC data that should have fixed addresses.