CMakeLists.txt 3.2 KB

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