Merge branch 'feature/add_ability_to_specify_spiffsgen_dependencies' into 'master'
Add ability to specify dependencies for spiffsgen See merge request idf/esp-idf!4933
This commit is contained in:
commit
934a1a3223
4 changed files with 40 additions and 12 deletions
|
@ -19,8 +19,7 @@ endif
|
|||
# have the created image flashed using `make flash`
|
||||
define spiffs_create_partition_image
|
||||
|
||||
|
||||
$(1)_bin: $(PARTITION_TABLE_BIN) | check_python_dependencies
|
||||
$(1)_bin: $(PARTITION_TABLE_BIN) $(SPIFFS_IMAGE_DEPENDS) | check_python_dependencies
|
||||
partition_size=`$(GET_PART_INFO) \
|
||||
--partition-table-file $(PARTITION_TABLE_BIN) \
|
||||
get_partition_info --partition-name $(1) --info size`; \
|
||||
|
@ -35,9 +34,11 @@ all_binaries: $(1)_bin
|
|||
print_flash_cmd: $(1)_bin
|
||||
|
||||
# Append the created binary to esptool_py args if FLASH_IN_PROJECT is set
|
||||
ifeq ($(3), FLASH_IN_PROJECT)
|
||||
ifdef SPIFFS_IMAGE_FLASH_IN_PROJECT
|
||||
ifeq ($(SPIFFS_IMAGE_FLASH_IN_PROJECT),1)
|
||||
SPIFFSGEN_FLASH_IN_PROJECT += $(1)
|
||||
endif
|
||||
endif
|
||||
endef
|
||||
|
||||
ESPTOOL_ALL_FLASH_ARGS += $(foreach partition,$(SPIFFSGEN_FLASH_IN_PROJECT), \
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
# have the created image flashed using `idf.py flash`
|
||||
function(spiffs_create_partition_image partition base_dir)
|
||||
set(options FLASH_IN_PROJECT)
|
||||
cmake_parse_arguments(arg "${options}" "" "" "${ARGN}")
|
||||
set(multi DEPENDS)
|
||||
cmake_parse_arguments(arg "${options}" "" "${multi}" "${ARGN}")
|
||||
|
||||
idf_build_get_property(idf_path IDF_PATH)
|
||||
set(spiffsgen_py ${PYTHON} ${idf_path}/components/spiffs/spiffsgen.py)
|
||||
|
@ -33,6 +34,7 @@ function(spiffs_create_partition_image partition base_dir)
|
|||
--meta-len=${CONFIG_SPIFFS_META_LENGTH}
|
||||
${use_magic}
|
||||
${use_magic_len}
|
||||
DEPENDS ${arg_DEPENDS}
|
||||
)
|
||||
|
||||
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY
|
||||
|
|
|
@ -44,26 +44,50 @@ Aside from invoking the ``spiffsgen.py`` standalone by manually running it from
|
|||
|
||||
Make::
|
||||
|
||||
$(eval $(call spiffs_create_partition_image,<partition>,<base_dir>,[FLASH_IN_PROJECT]))
|
||||
SPIFFS_IMAGE_FLASH_IN_PROJECT := ...
|
||||
SPIFFS_IMAGE_DEPENDS := ...
|
||||
$(eval $(call spiffs_create_partition_image,<partition>,<base_dir>))
|
||||
|
||||
CMake::
|
||||
|
||||
spiffs_create_partition_image(<partition> <base_dir> [FLASH_IN_PROJECT])
|
||||
spiffs_create_partition_image(<partition> <base_dir> [FLASH_IN_PROJECT] [DEPENDS dep dep dep...])
|
||||
|
||||
This is more convenient as the build configuration is automatically passed to the tool, ensuring that the generated image is valid for that build. An example of this is while the *image_size* is required for the standalone invocation, only the *partition* name is required when using ``spiffs_create_partition_image`` -- the image size is automatically obtained from the project's partition table.
|
||||
|
||||
Due to the differences in structure between Make and Cmake, it is important to note that:
|
||||
Due to the differences in structure between Make and CMake, it is important to note that:
|
||||
- for Make ``spiffs_create_partition_image`` must be called from the project Makefile
|
||||
- for CMake ``spiffs_create_partition_image`` must be called from one of the component CMakeLists.txt files
|
||||
|
||||
For both build systems, the image will be created in the build directory with the filename *partition*.bin.
|
||||
Optionally, user can opt to have the image automatically flashed together with the app binaries, partition tables, etc. on
|
||||
``idf.py flash`` or ``make flash`` by specifying ``FLASH_IN_PROJECT``. For example,
|
||||
|
||||
Optionally, you can opt to have the image automatically flashed together with the app binaries, partition tables, etc., with
|
||||
``idf.py flash`` or ``make flash`` by specifying ``FLASH_IN_PROJECT``. For example::
|
||||
in Make::
|
||||
|
||||
SPIFFS_IMAGE_FLASH_IN_PROJECT := 1
|
||||
$(eval $(call spiffs_create_partition_image,<partition>,<base_dir>))
|
||||
|
||||
in CMake::
|
||||
|
||||
spiffs_create_partition_image(my_spiffs_partition my_folder FLASH_IN_PROJECT)
|
||||
|
||||
If FLASH_IN_PROJECT is not specified, the image will still be generated, but you will have to flash it manually using ``esptool.py``, ``parttool.py``, or a custom build system target.
|
||||
If FLASH_IN_PROJECT/SPIFFS_IMAGE_FLASH_IN_PROJECT is not specified, the image will still be generated, but you will have to flash it manually using ``esptool.py``, ``parttool.py``, or a custom build system target.
|
||||
|
||||
There are cases where the contents of the base directory itself is generated at build time. Users can use DEPENDS/SPIFFS_IMAGE_DEPENDS to specify targets
|
||||
that should be executed before generating the image.
|
||||
|
||||
in Make::
|
||||
|
||||
dep:
|
||||
...
|
||||
|
||||
SPIFFS_IMAGE_DEPENDS := dep
|
||||
$(eval $(call spiffs_create_partition_image,<partition>,<base_dir>))
|
||||
|
||||
in CMake::
|
||||
|
||||
add_custom_target(dep COMMAND ...)
|
||||
|
||||
spiffs_create_partition_image(my_spiffs_partition my_folder DEPENDS dep)
|
||||
|
||||
+For an example, see :example:`examples/storage/spiffsgen>`.
|
||||
|
||||
|
|
|
@ -12,4 +12,5 @@ include $(IDF_PATH)/make/project.mk
|
|||
# that fits the partition named 'storage'. FLASH_IN_PROJECT indicates that
|
||||
# the generated image should be flashed when the entire project is flashed to
|
||||
# the target with 'make flash'.
|
||||
$(eval $(call spiffs_create_partition_image,storage,spiffs_image,FLASH_IN_PROJECT))
|
||||
SPIFFS_IMAGE_FLASH_IN_PROJECT := 1
|
||||
$(eval $(call spiffs_create_partition_image,storage,spiffs_image))
|
Loading…
Reference in a new issue