Merge branch 'bugfix/can_mmap_after_get_enough_free_mmu_pages_v4.0' into 'release/v4.0'

flash_mmap: can mmap after get enough free MMU pages (backport v4.0)

See merge request espressif/esp-idf!10586
This commit is contained in:
Jiang Jiang Jian 2020-11-16 19:40:26 +08:00
commit f42e5745e6
2 changed files with 3 additions and 3 deletions

View File

@ -158,6 +158,7 @@ esp_err_t IRAM_ATTR spi_flash_mmap_pages(const int *pages, size_t page_count, sp
uint32_t region_addr; // base address of memory region
get_mmu_region(memory,&region_begin,&region_size,&region_addr);
if (region_size < page_count) {
spi_flash_enable_interrupts_caches_and_other_cpu();
return ESP_ERR_NO_MEM;
}
// The following part searches for a range of MMU entries which can be used.

View File

@ -317,9 +317,8 @@ TEST_CASE("flash_mmap can mmap after get enough free MMU pages", "[spi_flash][mm
}
}
uint32_t free_pages = spi_flash_mmap_get_free_pages(SPI_FLASH_MMAP_DATA);
if (spi_flash_get_chip_size() <= 0x200000) {
free_pages -= 0x200000/0x10000;
}
uint32_t flash_pages = spi_flash_get_chip_size() / SPI_FLASH_MMU_PAGE_SIZE;
free_pages = (free_pages > flash_pages) ? flash_pages : free_pages;
printf("Mapping %x (+%x)\n", 0, free_pages * SPI_FLASH_MMU_PAGE_SIZE);
const void *ptr2;