project_include.cmake 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. if(NOT BOOTLOADER_BUILD)
  2. set(PARTITION_TABLE_OFFSET ${CONFIG_PARTITION_TABLE_OFFSET})
  3. # Set PARTITION_CSV_PATH to the configured partition CSV file
  4. # absolute path
  5. if(CONFIG_PARTITION_TABLE_CUSTOM)
  6. # Custom filename expands any path relative to the project
  7. get_filename_component(PARTITION_CSV_PATH "${CONFIG_PARTITION_TABLE_FILENAME}" ABSOLUTE BASE_DIR "${PROJECT_PATH}")
  8. if(NOT EXISTS "${PARTITION_CSV_PATH}")
  9. message(WARNING "Partition table CSV file ${PARTITION_CSV_PATH} not found. "
  10. "Change custom partition CSV path in menuconfig.")
  11. # Note: partition_table CMakeLists.txt contains some logic to create a dummy
  12. # partition_table target in this case, see comments in that file.
  13. endif()
  14. else()
  15. # Other .csv files are always in the component directory
  16. get_filename_component(PARTITION_CSV_PATH "${COMPONENT_PATH}/${CONFIG_PARTITION_TABLE_FILENAME}" ABSOLUTE)
  17. if(NOT EXISTS "${PARTITION_CSV_PATH}")
  18. message(FATAL_ERROR "Internal error, built-in ${PARTITION_CSV_PATH} not found.")
  19. endif()
  20. endif()
  21. # need to re-run CMake if the partition CSV changes, as the offsets/sizes of partitions may change
  22. set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${PARTITION_CSV_PATH})
  23. # Parse the partition table to get variable partition offsets & sizes which must be known at CMake runtime
  24. function(get_partition_info variable get_part_info_args)
  25. separate_arguments(get_part_info_args)
  26. execute_process(COMMAND ${PYTHON}
  27. ${COMPONENT_PATH}/parttool.py -q
  28. --partition-table-offset ${PARTITION_TABLE_OFFSET}
  29. ${get_part_info_args}
  30. ${PARTITION_CSV_PATH}
  31. OUTPUT_VARIABLE result
  32. RESULT_VARIABLE exit_code
  33. OUTPUT_STRIP_TRAILING_WHITESPACE)
  34. if(NOT ${exit_code} EQUAL 0 AND NOT ${exit_code} EQUAL 1)
  35. # can't fail here as it would prevent the user from running 'menuconfig' again
  36. message(WARNING "parttool.py execution failed (${result}), problem with partition CSV file (see above)")
  37. endif()
  38. set(${variable} ${result} PARENT_SCOPE)
  39. endfunction()
  40. if(CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION)
  41. get_partition_info(PHY_PARTITION_OFFSET "--type data --subtype phy --offset")
  42. set(PHY_PARTITION_BIN_FILE "${CMAKE_BINARY_DIR}/esp32/phy_init_data.bin")
  43. endif()
  44. get_partition_info(APP_PARTITION_OFFSET "--default-boot-partition --offset")
  45. get_partition_info(OTADATA_PARTITION_OFFSET "--type data --subtype ota --offset")
  46. get_partition_info(OTADATA_PARTITION_SIZE "--type data --subtype ota --size")
  47. endif()