mirror of
https://github.com/espressif/esp-idf.git
synced 2025-12-07 17:08:49 +00:00
fix(esp_mm): for existing mmap region, consider new offset for virtual addr
While returning virtual address for existing memory mapped region, newly supplied offset from the physical address was not getting considered. This was a regression present from ESP-IDF 5.1 release. Added test case in spi_flash component that fails without this fix. Closes https://github.com/espressif/esp-idf/issues/13929
This commit is contained in:
@@ -101,6 +101,33 @@ static void setup_mmap_tests(void)
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Can get correct data in existing mapped region", "[spi_flash][mmap]")
|
||||
{
|
||||
setup_mmap_tests();
|
||||
|
||||
printf("Mapping %"PRIx32" (+%"PRIx32")\n", start, end - start);
|
||||
const void *ptr1;
|
||||
TEST_ESP_OK( spi_flash_mmap(start, end - start, SPI_FLASH_MMAP_DATA, &ptr1, &handle1) );
|
||||
printf("mmap_res: handle=%"PRIx32" ptr=%p\n", (uint32_t)handle1, ptr1);
|
||||
|
||||
/* Remap in the previously mapped region itself */
|
||||
uint32_t new_start = start + CONFIG_MMU_PAGE_SIZE;
|
||||
printf("Mapping %"PRIx32" (+%"PRIx32")\n", new_start, end - new_start);
|
||||
const void *ptr2;
|
||||
TEST_ESP_OK( spi_flash_mmap(new_start, end - new_start, SPI_FLASH_MMAP_DATA, &ptr2, &handle2) );
|
||||
printf("mmap_res: handle=%"PRIx32" ptr=%p\n", (uint32_t)handle2, ptr2);
|
||||
|
||||
const void *src1 = (void *) ((uint32_t) ptr1 + CONFIG_MMU_PAGE_SIZE);
|
||||
const void *src2 = ptr2;
|
||||
/* Memory contents should be identical - as the region is same */
|
||||
TEST_ASSERT_EQUAL(0, memcmp(src1, src2, end - new_start));
|
||||
|
||||
spi_flash_munmap(handle1);
|
||||
handle1 = 0;
|
||||
spi_flash_munmap(handle2);
|
||||
handle2 = 0;
|
||||
TEST_ASSERT_EQUAL_PTR(NULL, spi_flash_phys2cache(start, SPI_FLASH_MMAP_DATA));
|
||||
}
|
||||
|
||||
TEST_CASE("Can mmap into data address space", "[spi_flash][mmap]")
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user