project_include.cmake 2.9 KB

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