Skip to content

Commit

Permalink
Merge branch 'feat/usb_device_example_support_usb_otg' into 'master'
Browse files Browse the repository at this point in the history
feat(usb_device): add usb otg support

See merge request ae_group/esp-iot-solution!1010
  • Loading branch information
leeebo committed Jun 28, 2024
2 parents dd15770 + 7706e83 commit 981676d
Show file tree
Hide file tree
Showing 56 changed files with 812 additions and 20 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,7 @@ XUNIT_RESULT.xml

#format file
.editorconfig

#launchpad
binaries/
output.json
12 changes: 7 additions & 5 deletions .gitlab/ci/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@
- "**/build*/*.map"
- "**/build*/*.elf"
- "**/build*/flasher_args.json"
- "**/build*/flash_args"
- "**/build*/flash_project_args"
- "**/build*/config/sdkconfig.json"
- "**/build*/bootloader/*.bin"
- "**/build*/bootloader/*.elf"
- "**/build*/partition_table/*.bin"
- "**/build*/mmap_build/*.bin"
- "**/build*/**/*.bin"
- size_info.txt
expire_in: 1 week
variables:
Expand All @@ -49,7 +51,7 @@
- IMAGE: espressif/idf:release-v5.2
- IMAGE: espressif/idf:release-v5.3

.build_idf_version_larger_than_v5_0:
.build_idf_version_greater_equal_v5_0:
parallel:
matrix:
- IMAGE: espressif/idf:release-v5.0
Expand Down Expand Up @@ -598,7 +600,7 @@ build_example_usb_device_usb_dongle:
extends:
- .build_examples_template
- .rules:build:example_usb_device_usb_dongle
- .build_idf_version_larger_than_v5_0
- .build_idf_version_greater_equal_v5_0
variables:
EXAMPLE_DIR: examples/usb/device/usb_dongle

Expand All @@ -625,15 +627,15 @@ build_example_usb_device_usb_dual_uvc_device:
extends:
- .build_examples_template
- .rules:build:example_usb_device_usb_dual_uvc_device
- .build_idf_version_larger_than_v5_0
- .build_idf_version_greater_equal_v5_0
variables:
EXAMPLE_DIR: examples/usb/device/usb_dual_uvc_device

build_example_usb_device_usb_webcam:
extends:
- .build_examples_template
- .rules:build:example_usb_device_usb_webcam
- .build_idf_version_larger_than_v5_0
- .build_idf_version_greater_equal_v5_0
variables:
EXAMPLE_DIR: examples/usb/device/usb_webcam

Expand Down Expand Up @@ -715,7 +717,7 @@ build_example_usb_host_usb_camera_mic_spk:
parallel:
matrix:
- IMAGE: espressif/idf:release-v4.4
- IMAGE: espressif/idf:release-v5.0
- IMAGE: espressif/idf:release-v5.1
variables:
EXAMPLE_DIR: examples/usb/host/usb_camera_mic_spk

Expand Down
54 changes: 54 additions & 0 deletions .gitlab/ci/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ deploy_docs_preview:
extends:
- .deploy_docs_template
- .rules:deploy:docs_preview
environment:
name: esp-iot-solution_docs_preview
url: ${FINAL_PREVIEW_URL}
variables:
TYPE: "preview"
DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/"
Expand All @@ -56,11 +59,17 @@ deploy_docs_preview:
DOCS_DEPLOY_SERVER_USER: "$DOCS_PREVIEW_SERVER_USER"
DOCS_DEPLOY_PATH: "$DOCS_PREVIEW_PATH"
DOCS_DEPLOY_URL_BASE: "$DOCS_PREVIEW_URL_BASE"
before_script:
- export SANITIZED_BRANCH_NAME=$(echo "$CI_COMMIT_REF_NAME" | tr '/' '-')
- export FINAL_PREVIEW_URL="https://preview-docs.espressif.com/projects/esp-iot-solution/zh_CN/$SANITIZED_BRANCH_NAME/index.html"

deploy_docs_production:
extends:
- .deploy_docs_template
- .rules:deploy:docs_production
environment:
name: esp-iot-solution_docs_preview
url: https://docs.espressif.com/projects/esp-iot-solution/zh_CN/latest/index.html
variables:
TYPE: "production"
DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/"
Expand All @@ -69,3 +78,48 @@ deploy_docs_production:
DOCS_DEPLOY_SERVER_USER: "$DOCS_PROD_SERVER_USER"
DOCS_DEPLOY_PATH: "$DOCS_PROD_PATH"
DOCS_DEPLOY_URL_BASE: "$DOCS_PROD_URL_BASE"

