dfu_ext.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. from idf_py_actions.tools import is_target_supported, ensure_build_directory, run_target
  2. from idf_py_actions.errors import FatalError
  3. def action_extensions(base_actions, project_path):
  4. SUPPORTED_TARGETS = ['esp32s2']
  5. def dfu_target(target_name, ctx, args):
  6. ensure_build_directory(args, ctx.info_name)
  7. run_target(target_name, args)
  8. def dfu_flash_target(target_name, ctx, args):
  9. ensure_build_directory(args, ctx.info_name)
  10. try:
  11. run_target(target_name, args)
  12. except FatalError:
  13. # Cannot capture the error from dfu-util here so the best advise is:
  14. print('Please have a look at the "Device Firmware Upgrade through USB" chapter in API Guides of the '
  15. 'ESP-IDF documentation for solving common dfu-util issues.')
  16. raise
  17. dfu_actions = {
  18. "actions": {
  19. "dfu": {
  20. "callback": dfu_target,
  21. "short_help": "Build the DFU binary",
  22. "dependencies": ["all"],
  23. },
  24. "dfu-flash": {
  25. "callback": dfu_flash_target,
  26. "short_help": "Flash the DFU binary",
  27. "order_dependencies": ["dfu"],
  28. },
  29. }
  30. }
  31. return dfu_actions if is_target_supported(project_path, SUPPORTED_TARGETS) else {}