1 Star 0 Fork 0

esp-components/esp_littlefs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
project_include.cmake 2.73 KB
一键复制 编辑 原始数据 按行查看 历史
Jacques Germishuys 提交于 2021-12-13 04:15 +08:00 . support alternative IDF version syntax
# littlefs_create_partition_image
#
# Create a littlefs image of the specified directory on the host during build and optionally
# have the created image flashed using `idf.py flash`
set(MKLITTLEFS_DIR "${CMAKE_CURRENT_LIST_DIR}/mklittlefs")
set(MKLITTLEFS "${MKLITTLEFS_DIR}/mklittlefs")
function(littlefs_create_partition_image partition base_dir)
set(options FLASH_IN_PROJECT)
set(multi DEPENDS)
cmake_parse_arguments(arg "${options}" "" "${multi}" "${ARGN}")
idf_build_get_property(idf_path IDF_PATH)
get_filename_component(base_dir_full_path ${base_dir} ABSOLUTE)
partition_table_get_partition_info(size "--partition-name ${partition}" "size")
partition_table_get_partition_info(offset "--partition-name ${partition}" "offset")
add_custom_command(
OUTPUT ${MKLITTLEFS}
COMMAND make dist
WORKING_DIRECTORY ${MKLITTLEFS_DIR}
)
if("${size}" AND "${offset}")
set(image_file ${CMAKE_BINARY_DIR}/${partition}.bin)
# Execute LittleFS 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(littlefs_${partition}_bin ALL
COMMAND ${MKLITTLEFS} -d 0 -c ${base_dir_full_path} -s ${size} -p ${CONFIG_LITTLEFS_PAGE_SIZE} -b 4096 ${image_file}
DEPENDS ${arg_DEPENDS} ${MKLITTLEFS}
)
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES
${image_file})
if(IDF_VER MATCHES "^v")
string(SUBSTRING "${IDF_VER}" 1 -1 IDF_VER_NO_V)
else()
string(SUBSTRING "${IDF_VER}" 0 -1 IDF_VER_NO_V)
endif()
if(${IDF_VER_NO_V} VERSION_LESS 4.1)
message(WARNING "Unsupported/unmaintained/deprecated ESP-IDF version ${IDF_VER}")
endif()
if(${IDF_VER_NO_V} VERSION_GREATER 4.2)
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}")
esptool_py_flash_target_image(${partition}-flash "${partition}" "${offset}" "${image_file}")
add_dependencies(${partition}-flash littlefs_${partition}_bin)
if(arg_FLASH_IN_PROJECT)
esptool_py_flash_target_image(flash "${partition}" "${offset}" "${image_file}")
add_dependencies(flash littlefs_${partition}_bin)
endif()
else()
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()
endif()
else()
set(message "Failed to create littlefs image for partition '${partition}'. "
"Check project configuration if using the correct partition table file."
)
fail_at_build_time(littlefs_${partition}_bin "${message}")
endif()
endfunction()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/esp-components/esp_littlefs.git
git@gitee.com:esp-components/esp_littlefs.git
esp-components
esp_littlefs
esp_littlefs
master

搜索帮助