# Up to 50 jobs can needs
# Please modify tools/ci/launchpad/upload_project_config.yml at same time.
pack-upload_files:
stage: deploy
image: espressif/idf:release-v5.3
tags: ['build']
needs:
- job: "build_example_usb_device_usb_dual_uvc_device: [espressif/idf:release-v5.3]"
- job: "build_example_usb_device_usb_webcam: [espressif/idf:release-v5.3]"
- job: "build_example_usb_host_usb_camera_lcd_display: [espressif/idf:release-v5.1]"
- job: "build_example_usb_host_usb_camera_mic_spk: [espressif/idf:release-v5.1]"
artifacts:
when: always
paths:
- binaries/
expire_in: 1 week
rules:
- if: $CI_COMMIT_REF_NAME == "master"
- if: $CI_COMMIT_REF_NAME == "feat/usb_device_example_support_usb_otg"
script:
- pip install rtoml ruamel.yaml --upgrade
- pip install idf_build_apps
- python tools/build_apps.py . --find -o output.json -t all
- echo "Merging binaries and generating config.toml..."
- python tools/ci/launchpad/generateFiles.py output.json

include:
- project: 'ae_group/test-related/ae_upload_dl'
# Use ref to specify the branch name (etc: ref: 'feat/add_esp-dev-kits')
file: 'trigger.yml'

upload-dl-trigger:
needs:
- job: "pack-upload_files"
artifacts: false
rules:
- if: $CI_COMMIT_REF_NAME == "master"
environment:
name: esp-iot-solution_launchpad
url: https://espressif.github.io/esp-launchpad/?flashConfigURL=https://dl.espressif.com/AE/esp-iot-solution/config.toml
variables:
SOURCE_PROJECT_TOKEN: ${UPLOAD_ACCESS_TOKEN}
# Use TRIGGER_REPO_REF to specify the branch name (etc: TRIGGER_REPO_REF: 'feat/add_esp-iot-solution')
# Use UPLOAD_TO_DBG_DIR to specify the directory name (etc: UPLOAD_TO_DBG_DIR: '1')
3 changes: 2 additions & 1 deletion .gitlab/ci/rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

# build system, if changed, build all apps
.patterns-build_system: &patterns-build_system
- "tools/build_apps.py"
# For test
# - "tools/build_apps.py"
- "conftest.py"
- "pytest.ini"

