Merge branch 'ci/add_p4_usb_host_to_ci' into 'master'

feature(usb): Add USB support for ESP32-P4

Closes IDF-6873

See merge request espressif/esp-idf!28585
This commit is contained in:
Tomas Rezucha 2024-01-31 22:04:23 +08:00
commit 49f3dae095
45 changed files with 208 additions and 67 deletions

View File

@ -248,9 +248,10 @@ if(NOT BOOTLOADER_BUILD)
endif()
if(CONFIG_SOC_USB_OTG_SUPPORTED)
list(APPEND srcs
"usb_dwc_hal.c"
"usb_fsls_phy_hal.c")
list(APPEND srcs "usb_dwc_hal.c")
if(NOT ${target} STREQUAL "esp32p4")
list(APPEND srcs "usb_fsls_phy_hal.c")
endif()
endif()
if(${target} STREQUAL "esp32")

View File

@ -114,8 +114,10 @@ if(CONFIG_SOC_IEEE802154_SUPPORTED)
endif()
if(CONFIG_SOC_USB_OTG_SUPPORTED)
list(APPEND srcs "${target}/usb_periph.c"
"${target}/usb_dwc_periph.c")
if(NOT ${target} STREQUAL "esp32p4")
list(APPEND srcs "${target}/usb_periph.c"
"${target}/usb_dwc_periph.c")
endif()
endif()
if(CONFIG_SOC_DAC_SUPPORTED)

View File

@ -63,6 +63,10 @@ config SOC_EMAC_SUPPORTED
bool
default y
config SOC_USB_OTG_SUPPORTED
bool
default y
config SOC_TEMP_SENSOR_SUPPORTED
bool
default y

View File

@ -36,6 +36,7 @@
// #define SOC_PARLIO_SUPPORTED 1 //TODO: IDF-7471
#define SOC_ASYNC_MEMCPY_SUPPORTED 1
#define SOC_EMAC_SUPPORTED 1
#define SOC_USB_OTG_SUPPORTED 1
// disable usb serial jtag for esp32p4, current image does not support
// #define SOC_USB_SERIAL_JTAG_SUPPORTED 1 //TODO: IDF-7496
#define SOC_TEMP_SENSOR_SUPPORTED 1

View File

@ -0,0 +1,20 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
/*
Note: These macros are deprecated.
We define them for P4 only for backward compatibility with older version of esp_tinyusb
Todo: Remove in IDF v6.0 (IDF-9029)
*/
#define USBPHY_VP_NUM -1
#define USBPHY_VM_NUM -1
#define USBPHY_RCV_NUM -1
#define USBPHY_OEN_NUM -1
#define USBPHY_VPO_NUM -1
#define USBPHY_VMO_NUM -1

View File

@ -18,8 +18,12 @@ if(CONFIG_SOC_USB_OTG_SUPPORTED)
"usb_helpers.c"
"usb_host.c"
"usb_private.c"
"usbh.c"
"usb_phy.c")
"usbh.c")
if(NOT ${target} STREQUAL "esp32p4")
list(APPEND srcs "usb_phy.c")
else()
list(APPEND srcs "usb_phy_p4.c")
endif()
list(APPEND include "include")
list(APPEND priv_includes "private_include")
endif()

View File

@ -7,7 +7,7 @@
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include "esp_err.h"
#include "soc/soc_caps.h"
#include "hal/usb_phy_types.h"

View File

@ -3,8 +3,17 @@
components/usb/test_apps:
enable:
- if: SOC_USB_OTG_SUPPORTED == 1
disable_test:
- if: IDF_TARGET not in ["esp32s3"]
temporary: true
reason: lack of runners with usb_host_flash_disk tag
depends_components:
- usb
depends_filepatterns:
- components/hal/usb*.c
- components/hal/include/hal/usb*.h
- components/hal/esp32*/include/hal/usb*.h
- components/soc/esp32*/usb*.c
- components/soc/include/soc/usb*.h
- components/soc/esp32*/include/soc/usb_dwc_*.h
- components/soc/esp32*/include/soc/usb_wrap_*.h

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- |
| Supported Targets | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- | -------- |
# USB: Host test application

