@@ -87,6 +87,16 @@ else()
87
87
set (imgtool_path "${IMGTOOL_COMMAND} " )
88
88
endif ()
89
89
90
+ # Find installed esptool, if not found falls to IDF's
91
+ find_program (ESPTOOL_COMMAND
92
+ NAMES esptool esptool.py
93
+ )
94
+ if ("${ESPTOOL_COMMAND} " MATCHES "ESPTOOL_COMMAND-NOTFOUND" )
95
+ set (esptool_path "${IDF_PATH} /components/esptool_py/esptool/esptool.py" )
96
+ else ()
97
+ set (esptool_path "${ESPTOOL_COMMAND} " )
98
+ endif ()
99
+
90
100
if (DEFINED CONFIG_ESP_SIGN_RSA)
91
101
include (${CMAKE_CURRENT_LIST_DIR} /include /crypto_config/rsa.cmake)
92
102
elseif (DEFINED CONFIG_ESP_SIGN_EC256)
@@ -275,7 +285,7 @@ target_link_libraries(
275
285
# Note: Both binary generation and flash steps still have some default arguments
276
286
add_custom_command (TARGET ${APP_EXECUTABLE} POST_BUILD
277
287
COMMAND
278
- ${IDF_PATH} /components/esptool_py/esptool/esptool.py
288
+ ${esptool_path}
279
289
--chip ${MCUBOOT_TARGET} elf2image --min-rev ${ESP_MIN_REVISION}
280
290
--flash_mode dio --flash_freq 40m --flash_size ${CONFIG_ESP_FLASH_SIZE}
281
291
-o ${APP_NAME} .bin ${APP_NAME} .elf
@@ -296,7 +306,7 @@ add_custom_target(flash DEPENDS ${APP_NAME}.bin)
296
306
add_custom_command (TARGET flash
297
307
USES_TERMINAL
298
308
COMMAND
299
- ${IDF_PATH} /components/esptool_py/esptool/esptool.py
309
+ ${esptool_path}
300
310
-p ${FLASH_PORT} -b 2000000 --before default_reset --after no_reset
301
311
--chip ${MCUBOOT_TARGET} write_flash
302
312
--flash_mode dio --flash_size ${CONFIG_ESP_FLASH_SIZE}
0 commit comments