1# Add UF2 build target 2 3function(__add_uf2_targets) 4 idf_build_get_property(target IDF_TARGET) 5 if("${target}" STREQUAL "esp32") 6 set(uf2_family_id "0x1c5f21b0") 7 elseif("${target}" STREQUAL "esp32s2") 8 set(uf2_family_id "0xbfdd4eee") 9 elseif("${target}" STREQUAL "esp32c3") 10 set(uf2_family_id "0xd42ba06c") 11 elseif("${target}" STREQUAL "esp32s3") 12 set(uf2_family_id "0xc47e5767") 13 elseif("${target}" STREQUAL "linux") 14 return() 15 else() 16 message(FATAL_ERROR "UF2 family identificator is unknown for ${target}") 17 # Generate an ID and submit a pull request as described here: https://github.com/microsoft/uf2 18 endif() 19 20 idf_build_get_property(python PYTHON) 21 idf_build_get_property(idf_path IDF_PATH) 22 23 add_custom_target(uf2-app 24 COMMAND ${python} ${idf_path}/tools/mkuf2.py write 25 -o "${CMAKE_CURRENT_BINARY_DIR}/uf2-app.bin" 26 --json "${CMAKE_CURRENT_BINARY_DIR}/flasher_args.json" 27 --chip-id "${uf2_family_id}" 28 --bin app 29 DEPENDS gen_project_binary 30 VERBATIM 31 USES_TERMINAL) 32 33 add_custom_target(uf2 34 COMMAND ${python} ${idf_path}/tools/mkuf2.py write 35 -o "${CMAKE_CURRENT_BINARY_DIR}/uf2.bin" 36 --json "${CMAKE_CURRENT_BINARY_DIR}/flasher_args.json" 37 --chip-id "${uf2_family_id}" 38 DEPENDS gen_project_binary bootloader 39 VERBATIM 40 USES_TERMINAL) 41endfunction() 42