View File

@ -1,12 +1,13 @@
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0
import pytest
from pytest_embedded import Dut
@pytest.mark.esp32s2
@pytest.mark.esp32s3
@pytest.mark.esp32p4
@pytest.mark.temp_skip_ci(targets=['esp32s2', 'esp32p4'], reason='lack of runners with usb_host_flash_disk tag')
@pytest.mark.usb_host_flash_disk
def test_usb_hcd(dut: Dut) -> None:
dut.run_all_single_board_cases(group='full_speed')

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- |
| Supported Targets | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- | -------- |
# USB: Host test application

View File

@ -1,12 +1,13 @@
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0
import pytest
from pytest_embedded import Dut
@pytest.mark.esp32s2
@pytest.mark.esp32s3
@pytest.mark.esp32p4
@pytest.mark.temp_skip_ci(targets=['esp32s2', 'esp32p4'], reason='lack of runners with usb_host_flash_disk tag')
@pytest.mark.usb_host_flash_disk
def test_usb_host(dut: Dut) -> None:
dut.run_all_single_board_cases(group='full_speed')

View File

@ -0,0 +1,30 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
// This is only a dummy USB PHY file for successful linking of ESP32-P4 target
// The internal HS PHY is enabled by default, therefore it needs no configuration
// TODO: Remove this file when proper support of P4 PHYs is implemented IDF-7323
#include "esp_private/usb_phy.h"
esp_err_t usb_new_phy(const usb_phy_config_t *config, usb_phy_handle_t *handle_ret)
{
return ESP_OK;
}
esp_err_t usb_del_phy(usb_phy_handle_t handle)
{
return ESP_OK;
}
esp_err_t usb_phy_get_phy_status(usb_phy_target_t target, usb_phy_status_t *status)
{
return ESP_OK;
}
esp_err_t usb_phy_action(usb_phy_handle_t handle, usb_phy_action_t action)
{
return ESP_OK;
}

View File