Expand Down
6 changes: 2 additions & 4 deletions .gitlab/ci/target_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -574,12 +574,10 @@ examples_test_usb_uf2_nvs:
- .rules:build:example_usb_device_usb_uf2_nvs
needs:
- job: "build_example_usb_device_usb_uf2_nvs"
artifacts: true
optional: true
parallel:
matrix:
- IDF_TARGET: esp32s3
IDF_VERSION: "5.0"
IDF_VERSION: "5.1"
ENV_TAG: usb-otg_camera
- IDF_TARGET: esp32s3
IDF_VERSION: "4.4"
Expand All @@ -604,7 +602,7 @@ examples_test_usb_uf2_ota:
parallel:
matrix:
- IDF_TARGET: esp32s3
IDF_VERSION: "5.0"
IDF_VERSION: "5.1"
ENV_TAG: usb-otg_camera
- IDF_TARGET: esp32s3
IDF_VERSION: "4.4"
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
[![Documentation Status](https://dl.espressif.com/AE/docs/docs_latest.svg)](https://docs.espressif.com/projects/esp-iot-solution/en)

<a href="https://espressif.github.io/esp-launchpad/?flashConfigURL=https://dl.espressif.com/AE/esp-iot-solution/config.toml">
<img alt="Try it with ESP Launchpad" src="https://espressif.github.io/esp-launchpad/assets/try_with_launchpad.png" width="200" height="56">
</a>

## Espressif IoT Solution Overview

* [中文版](./README_CN.md)
Expand Down Expand Up @@ -84,7 +88,7 @@ The registered components in ESP-IoT-Solution are listed below:
| [esp_tinyuf2](https://components.espressif.com/components/espressif/esp_tinyuf2) | [![Component Registry](https://components.espressif.com/components/espressif/esp_tinyuf2/badge.svg)](https://components.espressif.com/components/espressif/esp_tinyuf2) |
| [extended_vfs](https://components.espressif.com/components/espressif/extended_vfs) | [![Component Registry](https://components.espressif.com/components/espressif/extended_vfs/badge.svg)](https://components.espressif.com/components/espressif/extended_vfs) |
| [gprof](https://components.espressif.com/components/espressif/gprof) | [![Component Registry](https://components.espressif.com/components/espressif/gprof/badge.svg)](https://components.espressif.com/components/espressif/gprof) |
| [i2c_bus](https://components.espressif.com/components/espressif/i2c_bus) | [![Component Registry](https://components.espressif.com/components/espressif/i2c_bus/badge.svg)](https://components.espressif.com/components/espressif/i2c_bus)
| [i2c_bus](https://components.espressif.com/components/espressif/i2c_bus) | [![Component Registry](https://components.espressif.com/components/espressif/i2c_bus/badge.svg)](https://components.espressif.com/components/espressif/i2c_bus)
| [iot_usbh](https://components.espressif.com/components/espressif/iot_usbh) | [![Component Registry](https://components.espressif.com/components/espressif/iot_usbh/badge.svg)](https://components.espressif.com/components/espressif/iot_usbh) |
| [iot_usbh_cdc](https://components.espressif.com/components/espressif/iot_usbh_cdc) | [![Component Registry](https://components.espressif.com/components/espressif/iot_usbh_cdc/badge.svg)](https://components.espressif.com/components/espressif/iot_usbh_cdc) |
| [iot_usbh_modem](https://components.espressif.com/components/espressif/iot_usbh_modem) | [![Component Registry](https://components.espressif.com/components/espressif/iot_usbh_modem/badge.svg)](https://components.espressif.com/components/espressif/iot_usbh_modem) |
Expand Down
4 changes: 4 additions & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
[![Documentation Status](https://dl.espressif.com/AE/docs/docs_latest.svg)](https://docs.espressif.com/projects/esp-iot-solution/zh_CN)

<a href="https://espressif.github.io/esp-launchpad/?flashConfigURL=https://dl.espressif.com/AE/esp-iot-solution/config.toml">
<img alt="Try it with ESP Launchpad" src="https://espressif.github.io/esp-launchpad/assets/try_with_launchpad.png" width="200" height="56">
</a>

## Espressif IoT Solution 概述

* [English Version](./README.md)
Expand Down
32 changes: 32 additions & 0 deletions examples/.build-rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ examples/usb/device/usb_uac:
examples/usb/device/usb_dual_uvc_device:
enable:
- if: IDF_TARGET in ["esp32s3","esp32s2","esp32p4"]
disable:
- if: IDF_VERSION_MAJOR == 5 and IDF_VERSION_MINOR == 0
temporary: true
reason: esp32-s3-usb-otg not supported idf release 5.0 build yet

examples/usb/device/usb_webcam:
enable:
Expand All @@ -248,6 +252,10 @@ examples/usb/device/usb_webcam:
examples/usb/device/usb_hid_device:
enable:
- if: IDF_TARGET in ["esp32s2","esp32s3"]
disable:
- if: IDF_VERSION_MAJOR == 5 and IDF_VERSION_MINOR == 0
temporary: true
reason: esp32-s3-usb-otg not supported idf release 5.0 build yet

examples/usb/device/usb_lcd_display:
enable:
Expand All @@ -256,18 +264,34 @@ examples/usb/device/usb_lcd_display:
examples/usb/device/usb_msc_wireless_disk:
enable:
- if: IDF_TARGET in ["esp32s2","esp32s3"] and (IDF_VERSION_MAJOR == 5 and IDF_VERSION_MINOR == 0)
disable:
- if: IDF_VERSION_MAJOR == 5 and IDF_VERSION_MINOR == 0
temporary: true
reason: esp32-s3-usb-otg not supported idf release 5.0 build yet

examples/usb/device/usb_surface_dial:
enable:
- if: IDF_TARGET in ["esp32s2","esp32s3"]
disable:
- if: IDF_VERSION_MAJOR == 5 and IDF_VERSION_MINOR == 0
temporary: true
reason: esp32-s3-usb-otg not supported idf release 5.0 build yet

examples/usb/device/usb_uf2_nvs:
enable:
- if: IDF_TARGET in ["esp32s2","esp32s3"]
disable:
- if: IDF_VERSION_MAJOR == 5 and IDF_VERSION_MINOR == 0
temporary: true
reason: esp32-s3-usb-otg not supported idf release 5.0 build yet

examples/usb/device/usb_uf2_ota:
enable:
- if: IDF_TARGET in ["esp32s2","esp32s3"]
disable:
- if: IDF_VERSION_MAJOR == 5 and IDF_VERSION_MINOR == 0
temporary: true
reason: esp32-s3-usb-otg not supported idf release 5.0 build yet

examples/usb/host/usb_camera_lcd_display:
enable:
Expand All @@ -276,6 +300,10 @@ examples/usb/host/usb_camera_lcd_display:
examples/usb/host/usb_camera_mic_spk:
enable:
- if: IDF_TARGET in ["esp32s2","esp32s3"]
disable:
- if: IDF_VERSION_MAJOR == 5 and IDF_VERSION_MINOR == 0
temporary: true
reason: esp32-s3-usb-otg not supported idf release 5.0 build yet

examples/usb/host/usb_audio_player:
enable:
Expand All @@ -292,6 +320,10 @@ examples/usb/host/usb_cdc_basic:
examples/usb/host/usb_msc_ota:
enable:
- if: SOC_USB_OTG_SUPPORTED == 1
disable:
- if: IDF_VERSION_MAJOR == 5 and IDF_VERSION_MINOR == 0
temporary: true
reason: esp32-s3-usb-otg not supported idf release 5.0 build yet

examples/utilities/xz_decompress_file:
enable:
Expand Down
24 changes: 24 additions & 0 deletions examples/usb/device/usb_dual_uvc_device/main/Kconfig.projbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
menu "Example Configuration"

choice DEVELOPMENT_BOARD_SELECTION
prompt "Select the development board you are using"
default ESP32_S3_USB_OTG if IDF_TARGET_ESP32S3
default ESP32_S2_GENERIC if IDF_TARGET_ESP32S2
help
Select this option to choose the board for the example.

config ESP32_S3_USB_OTG
bool "ESP32 S3 USB OTG"
depends on IDF_TARGET_ESP32S3

config ESP32_S3_GENERIC
bool "ESP32 S3 GENERIC"
depends on IDF_TARGET_ESP32S3

config ESP32_S2_GENERIC
bool "ESP32 S2 GENERIC"
depends on IDF_TARGET_ESP32S2

endchoice

endmenu
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
version: 0.1.0
targets:
- esp32s2
- esp32s3
- esp32p4
dependencies:
espressif/esp32_s3_usb_otg:
version: "^1.5.1"
rules:
- if: "target in [esp32s3]"
usb_device_uvc:
version: "1.1.*"
override_path: "../../../../../components/usb/usb_device_uvc"
Expand Down
7 changes: 7 additions & 0 deletions examples/usb/device/usb_dual_uvc_device/main/usb_uvc_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@
#include "usb_device_uvc.h"
#include "usb_cam.h"
#include "esp_spiffs.h"
#ifdef CONFIG_ESP32_S3_USB_OTG
#include "bsp/esp-bsp.h"
#endif

void app_main(void)
{
#ifdef CONFIG_ESP32_S3_USB_OTG
bsp_usb_mode_select_device();
#endif

esp_vfs_spiffs_conf_t conf = {
.base_path = "/spiffs",
.partition_label = "avi",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_IDF_TARGET="esp32s3"
CONFIG_ESP32_S3_USB_OTG=y
21 changes: 21 additions & 0 deletions examples/usb/device/usb_hid_device/main/Kconfig.projbuild
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
menu "USB HID Device Example"

choice DEVELOPMENT_BOARD_SELECTION
prompt "Select the development board you are using"
default ESP32_S3_USB_OTG if IDF_TARGET_ESP32S3
default ESP32_S2_GENERIC if IDF_TARGET_ESP32S2
help
Select this option to choose the board for the example.

config ESP32_S3_USB_OTG
bool "ESP32 S3 USB OTG"
depends on IDF_TARGET_ESP32S3

config ESP32_S3_GENERIC
bool "ESP32 S3 GENERIC"
depends on IDF_TARGET_ESP32S3

config ESP32_S2_GENERIC
bool "ESP32 S2 GENERIC"
depends on IDF_TARGET_ESP32S2

endchoice

choice HID_SUBCLASS
prompt "HID Device"
default SUBCLASS_MOUSE
Expand Down
4 changes: 4 additions & 0 deletions examples/usb/device/usb_hid_device/main/idf_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ dependencies:
version: ">=0.15.0~6"
rules:
- if: "idf_version >=4.4,<5.0"
espressif/esp32_s3_usb_otg:
version: "^1.5.1"
rules:
- if: "target in [esp32s3]"
6 changes: 6 additions & 0 deletions examples/usb/device/usb_hid_device/main/usb_hid_device_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#include "iot_button.h"
#include "esp_private/usb_phy.h"
#include "tinyusb_hid.h"
#ifdef CONFIG_ESP32_S3_USB_OTG
#include "bsp/esp-bsp.h"
#endif

#define TAG "HID Example"

Expand Down Expand Up @@ -211,6 +214,9 @@ static void usb_phy_init(void)

void app_main(void)
{
#ifdef CONFIG_ESP32_S3_USB_OTG
bsp_usb_mode_select_device();
#endif
// switch esp usb phy to usb-otg
usb_phy_init();
tud_init(BOARD_TUD_RHPORT);
Expand Down
Loading

0 comments on commit 981676d

Please sign in to comment.