CMakeLists.txt 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. if(CONFIG_BOOTLOADER_APP_ANTI_ROLLBACK AND factory_offset)
  14. fail_at_build_time(check_table_contents
  15. "ERROR: Anti-rollback option is enabled. Partition table should consist of two ota app without factory partition.")
  16. add_dependencies(app check_table_contents)
  17. endif()
  18. # Generate flasher_args.json for tools that need it. The variables below are used
  19. # in configuring the template flasher_args.json.in.
  20. # Some of the variables (flash mode, size, frequency) are already set in project_include.cmake.
  21. set(ESPTOOLPY_BEFORE "${CONFIG_ESPTOOLPY_BEFORE}")
  22. set(ESPTOOLPY_AFTER "${CONFIG_ESPTOOLPY_AFTER}")
  23. set(ESPTOOLPY_CHIP "${target}")
  24. if(CONFIG_ESPTOOLPY_WITH_STUB)
  25. set(ESPTOOLPY_WITH_STUB true)
  26. else()
  27. set(ESPTOOLPY_WITH_STUB false)
  28. endif()
  29. if(CONFIG_SECURE_BOOT OR CONFIG_SECURE_FLASH_ENC_ENABLED)
  30. # If security enabled then override post flash option
  31. set(ESPTOOLPY_AFTER "no_reset")
  32. endif()
  33. if(CONFIG_APP_BUILD_GENERATE_BINARIES)
  34. file(READ "flasher_args.json.in" flasher_args_content)
  35. string(CONFIGURE "${flasher_args_content}" flasher_args_content)
  36. file_generate("${CMAKE_CURRENT_BINARY_DIR}/flasher_args.json.in"
  37. CONTENT "${flasher_args_content}")
  38. file_generate("${CMAKE_BINARY_DIR}/flasher_args.json"
  39. INPUT "${CMAKE_CURRENT_BINARY_DIR}/flasher_args.json.in")
  40. endif()
  41. endif()