-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/xip_psram_c5' into 'master'
psram: xip_psram support on c5/c61, also fixed cache writeback/invalidate not work issue on c61 Closes IDF-8688, IDF-9292, and IDF-11008 See merge request espressif/esp-idf!33265
- Loading branch information
Showing
23 changed files
with
236 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
components/esp_psram/test_apps/psram/sdkconfig.ci.esp32c5_advanced
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
CONFIG_IDF_TARGET="esp32c5" | ||
|
||
CONFIG_COMPILER_OPTIMIZATION_SIZE=y | ||
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y | ||
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y | ||
|
||
CONFIG_SPIRAM=y | ||
CONFIG_SPIRAM_SPEED_80M=y | ||
CONFIG_SPIRAM_XIP_FROM_PSRAM=y | ||
CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y | ||
CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY=y | ||
|
||
CONFIG_PARTITION_TABLE_CUSTOM=y | ||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" | ||
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" |
15 changes: 15 additions & 0 deletions
15
components/esp_psram/test_apps/psram/sdkconfig.ci.esp32c61_advanced
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
CONFIG_IDF_TARGET="esp32c61" | ||
|
||
CONFIG_COMPILER_OPTIMIZATION_SIZE=y | ||
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y | ||
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y | ||
|
||
CONFIG_SPIRAM=y | ||
CONFIG_SPIRAM_SPEED_80M=y | ||
CONFIG_SPIRAM_XIP_FROM_PSRAM=y | ||
CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y | ||
CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY=y | ||
|
||
CONFIG_PARTITION_TABLE_CUSTOM=y | ||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" | ||
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <stdint.h> | ||
#include <stdbool.h> | ||
#include "sdkconfig.h" | ||
#include "esp_rom_caps.h" | ||
#include "soc/soc_caps.h" | ||
#include "soc/cache_reg.h" | ||
#include "soc/cache_struct.h" | ||
#include "soc/ext_mem_defs.h" | ||
#include "hal/assert.h" | ||
#include "esp32c61/rom/cache.h" | ||
|
||
#include "esp_rom_sys.h" | ||
|
||
#define CACHE_MAX_SYNC_NUM ((CACHE_SYNC_SIZE + 1) >> 1) | ||
|
||
/** | ||
* @brief Sync Cache items | ||
* | ||
* @param type sync type | ||
* @param addr address | ||
* @param bytes bytes to be synced | ||
*/ | ||
__attribute__((always_inline)) | ||
static inline void s_cache_sync_items(uint32_t type, uint32_t addr, uint32_t bytes) | ||
{ | ||
REG_WRITE(CACHE_SYNC_ADDR_REG, addr); | ||
REG_SET_FIELD(CACHE_SYNC_SIZE_REG, CACHE_SYNC_SIZE, bytes); | ||
REG_SET_BIT(CACHE_SYNC_CTRL_REG, type); | ||
while (!REG_GET_BIT(CACHE_SYNC_CTRL_REG, CACHE_SYNC_DONE)) | ||
; | ||
} | ||
|
||
int Cache_Invalidate_Addr(uint32_t vaddr, uint32_t size) | ||
{ | ||
uint32_t plus = 0; | ||
uint32_t cache_line_size = 32; | ||
uint32_t cache_max_sync_size = CACHE_MAX_SYNC_NUM; | ||
if (size == 0) { | ||
HAL_ASSERT(false); | ||
} | ||
//aligned start address to cache line size | ||
plus = vaddr & (cache_line_size - 1); | ||
vaddr -= plus; | ||
//make the length fit the start address | ||
size += plus; | ||
//aligned the length to cache line size(0->0) | ||
size = (size + cache_line_size - 1) & ~(cache_line_size - 1); | ||
|
||
while (size > 0) { | ||
//aligned to cache_max_sync_size, (0->cache_max_sync_size) | ||
uint32_t this_size = ((vaddr + cache_max_sync_size) & ~(cache_max_sync_size - 1)) - vaddr; | ||
if (this_size > size) { | ||
this_size = size; | ||
} | ||
s_cache_sync_items(CACHE_SYNC_INVALIDATE, vaddr, this_size); | ||
vaddr += this_size; | ||
size -= this_size; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
int Cache_WriteBack_Addr(uint32_t vaddr, uint32_t size) | ||
{ | ||
uint32_t plus = 0; | ||
uint32_t cache_line_size = 32; | ||
uint32_t cache_max_sync_size = CACHE_MAX_SYNC_NUM; | ||
if (size == 0) { | ||
HAL_ASSERT(false); | ||
} | ||
//aligned start address to cache line size | ||
plus = vaddr & (cache_line_size - 1); | ||
vaddr -= plus; | ||
//make the length fit the start address | ||
size += plus; | ||
//aligned the length to cache line size(0->0) | ||
size = (size + cache_line_size - 1) & ~(cache_line_size - 1); | ||
|
||
while (size > 0) { | ||
//aligned to cache_max_sync_size, (0->cache_max_sync_size) | ||
uint32_t this_size = ((vaddr + cache_max_sync_size) & ~(cache_max_sync_size - 1)) - vaddr; | ||
if (this_size > size) { | ||
this_size = size; | ||
} | ||
s_cache_sync_items(CACHE_SYNC_WRITEBACK, vaddr, this_size); | ||
vaddr += this_size; | ||
size -= this_size; | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.