Storage: Partition APIs moved to the new component 'esp_partition'

All the partition handling API functions and data-types were moved from the 'spi_flash' component to the new one named 'esp_partition'. See Storage 5.x migration guide for more details
This commit is contained in:
Martin Vychodil 2022-10-14 14:15:32 +02:00
parent 725eacbf16
commit af81bd1b0a
85 changed files with 394 additions and 156 deletions

View File

@ -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:

View File

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

View File

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

View File

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

View File

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

View File

@ -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"

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,2 @@
idf_component_register(SRCS "partition_api_test.c"
REQUIRES esp_partition unity)

View File

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

View File

@ -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"

View File

@ -11,8 +11,6 @@
#include <stdbool.h>
#include <stddef.h>
#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.

View File

@ -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
*

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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"

View File

@ -18,6 +18,8 @@
#include <esp_log.h>
#include <esp_partition.h>
#include <esp_attr.h>
#include "esp_flash.h"
#include "spi_flash_mmap.h"
TEST_CASE("Test erase partition", "[spi_flash][esp_flash]")
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 <string.h>
#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";

View File

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

View File

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

View File

@ -40,4 +40,5 @@ INCLUDE_DIRS := \
hal/include \
spi_flash/include \
wear_levelling/include \
esp_partition/include \
)

View File

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

View File

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

View File

@ -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"

View File

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

View File

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

View File

@ -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"},

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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"]

View File

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

View File

@ -1,2 +0,0 @@
idf_component_register(SRCS "partition_api_test.cpp"
REQUIRES spi_flash)

View File

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

View File

@ -1,11 +1,8 @@
#include "SpiFlash.h"
#include <string.h>
#include <stdlib.h>
#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"

View File

@ -1,6 +1,3 @@
#include "spi_flash_mmap.h"
#include "esp_partition.h"
#include "esp_err.h"
#include "esp_rom_spiflash.h"

View File

@ -37,5 +37,6 @@ INCLUDE_DIRS := \
bootloader_support/bootloader_flash/include \
app_update/include \
hal/include \
esp_partition/include \
spi_flash/include \
)

View File

@ -7,6 +7,7 @@
#include <unity.h>
#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 <esp_attr.h>

View File

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

View File

@ -10,6 +10,7 @@
#include <esp_attr.h>
#include <esp_partition.h>
#include <esp_flash_encrypt.h>
#include "esp_flash.h"
#include "test_utils.h"

View File

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

View File

@ -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"

View File

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

View File

@ -40,4 +40,5 @@ INCLUDE_DIRS := \
spi_flash/include \
hal/include \
wear_levelling/include \
esp_partition/include \
)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -39,4 +39,5 @@ INCLUDE_DIRS := \
app_update/include \
hal/include \
spi_flash/include \
esp_partition/include \
)

View File

@ -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 \

View File

@ -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 <esp_partition/include/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

View File

@ -1,6 +1,41 @@
存储
=======
分区 API 的新组件
------------------------------------
非兼容性更新:所有的分区 API 代码都已迁移到新组件 :component:`esp_partition` 中。如需查看所有受影响的函数及数据类型,请参见头文件 :component_file:`esp_partition.h <esp_partition/include/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

View File

@ -12,6 +12,8 @@
#include <stddef.h>
#include <string.h>
#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"

View File

@ -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"

View File

@ -1,2 +1,4 @@
idf_component_register(SRCS "main.c"
INCLUDE_DIRS ".")
INCLUDE_DIRS "."
REQUIRES esp_partition
PRIV_REQUIRES spi_flash)

View File

@ -8,6 +8,7 @@
#include <string.h>
#include <assert.h>
#include "esp_partition.h"
#include "spi_flash_mmap.h"
#include "esp_log.h"
static const char *TAG = "example";

View File

@ -1,2 +1,4 @@
idf_component_register(SRCS "main.c"
INCLUDE_DIRS ".")
INCLUDE_DIRS "."
REQUIRES esp_partition
PRIV_REQUIRES spi_flash)

View File

@ -8,6 +8,7 @@
#include <string.h>
#include <assert.h>
#include "esp_partition.h"
#include "spi_flash_mmap.h"
#include "esp_log.h"
static const char *TAG = "example";

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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