From e93daa4e81528b27a2bc4574e940550f97207519 Mon Sep 17 00:00:00 2001 From: jiangguangming Date: Tue, 21 Jul 2020 18:04:27 +0800 Subject: [PATCH] flash_mmap: can mmap after get enough free MMU pages --- components/spi_flash/test/test_mmap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/components/spi_flash/test/test_mmap.c b/components/spi_flash/test/test_mmap.c index 80458e77e1..8e187cb67d 100644 --- a/components/spi_flash/test/test_mmap.c +++ b/components/spi_flash/test/test_mmap.c @@ -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;