From dbef11a5ec943b678ec5d84977134009587d63c5 Mon Sep 17 00:00:00 2001 From: Tomas Rezucha Date: Tue, 22 Nov 2022 23:24:18 +0100 Subject: [PATCH] esp: ESP port commit Changes: 1. Removed upstream GitHub actions 2. Added upload GitHub action to IDF component registry 3. Added CMakeLists.txt 4. Updated README.rst This commit can be cherry-picked to any release branch in the future --- .github/workflows/build_aarch64.yml | 84 ---------- .github/workflows/build_arm.yml | 217 ------------------------- .github/workflows/build_esp.yml | 64 -------- .github/workflows/build_msp430.yml | 83 ---------- .github/workflows/build_renesas.yml | 83 ---------- .github/workflows/build_riscv.yml | 83 ---------- .github/workflows/trigger.yml | 60 ------- .github/workflows/upload_component.yml | 25 +++ CMakeLists.txt | 52 ++++++ README.md | 50 ++++++ idf_component.yml | 7 + 11 files changed, 134 insertions(+), 674 deletions(-) delete mode 100644 .github/workflows/build_aarch64.yml delete mode 100644 .github/workflows/build_arm.yml delete mode 100644 .github/workflows/build_esp.yml delete mode 100644 .github/workflows/build_msp430.yml delete mode 100644 .github/workflows/build_renesas.yml delete mode 100644 .github/workflows/build_riscv.yml delete mode 100644 .github/workflows/trigger.yml create mode 100644 .github/workflows/upload_component.yml create mode 100644 CMakeLists.txt create mode 100644 README.md create mode 100644 idf_component.yml diff --git a/.github/workflows/build_aarch64.yml b/.github/workflows/build_aarch64.yml deleted file mode 100644 index c552a957..00000000 --- a/.github/workflows/build_aarch64.yml +++ /dev/null @@ -1,84 +0,0 @@ -name: Build AArch64 - -on: - push: - paths: - - 'src/**' - - 'examples/**' - - 'lib/**' - - 'hw/**' - pull_request: - branches: [ master ] - paths: - - 'src/**' - - 'examples/**' - - 'lib/**' - - 'hw/**' - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - # --------------------------------------- - # Build AARCH64 family - # --------------------------------------- - build-arm: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - family: - # Alphabetical order - - 'broadcom_64bit' - steps: - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - - name: Checkout TinyUSB - uses: actions/checkout@v3 - - - name: Checkout common submodules in lib - run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip lib/sct_neopixel - - - name: Checkout hathach/linkermap - uses: actions/checkout@v3 - with: - repository: hathach/linkermap - path: linkermap - - - name: Set Toolchain URL - run: echo >> $GITHUB_ENV TOOLCHAIN_URL=https://developer.arm.com/-/media/Files/downloads/gnu-a/10.3-2021.07/binrel/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz - - - name: Cache Toolchain - uses: actions/cache@v3 - id: cache-toolchain - with: - path: ~/cache/ - key: ${{ runner.os }}-21-11-02-${{ env.TOOLCHAIN_URL }} - - - name: Install Toolchain - if: steps.cache-toolchain.outputs.cache-hit != 'true' - run: | - mkdir -p ~/cache/toolchain - wget --progress=dot:mega $TOOLCHAIN_URL -O toolchain.tar.gz - tar -C ~/cache/toolchain -xaf toolchain.tar.gz - - - name: Set Toolchain Path - run: echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin` - - - name: Get Dependencies - run: python3 tools/get_dependencies.py ${{ matrix.family }} - - - name: Build - run: python3 tools/build_family.py ${{ matrix.family }} - - - name: Linker Map - run: | - pip install linkermap/ - for ex in `ls -d examples/device/*/`; do \ - find ${ex} -name *.map -print -quit | \ - xargs -I % sh -c 'echo "::group::%"; linkermap -v %; echo "::endgroup::"'; \ - done diff --git a/.github/workflows/build_arm.yml b/.github/workflows/build_arm.yml deleted file mode 100644 index c16fc0d4..00000000 --- a/.github/workflows/build_arm.yml +++ /dev/null @@ -1,217 +0,0 @@ -name: Build ARM - -on: - push: - paths: - - 'src/**' - - 'examples/**' - - 'lib/**' - - 'hw/**' - pull_request: - branches: [ master ] - paths: - - 'src/**' - - 'examples/**' - - 'lib/**' - - 'hw/**' - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - # --------------------------------------- - # Build ARM family - # --------------------------------------- - build-arm: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - family: - # Alphabetical order - - 'broadcom_32bit' - - 'imxrt' - - 'lpc15' - - 'lpc18' - - 'lpc54' - - 'lpc55' - - 'mm32' - - 'msp432e4' - - 'nrf' - - 'rp2040' - - 'samd11' - - 'samd21' - - 'samd51' - - 'saml2x' - - 'stm32f0' - - 'stm32f1' - - 'stm32f4' - - 'stm32f7' - - 'stm32g4' - - 'stm32h7' - - 'stm32l4' - - 'stm32wb' - - 'tm4c123' - - 'xmc4000' - steps: - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - - name: Install ARM GCC - uses: carlosperate/arm-none-eabi-gcc-action@v1 - with: - release: '11.2-2022.02' - - - name: Checkout TinyUSB - uses: actions/checkout@v3 - - - name: Checkout common submodules in lib - run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip lib/sct_neopixel - - - name: Checkout hathach/linkermap - uses: actions/checkout@v3 - with: - repository: hathach/linkermap - path: linkermap - - - name: Checkout pico-sdk for rp2040 - if: matrix.family == 'rp2040' - run: | - git clone --depth 1 -b develop https://github.com/raspberrypi/pico-sdk ~/pico-sdk - echo >> $GITHUB_ENV PICO_SDK_PATH=~/pico-sdk - - - name: Get Dependencies - run: python3 tools/get_dependencies.py ${{ matrix.family }} - - - name: Build - run: python3 tools/build_family.py ${{ matrix.family }} - - - name: Linker Map - run: | - pip install linkermap/ - # find -quit to only print linkermap of 1 board per example - for ex in `ls -d examples/*/*/` - do - find ${ex} -name *.map -print -quit | xargs -I % sh -c 'echo "::group::%"; linkermap -v %; echo "::endgroup::"' - done - - # Following steps are for Hardware Test with self-hosted - - - name: Prepare Artifacts - if: matrix.family == 'rp2040' && github.repository_owner == 'hathach' - run: find examples/ -name "*.elf" -exec mv {} . \; - - - name: Upload Artifacts for Hardware Test - if: matrix.family == 'rp2040' && github.repository_owner == 'hathach' - uses: actions/upload-artifact@v3 - with: - name: ${{ matrix.family }} - path: | - *.elf - - # --------------------------------------- - # Build all no-family (orphaned) boards - # disable this workflow since it is often failed randomly - # --------------------------------------- - build-board: - runs-on: ubuntu-latest - if: false - strategy: - fail-fast: false - matrix: - example: - # Alphabetical order, a group of 4 - - 'device/audio_test device/board_test device/cdc_dual_ports device/cdc_msc' - - 'device/cdc_msc_freertos device/dfu_runtime device/hid_composite device/hid_composite_freertos' - - 'device/hid_generic_inout device/hid_multiple_interface device/midi_test device/msc_dual_lun' - - 'device/net_lwip_webserver' - - 'device/uac2_headset device/usbtmc device/webusb_serial host/cdc_msc_hid' - - steps: - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - - name: Install ARM GCC - uses: carlosperate/arm-none-eabi-gcc-action@v1 - with: - release: '11.2-2022.02' - - - name: Checkout TinyUSB - uses: actions/checkout@v3 - - - name: Checkout common submodules in lib - run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip - - - name: Build - run: python3 tools/build_board.py ${{ matrix.example }} - - # --------------------------------------- - # Hardware in the loop (HIL) - # Current self-hosted instance is running on an RPI4 with - # - pico + pico-probe connected via USB - # - pico-probe is /dev/ttyACM0 - # --------------------------------------- - hw-rp2040-test: - # Limit the run to only hathach due to limited resource on RPI4 - if: github.repository_owner == 'hathach' - needs: build-arm - runs-on: [self-hosted, Linux, ARM64, rp2040] - - steps: - - name: Clean workspace - run: | - echo "Cleaning up previous run" - rm -rf "${{ github.workspace }}" - mkdir -p "${{ github.workspace }}" - - - name: Download rp2040 Artifacts - uses: actions/download-artifact@v3 - with: - name: rp2040 - - - name: Create flash.sh - run: | - echo > flash.sh 'cmdout=$(openocd -f "interface/picoprobe.cfg" -f "target/rp2040.cfg" -c "program $1 reset exit")' - echo >> flash.sh 'if (( $? )) ; then echo $cmdout ; fi' - chmod +x flash.sh - - - name: Test cdc_dual_ports - run: | - ./flash.sh cdc_dual_ports.elf - while (! ([ -e /dev/ttyACM1 ] && [ -e /dev/ttyACM2 ])) && [ $SECONDS -le 5 ]; do :; done - test -e /dev/ttyACM1 && echo "ttyACM1 exists" - test -e /dev/ttyACM2 && echo "ttyACM2 exists" - - - name: Test cdc_msc - run: | - ./flash.sh cdc_msc.elf - readme='/media/pi/TinyUSB MSC/README.TXT' - while (! ([ -e /dev/ttyACM1 ] && [ -f "$readme" ])) && [ $SECONDS -le 5 ]; do :; done - test -e /dev/ttyACM1 && echo "ttyACM1 exists" - test -f "$readme" && echo "$readme exists" - cat "$readme" - - - name: Test dfu - run: | - ./flash.sh dfu.elf - while (! (dfu-util -l | grep "Found DFU")) && [ $SECONDS -le 5 ]; do :; done - dfu-util -d cafe -a 0 -U dfu0 - dfu-util -d cafe -a 1 -U dfu1 - grep "TinyUSB DFU! - Partition 0" dfu0 - grep "TinyUSB DFU! - Partition 1" dfu1 - - - name: Test dfu_runtime - run: | - ./flash.sh dfu_runtime.elf - while (! (dfu-util -l | grep "Found Runtime")) && [ $SECONDS -le 5 ]; do :; done - -# - name: Test hid_boot_interface -# run: | -# ./flash.sh hid_boot_interface.elf -# while (! (dfu-util -l | grep "Found Runtime")) && [ $SECONDS -le 5 ]; do :; done - diff --git a/.github/workflows/build_esp.yml b/.github/workflows/build_esp.yml deleted file mode 100644 index 2e2859c9..00000000 --- a/.github/workflows/build_esp.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: Build ESP - -on: - push: - paths: - - 'src/**' - - 'examples/**' - - 'lib/**' - - 'hw/**' - pull_request: - branches: [ master ] - paths: - - 'src/**' - - 'examples/**' - - 'lib/**' - - 'hw/**' - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - build-esp: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - board: - # Alphabetical order - # ESP32-S2 - - 'espressif_saola_1' - # ESP32-S3 - #- 'espressif_s3_devkitm' - # S3 compile error with "dangerous relocation: call8: call target out of range: memcpy" - - steps: - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - - name: Pull ESP-IDF docker - run: docker pull espressif/idf:latest - - - name: Checkout TinyUSB - uses: actions/checkout@v3 - - - name: Checkout hathach/linkermap - uses: actions/checkout@v3 - with: - repository: hathach/linkermap - path: linkermap - - - name: Build - run: docker run --rm -v $PWD:/project -w /project espressif/idf:latest python3 tools/build_esp32sx.py ${{ matrix.board }} - - - name: Linker Map - run: | - pip install linkermap/ - # find -quit to only print linkermap of 1 board per example - for ex in `ls -d examples/device/*/` - do - find ${ex} -maxdepth 3 -name *.map -print -quit | xargs -I % sh -c 'echo "::group::%"; linkermap -v %; echo "::endgroup::"' - done diff --git a/.github/workflows/build_msp430.yml b/.github/workflows/build_msp430.yml deleted file mode 100644 index 7e1c5b12..00000000 --- a/.github/workflows/build_msp430.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: Build MSP430 - -on: - push: - paths: - - 'src/**' - - 'examples/**' - - 'lib/**' - - 'hw/**' - pull_request: - branches: [ master ] - paths: - - 'src/**' - - 'examples/**' - - 'lib/**' - - 'hw/**' - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - build-msp430: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - family: - # Alphabetical order - - 'msp430' - - steps: - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - - name: Checkout TinyUSB - uses: actions/checkout@v3 - - - name: Checkout common submodules in lib - run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip - - - name: Checkout hathach/linkermap - uses: actions/checkout@v3 - with: - repository: hathach/linkermap - path: linkermap - - - name: Set Toolchain URL - run: echo >> $GITHUB_ENV TOOLCHAIN_URL=http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/9_2_0_0/export/msp430-gcc-9.2.0.50_linux64.tar.bz2 - - - name: Cache Toolchain - uses: actions/cache@v3 - id: cache-toolchain - with: - path: ~/cache/ - key: ${{ runner.os }}-21-03-04-${{ env.TOOLCHAIN_URL }} - - - name: Install Toolchain - if: steps.cache-toolchain.outputs.cache-hit != 'true' - run: | - mkdir -p ~/cache/toolchain - wget --progress=dot:mega $TOOLCHAIN_URL -O toolchain.tar.bz2 - tar -C ~/cache/toolchain -xaf toolchain.tar.bz2 - - - name: Set Toolchain Path - run: echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin` - - - name: Get Dependencies - run: python3 tools/get_dependencies.py ${{ matrix.family }} - - - name: Build - run: python3 tools/build_family.py ${{ matrix.family }} - - - name: Linker Map - run: | - pip install linkermap/ - # find -quit to only print linkermap of 1 board per example - for ex in `ls -d examples/device/*/` - do - find ${ex} -name *.map -print -quit | xargs -I % sh -c 'echo "::group::%"; linkermap -v %; echo "::endgroup::"' - done diff --git a/.github/workflows/build_renesas.yml b/.github/workflows/build_renesas.yml deleted file mode 100644 index d9254dea..00000000 --- a/.github/workflows/build_renesas.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: Build Renesas - -on: - push: - paths: - - 'src/**' - - 'examples/**' - - 'lib/**' - - 'hw/**' - pull_request: - branches: [ master ] - paths: - - 'src/**' - - 'examples/**' - - 'lib/**' - - 'hw/**' - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - build-rx: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - family: - # Alphabetical order - - 'rx' - steps: - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - - name: Checkout TinyUSB - uses: actions/checkout@v3 - - - name: Checkout common submodules in lib - run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip - - - name: Checkout hathach/linkermap - uses: actions/checkout@v3 - with: - repository: hathach/linkermap - path: linkermap - - - name: Set Toolchain URL - run: echo >> $GITHUB_ENV TOOLCHAIN_URL=http://gcc-renesas.com/downloads/get.php?f=rx/8.3.0.202004-gnurx/gcc-8.3.0.202004-GNURX-ELF.run - - - name: Cache Toolchain - uses: actions/cache@v3 - id: cache-toolchain - with: - path: ~/cache/ - key: ${{ runner.os }}-21-03-30-${{ env.TOOLCHAIN_URL }} - - - name: Install Toolchain - if: steps.cache-toolchain.outputs.cache-hit != 'true' - run: | - mkdir -p ~/cache/toolchain/gnurx - wget --progress=dot:mega $TOOLCHAIN_URL -O toolchain.run - chmod +x toolchain.run - ./toolchain.run -p ~/cache/toolchain/gnurx -y - - - name: Set Toolchain Path - run: echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin` - - - name: Get Dependencies - run: python3 tools/get_dependencies.py ${{ matrix.family }} - - - name: Build - run: python3 tools/build_family.py ${{ matrix.family }} - - - name: Linker Map - run: | - pip install linkermap/ - # find -quit to only print linkermap of 1 board per example - for ex in `ls -d examples/device/*/` - do - find ${ex} -name *.map -print -quit | xargs -I % sh -c 'echo "::group::%"; linkermap -v %; echo "::endgroup::"' - done diff --git a/.github/workflows/build_riscv.yml b/.github/workflows/build_riscv.yml deleted file mode 100644 index 026da7bd..00000000 --- a/.github/workflows/build_riscv.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: Build RISC-V - -on: - push: - paths: - - 'src/**' - - 'examples/**' - - 'lib/**' - - 'hw/**' - pull_request: - branches: [ master ] - paths: - - 'src/**' - - 'examples/**' - - 'lib/**' - - 'hw/**' - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - build-riscv: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - family: - # Alphabetical order - - 'fomu' - - 'gd32vf103' - steps: - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - - name: Checkout TinyUSB - uses: actions/checkout@v3 - - - name: Checkout common submodules in lib - run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip - - - name: Checkout hathach/linkermap - uses: actions/checkout@v3 - with: - repository: hathach/linkermap - path: linkermap - - - name: Set Toolchain URL - run: echo >> $GITHUB_ENV TOOLCHAIN_URL=https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack/releases/download/v10.1.0-1.1/xpack-riscv-none-embed-gcc-10.1.0-1.1-linux-x64.tar.gz - - - name: Cache Toolchain - uses: actions/cache@v3 - id: cache-toolchain - with: - path: ~/cache/ - key: ${{ runner.os }}-21-03-04-${{ env.TOOLCHAIN_URL }} - - - name: Install Toolchain - if: steps.cache-toolchain.outputs.cache-hit != 'true' - run: | - mkdir -p ~/cache/toolchain - wget --progress=dot:mega $TOOLCHAIN_URL -O toolchain.tar.gz - tar -C ~/cache/toolchain -xaf toolchain.tar.gz - - - name: Set Toolchain Path - run: echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin` - - - name: Get Dependencies - run: python3 tools/get_dependencies.py ${{ matrix.family }} - - - name: Build - run: python3 tools/build_family.py ${{ matrix.family }} - - - name: Linker Map - run: | - pip install linkermap/ - # find -quit to only print linkermap of 1 board per example - for ex in `ls -d examples/device/*/` - do - find ${ex} -name *.map -print -quit | xargs -I % sh -c 'echo "::group::%"; linkermap -v %; echo "::endgroup::"' - done diff --git a/.github/workflows/trigger.yml b/.github/workflows/trigger.yml deleted file mode 100644 index e434ca23..00000000 --- a/.github/workflows/trigger.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: Trigger Repos - -on: - push: - branches: master - release: - types: - - created - -jobs: - trigger-mynewt: - if: github.repository == 'hathach/tinyusb' - runs-on: ubuntu-latest - steps: - - name: Trigger mynewt-tinyusb-example - shell: bash - run: | - curl -X POST -H "Authorization: token ${{ secrets.API_TOKEN_GITHUB }}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" --data '{"event_type": "rebuild"}' https://api.github.com/repos/hathach/mynewt-tinyusb-example/dispatches - - mirror-tinyusb-src: - if: github.repository == 'hathach/tinyusb' - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Push to tinyusb_src - run: | - # clone tinyusb_src with PAT - git config --global user.email "thach@tinyusb.org" - git config --global user.name "hathach" - git clone --depth 1 --single-branch --branch main "https://${{ secrets.API_TOKEN_GITHUB }}@github.com/hathach/tinyusb_src.git" tinyusb_src - - # Remove all files - rm -rf tinyusb_src/* - - # Copy src and other files - cp -r src tinyusb_src/ - cp LICENSE tinyusb_src/ - cd tinyusb_src - - # Commit if there is changes - if [ -n "$(git status --porcelain)" ]; then - git add . - git commit --message "Update from https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA" - git push - fi - - - name: Create tinyusb_src Release - if: ${{ github.event_name == 'release' }} - run: | - # Push tag - cd tinyusb_src - git tag ${{ github.event.release.tag_name }} - git push origin ${{ github.event.release.tag_name }} - - # Send POST reqwuest to release https://docs.github.com/en/rest/reference/repos#create-a-release - bb={{ github.event.release.body }} - bb=${bb//\n/\\\n} - curl -X POST -H "Authorization: token ${{ secrets.API_TOKEN_GITHUB }}" -H "Accept: application/vnd.github.v3+json" --data '{"tag_name": "${{ github.event.release.tag_name }}", "name": "${{ github.event.release.name }}", "body": "$bb", "draft": ${{ github.event.release.draft }}, "prerelease": ${{ github.event.release.prerelease }}}' https://api.github.com/repos/hathach/tinyusb_src/releases diff --git a/.github/workflows/upload_component.yml b/.github/workflows/upload_component.yml new file mode 100644 index 00000000..f5cdc444 --- /dev/null +++ b/.github/workflows/upload_component.yml @@ -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 + + - 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 }} diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..3162003e --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,52 @@ +idf_build_get_property(target IDF_TARGET) + +set(tusb_family "esp32sx") + +if(target STREQUAL "esp32s3") + set(tusb_mcu "OPT_MCU_ESP32S3") +elseif(target STREQUAL "esp32s2") + set(tusb_mcu "OPT_MCU_ESP32S2") +endif() + +set(compile_options + "-DCFG_TUSB_MCU=${tusb_mcu}" + ) + +idf_component_get_property(freertos_component_dir freertos COMPONENT_DIR) + +set(includes_private + "hw/bsp/" + "src/" + "src/device" + ) + +set(includes_public + "src/" + # The FreeRTOS API include convention in tinyusb is different from esp-idf + "${freertos_component_dir}/FreeRTOS-Kernel/include/freertos" + ) + +set(srcs + "src/portable/espressif/${tusb_family}/dcd_${tusb_family}.c" + "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/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 driver + REQUIRED_IDF_TARGETS esp32s2 esp32s3 + ) + +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") diff --git a/README.md b/README.md new file mode 100644 index 00000000..a738b719 --- /dev/null +++ b/README.md @@ -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 informatin 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.12.1" # Automatically update bugfix releases. TinyUSB does not guarantee backward compatibility +``` + +Or simply run: +``` +idf.py add-dependency tinyusb~0.12.1 +``` + +README from the upstream TinyUSB can be found [here](README.rst). diff --git a/idf_component.yml b/idf_component.yml new file mode 100644 index 00000000..c1223de4 --- /dev/null +++ b/idf_component.yml @@ -0,0 +1,7 @@ +description: TinyUSB ported to Espressif's SoCs +url: https://github.com/espressif/tinyusb +dependencies: + idf: '>=5.0' # IDF 4.x contains TinyUSB as submodule +targets: + - esp32s2 + - esp32s3