forked from hathach/tinyusb
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tinyusb): Added initial files to make an idf component
- Loading branch information
Showing
5 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Push TinyUSB to Espressif Component Service | ||
|
||
# If the commit is tagged, it will be uploaded. Other scenario silently fail. | ||
on: | ||
push: | ||
tags: | ||
- v* | ||
|
||
jobs: | ||
upload_components: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Remove unneeded files | ||
shell: bash | ||
run: rm -rf docs tools lib/embedded-cli lib/fatfs lib/SEGGER_RTT | ||
|
||
- name: Upload components to component service | ||
uses: espressif/upload-components-ci-action@v1 | ||
with: | ||
name: "tinyusb" | ||
version: ${{ github.ref_name }} | ||
namespace: "espressif" | ||
api_token: ${{ secrets.IDF_COMPONENT_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
idf_build_get_property(target IDF_TARGET) | ||
|
||
if(target STREQUAL "esp32s3") | ||
set(tusb_mcu "OPT_MCU_ESP32S3") | ||
set(tusb_family "esp32sx") | ||
elseif(target STREQUAL "esp32s2") | ||
set(tusb_mcu "OPT_MCU_ESP32S2") | ||
set(tusb_family "esp32sx") | ||
elseif(target STREQUAL "esp32p4") | ||
set(tusb_mcu "OPT_MCU_ESP32P4") | ||
set(tusb_family "esp32px") | ||
endif() | ||
|
||
set(compile_options | ||
"-DCFG_TUSB_MCU=${tusb_mcu}" | ||
) | ||
|
||
idf_component_get_property(freertos_include freertos ORIG_INCLUDE_PATH) | ||
|
||
set(includes_private | ||
"src/" | ||
"src/device" | ||
"lib/networking" # For RNDIS definitions | ||
) | ||
|
||
set(includes_public | ||
"src/" | ||
# The FreeRTOS API include convention in tinyusb is different from esp-idf | ||
"${freertos_include}" | ||
) | ||
|
||
set(srcs | ||
"src/class/cdc/cdc_device.c" | ||
"src/class/hid/hid_device.c" | ||
"src/class/midi/midi_device.c" | ||
"src/class/msc/msc_device.c" | ||
"src/class/vendor/vendor_device.c" | ||
"src/class/audio/audio_device.c" | ||
"src/class/video/video_device.c" | ||
"src/class/bth/bth_device.c" | ||
# NET class | ||
"src/class/net/ecm_rndis_device.c" | ||
"lib/networking/rndis_reports.c" | ||
"src/class/net/ncm_device.c" | ||
# DFU | ||
"src/class/dfu/dfu_device.c" | ||
"src/class/dfu/dfu_rt_device.c" | ||
# Common, device-mode related | ||
"src/portable/synopsys/dwc2/dcd_dwc2.c" | ||
"src/common/tusb_fifo.c" | ||
"src/device/usbd_control.c" | ||
"src/device/usbd.c" | ||
"src/tusb.c" | ||
) | ||
|
||
idf_component_register(SRCS ${srcs} | ||
INCLUDE_DIRS ${includes_public} | ||
PRIV_INCLUDE_DIRS ${includes_private} | ||
PRIV_REQUIRES esp_netif # required by rndis_reports.c: #include "netif/ethernet.h" | ||
) | ||
|
||
target_compile_options(${COMPONENT_LIB} PUBLIC ${compile_options}) | ||
|
||
# when no builtin class driver is enabled, an uint8_t data compared with `BUILTIN_DRIVER_COUNT` will always be false | ||
set_source_files_properties("src/device/usbd.c" PROPERTIES COMPILE_FLAGS "-Wno-type-limits") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Espressif TinyUSB fork | ||
|
||
This is a fork of upstream [TinyUSB](https://github.com/hathach/tinyusb) with integration into ESP-IDF build system. | ||
It is used mostly for rapid bugfixing and for releases independent from the upstream project. | ||
We try to push all bugfixes and features to the upstream. | ||
|
||
## How to use | ||
|
||
There are two options of using TinyUSB with Espressif's SoCs. | ||
|
||
### 1. Use this component together with [Espressif TinyUSB additions](https://github.com/espressif/idf-extra-components/tree/master/usb/esp_tinyusb/) | ||
|
||
This is identical approach as in ESP-IDF 4.x releases. You can configure TinyUSB using Kconfig, as usual. Just add ``idf_component.yml`` to your main component with the following content:: | ||
|
||
```yaml | ||
## IDF Component Manager Manifest File | ||
dependencies: | ||
esp_tinyusb: "^1.0.0" # Automatically update minor releases | ||
``` | ||
Or simply run: | ||
``` | ||
idf.py add-dependency "esp_tinyusb^1.0.0" | ||
``` | ||
### 2. Use TinyUSB only, without the [additions](https://github.com/espressif/idf-extra-components/tree/master/usb/esp_tinyusb/) | ||
|
||
Use this option for custom TinyUSB applications. | ||
In this case you will have to provide configuration header file ``tusb_config.h``. More information about TinyUSB configuration can be found [in official TinyUSB documentation](https://docs.tinyusb.org/en/latest/reference/getting_started.html). | ||
|
||
You will also have to tell TinyUSB where to find the configuration file. This can be achieved by adding following CMake snippet to you main component's ``CMakeLists.txt``: | ||
|
||
```cmake | ||
idf_component_get_property(tusb_lib espressif__tinyusb COMPONENT_LIB) | ||
target_include_directories(${tusb_lib} PRIVATE path_to_your_tusb_config) | ||
``` | ||
|
||
Again, you can add this component to your project by adding ``idf_component.yml`` file: | ||
|
||
```yaml | ||
## IDF Component Manager Manifest File | ||
dependencies: | ||
tinyusb: "~0.15.1" # Automatically update bugfix releases. TinyUSB does not guarantee backward compatibility | ||
``` | ||
Or simply run: | ||
``` | ||
idf.py add-dependency "tinyusb~0.15.1" | ||
``` | ||
|
||
README from the upstream TinyUSB can be found in [hathach/tinyusb/README](https://github.com/hathach/tinyusb/blob/master/README.rst). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
description: TinyUSB ported to Espressif's SoCs | ||
url: https://docs.tinyusb.org/en/latest/ | ||
documentation: "https://docs.tinyusb.org/en/latest/" | ||
repository: "https://github.com/espressif/tinyusb.git" | ||
dependencies: | ||
idf: '>=5.0' # IDF 4.x contains TinyUSB as submodule | ||
targets: | ||
- esp32s2 | ||
- esp32s3 | ||
- esp32p4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
supplier: 'Organization: Espressif Systems (Shanghai) CO LTD' | ||
originator: 'Person: Ha Thach <[email protected]>' |