From 77585bd14e4aff39f02ed167402fc62b2fb643c2 Mon Sep 17 00:00:00 2001 From: Renz Christian Bagaporo Date: Tue, 5 Nov 2019 14:52:14 +0800 Subject: [PATCH] spiffs: fix build issue on clean project From issue: I did some poking around in components/spiffs/project_include.cmake and it looks like what is failing is it isn't getting an offset from parttool.py. I think what the problem is that the parttool.py cannot determine the offset of the storage partition as I can't run menuconfig to set the custom partitions. I have tested that this problem is solvable by manually setting the custom partitions in sdkconfig and that is a workaround but there should be at least a better error message in the configuration when it cannot find the partition as this would also happen if the partition name was misspelled. Closes https://github.com/espressif/esp-idf/issues/4236 --- components/spiffs/project_include.cmake | 62 ++++++++++++++----------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/components/spiffs/project_include.cmake b/components/spiffs/project_include.cmake index 061a67d0b..bd892f489 100644 --- a/components/spiffs/project_include.cmake +++ b/components/spiffs/project_include.cmake @@ -15,40 +15,46 @@ function(spiffs_create_partition_image partition base_dir) partition_table_get_partition_info(size "--partition-name ${partition}" "size") partition_table_get_partition_info(offset "--partition-name ${partition}" "offset") - set(image_file ${CMAKE_BINARY_DIR}/${partition}.bin) + if("${size}" AND "${offset}") + set(image_file ${CMAKE_BINARY_DIR}/${partition}.bin) - if(CONFIG_SPIFFS_USE_MAGIC) - set(use_magic "--use-magic") - endif() + if(CONFIG_SPIFFS_USE_MAGIC) + set(use_magic "--use-magic") + endif() - if(CONFIG_SPIFFS_USE_MAGIC_LENGTH) - set(use_magic_len "--use-magic-len") - endif() + if(CONFIG_SPIFFS_USE_MAGIC_LENGTH) + set(use_magic_len "--use-magic-len") + endif() - if(CONFIG_SPIFFS_FOLLOW_SYMLINKS) - set(follow_symlinks "--follow-symlinks") - endif() + if(CONFIG_SPIFFS_FOLLOW_SYMLINKS) + set(follow_symlinks "--follow-symlinks") + endif() - # Execute SPIFFS image generation; this always executes as there is no way to specify for CMake to watch for - # contents of the base dir changing. - add_custom_target(spiffs_${partition}_bin ALL - COMMAND ${spiffsgen_py} ${size} ${base_dir_full_path} ${image_file} - --page-size=${CONFIG_SPIFFS_PAGE_SIZE} - --obj-name-len=${CONFIG_SPIFFS_OBJ_NAME_LEN} - --meta-len=${CONFIG_SPIFFS_META_LENGTH} - ${follow_symlinks} - ${use_magic} - ${use_magic_len} - DEPENDS ${arg_DEPENDS} - ) + # Execute SPIFFS image generation; this always executes as there is no way to specify for CMake to watch for + # contents of the base dir changing. + add_custom_target(spiffs_${partition}_bin ALL + COMMAND ${spiffsgen_py} ${size} ${base_dir_full_path} ${image_file} + --page-size=${CONFIG_SPIFFS_PAGE_SIZE} + --obj-name-len=${CONFIG_SPIFFS_OBJ_NAME_LEN} + --meta-len=${CONFIG_SPIFFS_META_LENGTH} + ${follow_symlinks} + ${use_magic} + ${use_magic_len} + DEPENDS ${arg_DEPENDS} + ) - set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY - ADDITIONAL_MAKE_CLEAN_FILES - ${image_file}) + set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY + ADDITIONAL_MAKE_CLEAN_FILES + ${image_file}) - if(arg_FLASH_IN_PROJECT) - esptool_py_flash_project_args(${partition} ${offset} ${image_file} FLASH_IN_PROJECT) + if(arg_FLASH_IN_PROJECT) + esptool_py_flash_project_args("${partition}" "${offset}" "${image_file}" FLASH_IN_PROJECT) + else() + esptool_py_flash_project_args("${partition}" "${offset}" "${image_file}") + endif() else() - esptool_py_flash_project_args(${partition} ${offset} ${image_file}) + set(message "Failed to create SPIFFS image for partition '${partition}'. " + "Check project configuration if using the correct partition table file.") + fail_at_build_time(spiffs_${partition}_bin "${message}") endif() endfunction()