From 6a18eaeaf5a8048a4a4890856de12e15617a46fe Mon Sep 17 00:00:00 2001 From: Renz Christian Bagaporo Date: Fri, 10 May 2019 18:40:46 +0800 Subject: [PATCH] esptool_py: fix issue with variable for esptool args elf2image-only arguments are being added to esptool args meant for flashing --- components/esptool_py/CMakeLists.txt | 2 +- components/esptool_py/project_include.cmake | 29 ++++++++++++++------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/components/esptool_py/CMakeLists.txt b/components/esptool_py/CMakeLists.txt index be1cdbf77a..f306c2a1f4 100644 --- a/components/esptool_py/CMakeLists.txt +++ b/components/esptool_py/CMakeLists.txt @@ -1,6 +1,6 @@ idf_component_register(REQUIRES bootloader) -string(REPLACE ";" " " ESPTOOLPY_FLASH_PROJECT_OPTIONS "${ESPTOOLPY_ELF2IMAGE_FLASH_OPTIONS}") +string(REPLACE ";" " " ESPTOOLPY_FLASH_PROJECT_OPTIONS "${ESPTOOLPY_FLASH_OPTIONS}") set(ESPTOOLPY_FLASH_PROJECT_OPTIONS "${ESPTOOLPY_FLASH_PROJECT_OPTIONS}" ) diff --git a/components/esptool_py/project_include.cmake b/components/esptool_py/project_include.cmake index 7d064f9c2c..1d5a64cfcd 100644 --- a/components/esptool_py/project_include.cmake +++ b/components/esptool_py/project_include.cmake @@ -31,7 +31,7 @@ else() set(ESPTOOLPY_COMPRESSED_OPT -u) endif() -set(ESPTOOLPY_ELF2IMAGE_FLASH_OPTIONS +set(ESPTOOLPY_FLASH_OPTIONS --flash_mode ${ESPFLASHMODE} --flash_freq ${ESPFLASHFREQ} --flash_size ${ESPFLASHSIZE} @@ -40,19 +40,18 @@ set(ESPTOOLPY_ELF2IMAGE_FLASH_OPTIONS # String for printing flash command string(REPLACE ";" " " ESPTOOLPY_WRITE_FLASH_STR "${ESPTOOLPY} --port (PORT) --baud (BAUD) --before ${ESPTOOLPY_BEFORE} --after ${ESPTOOLPY_AFTER} " - "write_flash ${ESPTOOLPY_ELF2IMAGE_FLASH_OPTIONS} ${ESPTOOLPY_EXTRA_FLASH_OPTIONS} ${ESPTOOLPY_COMPRESSED_OPT}") - -if(CONFIG_SECURE_BOOT_ENABLED AND - NOT CONFIG_SECURE_BOOT_ALLOW_SHORT_APP_PARTITION AND - NOT BOOTLOADER_BUILD) - set(ESPTOOLPY_ELF2IMAGE_FLASH_OPTIONS - ${ESPTOOLPY_ELF2IMAGE_FLASH_OPTIONS} --secure-pad) -endif() + "write_flash ${ESPTOOLPY_FLASH_OPTIONS} ${ESPTOOLPY_EXTRA_FLASH_OPTIONS} ${ESPTOOLPY_COMPRESSED_OPT}") if(NOT BOOTLOADER_BUILD) set(ESPTOOLPY_ELF2IMAGE_OPTIONS --elf-sha256-offset 0xb0) endif() +if(CONFIG_SECURE_BOOT_ENABLED AND + NOT CONFIG_SECURE_BOOT_ALLOW_SHORT_APP_PARTITION + AND NOT BOOTLOADER_BUILD) + set(ESPTOOLPY_ELF2IMAGE_OPTIONS ${ESPTOOLPY_ELF2IMAGE_OPTIONS} --secure-pad) +endif() + if(CONFIG_ESPTOOLPY_FLASHSIZE_DETECT) # Set ESPFLASHSIZE to 'detect' *after* elf2image options are generated, # as elf2image can't have 'detect' as an option... @@ -76,7 +75,7 @@ set(PROJECT_BIN "${elf_name}.bin") # Add 'app.bin' target - generates with elf2image # add_custom_command(OUTPUT "${build_dir}/.bin_timestamp" - COMMAND ${ESPTOOLPY} elf2image ${ESPTOOLPY_ELF2IMAGE_FLASH_OPTIONS} ${ESPTOOLPY_ELF2IMAGE_OPTIONS} + COMMAND ${ESPTOOLPY} elf2image ${ESPTOOLPY_FLASH_OPTIONS} ${ESPTOOLPY_ELF2IMAGE_OPTIONS} -o "${build_dir}/${unsigned_project_binary}" "${elf}" COMMAND ${CMAKE_COMMAND} -E echo "Generated ${build_dir}/${unsigned_project_binary}" COMMAND ${CMAKE_COMMAND} -E md5sum "${build_dir}/${unsigned_project_binary}" > "${build_dir}/.bin_timestamp" @@ -87,6 +86,11 @@ add_custom_command(OUTPUT "${build_dir}/.bin_timestamp" ) add_custom_target(gen_project_binary DEPENDS "${build_dir}/.bin_timestamp") +set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES + "${build_dir}/${unsigned_project_binary}" + ) + if(NOT BOOTLOADER_BUILD AND CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES) @@ -103,6 +107,11 @@ if(NOT BOOTLOADER_BUILD AND ) add_custom_target(gen_signed_project_binary DEPENDS "${build_dir}/.signed_bin_timestamp") add_dependencies(gen_project_binary gen_signed_project_binary) + + set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES + "${build_dir}/${PROJECT_BIN}" + ) endif() if(NOT BOOTLOADER_BUILD)