CMakeLists.txt 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. idf_component_register(SRCS "esp_ota_ops.c" "esp_ota_app_desc.c"
  2. INCLUDE_DIRS "include"
  3. REQUIRES spi_flash partition_table bootloader_support esp_app_format
  4. PRIV_REQUIRES esptool_py efuse)
  5. if(NOT BOOTLOADER_BUILD)
  6. partition_table_get_partition_info(otadata_offset "--partition-type data --partition-subtype ota" "offset")
  7. partition_table_get_partition_info(otadata_size "--partition-type data --partition-subtype ota" "size")
  8. # Add custom target for generating empty otadata partition for flashing
  9. if(otadata_size AND otadata_offset)
  10. idf_build_get_property(build_dir BUILD_DIR)
  11. set(blank_otadata_file ${build_dir}/ota_data_initial.bin)
  12. idf_build_get_property(idf_path IDF_PATH)
  13. idf_build_get_property(python PYTHON)
  14. idf_component_get_property(partition_table_dir partition_table COMPONENT_DIR)
  15. add_custom_command(OUTPUT ${blank_otadata_file}
  16. COMMAND ${python} ${partition_table_dir}/gen_empty_partition.py
  17. ${otadata_size} ${blank_otadata_file})
  18. add_custom_target(blank_ota_data ALL DEPENDS ${blank_otadata_file})
  19. add_dependencies(flash blank_ota_data)
  20. add_dependencies(encrypted-flash blank_ota_data)
  21. set(otatool_py "${python}" "${COMPONENT_DIR}/otatool.py")
  22. set(esptool_args --esptool-args before=${CONFIG_ESPTOOLPY_BEFORE} after=${CONFIG_ESPTOOLPY_AFTER})
  23. set(otatool_args --partition-table-file ${PARTITION_CSV_PATH})
  24. list(APPEND otatool_args --partition-table-offset ${PARTITION_TABLE_OFFSET})
  25. idf_component_get_property(esptool_py_dir esptool_py COMPONENT_DIR)
  26. add_custom_target(read-otadata DEPENDS "${PARTITION_CSV_PATH}"
  27. COMMAND ${CMAKE_COMMAND}
  28. -D "IDF_PATH=${idf_path}"
  29. -D "SERIAL_TOOL=${otatool_py}"
  30. -D "SERIAL_TOOL_ARGS=${esptool_args};${otatool_args};read_otadata"
  31. -D "WORKING_DIRECTORY=${build_dir}"
  32. -P ${esptool_py_dir}/run_serial_tool.cmake
  33. WORKING_DIRECTORY "${build_dir}"
  34. USES_TERMINAL
  35. VERBATIM
  36. )
  37. add_deprecated_target_alias(read_otadata read-otadata)
  38. add_custom_target(erase-otadata DEPENDS "${PARTITION_CSV_PATH}"
  39. COMMAND ${CMAKE_COMMAND}
  40. -D "IDF_PATH=${idf_path}"
  41. -D "SERIAL_TOOL=${otatool_py}"
  42. -D "SERIAL_TOOL_ARGS=${esptool_args};${otatool_args};erase_otadata"
  43. -D "WORKING_DIRECTORY=${build_dir}"
  44. -P ${esptool_py_dir}/run_serial_tool.cmake
  45. WORKING_DIRECTORY "${build_dir}"
  46. USES_TERMINAL
  47. VERBATIM
  48. )
  49. add_deprecated_target_alias(erase_otadata erase-otadata)
  50. idf_component_get_property(main_args esptool_py FLASH_ARGS)
  51. idf_component_get_property(sub_args esptool_py FLASH_SUB_ARGS)
  52. esptool_py_flash_target(otadata-flash "${main_args}" "${sub_args}")
  53. esptool_py_flash_target_image(otadata-flash otadata "${otadata_offset}" "${blank_otadata_file}")
  54. esptool_py_flash_target_image(flash otadata "${otadata_offset}" "${blank_otadata_file}")
  55. endif()
  56. endif()