Skip to content

Commit 26ed3f4

Browse files
committedJul 24, 2023
espressif: preferred use of a installed esptool
Signed-off-by: Almir Okato <almir.okato@espressif.com>
1 parent 018b770 commit 26ed3f4

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed
 

‎boot/espressif/CMakeLists.txt

+12-2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,16 @@ else()
8787
set(imgtool_path "${IMGTOOL_COMMAND}")
8888
endif()
8989

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+
90100
if (DEFINED CONFIG_ESP_SIGN_RSA)
91101
include(${CMAKE_CURRENT_LIST_DIR}/include/crypto_config/rsa.cmake)
92102
elseif (DEFINED CONFIG_ESP_SIGN_EC256)
@@ -275,7 +285,7 @@ target_link_libraries(
275285
# Note: Both binary generation and flash steps still have some default arguments
276286
add_custom_command(TARGET ${APP_EXECUTABLE} POST_BUILD
277287
COMMAND
278-
${IDF_PATH}/components/esptool_py/esptool/esptool.py
288+
${esptool_path}
279289
--chip ${MCUBOOT_TARGET} elf2image --min-rev ${ESP_MIN_REVISION}
280290
--flash_mode dio --flash_freq 40m --flash_size ${CONFIG_ESP_FLASH_SIZE}
281291
-o ${APP_NAME}.bin ${APP_NAME}.elf
@@ -296,7 +306,7 @@ add_custom_target(flash DEPENDS ${APP_NAME}.bin)
296306
add_custom_command(TARGET flash
297307
USES_TERMINAL
298308
COMMAND
299-
${IDF_PATH}/components/esptool_py/esptool/esptool.py
309+
${esptool_path}
300310
-p ${FLASH_PORT} -b 2000000 --before default_reset --after no_reset
301311
--chip ${MCUBOOT_TARGET} write_flash
302312
--flash_mode dio --flash_size ${CONFIG_ESP_FLASH_SIZE}

0 commit comments

Comments
 (0)
Please sign in to comment.