Skip to content

Commit

Permalink
Merge branch 'feat/uf2-to-esptool' into 'master'
Browse files Browse the repository at this point in the history
feat(tools): move uf2 file generation to esptool

Closes IDF-7434

See merge request espressif/esp-idf!25655
  • Loading branch information
peterdragun committed Oct 12, 2023
2 parents aa9f81c + 9acf412 commit 95b7649
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 394 deletions.
6 changes: 0 additions & 6 deletions .gitlab/ci/host-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,6 @@ test_mkdfu:
- cd ${IDF_PATH}/tools/test_mkdfu
- ./test_mkdfu.py

test_mkuf2:
extends: .host_test_template
script:
- cd ${IDF_PATH}/tools/test_mkuf2
- ./test_mkuf2.py

test_sbom:
extends:
- .host_test_template
Expand Down
1 change: 0 additions & 1 deletion .gitlab/ci/rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@
- "tools/gen_soc_caps_kconfig/test/test_gen_soc_caps_kconfig.py"

- "tools/mkuf2.py"
- "tools/test_mkuf2/test_mkuf2.py"

- "tools/split_paths_by_spaces.py"

Expand Down
25 changes: 25 additions & 0 deletions components/esptool_py/project_include.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ set(ESPTOOLPY ${python} "$ENV{ESPTOOL_WRAPPER}" "${CMAKE_CURRENT_LIST_DIR}/espto
set(ESPSECUREPY ${python} "${CMAKE_CURRENT_LIST_DIR}/esptool/espsecure.py")
set(ESPEFUSEPY ${python} "${CMAKE_CURRENT_LIST_DIR}/esptool/espefuse.py")
set(ESPMONITOR ${python} -m esp_idf_monitor)
set(ESPMKUF2 ${python} "${idf_path}/tools/mkuf2.py" write --chip ${chip_model})
set(ESPTOOLPY_CHIP "${chip_model}")

if(NOT CONFIG_APP_BUILD_TYPE_RAM AND CONFIG_APP_BUILD_GENERATE_BINARIES)
Expand Down Expand Up @@ -208,6 +209,30 @@ add_custom_target(erase_flash
VERBATIM
)

set(UF2_ARGS --json "${CMAKE_CURRENT_BINARY_DIR}/flasher_args.json")

add_custom_target(uf2
COMMAND ${CMAKE_COMMAND}
-D "IDF_PATH=${idf_path}"
-D "SERIAL_TOOL=${ESPMKUF2}"
-D "SERIAL_TOOL_ARGS=${UF2_ARGS};-o;${CMAKE_CURRENT_BINARY_DIR}/uf2.bin"
-P run_serial_tool.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
USES_TERMINAL
VERBATIM
)

add_custom_target(uf2-app
COMMAND ${CMAKE_COMMAND}
-D "IDF_PATH=${idf_path}"
-D "SERIAL_TOOL=${ESPMKUF2}"
-D "SERIAL_TOOL_ARGS=${UF2_ARGS};-o;${CMAKE_CURRENT_BINARY_DIR}/uf2-app.bin;--bin;app"
-P run_serial_tool.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
USES_TERMINAL
VERBATIM
)

add_custom_target(monitor
COMMAND ${CMAKE_COMMAND}
-D "IDF_PATH=${idf_path}"
Expand Down
1 change: 0 additions & 1 deletion tools/ci/executable-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,5 @@ tools/test_idf_py/test_hints.py
tools/test_idf_py/test_idf_py.py
tools/test_idf_tools/test_idf_tools.py
tools/test_mkdfu/test_mkdfu.py
tools/test_mkuf2/test_mkuf2.py
tools/unit-test-app/tools/get_available_configs.sh
tools/unit-test-app/unit_test.py
1 change: 0 additions & 1 deletion tools/ci/mypy_ignore_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ tools/test_idf_py/test_idf_extensions/test_ext/test_extension.py
tools/test_idf_py/test_idf_py.py
tools/test_idf_tools/test_idf_tools.py
tools/test_mkdfu/test_mkdfu.py
tools/test_mkuf2/test_mkuf2.py
tools/unit-test-app/idf_ext.py
tools/unit-test-app/tools/CreateSectionTable.py
tools/unit-test-app/tools/UnitTestParser.py
Expand Down
1 change: 0 additions & 1 deletion tools/cmake/idf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ if(NOT __idf_env_set)
include(targets)
include(ldgen)
include(dfu)
include(uf2)
include(version)

__build_init("${idf_path}")
Expand Down
3 changes: 0 additions & 3 deletions tools/cmake/project.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -718,9 +718,6 @@ macro(project project_name)
# Add DFU build and flash targets
__add_dfu_targets()

# Add UF2 build targets
__add_uf2_targets()

idf_build_executable(${project_elf})

__project_info("${test_components}")
Expand Down
49 changes: 0 additions & 49 deletions tools/cmake/uf2.cmake

This file was deleted.

19 changes: 16 additions & 3 deletions tools/idf_py_actions/uf2_ext.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
from typing import Dict, List

Expand All @@ -7,19 +7,32 @@


def action_extensions(base_actions: Dict, project_path: List) -> Dict:
def uf2_target(target_name: str, ctx: Context, args: PropertyDict) -> None:
def uf2_target(target_name: str, ctx: Context, args: PropertyDict, md5_disable: bool) -> None:
ensure_build_directory(args, ctx.info_name)
run_target(target_name, args)
extra = list()
if md5_disable:
extra.append('--md5-disable')
run_target(target_name, args, env={'SERIAL_TOOL_EXTRA_ARGS': ' '.join(extra)})

uf2_options = [
{
'names': ['--md5-disable'],
'is_flag': True,
'help': 'Disable MD5 checksum',
},
]

uf2_actions = {
'actions': {
'uf2': {
'callback': uf2_target,
'options': uf2_options,
'short_help': 'Generate the UF2 binary with all the binaries included',
'dependencies': ['all'],
},
'uf2-app': {
'callback': uf2_target,
'options': uf2_options,
'short_help': 'Generate an UF2 binary for the application only',
'dependencies': ['all'],
},
Expand Down
Loading

0 comments on commit 95b7649

Please sign in to comment.