mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
feat(esp_partition): Add esp_partition_flash_binary() CMake function
Add a new CMake function esp_partition_flash_binary() that provides a unified API for registering partition data binaries to be flashed. It replaces the direct esptool_py_flash_target calls scattered across components (spiffs, fatfs, nvs_flash) with a single function that: - Resolves partition offset from the partition table automatically - Determines encryption requirements (auto-detect or ALWAYS_PLAINTEXT) - Creates per-partition flash targets (e.g. idf.py <partition>-flash) - Optionally includes the binary in `idf.py flash` via FLASH_IN_PROJECT On the linux target, the function registers binaries for pre-loading into the emulated flash. A build-time manifest (linux_flash_data.txt) is generated via file(GENERATE), and partition_linux.c reads it at runtime to copy each binary into the memory-mapped flash buffer at the correct offset. The partition_ops example is updated to use the new function and includes a custom_partition with pre-built data to demonstrate the full workflow, including on the linux target.
This commit is contained in:
@@ -43,20 +43,16 @@ function(nvs_create_partition_image partition csv)
|
||||
PROPERTY ADDITIONAL_CLEAN_FILES ${image_file}
|
||||
)
|
||||
|
||||
idf_component_get_property(main_args esptool_py FLASH_ARGS)
|
||||
idf_component_get_property(sub_args esptool_py FLASH_SUB_ARGS)
|
||||
esptool_py_flash_target(${partition}-flash "${main_args}" "${sub_args}" ALWAYS_PLAINTEXT)
|
||||
esptool_py_flash_to_partition(${partition}-flash "${partition}" "${image_file}")
|
||||
|
||||
add_dependencies(${partition}-flash nvs_${partition}_bin)
|
||||
set(register_target_optional_args ALWAYS_PLAINTEXT DEPENDS nvs_${partition}_bin)
|
||||
|
||||
if(arg_FLASH_IN_PROJECT)
|
||||
esptool_py_flash_to_partition(flash "${partition}" "${image_file}")
|
||||
add_dependencies(flash nvs_${partition}_bin)
|
||||
list(APPEND register_target_optional_args FLASH_IN_PROJECT)
|
||||
if(CONFIG_SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT)
|
||||
add_dependencies(encrypted-flash nvs_${partition}_bin)
|
||||
list(APPEND register_target_optional_args FLASH_IN_PROJECT_DEPENDENCY_TARGETS encrypted-flash)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
esp_partition_register_target(${partition} "${image_file}" ${register_target_optional_args})
|
||||
else()
|
||||
set(message
|
||||
"Failed to create NVS image for partition '${partition}'. "
|
||||
|
||||
Reference in New Issue
Block a user