From: Ivan Grokhotkov Date: Fri, 3 Mar 2017 03:27:01 +0000 (+0800) Subject: Merge branch 'feature/docs_partition_ota_flash' into 'master' X-Git-Tag: v2.1-rc1~291 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8911e666a0dca1748d3af0a365961179f4a27a80;p=esp-idf Merge branch 'feature/docs_partition_ota_flash' into 'master' Partition/SPI/OTA docs & OTA new functionality * Update partition, SPI flash & OTA docs to reflect functionality changes * Refactor OTA implementation to perform checks mentioned in API doc * Add new functions to OTA API: esp_ota_get_running_partition() & esp_ota_get_next_update_partition() functions * Add spi_flash_cache2phys() & spi_flash_phys2cache() functions to support esp_ota_get_running_partition() See merge request !513 --- 8911e666a0dca1748d3af0a365961179f4a27a80 diff --cc components/spi_flash/test/test_mmap.c index 7d9689feae,a2ef0fd56f..220b2b8de2 --- a/components/spi_flash/test/test_mmap.c +++ b/components/spi_flash/test/test_mmap.c @@@ -84,57 -131,13 +131,59 @@@ TEST_CASE("Can mmap into data address s printf("Unmapping handle3\n"); spi_flash_munmap(handle3); + handle3 = 0; + + TEST_ASSERT_EQUAL_PTR(NULL, spi_flash_phys2cache(start, SPI_FLASH_MMAP_DATA)); } +TEST_CASE("Can mmap into instruction address space", "[mmap]") +{ + printf("Mapping %x (+%x)\n", start, end - start); + spi_flash_mmap_handle_t handle1; + const void *ptr1; + ESP_ERROR_CHECK( spi_flash_mmap(start, end - start, SPI_FLASH_MMAP_INST, &ptr1, &handle1) ); + printf("mmap_res: handle=%d ptr=%p\n", handle1, ptr1); + + spi_flash_mmap_dump(); + + srand(0); + const uint32_t *data = (const uint32_t *) ptr1; + for (int block = 0; block < (end - start) / 0x10000; ++block) { + for (int sector = 0; sector < 16; ++sector) { + for (uint32_t word = 0; word < 1024; ++word) { + TEST_ASSERT_EQUAL_UINT32(rand(), data[(block * 16 + sector) * 1024 + word]); + } + } + } + printf("Mapping %x (+%x)\n", start - 0x10000, 0x20000); + spi_flash_mmap_handle_t handle2; + const void *ptr2; + ESP_ERROR_CHECK( spi_flash_mmap(start - 0x10000, 0x20000, SPI_FLASH_MMAP_DATA, &ptr2, &handle2) ); + printf("mmap_res: handle=%d ptr=%p\n", handle2, ptr2); + spi_flash_mmap_dump(); + + printf("Mapping %x (+%x)\n", start, 0x10000); + spi_flash_mmap_handle_t handle3; + const void *ptr3; + ESP_ERROR_CHECK( spi_flash_mmap(start, 0x10000, SPI_FLASH_MMAP_DATA, &ptr3, &handle3) ); + printf("mmap_res: handle=%d ptr=%p\n", handle3, ptr3); + spi_flash_mmap_dump(); + + printf("Unmapping handle1\n"); + spi_flash_munmap(handle1); + spi_flash_mmap_dump(); + + printf("Unmapping handle2\n"); + spi_flash_munmap(handle2); + spi_flash_mmap_dump(); + + printf("Unmapping handle3\n"); + spi_flash_munmap(handle3); + +} + TEST_CASE("flash_mmap invalidates just-written data", "[spi_flash]") { - spi_flash_mmap_handle_t handle1; const void *ptr1; const size_t test_size = 128;