From 94970371aff696e19785e83c1305decd82f748bf Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 8 Nov 2023 00:28:36 +0700 Subject: [PATCH] try to generate update-tinyuf2.uf2 --- ports/espressif/CMakeLists.txt | 8 ++++++++ .../components/self_update/project_include.cmake | 1 + .../components/self_update/subproject/main/CMakeLists.txt | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/ports/espressif/CMakeLists.txt b/ports/espressif/CMakeLists.txt index ee74db06c..0a51fd8f7 100644 --- a/ports/espressif/CMakeLists.txt +++ b/ports/espressif/CMakeLists.txt @@ -12,6 +12,14 @@ set(SDKCONFIG ${CMAKE_BINARY_DIR}/sdkconfig) include($ENV{IDF_PATH}/tools/cmake/project.cmake) +if(IDF_TARGET STREQUAL "esp32s3") + set(UF2_FAMILY_ID 0xc47e5767) +elseif(IDF_TARGET STREQUAL "esp32s2") + set(UF2_FAMILY_ID 0xbfdd4eee) +else() + message(FATAL_ERROR "Unsupported ${target}.") +endif() + execute_process(COMMAND git describe --dirty --always --tags OUTPUT_VARIABLE GIT_VERSION) string(STRIP ${GIT_VERSION} GIT_VERSION) diff --git a/ports/espressif/components/self_update/project_include.cmake b/ports/espressif/components/self_update/project_include.cmake index 2e8d5d85f..c0063ee4d 100644 --- a/ports/espressif/components/self_update/project_include.cmake +++ b/ports/espressif/components/self_update/project_include.cmake @@ -28,6 +28,7 @@ externalproject_add(self_update -DEXTRA_COMPONENT_DIRS=${CMAKE_CURRENT_LIST_DIR} -DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR} -DBOARD=${BOARD} + -DUF2_FAMILY_ID=${UF2_FAMILY_ID} ${extra_cmake_args} INSTALL_COMMAND "" BUILD_ALWAYS 1 # no easy way around this... diff --git a/ports/espressif/components/self_update/subproject/main/CMakeLists.txt b/ports/espressif/components/self_update/subproject/main/CMakeLists.txt index 87032f69b..e7540ed9b 100644 --- a/ports/espressif/components/self_update/subproject/main/CMakeLists.txt +++ b/ports/espressif/components/self_update/subproject/main/CMakeLists.txt @@ -12,3 +12,8 @@ add_custom_target(bootloader_bin DEPENDS bootloader_bin.c) add_dependencies(${COMPONENT_LIB} bootloader_bin) set_property(DIRECTORY "${COMPONENT_DIR}" APPEND PROPERTY ADDITIONAL_CLEAN_FILES bootloader_bin.c) + +cmake_print_variables(elf COMPONENT_LIB) +add_custom_command(TARGET ${COMPONENT_LIB} POST_BUILD + COMMAND ${Python_EXECUTABLE} ${UF2CONV_PY} -f ${UF2_FAMILY_ID} -b 0x0 -c -o ${CMAKE_BINARY_DIR}/update-tinyuf2.uf2 ${CMAKE_BINARY_DIR}/update-tinyuf2.bin + VERBATIM)