mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
feat(soc): add USB DFU and OTG console caps
Add USB DFU and OTG console SOC capability flags for esp32s2, esp32s3, and esp32p4. Use these caps in Kconfig, documentation conditionals, and idf.py DFU actions so USB support is derived from SOC capabilities instead of hardcoded target names.
This commit is contained in:
committed by
Tomas Rezucha
parent
a409bb50c5
commit
d4d993c818
@@ -1,19 +1,24 @@
|
||||
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
from typing import Dict
|
||||
|
||||
import os
|
||||
|
||||
from click.core import Context
|
||||
|
||||
from idf_py_actions.errors import FatalError
|
||||
from idf_py_actions.tools import ensure_build_directory
|
||||
from idf_py_actions.tools import is_target_supported
|
||||
from idf_py_actions.tools import PropertyDict
|
||||
from idf_py_actions.tools import ensure_build_directory
|
||||
from idf_py_actions.tools import get_sdkconfig_value
|
||||
from idf_py_actions.tools import run_target
|
||||
|
||||
SOC_USB_DFU_SUPPORTED = 'CONFIG_SOC_USB_DFU_SUPPORTED'
|
||||
|
||||
def action_extensions(base_actions: Dict, project_path: str) -> Dict:
|
||||
|
||||
SUPPORTED_TARGETS = ['esp32s2', 'esp32s3', 'esp32p4']
|
||||
def _soc_usb_dfu_supported(project_path: str) -> bool:
|
||||
return bool(get_sdkconfig_value(os.path.join(project_path, 'sdkconfig'), SOC_USB_DFU_SUPPORTED) == 'y')
|
||||
|
||||
|
||||
def action_extensions(base_actions: dict, project_path: str) -> dict:
|
||||
def dfu_target(target_name: str, ctx: Context, args: PropertyDict, part_size: str) -> None:
|
||||
ensure_build_directory(args, ctx.info_name)
|
||||
run_target(target_name, args, {'ESP_DFU_PART_SIZE': part_size} if part_size else {})
|
||||
@@ -29,8 +34,10 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
|
||||
run_target(target_name, args, {'ESP_DFU_PATH': path})
|
||||
except FatalError:
|
||||
# Cannot capture the error from dfu-util here so the best advise is:
|
||||
print('Please have a look at the "Device Firmware Upgrade through USB" chapter in API Guides of the '
|
||||
'ESP-IDF documentation for solving common dfu-util issues.')
|
||||
print(
|
||||
'Please have a look at the "Device Firmware Upgrade through USB" chapter in API Guides of the '
|
||||
'ESP-IDF documentation for solving common dfu-util issues.'
|
||||
)
|
||||
raise
|
||||
|
||||
dfu_actions = {
|
||||
@@ -43,8 +50,8 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
|
||||
{
|
||||
'names': ['--part-size'],
|
||||
'help': 'Large files are split up into smaller partitions in order to avoid timeout during '
|
||||
'erasing flash. This option allows to overwrite the default partition size of '
|
||||
'mkdfu.py.'
|
||||
'erasing flash. This option allows to overwrite the default partition size of '
|
||||
'mkdfu.py.',
|
||||
}
|
||||
],
|
||||
},
|
||||
@@ -62,12 +69,12 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
|
||||
'names': ['--path'],
|
||||
'default': '',
|
||||
'help': 'Specify path to DFU device. The default empty path works if there is just one '
|
||||
'ESP device with the same product identifier. See the device list for paths '
|
||||
'of available devices.'
|
||||
'ESP device with the same product identifier. See the device list for paths '
|
||||
'of available devices.',
|
||||
}
|
||||
],
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return dfu_actions if is_target_supported(project_path, SUPPORTED_TARGETS) else {}
|
||||
return dfu_actions if _soc_usb_dfu_supported(project_path) else {}
|
||||
|
||||
Reference in New Issue
Block a user