From 93b7eaf5b2a7d4b182a8ffae3b51a78146f4a038 Mon Sep 17 00:00:00 2001 From: Jeroen Domburg Date: Mon, 3 Jul 2017 18:00:25 +0800 Subject: [PATCH 1/2] esp_partition_mmap could map a page less than needed because it did not take the region offset into account. --- components/spi_flash/partition.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/spi_flash/partition.c b/components/spi_flash/partition.c index 94d6ff6a66..1c3ac610fa 100644 --- a/components/spi_flash/partition.c +++ b/components/spi_flash/partition.c @@ -315,7 +315,7 @@ esp_err_t esp_partition_mmap(const esp_partition_t* partition, uint32_t offset, // offset within 64kB block size_t region_offset = phys_addr & 0xffff; size_t mmap_addr = phys_addr & 0xffff0000; - esp_err_t rc = spi_flash_mmap(mmap_addr, size, memory, out_ptr, out_handle); + esp_err_t rc = spi_flash_mmap(mmap_addr, size+region_offset, memory, out_ptr, out_handle); // adjust returned pointer to point to the correct offset if (rc == ESP_OK) { *out_ptr = (void*) (((ptrdiff_t) *out_ptr) + region_offset); From 6c2b4854e17aee100f0ede99dbf4c085bb482be2 Mon Sep 17 00:00:00 2001 From: Jeroen Domburg Date: Thu, 6 Jul 2017 18:22:43 +0800 Subject: [PATCH 2/2] Add test for partition mmap straddling 64K page issue --- components/partition_table/test/test_partition.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/partition_table/test/test_partition.c b/components/partition_table/test/test_partition.c index 64ead9692c..5267b5bac7 100644 --- a/components/partition_table/test/test_partition.c +++ b/components/partition_table/test/test_partition.c @@ -73,7 +73,7 @@ TEST_CASE("Can write, read, mmap partition", "[partition][ignore]") const uint32_t *mmap_data; spi_flash_mmap_handle_t mmap_handle; size_t begin = 3000; - size_t size = 12000; + size_t size = 64000; //chosen so size is smaller than 64K but the mmap straddles 2 MMU blocks TEST_ASSERT_EQUAL(ESP_OK, esp_partition_mmap(p, begin, size, SPI_FLASH_MMAP_DATA, (const void **)&mmap_data, &mmap_handle)); srand(0);