diff --git a/.gitlab/ci/host-test.yml b/.gitlab/ci/host-test.yml index a3092ee2a4..54abb63d14 100644 --- a/.gitlab/ci/host-test.yml +++ b/.gitlab/ci/host-test.yml @@ -437,6 +437,14 @@ test_linux_example: - timeout 5 ./build/linux_host_app.elf >test.log || true - grep "Restarting" test.log +test_partition_api_host: + extends: .host_test_template + script: + - cd ${IDF_PATH}/components/esp_partition/host_test/partition_api_test + - idf.py build + - timeout 5 ./build/partition_api_test.elf >test.log + - grep " 0 Failures" test.log + test_gen_soc_caps_kconfig: extends: .host_test_template script: diff --git a/components/app_update/CMakeLists.txt b/components/app_update/CMakeLists.txt index 2fb1be8cdb..5d9692a73d 100644 --- a/components/app_update/CMakeLists.txt +++ b/components/app_update/CMakeLists.txt @@ -1,7 +1,7 @@ idf_component_register(SRCS "esp_ota_ops.c" "esp_ota_app_desc.c" INCLUDE_DIRS "include" - REQUIRES spi_flash partition_table bootloader_support esp_app_format - PRIV_REQUIRES esptool_py efuse) + REQUIRES partition_table bootloader_support esp_app_format esp_partition + PRIV_REQUIRES esptool_py efuse spi_flash) if(NOT BOOTLOADER_BUILD) partition_table_get_partition_info(otadata_offset "--partition-type data --partition-subtype ota" "offset") diff --git a/components/app_update/esp_ota_ops.c b/components/app_update/esp_ota_ops.c index eda7f97260..3bc6d0e0dd 100644 --- a/components/app_update/esp_ota_ops.c +++ b/components/app_update/esp_ota_ops.c @@ -14,7 +14,6 @@ #include "esp_err.h" #include "esp_partition.h" -#include "spi_flash_mmap.h" #include "esp_image_format.h" #include "esp_secure_boot.h" #include "esp_flash_encrypt.h" @@ -84,16 +83,16 @@ static const esp_partition_t *read_otadata(esp_ota_select_entry_t *two_otadata) return NULL; } - spi_flash_mmap_handle_t ota_data_map; + esp_partition_mmap_handle_t ota_data_map; const void *result = NULL; - esp_err_t err = esp_partition_mmap(otadata_partition, 0, otadata_partition->size, SPI_FLASH_MMAP_DATA, &result, &ota_data_map); + esp_err_t err = esp_partition_mmap(otadata_partition, 0, otadata_partition->size, ESP_PARTITION_MMAP_DATA, &result, &ota_data_map); if (err != ESP_OK) { ESP_LOGE(TAG, "mmap otadata filed. Err=0x%8x", err); return NULL; } else { memcpy(&two_otadata[0], result, sizeof(esp_ota_select_entry_t)); memcpy(&two_otadata[1], result + SPI_FLASH_SEC_SIZE, sizeof(esp_ota_select_entry_t)); - spi_flash_munmap(ota_data_map); + esp_partition_munmap(ota_data_map); } return otadata_partition; } diff --git a/components/app_update/test/CMakeLists.txt b/components/app_update/test/CMakeLists.txt index 7afb247dc9..5ebff2d19b 100644 --- a/components/app_update/test/CMakeLists.txt +++ b/components/app_update/test/CMakeLists.txt @@ -1,5 +1,5 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES cmock test_utils app_update bootloader_support nvs_flash driver + PRIV_REQUIRES cmock test_utils app_update bootloader_support nvs_flash driver spi_flash ) target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/driver/test/CMakeLists.txt b/components/driver/test/CMakeLists.txt index 0613585589..0c98179628 100644 --- a/components/driver/test/CMakeLists.txt +++ b/components/driver/test/CMakeLists.txt @@ -1,7 +1,7 @@ idf_component_register(SRC_DIRS . param_test touch_sensor_test dac_dma_test PRIV_INCLUDE_DIRS include param_test/include touch_sensor_test/include PRIV_REQUIRES cmock test_utils driver nvs_flash - esp_timer esp_adc esp_event esp_wifi) + esp_timer esp_adc esp_event esp_wifi spi_flash) target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") # A local copy of idf-extra-components esp_serial_slave_link, for stabilities of the SDIO test diff --git a/components/driver/test/test_spi_bus_lock.c b/components/driver/test/test_spi_bus_lock.c index 0d4ff36ba4..c4f099941a 100644 --- a/components/driver/test/test_spi_bus_lock.c +++ b/components/driver/test/test_spi_bus_lock.c @@ -8,6 +8,7 @@ #include "driver/spi_master.h" #include "driver/gpio.h" #include "esp_flash_spi_init.h" +#include "spi_flash_mmap.h" #include "test/test_common_spi.h" #include "unity.h" diff --git a/components/esp_hw_support/test/CMakeLists.txt b/components/esp_hw_support/test/CMakeLists.txt index 03d70c34c0..5479db5f6a 100644 --- a/components/esp_hw_support/test/CMakeLists.txt +++ b/components/esp_hw_support/test/CMakeLists.txt @@ -1,6 +1,6 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "${include_dirs}" - PRIV_REQUIRES cmock test_utils esp_hw_support driver efuse esp_timer esp_psram) + PRIV_REQUIRES cmock test_utils esp_hw_support driver efuse esp_timer esp_psram spi_flash) target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") target_link_libraries(${COMPONENT_LIB} INTERFACE "-u ld_include_test_dport_xt_highint5") diff --git a/components/esp_partition/.build-test-rules.yml b/components/esp_partition/.build-test-rules.yml new file mode 100644 index 0000000000..b46c556453 --- /dev/null +++ b/components/esp_partition/.build-test-rules.yml @@ -0,0 +1,6 @@ +# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps + +components/esp_partition/host_test/partition_api_test: + enable: + - if: IDF_TARGET == "linux" + reason: only test on linux diff --git a/components/esp_partition/CMakeLists.txt b/components/esp_partition/CMakeLists.txt new file mode 100644 index 0000000000..bd30fa8435 --- /dev/null +++ b/components/esp_partition/CMakeLists.txt @@ -0,0 +1,30 @@ +set(srcs "partition.c") +set(priv_reqs esp_system bootloader_support spi_flash app_update partition_table) +set(reqs) +set(include_dirs "include") + +idf_build_get_property(target IDF_TARGET) +if(${target} STREQUAL "linux") + list(APPEND srcs "partition_linux.c") + set(priv_reqs partition_table linux) + + # Steal some include directories from bootloader_support and hal components: + idf_component_get_property(hal_dir hal COMPONENT_DIR) + idf_component_get_property(bootloader_support_dir bootloader_support COMPONENT_DIR) + list(APPEND include_dirs include ${hal_dir}/include ${bootloader_support_dir}/include) +else() + list(APPEND srcs "partition_target.c") +endif() + +idf_component_register(SRCS "${srcs}" + INCLUDE_DIRS ${include_dirs} + REQUIRES ${reqs} + PRIV_REQUIRES ${priv_reqs}) + +if(CMAKE_C_COMPILER_ID MATCHES "GNU") + # These flags are GCC specific + set_property(SOURCE ${cache_srcs} APPEND_STRING PROPERTY COMPILE_FLAGS + " -fno-inline-small-functions -fno-inline-functions-called-once") +endif() + +target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/spi_flash/host_test/partition_api_test/CMakeLists.txt b/components/esp_partition/host_test/partition_api_test/CMakeLists.txt similarity index 85% rename from components/spi_flash/host_test/partition_api_test/CMakeLists.txt rename to components/esp_partition/host_test/partition_api_test/CMakeLists.txt index 469a614a14..3986bdb314 100644 --- a/components/spi_flash/host_test/partition_api_test/CMakeLists.txt +++ b/components/esp_partition/host_test/partition_api_test/CMakeLists.txt @@ -7,3 +7,5 @@ set(COMPONENTS main) list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/") project(partition_api_test) + +add_dependencies(partition_api_test.elf partition-table) diff --git a/components/spi_flash/host_test/partition_api_test/README.md b/components/esp_partition/host_test/partition_api_test/README.md similarity index 100% rename from components/spi_flash/host_test/partition_api_test/README.md rename to components/esp_partition/host_test/partition_api_test/README.md diff --git a/components/esp_partition/host_test/partition_api_test/main/CMakeLists.txt b/components/esp_partition/host_test/partition_api_test/main/CMakeLists.txt new file mode 100644 index 0000000000..5dee25b740 --- /dev/null +++ b/components/esp_partition/host_test/partition_api_test/main/CMakeLists.txt @@ -0,0 +1,2 @@ +idf_component_register(SRCS "partition_api_test.c" + REQUIRES esp_partition unity) diff --git a/components/spi_flash/host_test/partition_api_test/main/partition_api_test.cpp b/components/esp_partition/host_test/partition_api_test/main/partition_api_test.c similarity index 55% rename from components/spi_flash/host_test/partition_api_test/main/partition_api_test.cpp rename to components/esp_partition/host_test/partition_api_test/main/partition_api_test.c index 4ee8849496..2f0db43efa 100644 --- a/components/spi_flash/host_test/partition_api_test/main/partition_api_test.cpp +++ b/components/esp_partition/host_test/partition_api_test/main/partition_api_test.c @@ -10,64 +10,74 @@ #include "esp_err.h" #include "esp_partition.h" #include "esp_private/partition_linux.h" +#include "unity.h" +#include "unity_fixture.h" -int main(int argc, char **argv) + +TEST_GROUP(partition_api); + +TEST_SETUP(partition_api) { - printf("Partition API Linux emulation test: "); +} - //////////////////////////////////////// - //PARTITION LOOKUP: +TEST_TEAR_DOWN(partition_api) +{ +} - //1. esp_partition_find (label=STORAGE) +TEST(partition_api, test_partition_find_basic) +{ esp_partition_iterator_t iter = esp_partition_find(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, "storage"); - assert(iter); + TEST_ASSERT_NOT_NULL(iter); - //2. esp_partition_get (label=STORAGE) const esp_partition_t *part = esp_partition_get(iter); - assert(part); + TEST_ASSERT_NOT_NULL(part); - //3. esp_partition_iterator_release (label STORAGE iter): assumed OK esp_partition_iterator_release(iter); +} - //////////////////////////////////////// - //ITERATORS, PARTITION PROPERTIES: - - //4. esp_partition_find_first (type=APP, subtype=ANY) - const esp_partition_t *partition_app = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_ANY, NULL); - assert(partition_app); - - //5. enumerate all APP partitions - iter = esp_partition_find(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_ANY, NULL); - assert(iter); +TEST(partition_api, test_partition_find_app) +{ + esp_partition_iterator_t iter = esp_partition_find(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_ANY, NULL); + TEST_ASSERT_NOT_NULL(iter); size_t counter = 0; while (iter != NULL) { const esp_partition_t *part_data = esp_partition_get(iter); counter++; - assert(part_data); + TEST_ASSERT_NOT_NULL(part_data); iter = esp_partition_next(iter); } esp_partition_iterator_release(iter); +} - //6. enumerate all DATA partitions and print details for each - iter = esp_partition_find(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, NULL); - assert(iter); - counter = 0; +TEST(partition_api, test_partition_find_data) +{ + esp_partition_iterator_t iter = esp_partition_find(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, NULL); + TEST_ASSERT_NOT_NULL(iter); + size_t counter = 0; while (iter != NULL) { const esp_partition_t *part_data = esp_partition_get(iter); counter++; - assert(part_data); + TEST_ASSERT_NOT_NULL(part_data); iter = esp_partition_next(iter); } esp_partition_iterator_release(iter); +} + +TEST(partition_api, test_partition_find_first) +{ + const esp_partition_t *partition_app = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_ANY, NULL); + TEST_ASSERT_NOT_NULL(partition_app); - //7. esp_partition_find_first (type=DATA, label=STORAGE) const esp_partition_t *partition_data = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, "storage"); - assert(partition_data); + TEST_ASSERT_NOT_NULL(partition_data); +} - ///////////////////////////////////// - //OPERATIONS +TEST(partition_api, test_partition_ops) +{ + const esp_partition_t *partition_data = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, "storage"); + TEST_ASSERT_NOT_NULL(partition_data); uint8_t buff[] = "ABCDEFGHIJKLMNOP"; size_t bufsize = sizeof(buff); @@ -75,12 +85,12 @@ int main(int argc, char **argv) //8. esp_partition_write/raw esp_err_t err = esp_partition_write(partition_data, off, (const void *)buff, bufsize); - assert(err == ESP_OK); + TEST_ESP_OK(err); //9. esp_partition_read/raw uint8_t buffout[32] = {0}; err = esp_partition_read(partition_data, off, (void *)buffout, bufsize); - assert(err == ESP_OK); + TEST_ESP_OK(err); //10. esp_partition_erase_range uint8_t buferase[bufsize]; @@ -88,19 +98,32 @@ int main(int argc, char **argv) memset(buffout, 0, sizeof(buffout)); size_t sector_off = 0; //erase works per whole sector - offset must be aligned to 4kB boundaries - err = esp_partition_erase_range(partition_data, sector_off, SPI_FLASH_SEC_SIZE); + err = esp_partition_erase_range(partition_data, sector_off, partition_data->erase_size); assert(esp_partition_read(partition_data, off, (void *)buffout, bufsize) == ESP_OK); - assert(err == ESP_OK && memcmp(buffout, buferase, bufsize) == 0); + TEST_ESP_OK(err); + TEST_ASSERT_EQUAL(0, memcmp(buffout, buferase, bufsize)); //11. esp_partition_verify (partition_data) const esp_partition_t *verified_partition = esp_partition_verify(partition_data); - assert(verified_partition != NULL); + TEST_ASSERT_NOT_NULL(verified_partition); +} - //12. release SPI FLASH emulation block from memory - err = esp_partition_file_munmap(); - assert(err == ESP_OK); +TEST_GROUP_RUNNER(partition_api) +{ + RUN_TEST_CASE(partition_api, test_partition_find_basic); + RUN_TEST_CASE(partition_api, test_partition_find_app); + RUN_TEST_CASE(partition_api, test_partition_find_data); + RUN_TEST_CASE(partition_api, test_partition_find_first); + RUN_TEST_CASE(partition_api, test_partition_ops); +} - printf("OK\n"); +static void run_all_tests(void) +{ + RUN_TEST_GROUP(partition_api); +} +int main(int argc, char **argv) +{ + UNITY_MAIN_FUNC(run_all_tests); return 0; } diff --git a/components/spi_flash/host_test/partition_api_test/partition_table.csv b/components/esp_partition/host_test/partition_api_test/partition_table.csv similarity index 100% rename from components/spi_flash/host_test/partition_api_test/partition_table.csv rename to components/esp_partition/host_test/partition_api_test/partition_table.csv diff --git a/components/spi_flash/host_test/partition_api_test/sdkconfig.defaults b/components/esp_partition/host_test/partition_api_test/sdkconfig.defaults similarity index 89% rename from components/spi_flash/host_test/partition_api_test/sdkconfig.defaults rename to components/esp_partition/host_test/partition_api_test/sdkconfig.defaults index 47666febd9..275e768c6c 100644 --- a/components/spi_flash/host_test/partition_api_test/sdkconfig.defaults +++ b/components/esp_partition/host_test/partition_api_test/sdkconfig.defaults @@ -1,6 +1,7 @@ CONFIG_IDF_TARGET="linux" CONFIG_COMPILER_CXX_EXCEPTIONS=y CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=n +CONFIG_UNITY_ENABLE_FIXTURE=y CONFIG_PARTITION_TABLE_CUSTOM=y CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partition_table.csv" CONFIG_ESPTOOLPY_FLASHSIZE="4MB" diff --git a/components/spi_flash/include/esp_partition.h b/components/esp_partition/include/esp_partition.h similarity index 93% rename from components/spi_flash/include/esp_partition.h rename to components/esp_partition/include/esp_partition.h index 4d0d9d29b3..0b75dd5f1a 100644 --- a/components/spi_flash/include/esp_partition.h +++ b/components/esp_partition/include/esp_partition.h @@ -11,8 +11,6 @@ #include #include #include "esp_err.h" -#include "esp_flash.h" -#include "spi_flash_mmap.h" #ifdef __cplusplus extern "C" { @@ -23,6 +21,22 @@ extern "C" { * @brief Partition APIs */ +/** @cond */ +typedef struct esp_flash_t esp_flash_t; +/** @endcond */ + +/** + * @brief Enumeration which specifies memory space requested in an mmap call + */ +typedef enum { + ESP_PARTITION_MMAP_DATA, /**< map to data memory (Vaddr0), allows byte-aligned access, 4 MB total */ + ESP_PARTITION_MMAP_INST, /**< map to instruction memory (Vaddr1-3), allows only 4-byte-aligned access, 11 MB total */ +} esp_partition_mmap_memory_t; + +/** + * @brief Opaque handle for memory region obtained from esp_partition_mmap. + */ +typedef uint32_t esp_partition_mmap_handle_t; /** * @brief Partition type @@ -114,6 +128,7 @@ typedef struct { esp_partition_subtype_t subtype; /*!< partition subtype */ uint32_t address; /*!< starting address of the partition in flash */ uint32_t size; /*!< size of the partition, in bytes */ + uint32_t erase_size; /*!< size the erase operation should be aligned to */ char label[17]; /*!< partition label, zero-terminated ASCII string */ bool encrypted; /*!< flag is set to true if partition is encrypted */ } esp_partition_t; @@ -318,9 +333,9 @@ esp_err_t esp_partition_write_raw(const esp_partition_t* partition, * esp_partition_find_first or esp_partition_get. * Must be non-NULL. * @param offset Offset from the beginning of partition where erase operation - * should start. Must be aligned to 4 kilobytes. + * should start. Must be aligned to partition->erase_size. * @param size Size of the range which should be erased, in bytes. - * Must be divisible by 4 kilobytes. + * Must be divisible by partition->erase_size. * * @return ESP_OK, if the range was erased successfully; * ESP_ERR_INVALID_ARG, if iterator or dst are NULL; @@ -342,7 +357,7 @@ esp_err_t esp_partition_erase_range(const esp_partition_t* partition, * requested offset (not necessarily to the beginning of mmap-ed region). * * To release mapped memory, pass handle returned via out_handle argument to - * spi_flash_munmap function. + * esp_partition_munmap function. * * @param partition Pointer to partition structure obtained using * esp_partition_find_first or esp_partition_get. @@ -351,13 +366,25 @@ esp_err_t esp_partition_erase_range(const esp_partition_t* partition, * @param size Size of the area to be mapped. * @param memory Memory space where the region should be mapped * @param out_ptr Output, pointer to the mapped memory region - * @param out_handle Output, handle which should be used for spi_flash_munmap call + * @param out_handle Output, handle which should be used for esp_partition_munmap call * * @return ESP_OK, if successful */ esp_err_t esp_partition_mmap(const esp_partition_t* partition, size_t offset, size_t size, - spi_flash_mmap_memory_t memory, - const void** out_ptr, spi_flash_mmap_handle_t* out_handle); + esp_partition_mmap_memory_t memory, + const void** out_ptr, esp_partition_mmap_handle_t* out_handle); + +/** + * @brief Release region previously obtained using esp_partition_mmap + * + * @note Calling this function will not necessarily unmap memory region. + * Region will only be unmapped when there are no other handles which + * reference this region. In case of partially overlapping regions + * it is possible that memory will be unmapped partially. + * + * @param handle Handle obtained from spi_flash_mmap + */ +void esp_partition_munmap(esp_partition_mmap_handle_t handle); /** * @brief Get SHA-256 digest for required partition. diff --git a/components/spi_flash/include/esp_private/partition_linux.h b/components/esp_partition/include/esp_private/partition_linux.h similarity index 96% rename from components/spi_flash/include/esp_private/partition_linux.h rename to components/esp_partition/include/esp_private/partition_linux.h index 5da5738d78..efb1e65b0f 100644 --- a/components/spi_flash/include/esp_private/partition_linux.h +++ b/components/esp_partition/include/esp_private/partition_linux.h @@ -19,6 +19,9 @@ extern "C" { * @brief Private API functions used for Linux-target emulation of the Partition APIs (host-side testing) */ +/** @brief emulated sector size for the partition API on Linux */ +#define ESP_PARTITION_EMULATED_SECTOR_SIZE 0x1000 + /** * @brief Partition type to string conversion routine * diff --git a/components/spi_flash/partition.c b/components/esp_partition/partition.c similarity index 95% rename from components/spi_flash/partition.c rename to components/esp_partition/partition.c index 1ff38261aa..2bf015ec20 100644 --- a/components/spi_flash/partition.c +++ b/components/esp_partition/partition.c @@ -12,10 +12,10 @@ #include "sdkconfig.h" #include "esp_flash_partitions.h" #include "esp_attr.h" -#include "esp_flash.h" #include "esp_partition.h" #if !CONFIG_IDF_TARGET_LINUX +#include "esp_flash.h" #include "esp_flash_encrypt.h" #endif @@ -30,6 +30,13 @@ #include "esp_private/partition_linux.h" #endif +#ifndef CONFIG_IDF_TARGET_LINUX +#define MMU_PAGE_SIZE CONFIG_MMU_PAGE_SIZE +#else +// No relation to the page size on Linux; assume the same value as on ESP32 +#define MMU_PAGE_SIZE 65536 +#endif // CONFIG_MMU_PAGE_SIZE + #ifndef NDEBUG // Enable built-in checks in queue.h in debug builds #define INVARIANTS @@ -78,14 +85,16 @@ static esp_err_t load_partitions(void) esp_rom_md5_init(&context); #endif - uint32_t partition_align_pg_size = (ESP_PARTITION_TABLE_OFFSET) & ~(CONFIG_MMU_PAGE_SIZE - 1); + uint32_t partition_align_pg_size = (ESP_PARTITION_TABLE_OFFSET) & ~(MMU_PAGE_SIZE - 1); uint32_t partition_pad = ESP_PARTITION_TABLE_OFFSET - partition_align_pg_size; #if CONFIG_IDF_TARGET_LINUX esp_err_t err = esp_partition_file_mmap(&p_start); + size_t mapped_size = ESP_PARTITION_EMULATED_SECTOR_SIZE; #else esp_err_t err = spi_flash_mmap(partition_align_pg_size, SPI_FLASH_SEC_SIZE, SPI_FLASH_MMAP_DATA, (const void **)&p_start, &handle); + size_t mapped_size = SPI_FLASH_SEC_SIZE; #endif if (err != ESP_OK) { @@ -94,7 +103,7 @@ static esp_err_t load_partitions(void) // calculate partition address within mmap-ed region p_start += partition_pad; - p_end = p_start + SPI_FLASH_SEC_SIZE; + p_end = p_start + mapped_size; for (const uint8_t *p_entry = p_start; p_entry < p_end; p_entry += sizeof(esp_partition_info_t)) { esp_partition_info_t entry; @@ -129,6 +138,11 @@ static esp_err_t load_partitions(void) #endif item->info.address = entry.pos.offset; item->info.size = entry.pos.size; +#if CONFIG_IDF_TARGET_LINUX + item->info.erase_size = ESP_PARTITION_EMULATED_SECTOR_SIZE; +#else + item->info.erase_size = SPI_FLASH_SEC_SIZE; +#endif item->info.type = entry.type; item->info.subtype = entry.subtype; item->info.encrypted = entry.flags & PART_FLAG_ENCRYPTED; @@ -356,9 +370,14 @@ esp_err_t esp_partition_register_external(esp_flash_t *flash_chip, size_t offset *out_partition = NULL; } +#if CONFIG_IDF_TARGET_LINUX + return ESP_ERR_NOT_SUPPORTED; + +#else if (offset + size > flash_chip->size) { return ESP_ERR_INVALID_SIZE; } +#endif // CONFIG_IDF_TARGET_LINUX esp_err_t err = ensure_partitions_loaded(); if (err != ESP_OK) { diff --git a/components/spi_flash/partition_linux.c b/components/esp_partition/partition_linux.c similarity index 98% rename from components/spi_flash/partition_linux.c rename to components/esp_partition/partition_linux.c index 784b0d1c11..d20ccb5155 100644 --- a/components/spi_flash/partition_linux.c +++ b/components/esp_partition/partition_linux.c @@ -238,10 +238,10 @@ esp_err_t esp_partition_erase_range(const esp_partition_t *partition, size_t off { assert(partition != NULL); - if (offset > partition->size || offset % SPI_FLASH_SEC_SIZE != 0) { + if (offset > partition->size || offset % partition->erase_size != 0) { return ESP_ERR_INVALID_ARG; } - if (offset + size > partition->size || size % SPI_FLASH_SEC_SIZE != 0) { + if (offset + size > partition->size || size % partition->erase_size != 0) { return ESP_ERR_INVALID_SIZE; } diff --git a/components/spi_flash/partition_target.c b/components/esp_partition/partition_target.c similarity index 94% rename from components/spi_flash/partition_target.c rename to components/esp_partition/partition_target.c index cacdc3bba5..6d635f2fa0 100644 --- a/components/spi_flash/partition_target.c +++ b/components/esp_partition/partition_target.c @@ -143,8 +143,8 @@ esp_err_t esp_partition_erase_range(const esp_partition_t *partition, * mmaped pointers, and a single handle for all these regions. */ esp_err_t esp_partition_mmap(const esp_partition_t *partition, size_t offset, size_t size, - spi_flash_mmap_memory_t memory, - const void **out_ptr, spi_flash_mmap_handle_t *out_handle) + esp_partition_mmap_memory_t memory, + const void **out_ptr, esp_partition_mmap_handle_t *out_handle) { assert(partition != NULL); if (offset > partition->size) { @@ -160,7 +160,7 @@ esp_err_t esp_partition_mmap(const esp_partition_t *partition, size_t offset, si // offset within mmu page size block size_t region_offset = phys_addr & (CONFIG_MMU_PAGE_SIZE - 1); size_t mmap_addr = phys_addr & ~(CONFIG_MMU_PAGE_SIZE - 1); - esp_err_t rc = spi_flash_mmap(mmap_addr, size + region_offset, memory, out_ptr, out_handle); + esp_err_t rc = spi_flash_mmap(mmap_addr, size + region_offset, (spi_flash_mmap_memory_t) memory, out_ptr, (spi_flash_mmap_handle_t*) out_handle); // adjust returned pointer to point to the correct offset if (rc == ESP_OK) { *out_ptr = (void *) (((ptrdiff_t) * out_ptr) + region_offset); @@ -168,6 +168,11 @@ esp_err_t esp_partition_mmap(const esp_partition_t *partition, size_t offset, si return rc; } +void esp_partition_munmap(esp_partition_mmap_handle_t handle) +{ + spi_flash_munmap((spi_flash_mmap_handle_t) handle); +} + esp_err_t esp_partition_get_sha256(const esp_partition_t *partition, uint8_t *sha_256) { return bootloader_common_get_sha256_of_partition(partition->address, partition->size, partition->type, sha_256); diff --git a/components/esp_partition/test/CMakeLists.txt b/components/esp_partition/test/CMakeLists.txt new file mode 100644 index 0000000000..56c4de4a73 --- /dev/null +++ b/components/esp_partition/test/CMakeLists.txt @@ -0,0 +1,4 @@ +idf_component_register(SRC_DIRS "." + PRIV_INCLUDE_DIRS "." + PRIV_REQUIRES test_utils esp_partition esp_system app_update bootloader_support spi_flash) +target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/partition_table/test/test_partition.c b/components/esp_partition/test/test_partition.c similarity index 95% rename from components/partition_table/test/test_partition.c rename to components/esp_partition/test/test_partition.c index 50b2ce5a3b..b32edac109 100644 --- a/components/partition_table/test/test_partition.c +++ b/components/esp_partition/test/test_partition.c @@ -49,7 +49,7 @@ TEST_CASE("Can write, read, mmap partition", "[partition][ignore]") const esp_partition_t *p = get_test_data_partition(); printf("Using partition %s at 0x%x, size 0x%x\n", p->label, p->address, p->size); TEST_ASSERT_NOT_NULL(p); - const size_t max_size = 2 * SPI_FLASH_SEC_SIZE; + const size_t max_size = 2 * p->erase_size; uint8_t *data = (uint8_t *) malloc(max_size); TEST_ASSERT_NOT_NULL(data); @@ -85,10 +85,10 @@ TEST_CASE("Can write, read, mmap partition", "[partition][ignore]") free(data); const uint32_t *mmap_data; - spi_flash_mmap_handle_t mmap_handle; + esp_partition_mmap_handle_t mmap_handle; size_t begin = 3000; 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, + TEST_ASSERT_EQUAL(ESP_OK, esp_partition_mmap(p, begin, size, ESP_PARTITION_MMAP_DATA, (const void **)&mmap_data, &mmap_handle)); srand(0); for (size_t offset = 0; offset < p->size; offset += block_size) { @@ -107,5 +107,5 @@ TEST_CASE("Can write, read, mmap partition", "[partition][ignore]") } } - spi_flash_munmap(mmap_handle); + esp_partition_munmap(mmap_handle); } diff --git a/components/spi_flash/test/test_partition_ext.c b/components/esp_partition/test/test_partition_ext.c similarity index 92% rename from components/spi_flash/test/test_partition_ext.c rename to components/esp_partition/test/test_partition_ext.c index 62011a9ead..b2721c8788 100644 --- a/components/spi_flash/test/test_partition_ext.c +++ b/components/esp_partition/test/test_partition_ext.c @@ -1,4 +1,10 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Unlicense OR CC0-1.0 + */ #include "esp_flash.h" +#include "spi_flash_mmap.h" #include "esp_partition.h" #include "unity.h" diff --git a/components/spi_flash/test/test_partitions.c b/components/esp_partition/test/test_partitions.c similarity index 98% rename from components/spi_flash/test/test_partitions.c rename to components/esp_partition/test/test_partitions.c index d916de7c74..3565549c10 100644 --- a/components/spi_flash/test/test_partitions.c +++ b/components/esp_partition/test/test_partitions.c @@ -18,6 +18,8 @@ #include #include #include +#include "esp_flash.h" +#include "spi_flash_mmap.h" TEST_CASE("Test erase partition", "[spi_flash][esp_flash]") { diff --git a/components/esp_psram/test_apps/psram/main/test_psram.c b/components/esp_psram/test_apps/psram/main/test_psram.c index 7d7fad9bd5..10772f2b65 100644 --- a/components/esp_psram/test_apps/psram/main/test_psram.c +++ b/components/esp_psram/test_apps/psram/main/test_psram.c @@ -16,6 +16,8 @@ #include "esp_private/esp_psram_io.h" #include "esp_psram.h" #include "esp_private/esp_psram_extram.h" +#include "esp_flash.h" +#include "esp_partition.h" __attribute__((unused)) const static char *TAG = "PSRAM"; diff --git a/components/esp_ringbuf/test/CMakeLists.txt b/components/esp_ringbuf/test/CMakeLists.txt index b5fc2058f7..660c3d9398 100644 --- a/components/esp_ringbuf/test/CMakeLists.txt +++ b/components/esp_ringbuf/test/CMakeLists.txt @@ -1,4 +1,4 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES cmock test_utils esp_ringbuf driver) + PRIV_REQUIRES cmock test_utils esp_ringbuf driver spi_flash) target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/esp_system/CMakeLists.txt b/components/esp_system/CMakeLists.txt index 5e7e8e3c2f..e215e2adb6 100644 --- a/components/esp_system/CMakeLists.txt +++ b/components/esp_system/CMakeLists.txt @@ -38,7 +38,9 @@ else() # link-time registration is used. # [refactor-todo] requires "driver" for headers: # - spi_common_internal.h - pthread bootloader_support efuse driver + # [refactor-todo] esp_partition required for virtual efuse + # init code. Move to esp_efuse component. + pthread bootloader_support efuse driver esp_partition LDFRAGMENTS "linker.lf" "app.lf") add_subdirectory(port) diff --git a/components/esp_timer/test/CMakeLists.txt b/components/esp_timer/test/CMakeLists.txt index 6aa2625098..bf7f6ea740 100644 --- a/components/esp_timer/test/CMakeLists.txt +++ b/components/esp_timer/test/CMakeLists.txt @@ -1,4 +1,4 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "../private_include" - PRIV_REQUIRES cmock test_utils esp_timer) + PRIV_REQUIRES cmock test_utils esp_timer spi_flash) target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/espcoredump/CMakeLists.txt b/components/espcoredump/CMakeLists.txt index 6be5b6a29a..577e39a11f 100644 --- a/components/espcoredump/CMakeLists.txt +++ b/components/espcoredump/CMakeLists.txt @@ -24,7 +24,7 @@ idf_component_register(SRCS ${srcs} INCLUDE_DIRS ${includes} PRIV_INCLUDE_DIRS ${priv_includes} LDFRAGMENTS linker.lf - PRIV_REQUIRES spi_flash bootloader_support mbedtls esp_rom soc esp_system driver) + PRIV_REQUIRES esp_partition spi_flash bootloader_support mbedtls esp_rom soc esp_system driver) if(CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF) target_link_libraries(${COMPONENT_LIB} PRIVATE idf::esp_app_format) diff --git a/components/fatfs/CMakeLists.txt b/components/fatfs/CMakeLists.txt index 68489a2b64..05a1446948 100644 --- a/components/fatfs/CMakeLists.txt +++ b/components/fatfs/CMakeLists.txt @@ -12,7 +12,7 @@ set(srcs "diskio/diskio.c" idf_component_register(SRCS ${srcs} INCLUDE_DIRS diskio vfs src REQUIRES wear_levelling sdmmc - PRIV_REQUIRES vfs + PRIV_REQUIRES vfs spi_flash ) target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/fatfs/diskio/diskio_rawflash.c b/components/fatfs/diskio/diskio_rawflash.c index 382e532393..8ffa5715e8 100644 --- a/components/fatfs/diskio/diskio_rawflash.c +++ b/components/fatfs/diskio/diskio_rawflash.c @@ -1,16 +1,8 @@ -// Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include #include "diskio_impl.h" @@ -19,6 +11,8 @@ #include "esp_log.h" #include "diskio_rawflash.h" #include "esp_compiler.h" +#include "spi_flash_mmap.h" + static const char* TAG = "diskio_rawflash"; diff --git a/components/fatfs/test/CMakeLists.txt b/components/fatfs/test/CMakeLists.txt index 518f57c83a..f7818e4b9f 100644 --- a/components/fatfs/test/CMakeLists.txt +++ b/components/fatfs/test/CMakeLists.txt @@ -1,6 +1,6 @@ idf_component_register(SRC_DIRS . PRIV_INCLUDE_DIRS . - PRIV_REQUIRES cmock test_utils vfs fatfs + PRIV_REQUIRES cmock test_utils vfs fatfs spi_flash EMBED_TXTFILES fatfs.img ) target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/fatfs/test/test_fatfs_rawflash.c b/components/fatfs/test/test_fatfs_rawflash.c index efb7437198..dda6cfc4b0 100644 --- a/components/fatfs/test/test_fatfs_rawflash.c +++ b/components/fatfs/test/test_fatfs_rawflash.c @@ -22,6 +22,7 @@ #include "esp_partition.h" #include "ff.h" #include "esp_rom_sys.h" +#include "spi_flash_mmap.h" #if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2) diff --git a/components/fatfs/test_fatfs_host/Makefile.files b/components/fatfs/test_fatfs_host/Makefile.files index baa9597b70..f0c7bbf767 100644 --- a/components/fatfs/test_fatfs_host/Makefile.files +++ b/components/fatfs/test_fatfs_host/Makefile.files @@ -40,4 +40,5 @@ INCLUDE_DIRS := \ hal/include \ spi_flash/include \ wear_levelling/include \ + esp_partition/include \ ) diff --git a/components/heap/test/CMakeLists.txt b/components/heap/test/CMakeLists.txt index 3ccce3753e..0817b74f49 100644 --- a/components/heap/test/CMakeLists.txt +++ b/components/heap/test/CMakeLists.txt @@ -1,4 +1,4 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES cmock test_utils heap) + PRIV_REQUIRES cmock test_utils heap spi_flash) target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/mbedtls/test/CMakeLists.txt b/components/mbedtls/test/CMakeLists.txt index d51cbed59a..987a4b0baf 100644 --- a/components/mbedtls/test/CMakeLists.txt +++ b/components/mbedtls/test/CMakeLists.txt @@ -7,7 +7,7 @@ set(TEST_CRTS "crts/server_cert_chain.pem" idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES cmock test_utils mbedtls esp_timer + PRIV_REQUIRES cmock test_utils mbedtls esp_timer spi_flash EMBED_TXTFILES ${TEST_CRTS}) target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/mbedtls/test/test_sha.c b/components/mbedtls/test/test_sha.c index c6a771f67c..a40c70ee3d 100644 --- a/components/mbedtls/test/test_sha.c +++ b/components/mbedtls/test/test_sha.c @@ -12,6 +12,7 @@ #include "esp_heap_caps.h" #include "idf_performance.h" #include "esp_private/esp_clk.h" +#include "spi_flash_mmap.h" #include "soc/soc_caps.h" diff --git a/components/mqtt/test/CMakeLists.txt b/components/mqtt/test/CMakeLists.txt index 616d362045..3261bec86f 100644 --- a/components/mqtt/test/CMakeLists.txt +++ b/components/mqtt/test/CMakeLists.txt @@ -5,5 +5,5 @@ if(CONFIG_MQTT_PROTOCOL_5) endif() idf_component_register(SRCS "${srcs}" - PRIV_REQUIRES cmock test_utils mqtt nvs_flash app_update esp_eth esp_netif) + PRIV_REQUIRES cmock test_utils mqtt nvs_flash app_update esp_eth esp_netif spi_flash) target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/mqtt/test/test_mqtt.c b/components/mqtt/test/test_mqtt.c index 2494d03c8a..8b16188f90 100644 --- a/components/mqtt/test/test_mqtt.c +++ b/components/mqtt/test/test_mqtt.c @@ -23,6 +23,7 @@ #include "test_mqtt_client_broker.h" #include "test_mqtt_connection.h" #include "esp_mac.h" +#include "spi_flash_mmap.h" static void test_leak_setup(const char * file, long line) { diff --git a/components/mqtt/test/test_mqtt5.c b/components/mqtt/test/test_mqtt5.c index 01c33e79da..502cd1ce53 100644 --- a/components/mqtt/test/test_mqtt5.c +++ b/components/mqtt/test/test_mqtt5.c @@ -17,6 +17,7 @@ #include "test_mqtt5_client_broker.h" #include "test_mqtt_connection.h" #include "esp_mac.h" +#include "spi_flash_mmap.h" static esp_mqtt5_user_property_item_t user_property_arr[3] = { {"board", "esp32"}, diff --git a/components/newlib/test/CMakeLists.txt b/components/newlib/test/CMakeLists.txt index cb3cf2f346..12b5a18f5d 100644 --- a/components/newlib/test/CMakeLists.txt +++ b/components/newlib/test/CMakeLists.txt @@ -1,4 +1,4 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES cmock test_utils driver esp_timer) + PRIV_REQUIRES cmock test_utils driver esp_timer spi_flash) target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/nvs_flash/CMakeLists.txt b/components/nvs_flash/CMakeLists.txt index 306f365547..f19655a71d 100644 --- a/components/nvs_flash/CMakeLists.txt +++ b/components/nvs_flash/CMakeLists.txt @@ -14,7 +14,8 @@ set(srcs "src/nvs_api.cpp" "src/nvs_types.cpp") idf_component_register(SRCS "${srcs}" - REQUIRES "spi_flash" + REQUIRES "esp_partition" + PRIV_REQUIRES spi_flash INCLUDE_DIRS "include" PRIV_INCLUDE_DIRS "private_include") diff --git a/components/nvs_flash/host_test/nvs_page_test/CMakeLists.txt b/components/nvs_flash/host_test/nvs_page_test/CMakeLists.txt index 7cbfe573bb..b41cfaa008 100644 --- a/components/nvs_flash/host_test/nvs_page_test/CMakeLists.txt +++ b/components/nvs_flash/host_test/nvs_page_test/CMakeLists.txt @@ -6,6 +6,7 @@ set(COMPONENTS main) list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/driver/") list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/") list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/spi_flash/") +list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/esp_partition/") idf_build_set_property(COMPILE_DEFINITIONS "-DNO_DEBUG_STORAGE" APPEND) project(test_nvs_page_host) diff --git a/components/nvs_flash/host_test/nvs_page_test/main/CMakeLists.txt b/components/nvs_flash/host_test/nvs_page_test/main/CMakeLists.txt index a6fe64ec97..a9b8374dc2 100644 --- a/components/nvs_flash/host_test/nvs_page_test/main/CMakeLists.txt +++ b/components/nvs_flash/host_test/nvs_page_test/main/CMakeLists.txt @@ -5,7 +5,7 @@ idf_component_register(SRCS "nvs_page_test.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/../../../src" PRIV_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../private_include" - REQUIRES cmock nvs_flash spi_flash partition_table) + REQUIRES cmock nvs_flash spi_flash partition_table esp_partition) target_compile_options(${COMPONENT_LIB} PUBLIC --coverage) target_link_libraries(${COMPONENT_LIB} --coverage) diff --git a/components/nvs_flash/test/CMakeLists.txt b/components/nvs_flash/test/CMakeLists.txt index bcfbbc2b59..13515aa416 100644 --- a/components/nvs_flash/test/CMakeLists.txt +++ b/components/nvs_flash/test/CMakeLists.txt @@ -1,6 +1,6 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES cmock test_utils nvs_flash bootloader_support + PRIV_REQUIRES cmock test_utils nvs_flash bootloader_support spi_flash EMBED_TXTFILES encryption_keys.bin partition_encrypted.bin sample.bin) target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/nvs_flash/test_nvs_host/Makefile b/components/nvs_flash/test_nvs_host/Makefile index 10669bfb6f..7b66018ad2 100644 --- a/components/nvs_flash/test_nvs_host/Makefile +++ b/components/nvs_flash/test_nvs_host/Makefile @@ -38,9 +38,9 @@ else COMPILER := gcc endif -CPPFLAGS += -I../private_include -I../include -I../src -I../../esp_rom/include -I../../esp_rom/include/linux -I../../log/include -I./ -I../../esp_common/include -I../../esp32/include -I ../../mbedtls/mbedtls/include -I ../../spi_flash/include -I ../../hal/include -I ../../xtensa/include -I ../../../tools/catch -fprofile-arcs -ftest-coverage -g2 -ggdb -CFLAGS += -fprofile-arcs -ftest-coverage -DLINUX_TARGET -CXXFLAGS += -std=c++11 -Wall -Werror -DLINUX_TARGET +CPPFLAGS += -I../private_include -I../include -I../src -I../../esp_rom/include -I../../esp_rom/include/linux -I../../log/include -I./ -I../../esp_common/include -I../../esp32/include -I ../../mbedtls/mbedtls/include -I ../../spi_flash/include -I ../../esp_partition/include -I ../../hal/include -I ../../xtensa/include -I ../../../tools/catch -fprofile-arcs -ftest-coverage -g2 -ggdb +CFLAGS += -fprofile-arcs -ftest-coverage -DLINUX_TARGET -DLINUX_HOST_LEGACY_TEST +CXXFLAGS += -std=c++11 -Wall -Werror -DLINUX_TARGET -DLINUX_HOST_LEGACY_TEST LDFLAGS += -lstdc++ -Wall -fprofile-arcs -ftest-coverage ifeq ($(COMPILER),clang) diff --git a/components/partition_table/test/CMakeLists.txt b/components/partition_table/test/CMakeLists.txt deleted file mode 100644 index 9de17b084a..0000000000 --- a/components/partition_table/test/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -idf_component_register(SRC_DIRS "." - PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES cmock test_utils) -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/spi_flash/.build-test-rules.yml b/components/spi_flash/.build-test-rules.yml index 1521233f54..48dbd6dfcd 100644 --- a/components/spi_flash/.build-test-rules.yml +++ b/components/spi_flash/.build-test-rules.yml @@ -1,10 +1,5 @@ # Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps -components/spi_flash/host_test/partition_api_test: - enable: - - if: IDF_TARGET == "linux" - reason: only test on linux - components/spi_flash/test_apps/flash_encryption: disable_test: - if: IDF_TARGET in ["esp32c2", "esp32s2"] diff --git a/components/spi_flash/CMakeLists.txt b/components/spi_flash/CMakeLists.txt index 260b353b48..2374e85679 100644 --- a/components/spi_flash/CMakeLists.txt +++ b/components/spi_flash/CMakeLists.txt @@ -1,14 +1,5 @@ idf_build_get_property(target IDF_TARGET) if(${target} STREQUAL "linux") - set(srcs "partition.c" - "partition_linux.c") - idf_component_get_property(hal_dir hal COMPONENT_DIR) - idf_component_get_property(bootloader_support_dir bootloader_support COMPONENT_DIR) - - idf_component_register(SRCS "${srcs}" - INCLUDE_DIRS include ${hal_dir}/include ${bootloader_support_dir}/include - PRIV_INCLUDE_DIRS include/spi_flash - PRIV_REQUIRES linux partition_table) return() endif() @@ -23,11 +14,7 @@ else() "${target}/flash_ops_${target}.c" ) - set(srcs - "partition.c" - "partition_target.c" - "flash_brownout_hook.c" - ) + set(srcs "flash_brownout_hook.c") if(CONFIG_ESPTOOLPY_OCT_FLASH) list(APPEND srcs "${target}/spi_flash_oct_flash_init.c") diff --git a/components/spi_flash/host_test/partition_api_test/main/CMakeLists.txt b/components/spi_flash/host_test/partition_api_test/main/CMakeLists.txt deleted file mode 100644 index 408a6111e1..0000000000 --- a/components/spi_flash/host_test/partition_api_test/main/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -idf_component_register(SRCS "partition_api_test.cpp" - REQUIRES spi_flash) diff --git a/components/spi_flash/sim/Makefile.files b/components/spi_flash/sim/Makefile.files index 186fce56d3..7ea9d325f6 100644 --- a/components/spi_flash/sim/Makefile.files +++ b/components/spi_flash/sim/Makefile.files @@ -3,8 +3,8 @@ SOURCE_FILES := \ flash_mock.cpp \ flash_mock_util.c \ $(addprefix ../, \ - partition.c \ - ../spi_flash/partition_target.c \ + ../esp_partition/partition.c \ + ../esp_partition/partition_target.c \ flash_ops.c \ ../esp_rom/linux/esp_rom_efuse.c \ ) \ @@ -46,4 +46,5 @@ INCLUDE_DIRS := \ hal/esp32/include \ hal/platform_port/include \ spi_flash/include \ + esp_partition/include \ ) diff --git a/components/spi_flash/sim/flash_mock.cpp b/components/spi_flash/sim/flash_mock.cpp index f047cd5cba..54777d2458 100644 --- a/components/spi_flash/sim/flash_mock.cpp +++ b/components/spi_flash/sim/flash_mock.cpp @@ -1,11 +1,8 @@ -#include "SpiFlash.h" - #include #include +#include "SpiFlash.h" #include "spi_flash_mmap.h" -#include "esp_partition.h" - #include "esp_err.h" #include "esp_rom_spiflash.h" #include "esp_flash.h" diff --git a/components/spi_flash/sim/flash_mock_util.c b/components/spi_flash/sim/flash_mock_util.c index b84e2307c8..362cad2d7a 100644 --- a/components/spi_flash/sim/flash_mock_util.c +++ b/components/spi_flash/sim/flash_mock_util.c @@ -1,6 +1,3 @@ -#include "spi_flash_mmap.h" -#include "esp_partition.h" - #include "esp_err.h" #include "esp_rom_spiflash.h" diff --git a/components/spi_flash/sim/stubs/Makefile.files b/components/spi_flash/sim/stubs/Makefile.files index b2f789c39b..243d7f76dc 100644 --- a/components/spi_flash/sim/stubs/Makefile.files +++ b/components/spi_flash/sim/stubs/Makefile.files @@ -37,5 +37,6 @@ INCLUDE_DIRS := \ bootloader_support/bootloader_flash/include \ app_update/include \ hal/include \ + esp_partition/include \ spi_flash/include \ ) diff --git a/components/spi_flash/test/test_esp_flash.c b/components/spi_flash/test/test_esp_flash.c index 5e11e1d9dc..d274608b1b 100644 --- a/components/spi_flash/test/test_esp_flash.c +++ b/components/spi_flash/test/test_esp_flash.c @@ -7,6 +7,7 @@ #include #include "esp_flash.h" #include "esp_private/spi_common_internal.h" +#include "spi_flash_mmap.h" #include "esp_flash_spi_init.h" #include "memspi_host_driver.h" #include diff --git a/components/spi_flash/test/test_large_flash_writes.c b/components/spi_flash/test/test_large_flash_writes.c index 7305f64d69..cf8ac083b6 100644 --- a/components/spi_flash/test/test_large_flash_writes.c +++ b/components/spi_flash/test/test_large_flash_writes.c @@ -20,6 +20,7 @@ #include "esp_rom_spiflash.h" #include "esp_private/cache_utils.h" #include "soc/timer_periph.h" +#include "esp_flash.h" static const uint8_t large_const_buffer[16400] = { 203, // first byte diff --git a/components/spi_flash/test/test_mmap.c b/components/spi_flash/test/test_mmap.c index 0587ac6999..4c03620098 100644 --- a/components/spi_flash/test/test_mmap.c +++ b/components/spi_flash/test/test_mmap.c @@ -10,6 +10,7 @@ #include #include #include +#include "esp_flash.h" #include "test_utils.h" diff --git a/components/spi_flash/test/test_out_of_bounds_write.c b/components/spi_flash/test/test_out_of_bounds_write.c index 9854335321..10391bc002 100644 --- a/components/spi_flash/test/test_out_of_bounds_write.c +++ b/components/spi_flash/test/test_out_of_bounds_write.c @@ -3,6 +3,7 @@ #include "unity.h" #include "spi_flash_mmap.h" #include "esp_ota_ops.h" +#include "esp_flash.h" #if CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS || CONFIG_SPI_FLASH_DANGEROUS_WRITE_FAILS diff --git a/components/spi_flash/test/test_read_write.c b/components/spi_flash/test/test_read_write.c index a3e2b9d739..9412b25342 100644 --- a/components/spi_flash/test/test_read_write.c +++ b/components/spi_flash/test/test_read_write.c @@ -20,6 +20,8 @@ #include "esp_attr.h" #include "esp_heap_caps.h" #include "esp_rom_spiflash.h" +#include "esp_flash.h" + #if CONFIG_IDF_TARGET_ESP32 // Used for rom_fix function #include "esp32/rom/spi_flash.h" diff --git a/components/spiffs/CMakeLists.txt b/components/spiffs/CMakeLists.txt index a5e032dc2c..dd76da2cfa 100644 --- a/components/spiffs/CMakeLists.txt +++ b/components/spiffs/CMakeLists.txt @@ -1,14 +1,22 @@ -idf_component_register(SRCS "esp_spiffs.c" - "spiffs_api.c" - "spiffs/src/spiffs_cache.c" - "spiffs/src/spiffs_check.c" - "spiffs/src/spiffs_gc.c" - "spiffs/src/spiffs_hydrogen.c" - "spiffs/src/spiffs_nucleus.c" - INCLUDE_DIRS "include" - PRIV_INCLUDE_DIRS "." "spiffs/src" - REQUIRES spi_flash - PRIV_REQUIRES bootloader_support esptool_py vfs) +idf_build_get_property(target IDF_TARGET) + +list(APPEND srcs "spiffs_api.c" + "spiffs/src/spiffs_cache.c" + "spiffs/src/spiffs_check.c" + "spiffs/src/spiffs_gc.c" + "spiffs/src/spiffs_hydrogen.c" + "spiffs/src/spiffs_nucleus.c") + +if(NOT ${target} STREQUAL "linux") + list(APPEND pr bootloader_support esptool_py vfs) + list(APPEND srcs "esp_spiffs.c") +endif() + +idf_component_register(SRCS ${srcs} + INCLUDE_DIRS "include" + PRIV_INCLUDE_DIRS "." "spiffs/src" + REQUIRES esp_partition + PRIV_REQUIRES ${pr} spi_flash) if(CMAKE_C_COMPILER_ID MATCHES "GNU") set_source_files_properties(spiffs/src/spiffs_nucleus.c PROPERTIES COMPILE_FLAGS -Wno-stringop-truncation) diff --git a/components/spiffs/test_spiffs_host/Makefile.files b/components/spiffs/test_spiffs_host/Makefile.files index b8269837c5..8ddfe38989 100644 --- a/components/spiffs/test_spiffs_host/Makefile.files +++ b/components/spiffs/test_spiffs_host/Makefile.files @@ -40,4 +40,5 @@ INCLUDE_DIRS := \ spi_flash/include \ hal/include \ wear_levelling/include \ + esp_partition/include \ ) diff --git a/components/unity/CMakeLists.txt b/components/unity/CMakeLists.txt index 9659dbba89..91fe15e65a 100644 --- a/components/unity/CMakeLists.txt +++ b/components/unity/CMakeLists.txt @@ -45,8 +45,8 @@ endif() if(NOT "${target}" STREQUAL "linux") target_compile_definitions(${COMPONENT_LIB} PUBLIC - -DUNITY_INCLUDE_CONFIG_H - ) + -DUNITY_INCLUDE_CONFIG_H + ) endif() target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-unused-const-variable) diff --git a/components/wear_levelling/CMakeLists.txt b/components/wear_levelling/CMakeLists.txt index 1a44349585..751f682273 100644 --- a/components/wear_levelling/CMakeLists.txt +++ b/components/wear_levelling/CMakeLists.txt @@ -7,6 +7,7 @@ idf_component_register(SRCS "Partition.cpp" "wear_levelling.cpp" INCLUDE_DIRS include PRIV_INCLUDE_DIRS private_include - REQUIRES spi_flash) + REQUIRES esp_partition + PRIV_REQUIRES spi_flash) target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/wear_levelling/private_include/Partition.h b/components/wear_levelling/private_include/Partition.h index 3c83f0bbae..e07d409295 100644 --- a/components/wear_levelling/private_include/Partition.h +++ b/components/wear_levelling/private_include/Partition.h @@ -11,6 +11,7 @@ #include "Flash_Access.h" #include "esp_partition.h" +#include "spi_flash_mmap.h" // for SPI_FLASH_SEC_SIZE /** * @brief This class is used to access partition. Class implements Flash_Access interface diff --git a/components/wear_levelling/test_apps/main/CMakeLists.txt b/components/wear_levelling/test_apps/main/CMakeLists.txt index bb8eeaa368..84359c084b 100644 --- a/components/wear_levelling/test_apps/main/CMakeLists.txt +++ b/components/wear_levelling/test_apps/main/CMakeLists.txt @@ -1,6 +1,6 @@ idf_component_register(SRCS test_wl.c PRIV_INCLUDE_DIRS . - PRIV_REQUIRES wear_levelling unity + PRIV_REQUIRES wear_levelling unity spi_flash EMBED_FILES test_partition_v1.bin ) target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/wear_levelling/test_apps/main/test_wl.c b/components/wear_levelling/test_apps/main/test_wl.c index f8dd94454a..3f9fed84a0 100644 --- a/components/wear_levelling/test_apps/main/test_wl.c +++ b/components/wear_levelling/test_apps/main/test_wl.c @@ -13,6 +13,7 @@ #include "esp_private/esp_clk.h" #include "sdkconfig.h" #include "esp_cpu.h" +#include "spi_flash_mmap.h" TEST_GROUP(wear_levelling); diff --git a/components/wear_levelling/test_wl_host/Makefile.files b/components/wear_levelling/test_wl_host/Makefile.files index 3b010634c3..6c6f1b2705 100644 --- a/components/wear_levelling/test_wl_host/Makefile.files +++ b/components/wear_levelling/test_wl_host/Makefile.files @@ -39,4 +39,5 @@ INCLUDE_DIRS := \ app_update/include \ hal/include \ spi_flash/include \ + esp_partition/include \ ) diff --git a/docs/doxygen/Doxyfile b/docs/doxygen/Doxyfile index cb72b57c85..feb254b16c 100644 --- a/docs/doxygen/Doxyfile +++ b/docs/doxygen/Doxyfile @@ -207,7 +207,7 @@ INPUT = \ $(PROJECT_PATH)/components/soc/$(IDF_TARGET)/include/soc/uart_channel.h \ $(PROJECT_PATH)/components/spi_flash/include/esp_flash.h \ $(PROJECT_PATH)/components/spi_flash/include/esp_flash_spi_init.h \ - $(PROJECT_PATH)/components/spi_flash/include/esp_partition.h \ + $(PROJECT_PATH)/components/esp_partition/include/esp_partition.h \ $(PROJECT_PATH)/components/spi_flash/include/spi_flash_mmap.h \ $(PROJECT_PATH)/components/spiffs/include/esp_spiffs.h \ $(PROJECT_PATH)/components/ulp/ulp_common/include/ulp_common.h \ diff --git a/docs/en/migration-guides/release-5.x/storage.rst b/docs/en/migration-guides/release-5.x/storage.rst index 1797a8d672..ea247c7c70 100644 --- a/docs/en/migration-guides/release-5.x/storage.rst +++ b/docs/en/migration-guides/release-5.x/storage.rst @@ -1,6 +1,40 @@ Storage ======= +New Component for the Partition APIs +------------------------------------ + +Breaking change: all the Partition API code has been moved to a new component :component:`esp_partition`. For the complete list of affected functions and data-types, see header file :component_file:`esp_partition.h `. + +These API functions and data-types were previously a part of the :component:`spi_flash` component, and thus possible dependencies on the ``spi_flash`` in existing applications may cause the build failure, in case of direct esp_partition_* APIs/data-types use (for instance, ``fatal error: esp_partition.h: No such file or directory`` at lines with ``#include "esp_partition.h"``). If you encounter such an issue, please update your project's CMakeLists.txt file as follows: + +Original dependency setup: + +.. code-block:: cmake + + idf_component_register(... + REQUIRES spi_flash) + +Updated dependency setup: + +.. code-block:: cmake + + idf_component_register(... + REQUIRES spi_flash esp_partition) + +.. note:: + + Please update relevant ``REQUIRES`` or ``PRIV_REQUIRES`` section according to your project. The above-presented code snippet is just an example. + +If the issue persists, please let us know and we will assist you with your code migration. + +SDMMC/SDSPI +----------- + +SD card frequency on SDMMC/SDSPI interface can be now configured through ``sdmmc_host_t.max_freq_khz`` to a specific value, not only ``SDMMC_FREQ_PROBING`` (400 kHz), ``SDMMC_FREQ_DEFAULT`` (20 MHz), or ``SDMMC_FREQ_HIGHSPEED`` (40 MHz). Previously, in case you have specified a custom frequency other than any of the above-mentioned values, the closest lower-or-equal one was selected anyway. + +Now, the underlaying drivers calculate the nearest fitting value, given by available frequency dividers instead of an enumeration item selection. This could cause troubles in communication with your SD card without a change of the existing application code.If you encounter such an issue, please, keep trying different frequencies around your desired value unless you find the one working well. To check the frequency value calculated and actually applied, use ``void sdmmc_card_print_info(FILE* stream, const sdmmc_card_t* card)`` function. + FatFs ----- @@ -9,7 +43,7 @@ FatFs is now updated to v0.14. As a result, the function signature of ``f_mkfs() Partition Table --------------- -The partition table generator no longer supports misaligned partitions. When generating a partition table, ``esp-idf`` only accepts partitions with offsets that align to 4 KB. This change only affects generating new partition tables. Reading and writing to already existing partitions remains unchanged. +The partition table generator no longer supports misaligned partitions. When generating a partition table, ``ESP-IDF`` only accepts partitions with offsets that align to 4 KB. This change only affects generating new partition tables. Reading and writing to already existing partitions remains unchanged. VFS diff --git a/docs/zh_CN/migration-guides/release-5.x/storage.rst b/docs/zh_CN/migration-guides/release-5.x/storage.rst index d3e963a804..4146e6681c 100644 --- a/docs/zh_CN/migration-guides/release-5.x/storage.rst +++ b/docs/zh_CN/migration-guides/release-5.x/storage.rst @@ -1,6 +1,41 @@ 存储 ======= +分区 API 的新组件 +------------------------------------ + +非兼容性更新:所有的分区 API 代码都已迁移到新组件 :component:`esp_partition` 中。如需查看所有受影响的函数及数据类型,请参见头文件 :component_file:`esp_partition.h `。 + +在以前,这些 API 函数和数据类型属于 :component:`spi_flash` 组件。因此,在现有的应用程序中或将依赖 ``spi_flash``,这也意味着在直接使用 esp_partition_* API/数据类型时,可能会导致构建过程失败(比如,在出现 ``#include "esp_partition.h"`` 的行中报错 ``fatal error: esp_partition.h: No such file or directory``)。如果遇到类似问题,请按以下步骤更新项目中的 CMakeLists.txt 文件: + +原有的依赖性设置: + +.. code-block:: cmake + + idf_component_register(... + REQUIRES spi_flash) + +更新后的依赖性设置: + +.. code-block:: cmake + + idf_component_register(... + REQUIRES spi_flash esp_partition) + +.. note:: + + 请根据项目的实际情况,更新相应的 ``REQUIRES`` 或是 ``PRIV_REQUIRES`` 部分。上述代码片段仅为范例。 + +如果问题仍未解决,请联系我们,我们将协助您进行代码迁移。 + + +SDMMC/SDSPI +----------- + +用户现可通过 ``sdmmc_host_t.max_freq_khz`` 将 SDMMC/SDSPI 接口上的 SD 卡频率配置为特定值,不再局限于之前的 ``SDMMC_FREQ_PROBING`` (400 kHz)、 ``SDMMC_FREQ_DEFAULT`` (20 MHz) 或是 ``SDMMC_FREQ_HIGHSPEED`` (40 MHz)。此前,如果用户配置了上述三个给定频率之外的值,用户所选频率将自动调整为与其最为接近的给定值。 + +更新后,底层驱动将计算与用户配置的特定值最为接近的合适频率。相对于枚举项选择,该频率现由可用的分频器提供。不过,如果尚未更新现有的应用代码,可能会导致与 SD 卡的通信过程出现问题。如发现上述问题,请继续尝试配置与期望值接近的不同频率,直到找到合适的频率。如需查看底层驱动的计算结果以及实际应用的频率,请使用 ``void sdmmc_card_print_info(FILE* stream, const sdmmc_card_t* card)`` 函数。 + FatFs ----- @@ -9,7 +44,7 @@ FatFs 已更新至 v0.14, ``f_mkfs()`` 函数签名也已变更。新签名为 分区表 --------------- -分区表生成器不再支持未对齐的分区。生成分区表时, ``esp-idf`` 将只接受偏移量与 4 KB 对齐的分区。此变更仅影响新生成的分区表,不影响读写现有分区。 +分区表生成器不再支持未对齐的分区。生成分区表时, ``ESP-IDF`` 将只接受偏移量与 4 KB 对齐的分区。此变更仅影响新生成的分区表,不影响读写现有分区。 VFS diff --git a/examples/protocols/mqtt/ssl/main/app_main.c b/examples/protocols/mqtt/ssl/main/app_main.c index 3e6e863784..a9781113d5 100644 --- a/examples/protocols/mqtt/ssl/main/app_main.c +++ b/examples/protocols/mqtt/ssl/main/app_main.c @@ -12,6 +12,8 @@ #include #include #include "esp_system.h" +#include "esp_partition.h" +#include "spi_flash_mmap.h" #include "nvs_flash.h" #include "esp_event.h" #include "esp_netif.h" diff --git a/examples/protocols/mqtt/ssl_ds/main/idf_component.yml b/examples/protocols/mqtt/ssl_ds/main/idf_component.yml index 80c7c822a8..9c8c93c360 100644 --- a/examples/protocols/mqtt/ssl_ds/main/idf_component.yml +++ b/examples/protocols/mqtt/ssl_ds/main/idf_component.yml @@ -1,3 +1,5 @@ ## IDF Component Manager Manifest File dependencies: - espressif/esp_secure_cert_mgr: "^2.0.0" + espressif/esp_secure_cert_mgr: + version: "~3.0.3" + service_url: "https://api.staging.components.espressif.tools" diff --git a/examples/storage/partition_api/partition_mmap/main/CMakeLists.txt b/examples/storage/partition_api/partition_mmap/main/CMakeLists.txt index cf2c455cb5..29f3e8d2d5 100644 --- a/examples/storage/partition_api/partition_mmap/main/CMakeLists.txt +++ b/examples/storage/partition_api/partition_mmap/main/CMakeLists.txt @@ -1,2 +1,4 @@ idf_component_register(SRCS "main.c" - INCLUDE_DIRS ".") + INCLUDE_DIRS "." + REQUIRES esp_partition + PRIV_REQUIRES spi_flash) diff --git a/examples/storage/partition_api/partition_mmap/main/main.c b/examples/storage/partition_api/partition_mmap/main/main.c index 492dd8046b..30d8ec2da7 100644 --- a/examples/storage/partition_api/partition_mmap/main/main.c +++ b/examples/storage/partition_api/partition_mmap/main/main.c @@ -8,6 +8,7 @@ #include #include #include "esp_partition.h" +#include "spi_flash_mmap.h" #include "esp_log.h" static const char *TAG = "example"; diff --git a/examples/storage/partition_api/partition_ops/main/CMakeLists.txt b/examples/storage/partition_api/partition_ops/main/CMakeLists.txt index cf2c455cb5..29f3e8d2d5 100644 --- a/examples/storage/partition_api/partition_ops/main/CMakeLists.txt +++ b/examples/storage/partition_api/partition_ops/main/CMakeLists.txt @@ -1,2 +1,4 @@ idf_component_register(SRCS "main.c" - INCLUDE_DIRS ".") + INCLUDE_DIRS "." + REQUIRES esp_partition + PRIV_REQUIRES spi_flash) diff --git a/examples/storage/partition_api/partition_ops/main/main.c b/examples/storage/partition_api/partition_ops/main/main.c index 4afaa0d6a7..49486ad4fd 100644 --- a/examples/storage/partition_api/partition_ops/main/main.c +++ b/examples/storage/partition_api/partition_ops/main/main.c @@ -8,6 +8,7 @@ #include #include #include "esp_partition.h" +#include "spi_flash_mmap.h" #include "esp_log.h" static const char *TAG = "example"; diff --git a/examples/system/flash_suspend/main/app_main.c b/examples/system/flash_suspend/main/app_main.c index 62a4829607..73c744c943 100644 --- a/examples/system/flash_suspend/main/app_main.c +++ b/examples/system/flash_suspend/main/app_main.c @@ -19,6 +19,7 @@ #include "esp_cpu.h" #include "esp_partition.h" #include "driver/gptimer.h" +#include "esp_flash.h" #define TIMER_RESOLUTION_HZ (1 * 1000 * 1000) // 1MHz resolution diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index f41b951a65..e5018438c4 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -673,7 +673,6 @@ components/esp_wifi/src/smartconfig.c components/esp_wifi/test/test_wifi_init.c components/fatfs/diskio/diskio.c components/fatfs/diskio/diskio_impl.h -components/fatfs/diskio/diskio_rawflash.c components/fatfs/diskio/diskio_rawflash.h components/fatfs/diskio/diskio_wl.h components/fatfs/port/freertos/ffsystem.c diff --git a/tools/idf_py_actions/hints.yml b/tools/idf_py_actions/hints.yml index fd8a695c00..f951848ca7 100644 --- a/tools/idf_py_actions/hints.yml +++ b/tools/idf_py_actions/hints.yml @@ -240,3 +240,8 @@ re: "fatal error: (tinyusb.h): No such file or directory" hint: "{} was removed. Please use esp_tinyusb component from IDF component manager instead.\nYou can install `esp_tinyusb` using 'idf.py add-dependency espressif/esp_tinyusb' command.\nRefer to the migration guide for more details." match_to_output: True + +- + re: "fatal error: esp_partition.h: No such file or directory" + hint: "All the Partition APIs have been moved to the new component 'esp_partition' - please, update your project dependencies. See Storage migration guide 5.x for more details." + match_to_output: True diff --git a/tools/mocks/esp_partition/CMakeLists.txt b/tools/mocks/esp_partition/CMakeLists.txt new file mode 100644 index 0000000000..ba87c7fbdb --- /dev/null +++ b/tools/mocks/esp_partition/CMakeLists.txt @@ -0,0 +1,8 @@ +message(STATUS "building ESP_PARTITION MOCKS") + +idf_component_get_property(original_esp_partition_dir esp_partition COMPONENT_OVERRIDEN_DIR) + +idf_component_mock(INCLUDE_DIRS "${original_esp_partition_dir}/include" + REQUIRES spi_flash + MOCK_HEADER_FILES + ${original_esp_partition_dir}/include/esp_partition.h) diff --git a/tools/mocks/esp_partition/mock/mock_config.yaml b/tools/mocks/esp_partition/mock/mock_config.yaml new file mode 100644 index 0000000000..7afabb7f94 --- /dev/null +++ b/tools/mocks/esp_partition/mock/mock_config.yaml @@ -0,0 +1,10 @@ + :cmock: + :includes_h_pre_orig_header: + - esp_flash.h + :plugins: + - expect + - expect_any_args + - return_thru_ptr + - array + - ignore_arg + - callback diff --git a/tools/mocks/spi_flash/CMakeLists.txt b/tools/mocks/spi_flash/CMakeLists.txt index ceae52f0d5..a0f5bbd89d 100644 --- a/tools/mocks/spi_flash/CMakeLists.txt +++ b/tools/mocks/spi_flash/CMakeLists.txt @@ -2,7 +2,7 @@ # On Espressif chips, too many dependencies are missing at the moment. # Furthermore, this component can only mock the interfaces of # spi_master.h and gpio.h. -message(STATUS "building SPI FLASH MOCKS (only esp_partition* API)") +message(STATUS "building SPI FLASH MOCKS (only esp_partition support)") idf_component_get_property(original_spi_flash_dir spi_flash COMPONENT_OVERRIDEN_DIR) @@ -19,6 +19,5 @@ endif() idf_component_mock(INCLUDE_DIRS ${include_dirs} REQUIRES esp_common MOCK_HEADER_FILES - ${original_spi_flash_dir}/include/esp_partition.h ${original_spi_flash_dir}/include/esp_flash.h ${original_spi_flash_dir}/include/spi_flash_mmap.h) diff --git a/tools/test_apps/system/g1_components/CMakeLists.txt b/tools/test_apps/system/g1_components/CMakeLists.txt index 0380cdd395..3c2324800c 100644 --- a/tools/test_apps/system/g1_components/CMakeLists.txt +++ b/tools/test_apps/system/g1_components/CMakeLists.txt @@ -59,6 +59,9 @@ set(extra_components_which_shouldnt_be_included mbedtls # partition_table is pulled in by app_update, esptool_py, bootloader; all to be removed partition_table + # esp_partition is a new component for separated IDF partition APIs. Added due to its involvement in the spi_flash + # code. To be possibly removed (?) + esp_partition # pthread is required by esp_system (for initialization only, can be made a weak dependency) # and cxx. See also [refactor-todo] about cxx, can it work without pthread? pthread diff --git a/tools/test_apps/system/panic/main/CMakeLists.txt b/tools/test_apps/system/panic/main/CMakeLists.txt index ba36e85dd4..83427066bf 100644 --- a/tools/test_apps/system/panic/main/CMakeLists.txt +++ b/tools/test_apps/system/panic/main/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRCS "test_panic_main.c" INCLUDE_DIRS "." - REQUIRES spi_flash esp_system) + REQUIRES spi_flash esp_system esp_partition) diff --git a/tools/unit-test-app/components/test_utils/CMakeLists.txt b/tools/unit-test-app/components/test_utils/CMakeLists.txt index 63f56255c3..fee20cbf24 100644 --- a/tools/unit-test-app/components/test_utils/CMakeLists.txt +++ b/tools/unit-test-app/components/test_utils/CMakeLists.txt @@ -25,6 +25,6 @@ endif() idf_component_register(SRCS ${srcs} INCLUDE_DIRS include PRIV_INCLUDE_DIRS private_include - REQUIRES spi_flash idf_test cmock + REQUIRES esp_partition idf_test cmock PRIV_REQUIRES perfmon driver esp_netif) target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")