Merge branch 'bugfix/flash_mmap_output_psram_arg_v4.1' into 'release/v4.1'

mmap: fixed the issue mmap cannot be called with pointers to psram (v4.1)

See merge request espressif/esp-idf!17700
This commit is contained in:
Michael (XIAO Xufeng) 2022-04-25 10:14:28 +08:00
commit 23c2556ca7

View File

@ -164,6 +164,8 @@ esp_err_t IRAM_ATTR spi_flash_mmap_pages(const int *pages, size_t page_count, sp
const void** out_ptr, spi_flash_mmap_handle_t* out_handle)
{
esp_err_t ret;
const void* temp_ptr = *out_ptr = NULL;
spi_flash_mmap_handle_t temp_handle = *out_handle = (spi_flash_mmap_handle_t)NULL;
bool need_flush = false;
if (!page_count) {
return ESP_ERR_INVALID_ARG;
@ -219,8 +221,6 @@ esp_err_t IRAM_ATTR spi_flash_mmap_pages(const int *pages, size_t page_count, sp
}
// checked all the region(s) and haven't found anything?
if (start == end) {
*out_handle = 0;
*out_ptr = NULL;
ret = ESP_ERR_NO_MEM;
} else {
// set up mapping using pages
@ -262,8 +262,8 @@ esp_err_t IRAM_ATTR spi_flash_mmap_pages(const int *pages, size_t page_count, sp
new_entry->page = start;
new_entry->count = page_count;
new_entry->handle = ++s_mmap_last_handle;
*out_handle = new_entry->handle;
*out_ptr = (void*) (region_addr + (start - region_begin) * SPI_FLASH_MMU_PAGE_SIZE);
temp_handle = new_entry->handle;
temp_ptr = (void*) (region_addr + (start - region_begin) * SPI_FLASH_MMU_PAGE_SIZE);
ret = ESP_OK;
}
@ -286,9 +286,11 @@ esp_err_t IRAM_ATTR spi_flash_mmap_pages(const int *pages, size_t page_count, sp
}
spi_flash_enable_interrupts_caches_and_other_cpu();
if (*out_ptr == NULL) {
if (temp_ptr == NULL) {
free(new_entry);
}
*out_ptr = temp_ptr;
*out_handle = temp_handle;
return ret;
}