@ -109,9 +109,12 @@ USB_DOCS = ['api-reference/peripherals/usb_device.rst',
'api-reference/peripherals/usb_host/usb_host_notes_arch.rst',
'api-reference/peripherals/usb_host/usb_host_notes_design.rst',
'api-reference/peripherals/usb_host/usb_host_notes_dwc_otg.rst',
'api-reference/peripherals/usb_host/usb_host_notes_index.rst',
'api-guides/usb-otg-console.rst',
'api-guides/dfu.rst']
'api-reference/peripherals/usb_host/usb_host_notes_index.rst']
# TODO: Merge this back with `USB_DOCS` IDF-9919 IDF-9920 IDF-9133
USB_OTG_DFU_DOCS = ['api-guides/dfu.rst']
USB_OTG_CONSOLE_DOCS = ['api-guides/usb-otg-console.rst']
FTDI_JTAG_DOCS = ['api-guides/jtag-debugging/configure-ft2232h-jtag.rst']
@ -164,13 +167,13 @@ ESP32S2_DOCS = ['hw-reference/esp32s2/**',
'api-reference/peripherals/temp_sensor.rst',
'api-reference/system/async_memcpy.rst',
'api-reference/peripherals/touch_element.rst',
'api-guides/RF_calibration.rst'] + FTDI_JTAG_DOCS
'api-guides/RF_calibration.rst'] + FTDI_JTAG_DOCS + USB_OTG_DFU_DOCS + USB_OTG_CONSOLE_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/RF_calibration.rst'] + USB_OTG_DFU_DOCS + USB_OTG_CONSOLE_DOCS
# No JTAG docs for this one as it gets gated on SOC_USB_SERIAL_JTAG_SUPPORTED down below.
ESP32C3_DOCS = ['hw-reference/esp32c3/**',

View File

@ -8,3 +8,7 @@ INPUT += \
$(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_uart.h \
$(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_utils.h \
$(PROJECT_PATH)/components/ulp/ulp_common/include/ulp_common.h \
$(PROJECT_PATH)/components/usb/include/usb/usb_helpers.h \
$(PROJECT_PATH)/components/usb/include/usb/usb_host.h \
$(PROJECT_PATH)/components/usb/include/usb/usb_types_ch9.h \
$(PROJECT_PATH)/components/usb/include/usb/usb_types_stack.h \

View File

@ -17,7 +17,7 @@ API Guides
core_dump
current-consumption-measurement-modules
:SOC_RTC_MEM_SUPPORTED: deep-sleep-stub
:SOC_USB_OTG_SUPPORTED: dfu
:SOC_USB_OTG_SUPPORTED and not esp32p4: dfu
error-handling
:SOC_BLE_MESH_SUPPORTED: esp-ble-mesh/ble-mesh-index
:SOC_WIFI_MESH_SUPPORT: esp-wifi-mesh
@ -39,7 +39,7 @@ API Guides
tools/index
unit-tests
host-apps
:SOC_USB_OTG_SUPPORTED: usb-otg-console
:SOC_USB_OTG_SUPPORTED and not esp32p4: usb-otg-console
:SOC_USB_SERIAL_JTAG_SUPPORTED: usb-serial-jtag-console
:SOC_WIFI_SUPPORTED: wifi
:SOC_WIFI_SUPPORTED: wifi-security

View File

@ -17,7 +17,7 @@ API 指南
core_dump
current-consumption-measurement-modules
:SOC_RTC_MEM_SUPPORTED: deep-sleep-stub
:SOC_USB_OTG_SUPPORTED: dfu
:SOC_USB_OTG_SUPPORTED and not esp32p4: dfu
error-handling
:SOC_BLE_MESH_SUPPORTED: esp-ble-mesh/ble-mesh-index
:SOC_WIFI_MESH_SUPPORT: esp-wifi-mesh
@ -39,7 +39,7 @@ API 指南
tools/index
unit-tests
host-apps
:SOC_USB_OTG_SUPPORTED: usb-otg-console
:SOC_USB_OTG_SUPPORTED and not esp32p4: usb-otg-console
:SOC_USB_SERIAL_JTAG_SUPPORTED: usb-serial-jtag-console
:SOC_WIFI_SUPPORTED: wifi
:SOC_WIFI_SUPPORTED: wifi-security

View File

@ -421,24 +421,49 @@ examples/peripherals/uart/uart_echo_rs485:
enable:
- if: INCLUDE_DEFAULT == 1
examples/peripherals/usb:
examples/peripherals/usb/device:
disable:
- if: SOC_USB_OTG_SUPPORTED != 1
examples/peripherals/usb/device:
enable:
- if: SOC_USB_OTG_SUPPORTED == 1
disable_test:
- if: IDF_TARGET == "esp32s3"
- if: IDF_TARGET not in ["esp32s2"]
temporary: true
reason: lack of runners
reason: lack of runners with usb_device tag
depends_components:
- usb
depends_filepatterns:
- examples/peripherals/usb/device/**/*
examples/peripherals/usb/device/tusb_ncm:
disable:
- if: SOC_USB_OTG_SUPPORTED != 1 or SOC_WIFI_SUPPORTED != 1
disable_test:
- if: IDF_TARGET not in ["esp32s2"]
temporary: true
reason: lack of runners with usb_device tag
depends_components:
- usb
- esp_wifi
depends_filepatterns:
- examples/peripherals/usb/device/tusb_ncm/**/*
examples/peripherals/usb/host:
disable:
- if: SOC_USB_OTG_SUPPORTED != 1
disable_test:
- if: IDF_TARGET not in ["esp32s3"]
temporary: true
reason: lack of runners with usb_host_flash_disk tag
depends_components:
- usb
depends_filepatterns:
- components/hal/usb*.c
- components/hal/include/hal/usb*.h
- components/hal/esp32*/include/hal/usb*.h
- components/soc/esp32*/usb*.c
- components/soc/include/soc/usb*.h
- components/soc/esp32*/include/soc/usb_dwc_*.h
- components/soc/esp32*/include/soc/usb_wrap_*.h
- examples/peripherals/usb/host/**/*
- examples/peripherals/usb/device/**/*
examples/peripherals/usb_serial_jtag/usb_serial_jtag_echo:
disable:

View File

@ -4,6 +4,7 @@
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.16)
add_compile_options(-w) # Turn off warnings until esp_tinyusb is updated IEC-86
# "Trim" the build. Include the minimal set of components, main, and anything it depends on.
set(COMPONENTS main)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- |
| Supported Targets | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- | -------- |
# TinyUSB Composite Device (MSC + Serial) Example

View File

@ -9,6 +9,9 @@ from serial.tools.list_ports import comports
@pytest.mark.esp32s2
@pytest.mark.esp32s3
@pytest.mark.esp32p4
@pytest.mark.temp_skip_ci(targets=['esp32s3', 'esp32p4'], reason='lack of runners with usb_device tag')
@pytest.mark.usb_device
def test_usb_composite_device_serial_example(dut: Dut) -> None:
dut.expect_exact('Hello World!')

View File

@ -2,6 +2,7 @@
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.16)
add_compile_options(-w) # Turn off warnings until esp_tinyusb is updated IEC-86
# "Trim" the build. Include the minimal set of components, main, and anything it depends on.
set(COMPONENTS main)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- |
| Supported Targets | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- | -------- |
# TinyUSB Sample Descriptor

View File

@ -9,6 +9,9 @@ from serial.tools.list_ports import comports
@pytest.mark.esp32s2
@pytest.mark.esp32s3
@pytest.mark.esp32p4
@pytest.mark.temp_skip_ci(targets=['esp32s3', 'esp32p4'], reason='lack of runners with usb_device tag')
@pytest.mark.usb_device
def test_usb_device_console_example(dut: Dut) -> None:
dut.expect_exact('USB initialization DONE')

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- |
| Supported Targets | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- | -------- |
# TinyUSB Human Interface Device Example

View File

@ -5,6 +5,9 @@ from pytest_embedded import Dut
@pytest.mark.esp32s2
@pytest.mark.esp32s3
@pytest.mark.esp32p4
@pytest.mark.temp_skip_ci(targets=['esp32s3', 'esp32p4'], reason='lack of runners with usb_device tag')
@pytest.mark.usb_device
def test_usb_device_hid_example(dut: Dut) -> None:
dut.expect_exact('USB initialization DONE')

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- |
| Supported Targets | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- | -------- |
# TinyUSB MIDI Device Example

View File

@ -5,6 +5,9 @@ from pytest_embedded import Dut
@pytest.mark.esp32s2
@pytest.mark.esp32s3
@pytest.mark.esp32p4
@pytest.mark.temp_skip_ci(targets=['esp32s3', 'esp32p4'], reason='lack of runners with usb_device tag')
@pytest.mark.usb_device
def test_usb_device_midi_example(dut: Dut) -> None:
dut.expect_exact('USB initialization DONE')

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- |
| Supported Targets | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- | -------- |
# TinyUSB Mass Storage Device Example

View File

@ -5,6 +5,9 @@ from pytest_embedded import Dut
@pytest.mark.esp32s2
@pytest.mark.esp32s3
@pytest.mark.esp32p4
@pytest.mark.temp_skip_ci(targets=['esp32s3', 'esp32p4'], reason='lack of runners with usb_device tag')
@pytest.mark.usb_device
def test_usb_device_msc_example(dut: Dut) -> None:
dut.expect('Mount storage')

View File

@ -8,6 +8,8 @@ from pytest_embedded import Dut
@pytest.mark.esp32s2
@pytest.mark.esp32s3
@pytest.mark.temp_skip_ci(targets=['esp32s3'], reason='lack of runners with usb_device tag')
@pytest.mark.usb_device
def test_usb_device_ncm_example(dut: Dut) -> None:
netif_mac = dut.expect(r'Network interface HW address: ([0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2})')

View File

@ -2,6 +2,7 @@
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.16)
add_compile_options(-w) # Turn off warnings until esp_tinyusb is updated IEC-86
# "Trim" the build. Include the minimal set of components, main, and anything it depends on.
set(COMPONENTS main)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- |
| Supported Targets | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- | -------- |
# TinyUSB Serial Device Example

