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 "esp32h2") 14 set(uf2_family_id "0xd42ba06c") # ESP32H2-TODO: IDF-3487 15 elseif("${target}" STREQUAL "linux") 16 return() 17 else() 18 message(FATAL_ERROR "UF2 family identificator is unknown for ${target}") 19 # Generate an ID and submit a pull request as described here: https://github.com/microsoft/uf2 20 endif() 21 22 idf_build_get_property(python PYTHON) 23 idf_build_get_property(idf_path IDF_PATH) 24 25 add_custom_target(uf2-app 26 COMMAND ${python} ${idf_path}/tools/mkuf2.py write 27 -o "${CMAKE_CURRENT_BINARY_DIR}/uf2-app.bin" 28 --json "${CMAKE_CURRENT_BINARY_DIR}/flasher_args.json" 29 --chip-id "${uf2_family_id}" 30 --bin app 31 DEPENDS gen_project_binary 32 VERBATIM 33 USES_TERMINAL) 34 35 add_custom_target(uf2 36 COMMAND ${python} ${idf_path}/tools/mkuf2.py write 37 -o "${CMAKE_CURRENT_BINARY_DIR}/uf2.bin" 38 --json "${CMAKE_CURRENT_BINARY_DIR}/flasher_args.json" 39 --chip-id "${uf2_family_id}" 40 DEPENDS gen_project_binary bootloader 41 VERBATIM 42 USES_TERMINAL) 43endfunction() 44