Merge branch 'bugfix/partition_mmap_size' into 'master'

esp_partition_mmap size calculation fix

See merge request !947
This commit is contained in:
Jeroen Domburg 2017-07-06 18:44:59 +08:00
commit 927b5685cd
2 changed files with 2 additions and 2 deletions

View file

@ -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);

View file

@ -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);