View File

@ -9,6 +9,9 @@ from serial.tools.list_ports import comports
@pytest.mark.esp32s2
@pytest.mark.esp32s3
@pytest.mark.esp32p4
@pytest.mark.temp_skip_ci(targets=['esp32s3', 'esp32p4'], reason='lack of runners with usb_device tag')
@pytest.mark.usb_device
def test_usb_device_serial_example(dut: Dut) -> None:
dut.expect_exact('USB initialization DONE')

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- |
| Supported Targets | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- | -------- |
# USB CDC-ACM Host Driver Example

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- |
| Supported Targets | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- | -------- |
# USB CDC-ACM Virtual COM Port example

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- |
| Supported Targets | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- | -------- |
# USB HID Class example
This example implements a basic USB Host HID Class Driver, and demonstrates how to use the driver to communicate with USB HID devices (such as Keyboard and Mouse or both) on the ESP32-S2/S3. Currently, the example only supports the HID boot protocol which should be present on most USB Mouse and Keyboards. The example will continuously scan for the connection of any HID Mouse or Keyboard, and attempt to fetch HID reports from those devices once connected. To quit the example (and shut down the HID driver), users can GPIO0 to low (i.e., pressing the "Boot" button on most ESP dev kits).

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- |
| Supported Targets | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- | -------- |
# USB Mass Storage Class example

