diff options
| author | HiFiPhile <[email protected]> | 2024-04-01 12:35:57 +0200 |
|---|---|---|
| committer | HiFiPhile <[email protected]> | 2024-04-01 12:35:57 +0200 |
| commit | a1f01fcbe0fecb8d1783a105d7f22cba032dfced (patch) | |
| tree | c8174923ef0bdd1016f55ed731df4c2df3257940 /.github | |
| parent | dd0350f5499de586a3405fdcec632f059fd7534e (diff) | |
| parent | 82dfe95655c7b7564363a2d5cb2f5e32d431b223 (diff) | |
Merge remote-tracking branch 'upstream/master' into pr/1702
Diffstat (limited to '.github')
| -rw-r--r-- | .github/ISSUE_TEMPLATE/bug_report.yml | 12 | ||||
| -rw-r--r-- | .github/workflows/build_aarch64.yml | 52 | ||||
| -rw-r--r-- | .github/workflows/build_arm.yml | 144 | ||||
| -rw-r--r-- | .github/workflows/build_esp.yml | 113 | ||||
| -rw-r--r-- | .github/workflows/build_iar.yml | 58 | ||||
| -rw-r--r-- | .github/workflows/build_msp430.yml | 57 | ||||
| -rw-r--r-- | .github/workflows/build_renesas.yml | 54 | ||||
| -rw-r--r-- | .github/workflows/build_riscv.yml | 55 | ||||
| -rw-r--r-- | .github/workflows/build_win_mac.yml | 54 | ||||
| -rw-r--r-- | .github/workflows/cifuzz.yml | 34 | ||||
| -rw-r--r-- | .github/workflows/cmake_arm.yml | 169 | ||||
| -rw-r--r-- | .github/workflows/codeql-buildscript.sh | 5 | ||||
| -rw-r--r-- | .github/workflows/codeql.yml | 137 | ||||
| -rwxr-xr-x | .github/workflows/fail_on_error.py | 34 | ||||
| -rw-r--r-- | .github/workflows/labeler.yml | 63 | ||||
| -rw-r--r-- | .github/workflows/pre-commit.yml | 48 | ||||
| -rw-r--r-- | .github/workflows/trigger.yml | 10 |
17 files changed, 850 insertions, 249 deletions
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 2958d3b12..d00ee78bd 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -54,21 +54,21 @@ body: Exact steps in chronological order, details should be specific e.g if you use a command/script to test with, please post it as well. 1. Go to '...' 2. Click on '....' - 3. See error + 3. See error validations: required: true - type: textarea attributes: - label: Debug Log as txt file + label: Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2) placeholder: | Attach your debug log txt file here, where the issue occurred, best with comments to explain the actual events. - - Note1: Please DO NOT paste your lengthy log contents here since it hurts the readibility. - Note2: To enable logging, add `LOG=3` to to the make command if building with stock examples or set `CFG_TUSB_DEBUG=3` in your tusb_config.h. + + Note1: Please DO NOT paste your lengthy log contents here since it hurts the readability. + Note2: To enable logging, add `LOG=2` to to the make command if building with stock examples or set `CFG_TUSB_DEBUG=2` in your tusb_config.h. More information can be found at [example's readme](https://github.com/hathach/tinyusb/blob/master/docs/getting_started.md) validations: - required: false + required: true - type: textarea attributes: diff --git a/.github/workflows/build_aarch64.yml b/.github/workflows/build_aarch64.yml index b4ea8a0eb..e5dbf9494 100644 --- a/.github/workflows/build_aarch64.yml +++ b/.github/workflows/build_aarch64.yml @@ -1,11 +1,26 @@ name: Build AArch64 on: - pull_request: + workflow_dispatch: push: - release: - types: - - created + paths: + - 'src/**' + - 'examples/**' + - 'lib/**' + - 'hw/**' + - '.github/workflows/build_aarch64.yml' + pull_request: + branches: [ master ] + paths: + - 'src/**' + - 'examples/**' + - 'lib/**' + - 'hw/**' + - '.github/workflows/build_aarch64.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true jobs: # --------------------------------------- @@ -21,25 +36,18 @@ jobs: - 'broadcom_64bit' steps: - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 + 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 + uses: actions/checkout@v4 - 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@v2 + uses: actions/cache@v3 id: cache-toolchain with: path: ~/cache/ @@ -56,15 +64,7 @@ jobs: run: echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin` - name: Get Dependencies - run: python3 tools/get_dependencies.py ${{ matrix.family }} + run: python3 tools/get_deps.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 + run: python3 tools/build_make.py ${{ matrix.family }} diff --git a/.github/workflows/build_arm.yml b/.github/workflows/build_arm.yml index 4297ba895..9f3270c91 100644 --- a/.github/workflows/build_arm.yml +++ b/.github/workflows/build_arm.yml @@ -1,34 +1,30 @@ name: Build ARM on: - pull_request: + workflow_dispatch: push: - release: - types: - - created - -jobs: - # --------------------------------------- - # Unit testing with Ceedling - # --------------------------------------- - unit-test: - runs-on: ubuntu-latest - steps: - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: '2.7' - - - name: Checkout TinyUSB - uses: actions/checkout@v3 + paths: + - 'src/**' + - 'examples/**' + - 'lib/**' + - 'hw/**' + - 'tools/get_deps.py' + - '.github/workflows/build_arm.yml' + pull_request: + branches: [ master ] + paths: + - 'src/**' + - 'examples/**' + - 'lib/**' + - 'hw/**' + - 'tools/get_deps.py' + - '.github/workflows/build_arm.yml' - - name: Unit Tests - run: | - # Install Ceedling - gem install ceedling - cd test - ceedling test:all +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true +jobs: # --------------------------------------- # Build ARM family # --------------------------------------- @@ -40,89 +36,19 @@ jobs: 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' + - 'kinetis_k32l2' + - 'lpc11 lpc13 lpc15' + - 'lpc51' + - 'mm32 msp432e4' + - 'samd11 same5x saml2x' + - 'stm32f2 stm32f3' + - 'stm32l0 stm32wb' + - 'tm4c123 xmc4000' steps: - name: Setup Python - uses: actions/setup-python@v3 - - - 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 + uses: actions/setup-python@v5 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/ - 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 - - # --------------------------------------- - # Build all no-family (orphaned) boards - # --------------------------------------- - build-board: - runs-on: ubuntu-latest - 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@v3 + python-version: '3.x' - name: Install ARM GCC uses: carlosperate/arm-none-eabi-gcc-action@v1 @@ -130,10 +56,10 @@ jobs: release: '11.2-2022.02' - name: Checkout TinyUSB - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - name: Checkout common submodules in lib - run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip + - name: Get Dependencies + run: python3 tools/get_deps.py ${{ matrix.family }} - name: Build - run: python3 tools/build_board.py ${{ matrix.example }} + run: python3 tools/build_make.py ${{ matrix.family }} diff --git a/.github/workflows/build_esp.yml b/.github/workflows/build_esp.yml index 6a46773b2..d283c6535 100644 --- a/.github/workflows/build_esp.yml +++ b/.github/workflows/build_esp.yml @@ -1,11 +1,28 @@ name: Build ESP on: - pull_request: + workflow_dispatch: push: - release: - types: - - created + paths: + - 'src/**' + - 'examples/**' + - 'lib/**' + - 'hw/**' + - 'test/hil/**' + - '.github/workflows/build_esp.yml' + pull_request: + branches: [ master ] + paths: + - 'src/**' + - 'examples/**' + - 'lib/**' + - 'hw/**' + - 'test/hil/**' + - '.github/workflows/build_esp.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true jobs: build-esp: @@ -14,36 +31,84 @@ jobs: fail-fast: false matrix: board: - # Alphabetical order # ESP32-S2 - - 'espressif_saola_1' + - 'espressif_kaluga_1' # ESP32-S3 - #- 'espressif_s3_devkitm' - # S3 compile error with "dangerous relocation: call8: call target out of range: memcpy" - + - 'espressif_s3_devkitc' steps: - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 + with: + python-version: '3.x' - name: Pull ESP-IDF docker run: docker pull espressif/idf:latest - name: Checkout TinyUSB - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - name: Checkout hathach/linkermap - uses: actions/checkout@v3 + - name: Build + run: docker run --rm -v $PWD:/project -w /project espressif/idf:v5.1.1 python3 tools/build_esp32.py ${{ matrix.board }} + + - name: Upload Artifacts for Hardware Testing + if: matrix.board == 'espressif_s3_devkitc' && github.repository_owner == 'hathach' + uses: actions/upload-artifact@v4 with: - repository: hathach/linkermap - path: linkermap + name: ${{ matrix.board }} + path: | + cmake-build/cmake-build-${{ matrix.board }}/*/*/bootloader/bootloader.bin + cmake-build/cmake-build-${{ matrix.board }}/*/*/*.bin + cmake-build/cmake-build-${{ matrix.board }}/*/*/partition_table/partition-table.bin + cmake-build/cmake-build-${{ matrix.board }}/*/*/config.env + cmake-build/cmake-build-${{ matrix.board }}/*/*/flash_args - - name: Build - run: docker run --rm -v $PWD:/project -w /project espressif/idf:latest python3 tools/build_esp32sx.py ${{ matrix.board }} + # --------------------------------------- + # Hardware in the loop (HIL) + # Current self-hosted instance is running on an RPI4. For attached hardware checkout hil_pi4.json + # --------------------------------------- + hil-test: + # run only with hathach's commit due to limited resource on RPI4 + if: github.repository_owner == 'hathach' + needs: build-esp + runs-on: [self-hosted, esp32s3, hardware-in-the-loop] + strategy: + fail-fast: false + matrix: + board: + - 'espressif_s3_devkitc' + steps: + - name: Clean workspace + run: | + echo "Cleaning up previous run" + rm -rf "${{ github.workspace }}" + mkdir -p "${{ github.workspace }}" + + # USB bus on rpi4 is not stable, reset it before testing + - name: Reset USB bus + run: | + lsusb + lsusb -t + # reset VIA Labs 2.0 hub + sudo usbreset 001/002 + + # legacy code + #for port in $(lspci | grep USB | cut -d' ' -f1); do + # echo -n "0000:${port}"| sudo tee /sys/bus/pci/drivers/xhci_hcd/unbind; + # sleep 0.1; + # echo -n "0000:${port}" | sudo tee /sys/bus/pci/drivers/xhci_hcd/bind; + #done + + - name: Checkout test/hil + uses: actions/checkout@v4 + with: + sparse-checkout: test/hil + + - name: Download Artifacts + uses: actions/download-artifact@v4 + with: + name: ${{ matrix.board }} + path: cmake-build/cmake-build-${{ matrix.board }} - - name: Linker Map - run: | - pip install linkermap/ - 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 + - name: Test on actual hardware + run: | + python3 test/hil/hil_test.py --board ${{ matrix.board }} hil_pi4.json diff --git a/.github/workflows/build_iar.yml b/.github/workflows/build_iar.yml new file mode 100644 index 000000000..a0a022ecc --- /dev/null +++ b/.github/workflows/build_iar.yml @@ -0,0 +1,58 @@ +name: Build IAR + +on: + workflow_dispatch: + push: + paths: + - 'src/**' + - 'examples/**' + - 'lib/**' + - 'hw/**' + - 'tools/get_deps.py' + - 'test/hil/**' + - '.github/workflows/build_iar.yml' + pull_request: + branches: [ master ] + paths: + - 'src/**' + - 'examples/**' + - 'lib/**' + - 'hw/**' + - 'tools/get_deps.py' + - 'test/hil/**' + - '.github/workflows/build_iar.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + cmake: + runs-on: [self-hosted, Linux, X64, hifiphile] + strategy: + fail-fast: false + matrix: + family: + # Alphabetical order + # Note: bundle multiple families into a matrix since there is only one self-hosted instance can + # run IAR build. Too many matrix can hurt due to setup/teardown overhead. + - 'lpc43 stm32f0 stm32f1 stm32f7 stm32g0 stm32g4 stm32l4' + steps: + - name: Clean workspace + run: | + echo "Cleaning up previous run" + rm -rf "${{ github.workspace }}" + mkdir -p "${{ github.workspace }}" + + - name: Checkout TinyUSB + uses: actions/checkout@v4 + + - name: Get Dependencies + run: python3 tools/get_deps.py ${{ matrix.family }} + + - name: Build + run: python3 tools/build_cmake.py ${{ matrix.family }} -DTOOLCHAIN=iar -DCMAKE_BUILD_TYPE=MinSizeRel + + - name: Test on actual hardware (hardware in the loop) + run: | + python3 test/hil/hil_test.py hil_hfp.json diff --git a/.github/workflows/build_msp430.yml b/.github/workflows/build_msp430.yml index ea93f09a0..f913df913 100644 --- a/.github/workflows/build_msp430.yml +++ b/.github/workflows/build_msp430.yml @@ -1,13 +1,30 @@ name: Build MSP430 on: - pull_request: + workflow_dispatch: push: - release: - types: - - created + paths: + - 'src/**' + - 'examples/**' + - 'lib/**' + - 'hw/**' + - 'tools/get_deps.py' + - '.github/workflows/build_msp430.yml' + pull_request: + branches: [ master ] + paths: + - 'src/**' + - 'examples/**' + - 'lib/**' + - 'hw/**' + - 'tools/get_deps.py' + - '.github/workflows/build_msp430.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true -jobs: +jobs: build-msp430: runs-on: ubuntu-latest strategy: @@ -16,27 +33,21 @@ jobs: family: # Alphabetical order - 'msp430' + steps: - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 + 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 + uses: actions/checkout@v4 - 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@v2 + uses: actions/cache@v3 id: cache-toolchain with: path: ~/cache/ @@ -53,15 +64,7 @@ jobs: run: echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin` - name: Get Dependencies - run: python3 tools/get_dependencies.py ${{ matrix.family }} + run: python3 tools/get_deps.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 + run: python3 tools/build_make.py ${{ matrix.family }} diff --git a/.github/workflows/build_renesas.yml b/.github/workflows/build_renesas.yml index 2563d3549..ec06c9426 100644 --- a/.github/workflows/build_renesas.yml +++ b/.github/workflows/build_renesas.yml @@ -1,11 +1,28 @@ name: Build Renesas on: - pull_request: + workflow_dispatch: push: - release: - types: - - created + paths: + - 'src/**' + - 'examples/**' + - 'lib/**' + - 'hw/**' + - 'tools/get_deps.py' + - '.github/workflows/build_renesas.yml' + pull_request: + branches: [ master ] + paths: + - 'src/**' + - 'examples/**' + - 'lib/**' + - 'hw/**' + - 'tools/get_deps.py' + - '.github/workflows/build_renesas.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true jobs: build-rx: @@ -18,25 +35,18 @@ jobs: - 'rx' steps: - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 + 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 + uses: actions/checkout@v4 - 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@v2 + uses: actions/cache@v3 id: cache-toolchain with: path: ~/cache/ @@ -54,15 +64,7 @@ jobs: run: echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin` - name: Get Dependencies - run: python3 tools/get_dependencies.py ${{ matrix.family }} + run: python3 tools/get_deps.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 + run: python3 tools/build_make.py ${{ matrix.family }} diff --git a/.github/workflows/build_riscv.yml b/.github/workflows/build_riscv.yml index 90dc35206..e891a3a51 100644 --- a/.github/workflows/build_riscv.yml +++ b/.github/workflows/build_riscv.yml @@ -1,11 +1,28 @@ name: Build RISC-V on: - pull_request: + workflow_dispatch: push: - release: - types: - - created + paths: + - 'src/**' + - 'examples/**' + - 'lib/**' + - 'hw/**' + - 'tools/get_deps.py' + - '.github/workflows/build_riscv.yml' + pull_request: + branches: [ master ] + paths: + - 'src/**' + - 'examples/**' + - 'lib/**' + - 'hw/**' + - 'tools/get_deps.py' + - '.github/workflows/build_riscv.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true jobs: build-riscv: @@ -15,29 +32,23 @@ jobs: matrix: family: # Alphabetical order + - 'ch32v307' - 'fomu' - 'gd32vf103' steps: - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 + 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 + uses: actions/checkout@v4 - 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@v2 + uses: actions/cache@v3 id: cache-toolchain with: path: ~/cache/ @@ -54,15 +65,7 @@ jobs: run: echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin` - name: Get Dependencies - run: python3 tools/get_dependencies.py ${{ matrix.family }} + run: python3 tools/get_deps.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 + run: python3 tools/build_make.py ${{ matrix.family }} diff --git a/.github/workflows/build_win_mac.yml b/.github/workflows/build_win_mac.yml new file mode 100644 index 000000000..b33b5b593 --- /dev/null +++ b/.github/workflows/build_win_mac.yml @@ -0,0 +1,54 @@ +name: Build Windows/MacOS + +on: + workflow_dispatch: + push: + paths: + - 'src/**' + - 'examples/**' + - 'lib/**' + - 'hw/**' + - '.github/workflows/build_win_mac.yml' + pull_request: + branches: [ master ] + paths: + - 'src/**' + - 'examples/**' + - 'lib/**' + - 'hw/**' + - '.github/workflows/build_win_mac.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + # --------------------------------------- + # Build ARM family + # --------------------------------------- + build-arm: + strategy: + fail-fast: false + matrix: + os: [windows-latest, macos-latest] + runs-on: ${{ matrix.os }} + + steps: + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install ARM GCC + uses: carlosperate/arm-none-eabi-gcc-action@v1 + with: + release: '10.3-2021.10' + + - name: Checkout TinyUSB + uses: actions/checkout@v4 + + - name: Get Dependencies + run: python3 tools/get_deps.py stm32f4 + + - name: Build + run: python3 tools/build_make.py stm32f4 stm32f411disco diff --git a/.github/workflows/cifuzz.yml b/.github/workflows/cifuzz.yml new file mode 100644 index 000000000..5dc0f2764 --- /dev/null +++ b/.github/workflows/cifuzz.yml @@ -0,0 +1,34 @@ +name: CIFuzz +on: + workflow_dispatch: + pull_request: + branches: + - master + paths: + - '**.c' + - '**.cc' + - '**.cpp' + - '**.cxx' + - '**.h' +jobs: + Fuzzing: + runs-on: ubuntu-latest + steps: + - name: Build Fuzzers + id: build + uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master + with: + oss-fuzz-project-name: 'tinyusb' + language: c++ + - name: Run Fuzzers + uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master + with: + oss-fuzz-project-name: 'tinyusb' + language: c++ + fuzz-seconds: 600 + - name: Upload Crash + uses: actions/upload-artifact@v4 + if: failure() && steps.build.outcome == 'success' + with: + name: artifacts + path: ./out/artifacts diff --git a/.github/workflows/cmake_arm.yml b/.github/workflows/cmake_arm.yml new file mode 100644 index 000000000..1e5f61e0e --- /dev/null +++ b/.github/workflows/cmake_arm.yml @@ -0,0 +1,169 @@ +name: CMake ARM + +on: + workflow_dispatch: + push: + paths: + - 'src/**' + - 'examples/**' + - 'lib/**' + - 'hw/**' + - 'test/hil/**' + - 'tools/get_deps.py' + - '.github/workflows/cmake_arm.yml' + pull_request: + branches: [ master ] + paths: + - 'src/**' + - 'examples/**' + - 'lib/**' + - 'hw/**' + - 'test/hil/**' + - 'tools/get_deps.py' + - '.github/workflows/cmake_arm.yml' + +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 + - 'imxrt' + - 'kinetis_k kinetis_kl' + - 'lpc17 lpc18 lpc40 lpc43' + - 'lpc54 lpc55' + - 'mcx' + - 'nrf' + - 'ra' + - 'rp2040' + - 'samd21' + - 'samd51' + - 'stm32f0' + - 'stm32f1' + - 'stm32f4' + - 'stm32f7' + - 'stm32g0' + - 'stm32g4' + - 'stm32h5' + - 'stm32h7' + - 'stm32l4' + - 'stm32u5' + steps: + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install ARM GCC + uses: carlosperate/arm-none-eabi-gcc-action@v1 + with: + release: '11.2-2022.02' + + - name: Install Ninja + run: sudo apt install -y ninja-build + + - name: Checkout TinyUSB + uses: actions/checkout@v4 + + - name: Checkout pico-sdk for rp2040 + if: matrix.family == 'rp2040' + uses: actions/checkout@v4 + with: + repository: raspberrypi/pico-sdk + ref: develop + path: pico-sdk + + - name: Get Dependencies + run: python3 tools/get_deps.py ${{ matrix.family }} + + - name: Build + run: python tools/build_cmake.py ${{ matrix.family }} -DCMAKE_BUILD_TYPE=MinSizeRel + env: + # for rp2040, there is no harm if defined for other families + PICO_SDK_PATH: ${{ github.workspace }}/pico-sdk + + - name: Upload Artifacts for Hardware Testing (rp2040) + if: matrix.family == 'rp2040' && github.repository_owner == 'hathach' + uses: actions/upload-artifact@v4 + with: + name: raspberry_pi_pico + path: | + cmake-build/cmake-build-raspberry_pi_pico/*/*/*.elf + + - name: Upload Artifacts for Hardware Testing (nRF) + if: matrix.family == 'nrf' && github.repository_owner == 'hathach' + uses: actions/upload-artifact@v4 + with: + name: feather_nrf52840_express + path: | + cmake-build/cmake-build-feather_nrf52840_express/*/*/*.elf + + - name: Upload Artifacts for Hardware Testing (samd51) + if: matrix.family == 'samd51' && github.repository_owner == 'hathach' + uses: actions/upload-artifact@v4 + with: + name: itsybitsy_m4 + path: | + cmake-build/cmake-build-itsybitsy_m4/*/*/*.bin + + # --------------------------------------- + # Hardware in the loop (HIL) + # Current self-hosted instance is running on an RPI4. For attached hardware checkout hil_pi4.json + # --------------------------------------- + hil-test: + # run only with hathach's commit due to limited resource on RPI4 + if: github.repository_owner == 'hathach' + needs: build-arm + runs-on: [self-hosted, rp2040, nrf52840, hardware-in-the-loop] + strategy: + fail-fast: false + matrix: + board: + - 'feather_nrf52840_express' + - 'itsybitsy_m4' + - 'raspberry_pi_pico' + steps: + - name: Clean workspace + run: | + echo "Cleaning up previous run" + rm -rf "${{ github.workspace }}" + mkdir -p "${{ github.workspace }}" + + # USB bus on rpi4 is not stable, reset it before testing + - name: Reset USB bus + run: | + lsusb + lsusb -t + # reset VIA Labs 2.0 hub + sudo usbreset 001/002 + + # legacy code + #for port in $(lspci | grep USB | cut -d' ' -f1); do + # echo -n "0000:${port}"| sudo tee /sys/bus/pci/drivers/xhci_hcd/unbind; + # sleep 0.1; + # echo -n "0000:${port}" | sudo tee /sys/bus/pci/drivers/xhci_hcd/bind; + #done + + - name: Checkout test/hil + uses: actions/checkout@v4 + with: + sparse-checkout: test/hil + + - name: Download Artifacts + uses: actions/download-artifact@v4 + with: + name: ${{ matrix.board }} + path: cmake-build/cmake-build-${{ matrix.board }} + + - name: Test on actual hardware + run: | + python3 test/hil/hil_test.py --board ${{ matrix.board }} hil_pi4.json diff --git a/.github/workflows/codeql-buildscript.sh b/.github/workflows/codeql-buildscript.sh new file mode 100644 index 000000000..35e029922 --- /dev/null +++ b/.github/workflows/codeql-buildscript.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +FAMILY=stm32l4 +python3 tools/get_deps.py $FAMILY +python3 tools/build_make.py $FAMILY diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 000000000..1f7b60b9c --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,137 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ 'master' ] + paths: + - 'src/**' + - 'examples/**' + - 'lib/**' + - 'hw/**' + - '.github/workflows/codeql.yml' + pull_request: + branches: [ 'master' ] + paths: + - 'src/**' + - 'examples/**' + - 'lib/**' + - 'hw/**' + - '.github/workflows/codeql.yml' + schedule: + - cron: '0 0 * * *' + +jobs: + analyze: + name: Analyze + # Runner size impacts CodeQL analysis time. To learn more, please see: + # - https://gh.io/recommended-hardware-resources-for-running-codeql + # - https://gh.io/supported-runners-and-hardware-resources + # - https://gh.io/using-larger-runners + # Consider using larger runners for possible analysis time improvements. + runs-on: ubuntu-latest + timeout-minutes: 360 + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'c-cpp' ] + # CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ] + # Use only 'java-kotlin' to analyze code written in Java, Kotlin or both + # Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install ARM GCC + uses: carlosperate/arm-none-eabi-gcc-action@v1 + with: + release: '11.2-2022.02' + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + queries: security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). + # If this step fails, then you should remove it and run the build manually (see below) + #- name: Autobuild + # uses: github/codeql-action/autobuild@v2 + + # âšī¸ Command-line programs to run using the OS shell. + # đ See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + - run: | + ./.github/workflows/codeql-buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" + upload: false + id: step1 + + # Filter out rules with low severity or high false positive rate + # Also filter out warnings in third-party code + - name: Filter out unwanted errors and warnings + uses: advanced-security/filter-sarif@v1 + with: + patterns: | + -**:cpp/path-injection + -**:cpp/world-writable-file-creation + -**:cpp/poorly-documented-function + -**:cpp/potentially-dangerous-function + -**:cpp/use-of-goto + -**:cpp/integer-multiplication-cast-to-long + -**:cpp/comparison-with-wider-type + -**:cpp/leap-year/* + -**:cpp/ambiguously-signed-bit-field + -**:cpp/suspicious-pointer-scaling + -**:cpp/suspicious-pointer-scaling-void + -**:cpp/unsigned-comparison-zero + -**/third*party/** + -**/3rd*party/** + -**/external/** + input: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif + output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif + + - name: Upload SARIF + uses: github/codeql-action/upload-sarif@v2 + with: + sarif_file: ${{ steps.step1.outputs.sarif-output }} + category: "/language:${{matrix.language}}" + + - name: Archive CodeQL results + uses: actions/upload-artifact@v4 + with: + name: codeql-results + path: ${{ steps.step1.outputs.sarif-output }} + retention-days: 5 diff --git a/.github/workflows/fail_on_error.py b/.github/workflows/fail_on_error.py new file mode 100755 index 000000000..29791742b --- /dev/null +++ b/.github/workflows/fail_on_error.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 + +import json +import sys + +# Return whether SARIF file contains error-level results +def codeql_sarif_contain_error(filename): + with open(filename, 'r') as f: + s = json.load(f) + + for run in s.get('runs', []): + rules_metadata = run['tool']['driver']['rules'] + if not rules_metadata: + rules_metadata = run['tool']['extensions'][0]['rules'] + + for res in run.get('results', []): + if 'ruleIndex' in res: + rule_index = res['ruleIndex'] + elif 'rule' in res and 'index' in res['rule']: + rule_index = res['rule']['index'] + else: + continue + try: + rule_level = rules_metadata[rule_index]['defaultConfiguration']['level'] + except IndexError as e: + print(e, rule_index, len(rules_metadata)) + else: + if rule_level == 'error': + return True + return False + +if __name__ == "__main__": + if codeql_sarif_contain_error(sys.argv[1]): + sys.exit(1) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 000000000..4733c6f06 --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,63 @@ +name: Labeler + +on: + issues: + types: [opened] + pull_request: + types: [opened] + +jobs: + label-priority: + runs-on: ubuntu-latest + + steps: + - name: Label New Issue or PR + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + let label = ''; + let username = ''; + let issueOrPrNumber = 0; + + if (context.eventName === 'issues') { + username = context.payload.issue.user.login; + issueOrPrNumber = context.payload.issue.number; + } else if (context.eventName === 'pull_request') { + username = context.payload.pull_request.user.login; + issueOrPrNumber = context.payload.pull_request.number; + } + + // Check for Adafruit membership + const adafruitResponse = await github.rest.orgs.checkMembershipForUser({ + org: 'adafruit', + username: username + }); + + if (adafruitResponse.status === 204) { + console.log('Adafruit Member'); + label = 'Prio Urgent'; + } else { + // Check if the user is a contributor + const collaboratorResponse = await github.rest.repos.checkCollaborator({ + owner: context.repo.owner, + repo: context.repo.repo, + username: username + }); + + if (collaboratorResponse.status === 204) { + console.log('Contributor'); + label = 'Prio Higher'; + } else { + console.log('Not a contributor or Adafruit member'); + } + } + + if (label !== '') { + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issueOrPrNumber, + labels: [label] + }); + } diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 000000000..e36259daa --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,48 @@ +name: pre-commit + +on: + workflow_dispatch: + push: + pull_request: + branches: [ master ] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.0' + + - name: Checkout TinyUSB + uses: actions/checkout@v4 + + - name: Get Dependencies + run: | + gem install ceedling + #cd test/unit-test + #ceedling test:all + + - name: Run pre-commit + uses: pre-commit/[email protected] + + - name: Build Fuzzer + run: | + export CC=clang + export CXX=clang++ + fuzz_harness=$(ls -d test/fuzz/device/*/) + for h in $fuzz_harness + do + make -C $h get-deps + make -C $h all + done diff --git a/.github/workflows/trigger.yml b/.github/workflows/trigger.yml index e434ca238..cf40ac955 100644 --- a/.github/workflows/trigger.yml +++ b/.github/workflows/trigger.yml @@ -1,6 +1,7 @@ name: Trigger Repos on: + workflow_dispatch: push: branches: master release: @@ -22,7 +23,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Push to tinyusb_src run: | @@ -43,7 +44,7 @@ jobs: if [ -n "$(git status --porcelain)" ]; then git add . git commit --message "Update from https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA" - git push + git push fi - name: Create tinyusb_src Release @@ -53,8 +54,7 @@ jobs: 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} + bb="For release note, please checkout https://github.com/hathach/tinyusb/releases/tag/${{ github.event.release.tag_name }}" 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 |
