Skip to content

Commit 8f1e7bc

Browse files
committed
Merge branch 'feat/cache_mem_iram_h4' into 'master'
cache: use icache memroy as diram when single core See merge request espressif/esp-idf!43352
2 parents 6f9c520 + a28d986 commit 8f1e7bc

File tree

6 files changed

+39
-6
lines changed

6 files changed

+39
-6
lines changed

components/bootloader_support/src/esp32h4/bootloader_esp32h4.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ static inline void bootloader_config_dcache(void)
108108

109109
static inline void bootloader_config_icache1(void)
110110
{
111-
// TODO: [ESP32H4] IDF-12289
112111
#if CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE
113112
REG_CLR_BIT(LP_AON_SRAM_USAGE_CONF_REG, LP_AON_ICACHE1_USAGE);
114113
#else

components/esp_rom/esp32h4/include/esp32h4/rom/cache.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
extern "C" {
1414
#endif
1515

16-
//TODO: [ESP32H4] IDF-12289 inherit from verification branch, need check
17-
1816
/** \defgroup cache_apis, cache operation related apis
1917
* @brief cache apis
2018
*/

components/esp_system/port/cpu_start.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ static void start_other_core(void)
321321
}
322322
}
323323

324-
#if !SOC_CACHE_INTERNAL_MEM_VIA_L1CACHE && !CONFIG_IDF_TARGET_ESP32H4 // TODO IDF-12289
324+
#if !SOC_CACHE_INTERNAL_MEM_VIA_L1CACHE
325325
#if CONFIG_IDF_TARGET_ESP32
326326
static void restore_app_mmu_from_pro_mmu(void)
327327
{
@@ -466,7 +466,7 @@ FORCE_INLINE_ATTR IRAM_ATTR void ram_app_init(void)
466466
//Keep this static, the compiler will check output parameters are initialized.
467467
FORCE_INLINE_ATTR IRAM_ATTR void ext_mem_init(void)
468468
{
469-
#if !CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE && !SOC_CACHE_INTERNAL_MEM_VIA_L1CACHE && !CONFIG_IDF_TARGET_ESP32H4 // TODO IDF-12289
469+
#if !CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE && !SOC_CACHE_INTERNAL_MEM_VIA_L1CACHE
470470
// It helps to fix missed cache settings for other cores. It happens when bootloader is unicore.
471471
do_multicore_settings();
472472
#endif

components/hal/esp32h4/include/hal/cache_ll.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,35 @@ static inline void cache_ll_l1_enable_bus(uint32_t bus_id, cache_bus_mask_t mask
758758
REG_CLR_BIT(CACHE_L1_DCACHE_CTRL_REG, dbus_mask);
759759
}
760760

761+
/**
762+
* Returns enabled buses for a given core
763+
*
764+
* @param cache_id cache ID (when l1 cache is per core)
765+
*
766+
* @return State of enabled buses
767+
*/
768+
__attribute__((always_inline))
769+
static inline cache_bus_mask_t cache_ll_l1_get_enabled_bus(uint32_t cache_id)
770+
{
771+
cache_bus_mask_t mask = (cache_bus_mask_t)0;
772+
773+
uint32_t ibus_mask = REG_READ(CACHE_L1_ICACHE_CTRL_REG);
774+
if (cache_id == 0) {
775+
mask = (cache_bus_mask_t)(mask | ((!(ibus_mask & CACHE_L1_ICACHE_SHUT_IBUS0)) ? CACHE_BUS_IBUS0 : 0));
776+
} else if (cache_id == 1) {
777+
mask = (cache_bus_mask_t)(mask | ((!(ibus_mask & CACHE_L1_ICACHE_SHUT_IBUS1)) ? CACHE_BUS_IBUS0 : 0));
778+
}
779+
780+
uint32_t dbus_mask = REG_READ(CACHE_L1_DCACHE_CTRL_REG);
781+
if (cache_id == 0) {
782+
mask = (cache_bus_mask_t)(mask | ((!(dbus_mask & CACHE_L1_DCACHE_SHUT_DBUS0)) ? CACHE_BUS_DBUS0 : 0));
783+
} else if (cache_id == 1) {
784+
mask = (cache_bus_mask_t)(mask | ((!(dbus_mask & CACHE_L1_DCACHE_SHUT_DBUS1)) ? CACHE_BUS_DBUS0 : 0));
785+
}
786+
787+
return mask;
788+
}
789+
761790
/**
762791
* Disable the Cache Buses
763792
*

components/heap/port/esp32h4/memory_layout.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,11 @@ const size_t soc_memory_type_count = sizeof(soc_memory_types) / sizeof(soc_memor
6969
#define APP_USABLE_DIRAM_END (SOC_ROM_STACK_START - SOC_ROM_STACK_SIZE)
7070

7171
const soc_memory_region_t soc_memory_regions[] = {
72+
#if CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE
73+
{ SOC_RAM_ICACHE1_LOW, (SOC_RAM_ICACHE1_HIGH - SOC_RAM_ICACHE1_LOW), SOC_MEMORY_TYPE_RAM, SOC_RAM_ICACHE1_LOW, true}, //ICache1, when in single core mode, ICache1 is used as RAM
74+
#endif
7275
{ SOC_DIRAM_DRAM_LOW, (APP_USABLE_DIRAM_END - SOC_DIRAM_DRAM_LOW), SOC_MEMORY_TYPE_RAM, SOC_DIRAM_IRAM_LOW, false}, //D/IRAM, can be used as trace memory
73-
{ APP_USABLE_DIRAM_END, (SOC_DIRAM_DRAM_HIGH - APP_USABLE_DIRAM_END), SOC_MEMORY_TYPE_RAM, APP_USABLE_DIRAM_END, true}, //D/IRAM, can be used as trace memory (ROM reserved area)
76+
{ APP_USABLE_DIRAM_END, (SOC_DIRAM_DRAM_HIGH - APP_USABLE_DIRAM_END), SOC_MEMORY_TYPE_RAM, APP_USABLE_DIRAM_END, true}, //D/IRAM, can be used as trace memory (ROM reserved area)
7477
};
7578

7679
const size_t soc_memory_region_count = sizeof(soc_memory_regions) / sizeof(soc_memory_region_t);

components/soc/esp32h4/include/soc/soc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@
195195
#define SOC_ROM_STACK_START 0x4085d350
196196
#define SOC_ROM_STACK_SIZE 0x2000
197197

198+
//ICache1 region
199+
#define SOC_RAM_ICACHE1_LOW 0x40860000
200+
#define SOC_RAM_ICACHE1_HIGH 0x40867fff
201+
198202
//On RISC-V CPUs, the interrupt sources are all external interrupts, whose type, source and priority are configured by SW.
199203
//There is no HW NMI conception. SW should controlled the masked levels through INT_THRESH_REG.
200204

0 commit comments

Comments
 (0)