uf2_ext.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
  2. # SPDX-License-Identifier: Apache-2.0
  3. from typing import Dict, List
  4. from click.core import Context
  5. from idf_py_actions.tools import PropertyDict, ensure_build_directory, run_target
  6. def action_extensions(base_actions: Dict, project_path: List) -> Dict:
  7. def uf2_target(target_name: str, ctx: Context, args: PropertyDict, md5_disable: bool) -> None:
  8. ensure_build_directory(args, ctx.info_name)
  9. extra = list()
  10. if md5_disable:
  11. extra.append('--md5-disable')
  12. run_target(target_name, args, env={'SERIAL_TOOL_EXTRA_ARGS': ' '.join(extra)})
  13. uf2_options = [
  14. {
  15. 'names': ['--md5-disable'],
  16. 'is_flag': True,
  17. 'help': 'Disable MD5 checksum',
  18. },
  19. ]
  20. uf2_actions = {
  21. 'actions': {
  22. 'uf2': {
  23. 'callback': uf2_target,
  24. 'options': uf2_options,
  25. 'short_help': 'Generate the UF2 binary with all the binaries included',
  26. 'dependencies': ['all'],
  27. },
  28. 'uf2-app': {
  29. 'callback': uf2_target,
  30. 'options': uf2_options,
  31. 'short_help': 'Generate an UF2 binary for the application only',
  32. 'dependencies': ['all'],
  33. },
  34. }
  35. }
  36. return uf2_actions