CMakeLists.txt 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. idf_build_get_property(target IDF_TARGET)
  2. if(${target} STREQUAL "linux")
  3. return() # This component is not supported by the POSIX/Linux simulator
  4. endif()
  5. idf_component_register(REQUIRES bootloader PRIV_REQUIRES partition_table)
  6. if(NOT BOOTLOADER_BUILD)
  7. idf_build_get_property(build_dir BUILD_DIR)
  8. if(CONFIG_APP_BUILD_GENERATE_BINARIES)
  9. partition_table_get_partition_info(app_partition_offset "--partition-boot-default" "offset")
  10. esptool_py_custom_target(app-flash app "app")
  11. esptool_py_flash_target_image(app-flash app "${app_partition_offset}" "${build_dir}/${PROJECT_BIN}")
  12. esptool_py_flash_target_image(flash app "${app_partition_offset}" "${build_dir}/${PROJECT_BIN}")
  13. endif()
  14. # If anti-rollback option is set then factory partition should not be in Partition Table.
  15. # In this case, should be used the partition table with two ota app without the factory.
  16. partition_table_get_partition_info(factory_offset "--partition-type app --partition-subtype factory" "offset")
  17. partition_table_get_partition_info(test_offset "--partition-type app --partition-subtype test" "offset")
  18. if(CONFIG_BOOTLOADER_APP_ANTI_ROLLBACK AND (factory_offset OR test_offset))
  19. fail_at_build_time(check_table_contents "\
  20. ERROR: Anti-rollback option is enabled. Partition table should \
  21. consist of two ota app without factory or test partitions.")
  22. add_dependencies(app check_table_contents)
  23. endif()
  24. # Generate flasher_args.json for tools that need it. The variables below are used
  25. # in configuring the template flasher_args.json.in.
  26. # Some of the variables (flash mode, size, frequency, chip) are already set in project_include.cmake.
  27. set(ESPTOOLPY_BEFORE "${CONFIG_ESPTOOLPY_BEFORE}")
  28. set(ESPTOOLPY_AFTER "${CONFIG_ESPTOOLPY_AFTER}")
  29. if(CONFIG_ESPTOOLPY_NO_STUB)
  30. set(ESPTOOLPY_WITH_STUB false)
  31. else()
  32. set(ESPTOOLPY_WITH_STUB true)
  33. endif()
  34. if(CONFIG_SECURE_BOOT OR CONFIG_SECURE_FLASH_ENC_ENABLED)
  35. # If security enabled then override post flash option
  36. set(ESPTOOLPY_AFTER "no_reset")
  37. endif()
  38. if(CONFIG_APP_BUILD_GENERATE_BINARIES)
  39. # Generate flasher args files
  40. file(READ "flasher_args.json.in" flasher_args_content)
  41. string(CONFIGURE "${flasher_args_content}" flasher_args_content)
  42. file_generate("${CMAKE_CURRENT_BINARY_DIR}/flasher_args.json.in"
  43. CONTENT "${flasher_args_content}")
  44. file_generate("${CMAKE_BINARY_DIR}/flasher_args.json"
  45. INPUT "${CMAKE_CURRENT_BINARY_DIR}/flasher_args.json.in")
  46. if(CONFIG_APP_BUILD_TYPE_APP_2NDBOOT)
  47. # Generate app_check_size_command target to check the app size against the partition table parameters
  48. partition_table_add_check_size_target(app_check_size
  49. DEPENDS gen_project_binary
  50. BINARY_PATH "${build_dir}/${PROJECT_BIN}"
  51. PARTITION_TYPE app)
  52. add_dependencies(app app_check_size)
  53. endif()
  54. endif()
  55. endif() # NOT BOOTLOADER_BUILD
  56. if(BOOTLOADER_BUILD)
  57. # Generate bootloader post-build check of the bootloader size against the offset
  58. partition_table_add_check_bootloader_size_target(bootloader_check_size
  59. DEPENDS gen_project_binary
  60. BOOTLOADER_BINARY_PATH "${build_dir}/${PROJECT_BIN}"
  61. RESULT bootloader_check_size_command)
  62. add_dependencies(app bootloader_check_size) # note: in the subproject, so the target is 'app'...
  63. endif()