CMakeLists.txt 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. idf_component_register(REQUIRES bootloader)
  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) are already set in project_include.cmake.
  23. set(ESPTOOLPY_BEFORE "${CONFIG_ESPTOOLPY_BEFORE}")
  24. set(ESPTOOLPY_AFTER "${CONFIG_ESPTOOLPY_AFTER}")
  25. set(ESPTOOLPY_CHIP "${target}")
  26. if(CONFIG_ESPTOOLPY_NO_STUB)
  27. set(ESPTOOLPY_WITH_STUB false)
  28. else()
  29. set(ESPTOOLPY_WITH_STUB true)
  30. endif()
  31. if(CONFIG_SECURE_BOOT OR CONFIG_SECURE_FLASH_ENC_ENABLED)
  32. # If security enabled then override post flash option
  33. set(ESPTOOLPY_AFTER "no_reset")
  34. endif()
  35. if(CONFIG_APP_BUILD_GENERATE_BINARIES)
  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. endif()
  43. endif()