From e0a652f164c49a726edbe8d9a2559001e967e86d Mon Sep 17 00:00:00 2001 From: Renz Christian Bagaporo Date: Sun, 5 May 2019 15:42:39 +0800 Subject: [PATCH 1/2] spiffs: add ability to specify dependencies when dirs themselves are generated --- components/spiffs/Makefile.projbuild | 2 +- components/spiffs/project_include.cmake | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/components/spiffs/Makefile.projbuild b/components/spiffs/Makefile.projbuild index 13b2223a9a..645856c497 100644 --- a/components/spiffs/Makefile.projbuild +++ b/components/spiffs/Makefile.projbuild @@ -20,7 +20,7 @@ endif define spiffs_create_partition_image -$(1)_bin: $(PARTITION_TABLE_BIN) | check_python_dependencies +$(1)_bin: $(PARTITION_TABLE_BIN) $(DEPENDS) | check_python_dependencies partition_size=`$(GET_PART_INFO) \ --partition-table-file $(PARTITION_TABLE_BIN) \ get_partition_info --partition-name $(1) --info size`; \ diff --git a/components/spiffs/project_include.cmake b/components/spiffs/project_include.cmake index 19fc96ed7a..31f63b5111 100644 --- a/components/spiffs/project_include.cmake +++ b/components/spiffs/project_include.cmake @@ -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 From c65038fd7414bac3cf3f71a929b090e3b0c15c86 Mon Sep 17 00:00:00 2001 From: Renz Christian Bagaporo Date: Fri, 21 Jun 2019 10:58:00 +0800 Subject: [PATCH 2/2] spiffs,make: change spiffsgen build API --- components/spiffs/Makefile.projbuild | 7 +++-- docs/en/api-reference/storage/spiffs.rst | 38 +++++++++++++++++++----- examples/storage/spiffsgen/Makefile | 3 +- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/components/spiffs/Makefile.projbuild b/components/spiffs/Makefile.projbuild index 645856c497..4d8f39c081 100644 --- a/components/spiffs/Makefile.projbuild +++ b/components/spiffs/Makefile.projbuild @@ -19,8 +19,7 @@ endif # have the created image flashed using `make flash` define spiffs_create_partition_image - -$(1)_bin: $(PARTITION_TABLE_BIN) $(DEPENDS) | 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), \ diff --git a/docs/en/api-reference/storage/spiffs.rst b/docs/en/api-reference/storage/spiffs.rst index dcd31a022f..5620e83d77 100644 --- a/docs/en/api-reference/storage/spiffs.rst +++ b/docs/en/api-reference/storage/spiffs.rst @@ -44,26 +44,50 @@ Aside from invoking the ``spiffsgen.py`` standalone by manually running it from Make:: - $(eval $(call spiffs_create_partition_image,,,[FLASH_IN_PROJECT])) + SPIFFS_IMAGE_FLASH_IN_PROJECT := ... + SPIFFS_IMAGE_DEPENDS := ... + $(eval $(call spiffs_create_partition_image,,)) CMake:: - spiffs_create_partition_image( [FLASH_IN_PROJECT]) + spiffs_create_partition_image( [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,,)) + +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,,)) + +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>`. diff --git a/examples/storage/spiffsgen/Makefile b/examples/storage/spiffsgen/Makefile index 07cc03d6dd..300abdd6e8 100644 --- a/examples/storage/spiffsgen/Makefile +++ b/examples/storage/spiffsgen/Makefile @@ -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)) \ No newline at end of file +SPIFFS_IMAGE_FLASH_IN_PROJECT := 1 +$(eval $(call spiffs_create_partition_image,storage,spiffs_image)) \ No newline at end of file