mirror of
https://github.com/espressif/esp-idf.git
synced 2026-09-22 13:01:16 +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:
@@ -22,7 +22,7 @@ menu "ESP-STDIO"
|
||||
config ESP_CONSOLE_USB_CDC
|
||||
bool "USB CDC"
|
||||
# && !TINY_USB is because the ROM CDC driver is currently incompatible with TinyUSB.
|
||||
depends on (IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3) && !TINY_USB
|
||||
depends on SOC_USB_OTG_CONSOLE_SUPPORTED && !TINY_USB
|
||||
config ESP_CONSOLE_USB_SERIAL_JTAG
|
||||
bool "USB Serial/JTAG Controller"
|
||||
depends on SOC_USB_SERIAL_JTAG_SUPPORTED
|
||||
|
||||
@@ -111,6 +111,10 @@ config SOC_USB_OTG_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_USB_DFU_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_WIRELESS_HOST_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
#define SOC_ASYNC_MEMCPY_SUPPORTED 1
|
||||
#define SOC_EMAC_SUPPORTED 1
|
||||
#define SOC_USB_OTG_SUPPORTED 1
|
||||
#define SOC_USB_DFU_SUPPORTED 1
|
||||
#define SOC_WIRELESS_HOST_SUPPORTED 1
|
||||
#define SOC_USB_SERIAL_JTAG_SUPPORTED 1
|
||||
#define SOC_TEMP_SENSOR_SUPPORTED 1
|
||||
|
||||
@@ -47,6 +47,14 @@ config SOC_USB_OTG_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_USB_DFU_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_USB_OTG_CONSOLE_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_PCNT_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
@@ -54,6 +54,8 @@
|
||||
#define SOC_ULP_FSM_SUPPORTED 1
|
||||
#define SOC_RISCV_COPROC_SUPPORTED 1
|
||||
#define SOC_USB_OTG_SUPPORTED 1
|
||||
#define SOC_USB_DFU_SUPPORTED 1
|
||||
#define SOC_USB_OTG_CONSOLE_SUPPORTED 1
|
||||
#define SOC_PCNT_SUPPORTED 1
|
||||
#define SOC_PHY_SUPPORTED 1
|
||||
#define SOC_WIFI_SUPPORTED 1
|
||||
|
||||
@@ -95,6 +95,14 @@ config SOC_USB_OTG_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_USB_DFU_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_USB_OTG_CONSOLE_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_USB_SERIAL_JTAG_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
#define SOC_RISCV_COPROC_SUPPORTED 1
|
||||
#define SOC_BT_SUPPORTED 1
|
||||
#define SOC_USB_OTG_SUPPORTED 1
|
||||
#define SOC_USB_DFU_SUPPORTED 1
|
||||
#define SOC_USB_OTG_CONSOLE_SUPPORTED 1
|
||||
#define SOC_USB_SERIAL_JTAG_SUPPORTED 1
|
||||
#define SOC_CCOMP_TIMER_SUPPORTED 1
|
||||
#define SOC_ASYNC_MEMCPY_SUPPORTED 1
|
||||
|
||||
@@ -283,32 +283,22 @@ ESP32_DOCS = (
|
||||
+ QEMU_DOCS
|
||||
)
|
||||
|
||||
ESP32S2_DOCS = (
|
||||
[
|
||||
'hw-reference/esp32s2/**',
|
||||
'api-guides/usb-console.rst',
|
||||
'api-reference/peripherals/ds.rst',
|
||||
'api-guides/RF_calibration.rst',
|
||||
'api-guides/phy.rst',
|
||||
]
|
||||
+ FTDI_JTAG_DOCS
|
||||
+ USB_OTG_DFU_DOCS
|
||||
+ USB_OTG_CONSOLE_DOCS
|
||||
)
|
||||
ESP32S2_DOCS = [
|
||||
'hw-reference/esp32s2/**',
|
||||
'api-guides/usb-console.rst',
|
||||
'api-reference/peripherals/ds.rst',
|
||||
'api-guides/RF_calibration.rst',
|
||||
'api-guides/phy.rst',
|
||||
] + FTDI_JTAG_DOCS
|
||||
|
||||
ESP32S3_DOCS = (
|
||||
[
|
||||
'hw-reference/esp32s3/**',
|
||||
'api-reference/system/ipc.rst',
|
||||
'api-guides/flash_psram_config.rst',
|
||||
'api-reference/peripherals/sd_pullup_requirements.rst',
|
||||
'api-guides/RF_calibration.rst',
|
||||
'api-guides/phy.rst',
|
||||
]
|
||||
+ USB_OTG_DFU_DOCS
|
||||
+ USB_OTG_CONSOLE_DOCS
|
||||
+ QEMU_DOCS
|
||||
)
|
||||
ESP32S3_DOCS = [
|
||||
'hw-reference/esp32s3/**',
|
||||
'api-reference/system/ipc.rst',
|
||||
'api-guides/flash_psram_config.rst',
|
||||
'api-reference/peripherals/sd_pullup_requirements.rst',
|
||||
'api-guides/RF_calibration.rst',
|
||||
'api-guides/phy.rst',
|
||||
] + QEMU_DOCS
|
||||
|
||||
# No JTAG docs for this one as it gets gated on SOC_USB_SERIAL_JTAG_SUPPORTED down below.
|
||||
ESP32C3_DOCS = ['hw-reference/esp32c3/**', 'api-guides/RF_calibration.rst', 'api-guides/phy.rst'] + QEMU_DOCS
|
||||
@@ -354,7 +344,7 @@ ESP32P4_DOCS = [
|
||||
'api-reference/system/ipc.rst',
|
||||
'api-reference/peripherals/cap_touch_sens.rst',
|
||||
'api-reference/peripherals/sd_pullup_requirements.rst',
|
||||
] + USB_OTG_DFU_DOCS
|
||||
]
|
||||
|
||||
# format: {tag needed to include: documents to included}, tags are parsed from sdkconfig and peripheral_caps.h headers
|
||||
conditional_include_dict = {
|
||||
@@ -376,6 +366,8 @@ conditional_include_dict = {
|
||||
'SOC_SDMMC_HOST_SUPPORTED': SDMMC_DOCS,
|
||||
'SOC_SDIO_SLAVE_SUPPORTED': SDIO_SLAVE_DOCS,
|
||||
'SOC_MCPWM_SUPPORTED': MCPWM_DOCS,
|
||||
'SOC_USB_DFU_SUPPORTED': USB_OTG_DFU_DOCS,
|
||||
'SOC_USB_OTG_CONSOLE_SUPPORTED': USB_OTG_CONSOLE_DOCS,
|
||||
'SOC_USB_SERIAL_JTAG_SUPPORTED': USB_SERIAL_JTAG_DOCS,
|
||||
'SOC_DEDICATED_GPIO_SUPPORTED': DEDIC_GPIO_DOCS,
|
||||
'SOC_LCD_I80_SUPPORTED': I80_LCD_DOCS,
|
||||
|
||||
@@ -22,7 +22,7 @@ API Guides
|
||||
core_dump
|
||||
current-consumption-measurement-modules
|
||||
:ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB: deep-sleep-stub
|
||||
:SOC_USB_OTG_SUPPORTED and not esp32h4 and not esp32s31: dfu
|
||||
:SOC_USB_DFU_SUPPORTED: dfu
|
||||
error-handling
|
||||
:SOC_WIFI_MESH_SUPPORT: esp-wifi-mesh
|
||||
:SOC_SPIRAM_SUPPORTED: external-ram
|
||||
@@ -47,7 +47,7 @@ API Guides
|
||||
tools/index
|
||||
unit-tests
|
||||
host-apps
|
||||
:SOC_USB_OTG_SUPPORTED and not esp32p4 and not esp32h4 and not esp32s31: usb-otg-console
|
||||
:SOC_USB_OTG_CONSOLE_SUPPORTED: usb-otg-console
|
||||
:SOC_USB_SERIAL_JTAG_SUPPORTED: usb-serial-jtag-console
|
||||
:SOC_WIFI_SUPPORTED: wifi-driver/index
|
||||
:SOC_WIFI_SUPPORTED: wifi-security
|
||||
|
||||
@@ -21,7 +21,7 @@ On {IDF_TARGET_NAME}, ESP-IDF provides implementations of VFS drivers for I/O ov
|
||||
|
||||
- UART
|
||||
:SOC_USB_SERIAL_JTAG_SUPPORTED: - USB Serial/JTAG
|
||||
:esp32s2 or esp32s3: - USB CDC (using USB_OTG peripheral)
|
||||
:SOC_USB_OTG_CONSOLE_SUPPORTED: - USB CDC (using USB_OTG peripheral)
|
||||
- "Null" (no output)
|
||||
|
||||
Standard I/O is not limited to these options, though. See below on enabling custom destinations for standard I/O.
|
||||
@@ -35,7 +35,7 @@ Built-in implementations of standard I/O can be selected using several Kconfig o
|
||||
|
||||
- :ref:`CONFIG_ESP_CONSOLE_UART_DEFAULT<CONFIG_ESP_CONSOLE_UART_DEFAULT>` — Enables UART with default options (pin numbers, baud rate) for standard I/O.
|
||||
- :ref:`CONFIG_ESP_CONSOLE_UART_CUSTOM<CONFIG_ESP_CONSOLE_UART_CUSTOM>` — Enables UART for standard I/O, with TX/RX pin numbers and baud rate configurable via Kconfig.
|
||||
:esp32s2 or esp32s3: - :ref:`CONFIG_ESP_CONSOLE_USB_CDC<CONFIG_ESP_CONSOLE_USB_CDC>` — Enables USB CDC (using USB_OTG peripheral) for standard I/O. See :doc:`usb-otg-console` for details about hardware connections required.
|
||||
:SOC_USB_OTG_CONSOLE_SUPPORTED: - :ref:`CONFIG_ESP_CONSOLE_USB_CDC<CONFIG_ESP_CONSOLE_USB_CDC>` — Enables USB CDC (using USB_OTG peripheral) for standard I/O. See :doc:`usb-otg-console` for details about hardware connections required.
|
||||
:SOC_USB_SERIAL_JTAG_SUPPORTED: - :ref:`CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG<CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG>` — Enables USB Serial/JTAG for standard I/O. See :doc:`usb-serial-jtag-console` for details about hardware connections required.
|
||||
- :ref:`CONFIG_ESP_CONSOLE_NONE<CONFIG_ESP_CONSOLE_NONE>` — Disables standard I/O. If this option is selected, ``stdin``, ``stdout``, and ``stderr`` will be mapped to ``/dev/null`` and won't produce any output or generate any input.
|
||||
|
||||
@@ -102,7 +102,7 @@ When the interrupt-driven driver is installed, it is also possible to enable/dis
|
||||
|
||||
When the interrupt-driven driver is installed, it is also possible to enable/disable non-blocking behavior using ``fcntl`` function with ``O_NONBLOCK`` flag.
|
||||
|
||||
.. only:: esp32s2 or esp32s3
|
||||
.. only:: SOC_USB_OTG_CONSOLE_SUPPORTED
|
||||
|
||||
USB CDC (using USB_OTG peripheral)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@@ -132,7 +132,7 @@ It is also possible to configure line ending conversion for the specific VFS dri
|
||||
|
||||
- For UART: :cpp:func:`uart_vfs_dev_port_set_rx_line_endings` and :cpp:func:`uart_vfs_dev_port_set_tx_line_endings`
|
||||
:SOC_USB_SERIAL_JTAG_SUPPORTED: - For USB Serial/JTAG: :cpp:func:`usb_serial_jtag_vfs_set_rx_line_endings` and :cpp:func:`usb_serial_jtag_vfs_set_tx_line_endings`
|
||||
:esp32s2 or esp32s3: - For USB CDC (using USB_OTG peripheral): :cpp:func:`esp_vfs_dev_cdcacm_set_rx_line_endings` and :cpp:func:`esp_vfs_dev_cdcacm_set_tx_line_endings`
|
||||
:SOC_USB_OTG_CONSOLE_SUPPORTED: - For USB CDC (using USB_OTG peripheral): :cpp:func:`esp_vfs_dev_cdcacm_set_rx_line_endings` and :cpp:func:`esp_vfs_dev_cdcacm_set_tx_line_endings`
|
||||
|
||||
Buffering
|
||||
---------
|
||||
|
||||
@@ -22,7 +22,7 @@ API 指南
|
||||
core_dump
|
||||
current-consumption-measurement-modules
|
||||
:ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB: deep-sleep-stub
|
||||
:SOC_USB_OTG_SUPPORTED and not esp32h4 and not esp32s31: dfu
|
||||
:SOC_USB_DFU_SUPPORTED: dfu
|
||||
error-handling
|
||||
:SOC_WIFI_MESH_SUPPORT: esp-wifi-mesh
|
||||
:SOC_SPIRAM_SUPPORTED: external-ram
|
||||
@@ -47,7 +47,7 @@ API 指南
|
||||
tools/index
|
||||
unit-tests
|
||||
host-apps
|
||||
:SOC_USB_OTG_SUPPORTED and not esp32p4 and not esp32h4 and not esp32s31: usb-otg-console
|
||||
:SOC_USB_OTG_CONSOLE_SUPPORTED: usb-otg-console
|
||||
:SOC_USB_SERIAL_JTAG_SUPPORTED: usb-serial-jtag-console
|
||||
:SOC_WIFI_SUPPORTED: wifi-driver/index
|
||||
:SOC_WIFI_SUPPORTED: wifi-security
|
||||
|
||||
@@ -21,7 +21,7 @@ ESP-IDF 提供了 C 标准输入输出功能,如 ``stdin``、``stdout`` 和 ``
|
||||
|
||||
- UART
|
||||
:SOC_USB_SERIAL_JTAG_SUPPORTED: - USB Serial/JTAG
|
||||
:esp32s2 or esp32s3: - USB CDC(使用 USB_OTG 外设)
|
||||
:SOC_USB_OTG_CONSOLE_SUPPORTED: - USB CDC(使用 USB_OTG 外设)
|
||||
- "Null"(无输出)
|
||||
|
||||
不过,标准 I/O 并不限于这些选项。请参见下文,了解如何为标准 I/O 启用自定义目标。
|
||||
@@ -35,7 +35,7 @@ ESP-IDF 提供了 C 标准输入输出功能,如 ``stdin``、``stdout`` 和 ``
|
||||
|
||||
- :ref:`CONFIG_ESP_CONSOLE_UART_DEFAULT<CONFIG_ESP_CONSOLE_UART_DEFAULT>` — 启用 UART 用于标准 I/O,保持默认选项项(管脚号、波特率)。
|
||||
- :ref:`CONFIG_ESP_CONSOLE_UART_CUSTOM<CONFIG_ESP_CONSOLE_UART_CUSTOM>` — 启用 UART 用于标准 I/O,通过 Kconfig 配置 TX/RX 管脚号和波特率。
|
||||
:esp32s2 or esp32s3: - :ref:`CONFIG_ESP_CONSOLE_USB_CDC<CONFIG_ESP_CONSOLE_USB_CDC>` — 启用 USB CDC(使用 USB_OTG 外设)用于标准 I/O。硬件连接要求请参见 :doc:`usb-otg-console`。
|
||||
:SOC_USB_OTG_CONSOLE_SUPPORTED: - :ref:`CONFIG_ESP_CONSOLE_USB_CDC<CONFIG_ESP_CONSOLE_USB_CDC>` — 启用 USB CDC(使用 USB_OTG 外设)用于标准 I/O。硬件连接要求请参见 :doc:`usb-otg-console`。
|
||||
:SOC_USB_SERIAL_JTAG_SUPPORTED: - :ref:`CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG<CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG>` — 启用 USB Serial/JTAG 用于标准 I/O。硬件连接要求请参见 :doc:`usb-serial-jtag-console`。
|
||||
- :ref:`CONFIG_ESP_CONSOLE_NONE<CONFIG_ESP_CONSOLE_NONE>` — 禁用标准 I/O。选择此选项时, ``stdin``、 ``stdout`` 和 ``stderr`` 将映射到 ``/dev/null``,不会产生输出或输入。
|
||||
|
||||
@@ -102,7 +102,7 @@ UART
|
||||
|
||||
安装中断驱动后,也可使用带有 ``O_NONBLOCK`` 标志的 ``fcntl`` 函数启用/禁用非阻塞行为。
|
||||
|
||||
.. only:: esp32s2 or esp32s3
|
||||
.. only:: SOC_USB_OTG_CONSOLE_SUPPORTED
|
||||
|
||||
USB CDC(使用 USB_OTG 外设)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@@ -132,7 +132,7 @@ UART
|
||||
|
||||
- 对于 UART::cpp:func:`uart_vfs_dev_port_set_rx_line_endings` 和 :cpp:func:`uart_vfs_dev_port_set_tx_line_endings`
|
||||
:SOC_USB_SERIAL_JTAG_SUPPORTED: - 对于 USB Serial/JTAG::cpp:func:`usb_serial_jtag_vfs_set_rx_line_endings` 和 :cpp:func:`usb_serial_jtag_vfs_set_tx_line_endings`
|
||||
:esp32s2 or esp32s3: - 对于 USB CDC(使用 USB_OTG 外设)::cpp:func:`esp_vfs_dev_cdcacm_set_rx_line_endings` 和 :cpp:func:`esp_vfs_dev_cdcacm_set_tx_line_endings`
|
||||
:SOC_USB_OTG_CONSOLE_SUPPORTED: - 对于 USB CDC(使用 USB_OTG 外设)::cpp:func:`esp_vfs_dev_cdcacm_set_rx_line_endings` 和 :cpp:func:`esp_vfs_dev_cdcacm_set_tx_line_endings`
|
||||
|
||||
缓冲
|
||||
-----
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
# SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import os
|
||||
|
||||
from rich_click import Context
|
||||
|
||||
from idf_py_actions.errors import FatalError
|
||||
from idf_py_actions.tools import PropertyDict
|
||||
from idf_py_actions.tools import ensure_build_directory
|
||||
from idf_py_actions.tools import is_target_supported
|
||||
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 _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:
|
||||
SUPPORTED_TARGETS = ['esp32s2', 'esp32s3', 'esp32p4']
|
||||
|
||||
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 {})
|
||||
@@ -71,4 +77,4 @@ def action_extensions(base_actions: dict, project_path: str) -> dict:
|
||||
}
|
||||
}
|
||||
|
||||
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