View File

@ -1,5 +1,4 @@
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0
import pytest
from pytest_embedded import Dut
@ -7,6 +6,8 @@ from pytest_embedded import Dut
@pytest.mark.esp32s2
@pytest.mark.esp32s3
@pytest.mark.esp32p4
@pytest.mark.temp_skip_ci(targets=['esp32s2', 'esp32p4'], reason='lack of runners with usb_host_flash_disk tag')
@pytest.mark.usb_host_flash_disk
def test_usb_host_msc_example(dut: Dut) -> None:
# Check result of file_operations()

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- |
| Supported Targets | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- | -------- |
# USB Host Library Example

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- |
| Supported Targets | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- | -------- |
# USB Camera Example

View File

@ -4,12 +4,6 @@
CONFIG_SPIRAM=y
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=150000
CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y
CONFIG_SPIRAM_SPEED_80M=y
#
# SYSTEM
#
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
#
# USB

View File

@ -0,0 +1,9 @@
#
# SPIRAM
#
CONFIG_SPIRAM_SPEED_80M=y
#
# SYSTEM
#
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y

View File

@ -0,0 +1,9 @@
#
# SPIRAM
#
CONFIG_SPIRAM_SPEED_80M=y
#
# SYSTEM
#
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y

View File

@ -30,7 +30,7 @@ examples/system/console/advanced:
examples/system/console/advanced_usb_cdc:
disable:
- if: SOC_USB_OTG_SUPPORTED != 1
- if: SOC_USB_OTG_SUPPORTED != 1 or IDF_TARGET == "esp32p4" # TODO: IDF-8078, IDF-9120 and IDF-9133
depends_components:
- console
- vfs