2020-04-06 10:41:44 -04:00
|
|
|
# Add DFU build and flashing related targets
|
|
|
|
#
|
|
|
|
|
|
|
|
function(__add_dfu_targets)
|
|
|
|
idf_build_get_property(target IDF_TARGET)
|
2020-05-26 11:35:40 -04:00
|
|
|
if("${target}" STREQUAL "esp32")
|
2020-04-06 10:41:44 -04:00
|
|
|
return()
|
2020-05-26 11:35:40 -04:00
|
|
|
elseif("${target}" STREQUAL "esp32s2")
|
|
|
|
set(dfu_pid "2")
|
2020-01-15 08:50:19 -05:00
|
|
|
elseif("${target}" STREQUAL "esp32s3")
|
2021-09-24 10:10:19 -04:00
|
|
|
set(dfu_pid "9")
|
2020-12-28 21:00:45 -05:00
|
|
|
elseif("${target}" STREQUAL "esp32c3")
|
|
|
|
return()
|
2021-06-08 04:11:35 -04:00
|
|
|
elseif("${target}" STREQUAL "esp32h2")
|
|
|
|
return()
|
2022-01-17 21:32:56 -05:00
|
|
|
elseif("${target}" STREQUAL "esp32c2")
|
2021-09-23 02:30:50 -04:00
|
|
|
return()
|
2020-08-10 00:29:05 -04:00
|
|
|
elseif("${target}" STREQUAL "linux")
|
|
|
|
return()
|
2020-05-26 11:35:40 -04:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "DFU PID unknown for ${target}")
|
2020-04-06 10:41:44 -04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
idf_build_get_property(python PYTHON)
|
|
|
|
idf_build_get_property(idf_path IDF_PATH)
|
|
|
|
|
|
|
|
add_custom_target(dfu
|
|
|
|
COMMAND ${python} ${idf_path}/tools/mkdfu.py write
|
|
|
|
-o "${CMAKE_CURRENT_BINARY_DIR}/dfu.bin"
|
|
|
|
--json "${CMAKE_CURRENT_BINARY_DIR}/flasher_args.json"
|
2020-05-26 11:35:40 -04:00
|
|
|
--pid "${dfu_pid}"
|
2022-05-26 10:07:54 -04:00
|
|
|
--flash-size "${CONFIG_ESPTOOLPY_FLASHSIZE}"
|
2020-04-06 10:41:44 -04:00
|
|
|
DEPENDS gen_project_binary bootloader
|
|
|
|
VERBATIM
|
|
|
|
USES_TERMINAL)
|
|
|
|
|
2020-05-26 11:35:40 -04:00
|
|
|
add_custom_target(dfu-list
|
|
|
|
COMMAND ${CMAKE_COMMAND}
|
|
|
|
-D ESP_DFU_LIST="1"
|
|
|
|
-P ${idf_path}/tools/cmake/run_dfu_util.cmake
|
|
|
|
USES_TERMINAL)
|
|
|
|
|
2020-04-06 10:41:44 -04:00
|
|
|
add_custom_target(dfu-flash
|
2020-05-26 11:35:40 -04:00
|
|
|
COMMAND ${CMAKE_COMMAND}
|
|
|
|
-D ESP_DFU_BIN="${CMAKE_CURRENT_BINARY_DIR}/dfu.bin"
|
|
|
|
-D ESP_DFU_PID="${dfu_pid}"
|
|
|
|
-P ${idf_path}/tools/cmake/run_dfu_util.cmake
|
2020-04-06 10:41:44 -04:00
|
|
|
USES_TERMINAL)
|
|
|
|
endfunction()
|