project_include.cmake 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. # Set some global esptool.py variables
  2. #
  3. # Many of these are read when generating flash_app_args & flash_project_args
  4. idf_build_get_property(target IDF_TARGET)
  5. idf_build_get_property(python PYTHON)
  6. idf_build_get_property(idf_path IDF_PATH)
  7. set(chip_model ${target})
  8. if(target STREQUAL "esp32s3")
  9. if(CONFIG_IDF_TARGET_ESP32S3_BETA_VERSION_3)
  10. set(chip_model "esp32s3beta3")
  11. endif()
  12. endif()
  13. set(ESPTOOLPY ${python} "${CMAKE_CURRENT_LIST_DIR}/esptool/esptool.py" --chip ${chip_model})
  14. set(ESPSECUREPY ${python} "${CMAKE_CURRENT_LIST_DIR}/esptool/espsecure.py")
  15. set(ESPEFUSEPY ${python} "${CMAKE_CURRENT_LIST_DIR}/esptool/espefuse.py")
  16. set(ESPMONITOR ${python} "${idf_path}/tools/idf_monitor.py")
  17. set(ESPFLASHMODE ${CONFIG_ESPTOOLPY_FLASHMODE})
  18. set(ESPFLASHFREQ ${CONFIG_ESPTOOLPY_FLASHFREQ})
  19. set(ESPFLASHSIZE ${CONFIG_ESPTOOLPY_FLASHSIZE})
  20. set(ESPTOOLPY_FLASH_OPTIONS
  21. --flash_mode ${ESPFLASHMODE}
  22. --flash_freq ${ESPFLASHFREQ}
  23. --flash_size ${ESPFLASHSIZE}
  24. )
  25. if(NOT BOOTLOADER_BUILD)
  26. set(esptool_elf2image_args --elf-sha256-offset 0xb0)
  27. endif()
  28. if(NOT CONFIG_SECURE_BOOT_ALLOW_SHORT_APP_PARTITION AND
  29. NOT BOOTLOADER_BUILD)
  30. if(CONFIG_SECURE_SIGNED_APPS_ECDSA_SCHEME)
  31. list(APPEND esptool_elf2image_args --secure-pad)
  32. elseif(CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME)
  33. list(APPEND esptool_elf2image_args --secure-pad-v2)
  34. endif()
  35. endif()
  36. if(CONFIG_ESP32_REV_MIN)
  37. set(min_rev ${CONFIG_ESP32_REV_MIN})
  38. endif()
  39. if(CONFIG_ESP32C3_REV_MIN)
  40. set(min_rev ${CONFIG_ESP32C3_REV_MIN})
  41. endif()
  42. if(min_rev)
  43. list(APPEND esptool_elf2image_args --min-rev ${min_rev})
  44. set(monitor_rev_args --revision ${min_rev})
  45. unset(min_rev)
  46. endif()
  47. if(CONFIG_ESPTOOLPY_FLASHSIZE_DETECT)
  48. # Set ESPFLASHSIZE to 'detect' *after* elf2image options are generated,
  49. # as elf2image can't have 'detect' as an option...
  50. set(ESPFLASHSIZE detect)
  51. endif()
  52. if(CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME)
  53. set(ESPFLASHSIZE keep)
  54. endif()
  55. idf_build_get_property(build_dir BUILD_DIR)
  56. idf_build_get_property(elf_name EXECUTABLE_NAME GENERATOR_EXPRESSION)
  57. idf_build_get_property(elf EXECUTABLE GENERATOR_EXPRESSION)
  58. idf_build_get_property(elf_dir EXECUTABLE_DIR GENERATOR_EXPRESSION)
  59. if(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES AND NOT BOOTLOADER_BUILD)
  60. set(unsigned_project_binary "${elf_name}-unsigned.bin")
  61. else()
  62. set(unsigned_project_binary "${elf_name}.bin")
  63. endif()
  64. set(PROJECT_BIN "${elf_name}.bin")
  65. #
  66. # Add 'app.bin' target - generates with elf2image
  67. #
  68. if(CONFIG_APP_BUILD_GENERATE_BINARIES)
  69. add_custom_command(OUTPUT "${build_dir}/.bin_timestamp"
  70. COMMAND ${ESPTOOLPY} elf2image ${ESPTOOLPY_FLASH_OPTIONS} ${esptool_elf2image_args}
  71. -o "${build_dir}/${unsigned_project_binary}" "${elf_dir}/${elf}"
  72. COMMAND ${CMAKE_COMMAND} -E echo "Generated ${build_dir}/${unsigned_project_binary}"
  73. COMMAND ${CMAKE_COMMAND} -E md5sum "${build_dir}/${unsigned_project_binary}" > "${build_dir}/.bin_timestamp"
  74. DEPENDS ${elf}
  75. VERBATIM
  76. WORKING_DIRECTORY ${build_dir}
  77. COMMENT "Generating binary image from built executable"
  78. )
  79. add_custom_target(gen_project_binary DEPENDS "${build_dir}/.bin_timestamp")
  80. endif()
  81. set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
  82. APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
  83. "${build_dir}/${unsigned_project_binary}"
  84. )
  85. if(CONFIG_APP_BUILD_GENERATE_BINARIES)
  86. add_custom_target(app ALL DEPENDS gen_project_binary)
  87. endif()
  88. if(CONFIG_SECURE_SIGNED_APPS_ECDSA_SCHEME)
  89. set(secure_boot_version "1")
  90. elseif(CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME)
  91. set(secure_boot_version "2")
  92. endif()
  93. if(NOT BOOTLOADER_BUILD AND CONFIG_SECURE_SIGNED_APPS)
  94. if(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)
  95. # for locally signed secure boot image, add a signing step to get from unsigned app to signed app
  96. add_custom_command(OUTPUT "${build_dir}/.signed_bin_timestamp"
  97. COMMAND ${ESPSECUREPY} sign_data --version ${secure_boot_version} --keyfile ${secure_boot_signing_key}
  98. -o "${build_dir}/${PROJECT_BIN}" "${build_dir}/${unsigned_project_binary}"
  99. COMMAND ${CMAKE_COMMAND} -E echo "Generated signed binary image ${build_dir}/${PROJECT_BIN}"
  100. "from ${build_dir}/${unsigned_project_binary}"
  101. COMMAND ${CMAKE_COMMAND} -E md5sum "${build_dir}/${PROJECT_BIN}" > "${build_dir}/.signed_bin_timestamp"
  102. DEPENDS "${build_dir}/.bin_timestamp"
  103. VERBATIM
  104. COMMENT "Generating signed binary image"
  105. )
  106. add_custom_target(gen_signed_project_binary DEPENDS "${build_dir}/.signed_bin_timestamp")
  107. add_dependencies(gen_project_binary gen_signed_project_binary)
  108. set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
  109. APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
  110. "${build_dir}/${PROJECT_BIN}"
  111. )
  112. else()
  113. string(REPLACE ";" " " espsecurepy "${ESPSECUREPY}")
  114. add_custom_command(TARGET app POST_BUILD
  115. COMMAND ${CMAKE_COMMAND} -E echo
  116. "App built but not signed. Sign app before flashing"
  117. COMMAND ${CMAKE_COMMAND} -E echo
  118. "\t${espsecurepy} sign_data --keyfile KEYFILE --version ${secure_boot_version} \
  119. ${build_dir}/${PROJECT_BIN}"
  120. VERBATIM)
  121. endif()
  122. endif()
  123. add_custom_target(erase_flash
  124. COMMAND ${CMAKE_COMMAND}
  125. -D IDF_PATH="${idf_path}"
  126. -D SERIAL_TOOL="${ESPTOOLPY}"
  127. -D SERIAL_TOOL_ARGS="erase_flash"
  128. -P run_serial_tool.cmake
  129. WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
  130. USES_TERMINAL
  131. )
  132. add_custom_target(monitor
  133. COMMAND ${CMAKE_COMMAND}
  134. -D IDF_PATH="${idf_path}"
  135. -D SERIAL_TOOL="${ESPMONITOR}"
  136. -D SERIAL_TOOL_ARGS="--target ${target} ${monitor_rev_args} ${elf_dir}/${elf}"
  137. -D WORKING_DIRECTORY="${build_dir}"
  138. -P run_serial_tool.cmake
  139. WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
  140. USES_TERMINAL
  141. )
  142. set(esptool_flash_main_args "--before=${CONFIG_ESPTOOLPY_BEFORE}")
  143. if(CONFIG_SECURE_BOOT OR CONFIG_SECURE_FLASH_ENC_ENABLED)
  144. # If security enabled then override post flash option
  145. list(APPEND esptool_flash_main_args "--after=no_reset")
  146. else()
  147. list(APPEND esptool_flash_main_args "--after=${CONFIG_ESPTOOLPY_AFTER}")
  148. endif()
  149. if(CONFIG_ESPTOOLPY_NO_STUB)
  150. list(APPEND esptool_flash_main_args "--no-stub")
  151. endif()
  152. idf_component_set_property(esptool_py FLASH_ARGS "${esptool_flash_main_args}")
  153. idf_component_set_property(esptool_py FLASH_SUB_ARGS "${ESPTOOLPY_FLASH_OPTIONS}")
  154. function(esptool_py_partition_needs_encryption retencrypted partition_name)
  155. # Check if encryption is enabled
  156. if(CONFIG_SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT)
  157. # Encryption is enabled, get partition type, subtype and encrypted flag
  158. # to determine whether it needs encryption or not.
  159. partition_table_get_partition_info(type "--partition-name ${partition_name}" "type")
  160. partition_table_get_partition_info(subtype "--partition-name ${partition_name}" "subtype")
  161. partition_table_get_partition_info(encrypted "--partition-name ${partition_name}" "encrypted")
  162. # As defined in gen_esp32part.py file:
  163. # Types:
  164. # - APP 0x00
  165. # - DATA 0x01
  166. # Subtypes:
  167. # - ota 0x00
  168. # - nvs 0x02
  169. # If the partition is an app, an OTA or an NVS partition, then it should
  170. # be encrypted
  171. if(
  172. (${type} EQUAL 0) OR
  173. (${type} EQUAL 1 AND ${subtype} EQUAL 0) OR
  174. (${type} EQUAL 1 AND ${subtype} EQUAL 2)
  175. )
  176. set(encrypted TRUE)
  177. endif()
  178. # Return 'encrypted' value to the caller
  179. set(${retencrypted} ${encrypted} PARENT_SCOPE)
  180. else()
  181. # Encryption not enabled, return false
  182. set(${retencrypted} FALSE PARENT_SCOPE)
  183. endif()
  184. endfunction()
  185. function(esptool_py_flash_to_partition target_name partition_name binary_path)
  186. # Retrieve the offset for the partition to flash the image on
  187. partition_table_get_partition_info(offset "--partition-name ${partition_name}" "offset")
  188. if(NOT offset)
  189. message(FATAL_ERROR "Could not find offset of partition ${partition_name}")
  190. endif()
  191. # Check whether the partition needs encryption or not
  192. esptool_py_partition_needs_encryption(encrypted ${partition_name})
  193. # If the image should not be encrypted, we pass the option
  194. # ALWAYS_PLAINTEXT to the function esptool_py_flash_target_image
  195. if(NOT ${encrypted})
  196. set(option ALWAYS_PLAINTEXT)
  197. endif()
  198. # The image name is also the partition name
  199. esptool_py_flash_target_image(${target_name} ${partition_name} ${offset}
  200. ${binary_path} ${option})
  201. endfunction()
  202. # This function takes a fifth optional named parameter: "ALWAYS_PLAINTEXT". As
  203. # its name states, it marks whether the image should be flashed as plain text or
  204. # not. If build macro CONFIG_SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT is set and
  205. # this parameter is provided, then the image will be flahsed as plain text
  206. # (not encrypted) on the target. This parameter will be ignored if build macro
  207. # CONFIG_SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT is not set.
  208. function(esptool_py_flash_target_image target_name image_name offset image)
  209. set(options ALWAYS_PLAINTEXT)
  210. idf_build_get_property(build_dir BUILD_DIR)
  211. file(RELATIVE_PATH image ${build_dir} ${image})
  212. cmake_parse_arguments(arg "${options}" "" "" "${ARGN}")
  213. # Check if the image has to be plain text or not, depending on the macro
  214. # CONFIG_SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT and the parameter
  215. # ALWAYS_PLAINTEXT
  216. set(encrypted false)
  217. if(CONFIG_SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT AND
  218. NOT arg_ALWAYS_PLAINTEXT)
  219. set(encrypted true)
  220. endif()
  221. # In the following snippet of code, some properties are defined for our
  222. # current target. These properties will be used to generate the actual
  223. # target_name_args files using the target_name_args.in files.
  224. # Please see function esptool_py_flash_target above for more information
  225. # about these properties and how they are used.
  226. # Add the image file, with its offset, to the list of files to
  227. # flash to the target. No matter whether flash encryption is
  228. # enabled or not, plain binaries (non-encrypted) need to be
  229. # generated
  230. set_property(TARGET ${target_name} APPEND PROPERTY FLASH_FILE
  231. "\"${offset}\" : \"${image}\"")
  232. set_property(TARGET ${target_name} APPEND PROPERTY FLASH_ENTRY
  233. "\"${image_name}\" : { \"offset\" : \"${offset}\", \"file\" : \"${image}\",\
  234. \"encrypted\" : \"${encrypted}\" }")
  235. set_property(TARGET ${target_name} APPEND PROPERTY IMAGES "${offset} ${image}")
  236. if(CONFIG_SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT)
  237. # When flash encryption mode is enabled, if the current binary needs to
  238. # be encrypted, do the same as previously but prefixing target names
  239. # with "encrypted-".
  240. if(encrypted)
  241. set_property(TARGET encrypted-${target_name} APPEND PROPERTY FLASH_FILE
  242. "\"${offset}\" : \"${image}\"")
  243. set_property(TARGET encrypted-${target_name} APPEND PROPERTY FLASH_ENTRY
  244. "\"${image_name}\" : { \"offset\" : \"${offset}\", \"file\" : \"${image}\" , \
  245. \"encrypted\" : \"${encrypted}\" }")
  246. set_property(TARGET encrypted-${target_name} APPEND PROPERTY ENCRYPTED_IMAGES "${offset} ${image}")
  247. else()
  248. # The target doesn't need to be encrypted, thus, add the current
  249. # file to the NON_ENCRYPTED_IMAGES property
  250. set_property(TARGET encrypted-${target_name} APPEND PROPERTY NON_ENCRYPTED_IMAGES "${offset} ${image}")
  251. endif()
  252. endif()
  253. endfunction()
  254. # Use this function to generate a ternary expression that will be evaluated.
  255. # - retexpr is the expression returned by the function
  256. # - condition is the expression evaluated to a boolean
  257. # - condtrue is the expression to evaluate if condition is true
  258. # - condfalse is the expression to evaluate if condition is false
  259. # This function can be summarized as:
  260. # retexpr = condition ? condtrue : condfalse
  261. function(if_expr_generator retexpr condition condtrue condfalse)
  262. # CMake version 3.8 and above provide a ternary operator for expression
  263. # generator. For version under, we must simulate this behaviour
  264. if(${CMAKE_VERSION} VERSION_LESS "3.8.0")
  265. # If condtrue is not empty, then we have to do something in case the
  266. # condition is true. Generate the expression that will be used in that
  267. # case
  268. if(condtrue)
  269. set(iftrue "$<${condition}:${condtrue}>")
  270. endif()
  271. # Same for condfalse. If it is empty, it is useless to create an
  272. # expression that will be evaluated later
  273. if(condfalse)
  274. set(iffalse "$<$<NOT:${condition}>:${condfalse}>")
  275. endif()
  276. # Concatenate the previously generated expressions. If one of them was
  277. # not initialized (because of empty condtrue/condfalse) it will be
  278. # replaced by an empty string
  279. set(${retexpr} "${iftrue}${iffalse}" PARENT_SCOPE)
  280. else()
  281. # CMake 3.8 and above implement what we want, making the expression
  282. # simpler
  283. set(${retexpr} "$<IF:${condition},${condtrue},${condfalse}>" PARENT_SCOPE)
  284. endif()
  285. endfunction()
  286. function(esptool_py_flash_target target_name main_args sub_args)
  287. set(single_value OFFSET IMAGE) # template file to use to be able to
  288. # flash the image individually using esptool
  289. set(options ALWAYS_PLAINTEXT)
  290. cmake_parse_arguments(_ "${options}" "${single_value}" "" "${ARGN}")
  291. idf_build_get_property(idf_path IDF_PATH)
  292. idf_build_get_property(build_dir BUILD_DIR)
  293. idf_component_get_property(esptool_py_dir esptool_py COMPONENT_DIR)
  294. add_custom_target(${target_name}
  295. COMMAND ${CMAKE_COMMAND}
  296. -D IDF_PATH="${idf_path}"
  297. -D SERIAL_TOOL="${ESPTOOLPY}"
  298. -D SERIAL_TOOL_ARGS="${main_args};write_flash;@${target_name}_args"
  299. -D WORKING_DIRECTORY="${build_dir}"
  300. -P ${esptool_py_dir}/run_serial_tool.cmake
  301. WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
  302. USES_TERMINAL
  303. )
  304. set_target_properties(${target_name} PROPERTIES SUB_ARGS "${sub_args}")
  305. # Create the expression that contains the list of file names to pass
  306. # to esptool script
  307. set(flash_args_content "$<JOIN:$<TARGET_PROPERTY:${target_name},SUB_ARGS>, >\n\
  308. $<JOIN:$<TARGET_PROPERTY:${target_name},IMAGES>,\n>")
  309. # Write the previous expression to the target_name_args.in file
  310. file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${target_name}_args.in"
  311. CONTENT "${flash_args_content}")
  312. # Generate the actual expression value from the content of the file
  313. # we just wrote
  314. file(GENERATE OUTPUT "${build_dir}/${target_name}_args"
  315. INPUT "${CMAKE_CURRENT_BINARY_DIR}/${target_name}_args.in")
  316. # Check if the target has to be plain text or not, depending on the macro
  317. # CONFIG_SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT and the parameter
  318. # ALWAYS_PLAINTEXT
  319. set(encrypted FALSE)
  320. if(CONFIG_SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT AND
  321. NOT __ALWAYS_PLAINTEXT)
  322. set(encrypted TRUE)
  323. endif()
  324. # If the file needs to be encrypted, create a target file that lets the user
  325. # flash this partition independently from other files.
  326. # For example, if 'target_name' is app-flash and 'encrypted' is TRUE,
  327. # 'build' directory will contain a file name 'encrypted_app-flash_args'
  328. if(${encrypted})
  329. add_custom_target(encrypted-${target_name}
  330. COMMAND ${CMAKE_COMMAND}
  331. -D IDF_PATH="${idf_path}"
  332. -D SERIAL_TOOL="${ESPTOOLPY}"
  333. -D SERIAL_TOOL_ARGS="${main_args};write_flash;@encrypted_${target_name}_args"
  334. -D WORKING_DIRECTORY="${build_dir}"
  335. -P ${esptool_py_dir}/run_serial_tool.cmake
  336. WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
  337. USES_TERMINAL
  338. )
  339. # Generate the parameters for esptool.py command
  340. # In case we have both non encrypted and encrypted files to flash, we
  341. # can use --encrypt-files parameter to specify which ones should be
  342. # encrypted.
  343. # If we only have encrypted images to flash, we must use legacy
  344. # --encrypt parameter.
  345. # As the properties ENCRYPTED_IMAGES and NON_ENCRYPTED_IMAGES have not
  346. # been geenrated yet, we must use CMake expression generator to test
  347. # which esptool.py options we can use.
  348. # The variable has_non_encrypted_image will be evaluated to "1" if some
  349. # images must not be encrypted. This variable will be used in the next
  350. # expression
  351. set(has_non_encrypted_images "$<BOOL:$<TARGET_PROPERTY:\
  352. encrypted-${target_name},NON_ENCRYPTED_IMAGES>>")
  353. # Prepare esptool arguments (--encrypt or --encrypt-files)
  354. if_expr_generator(if_non_enc_expr ${has_non_encrypted_images}
  355. "" "--encrypt")
  356. set_target_properties(encrypted-${target_name} PROPERTIES SUB_ARGS
  357. "${sub_args}; ${if_non_enc_expr}")
  358. # Generate the list of files to pass to esptool
  359. set(encrypted_files "$<JOIN:$<TARGET_PROPERTY\
  360. :encrypted-${target_name},ENCRYPTED_IMAGES>,\n>")
  361. set(non_encrypted_files "$<JOIN:$<TARGET_PROPERTY:\
  362. encrypted-${target_name},NON_ENCRYPTED_IMAGES>,\n>")
  363. # Put both lists together, use --encrypted-files if we do also have
  364. # plain images to flash
  365. if_expr_generator(if_enc_expr ${has_non_encrypted_images}
  366. "--encrypt-files\n" "")
  367. set(flash_args_content "$<JOIN:$<TARGET_PROPERTY:\
  368. encrypted-${target_name},SUB_ARGS>, >\
  369. ${non_encrypted_files}\n\
  370. ${if_enc_expr}\
  371. ${encrypted_files}")
  372. # The expression is ready to be geenrated, write it to the file which
  373. # extension is .in
  374. file_generate("${CMAKE_CURRENT_BINARY_DIR}/encrypted_${target_name}_args.in"
  375. CONTENT "${flash_args_content}")
  376. # Generate the actual string from the content of the file we just wrote
  377. file_generate("${build_dir}/encrypted_${target_name}_args"
  378. INPUT "${CMAKE_CURRENT_BINARY_DIR}/encrypted_${target_name}_args.in")
  379. else()
  380. fail_target(encrypted-${target_name} "Error: The target encrypted-${target_name} requires"
  381. "CONFIG_SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT to be enabled.")
  382. endif()
  383. endfunction()
  384. function(esptool_py_custom_target target_name flasher_filename dependencies)
  385. idf_component_get_property(main_args esptool_py FLASH_ARGS)
  386. idf_component_get_property(sub_args esptool_py FLASH_SUB_ARGS)
  387. idf_build_get_property(build_dir BUILD_DIR)
  388. esptool_py_flash_target(${target_name} "${main_args}" "${sub_args}")
  389. # Copy the file to flash_xxx_args for compatibility for select target
  390. file_generate("${build_dir}/flash_${flasher_filename}_args"
  391. INPUT "${build_dir}/${target_name}_args")
  392. add_dependencies(${target_name} ${dependencies})
  393. if(CONFIG_SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT)
  394. file_generate("${build_dir}/flash_encrypted_${flasher_filename}_args"
  395. INPUT "${build_dir}/encrypted_${target_name}_args")
  396. add_dependencies(encrypted-${target_name} ${dependencies})
  397. endif()
  398. endfunction()
  399. if(NOT BOOTLOADER_BUILD)
  400. set(flash_deps "partition_table_bin")
  401. if(CONFIG_APP_BUILD_GENERATE_BINARIES)
  402. list(APPEND flash_deps "app")
  403. endif()
  404. if(CONFIG_APP_BUILD_BOOTLOADER)
  405. list(APPEND flash_deps "bootloader")
  406. endif()
  407. esptool_py_custom_target(flash project "${flash_deps}")
  408. endif()