diff --git a/.circleci/config.yml b/.circleci/config.yml index 4d541a595..fd5631e2e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,16 +18,65 @@ jobs: MATRIX_JSON=$(python .github/workflows/ci_set_matrix.py) echo "MATRIX_JSON=$MATRIX_JSON" - TOOLCHAIN_LIST=("arm-clang" "arm-gcc") - for toolchain in "${TOOLCHAIN_LIST[@]}"; do - FAMILY=$(echo $MATRIX_JSON | jq -r ".\"$toolchain\".family") - echo "${toolchain}_FAMILY=$FAMILY" - echo " - build:" >> .circleci/config2.yml + BUILDSYSTEM_TOOLCHAIN=( + "cmake arm-clang" + "make aarch64-gcc" + "make arm-gcc" + "make msp430-gcc" + "make riscv-gcc" + "make rx-gcc" + "cmake esp-idf" + ) + + # only build IAR if not forked PR, since IAR token is not shared + if [ -z $CIRCLE_PR_USERNAME ]; then + BUILDSYSTEM_TOOLCHAIN+=("cmake arm-iar") + fi + + RESOURCE_LARGE='["nrf", "imxrt", "stm32f4", "stm32h7"]' + + gen_build_entry() { + local build_system="$1" + local toolchain="$2" + local family="$3" + local resource_class="$4" + + if [[ "$toolchain" == "esp-idf" ]]; then + echo " - build-vm:" >> .circleci/config2.yml + else + echo " - build:" >> .circleci/config2.yml + fi + echo " matrix:" >> .circleci/config2.yml echo " parameters:" >> .circleci/config2.yml + echo " build-system: ['$build_system']" >> .circleci/config2.yml echo " toolchain: ['$toolchain']" >> .circleci/config2.yml - echo " build-system: ['cmake']" >> .circleci/config2.yml - echo " family: $FAMILY" >> .circleci/config2.yml + echo " family: $family" >> .circleci/config2.yml + echo " resource_class: ['$resource_class']" >> .circleci/config2.yml + } + + for e in "${BUILDSYSTEM_TOOLCHAIN[@]}"; do + e_arr=($e) + build_system="${e_arr[0]}" + toolchain="${e_arr[1]}" + FAMILY=$(echo $MATRIX_JSON | jq -r ".\"$toolchain\"") + echo "FAMILY_${toolchain}=$FAMILY" + + # FAMILY_LARGE = FAMILY - RESOURCE_LARGE + # Separate large from medium+ resources + FAMILY_LARGE=$(jq -n --argjson family "$FAMILY" --argjson resource "$RESOURCE_LARGE" '$family | map(select(IN($resource[])))') + FAMILY=$(jq -n --argjson family "$FAMILY" --argjson resource "$RESOURCE_LARGE" '$family | map(select(IN($resource[]) | not))') + + if [[ $toolchain == esp-idf ]]; then + gen_build_entry "$build_system" "$toolchain" "$FAMILY" "large" + else + gen_build_entry "$build_system" "$toolchain" "$FAMILY" "medium+" + + # add large resources if available + if [ "$(echo $FAMILY_LARGE | jq 'length')" -gt 0 ]; then + gen_build_entry "$build_system" "$toolchain" "$FAMILY_LARGE" "large" + fi + fi done - continuation/continue: @@ -35,5 +84,9 @@ jobs: workflows: set-matrix: + # Only build PR here, Push will be built by github action. + when: + and: + - not: << pipeline.git.branch.is_default >> jobs: - set-matrix diff --git a/.circleci/config2.yml b/.circleci/config2.yml index ea7fccaff..3b0294168 100644 --- a/.circleci/config2.yml +++ b/.circleci/config2.yml @@ -5,42 +5,67 @@ commands: parameters: toolchain: type: string + steps: + - run: + name: Set toolchain url and key + command: | + TOOLCHAIN_JSON='{ + "aarch64-gcc": "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", + "arm-clang": "https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/releases/download/release-19.1.1/LLVM-ET-Arm-19.1.1-Linux-x86_64.tar.xz", + "arm-gcc": "https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/download/v13.2.1-1.1/xpack-arm-none-eabi-gcc-13.2.1-1.1-linux-x64.tar.gz", + "msp430-gcc": "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", + "riscv-gcc": "https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack/releases/download/v13.2.0-2/xpack-riscv-none-elf-gcc-13.2.0-2-linux-x64.tar.gz", + "rx-gcc": "https://github.com/hathach/rx_device/releases/download/0.0.1/gcc-8.3.0.202411-GNURX-ELF.run", + "arm-iar": "https://updates.iar.com/FileStore/STANDARD/001/003/322/cxarm-9.60.3.deb" + }' + toolchain_url=$(echo $TOOLCHAIN_JSON | jq -r '.["<< parameters.toolchain >>"]') + + # only cache if not a github link + if [[ $toolchain_url != "https://github.com"* ]]; then + echo "<< parameters.toolchain >>-$toolchain_url" > toolchain_key + fi + echo "export toolchain_url=$toolchain_url" >> $BASH_ENV + + - restore_cache: + name: Restore Toolchain Cache + key: deps-{{ checksum "toolchain_key" }} + paths: + - ~/cache/<< parameters.toolchain >> + - run: name: Install Toolchain command: | - TOOLCHAIN_JSON='{ - "arm-clang": "https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/releases/download/release-17.0.1/LLVMEmbeddedToolchainForArm-17.0.1-Linux-x86_64.tar.xz", - "arm-gcc": "https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/download/v12.3.1-1.1/xpack-arm-none-eabi-gcc-12.3.1-1.1-linux-x64.tar.gz" - }' - toolchain_url=$(echo $TOOLCHAIN_JSON | jq -r '.["<< parameters.toolchain >>"]') - echo "toolchain_url=$toolchain_url" - - # download and extract toolchain - mkdir -p ~/cache/<< parameters.toolchain >> - wget $toolchain_url -O toolchain.tar.gz - tar -C ~/cache/<< parameters.toolchain >> -xaf toolchain.tar.gz - - # Add toolchain to PATH - echo "export PATH=$PATH:`echo ~/cache/<< parameters.toolchain >>/*/bin`" >> $BASH_ENV - - get-deps: - parameters: - family: - type: string - steps: - - run: - name: Get Dependencies - command: | - python tools/get_deps.py << parameters.family >> - - # Install Pico SDK - if [ << parameters.family >> == "rp2040" ]; then - git clone --depth 1 https://github.com/raspberrypi/pico-sdk.git ~/pico-sdk - echo "export PICO_SDK_PATH=~/pico-sdk" >> $BASH_ENV + # download if folder does not exist (not cached) + if [ ! -d ~/cache/<< parameters.toolchain >> ]; then + mkdir -p ~/cache/<< parameters.toolchain >> + if [[ << parameters.toolchain >> == rx-gcc ]]; then + wget --progress=dot:giga $toolchain_url -O toolchain.run + chmod +x toolchain.run + ./toolchain.run -p ~/cache/<< parameters.toolchain >>/gnurx -y + elif [[ << parameters.toolchain >> == arm-iar ]]; then + wget --progress=dot:giga $toolchain_url -O ~/cache/<< parameters.toolchain >>/toolchain.deb + else + wget --progress=dot:giga $toolchain_url -O toolchain.tar.gz + tar -C ~/cache/<< parameters.toolchain >> -xaf toolchain.tar.gz + fi fi -jobs: + # Add toolchain to PATH + if [[ << parameters.toolchain >> == arm-iar ]]; then + # Install IAR since we only cache deb file + sudo dpkg --ignore-depends=libusb-1.0-0 -i ~/cache/<< parameters.toolchain >>/toolchain.deb + echo "export PATH=$PATH:/opt/iar/cxarm/arm/bin" >> $BASH_ENV + else + echo "export PATH=$PATH:`echo ~/cache/<< parameters.toolchain >>/*/bin`" >> $BASH_ENV + fi + + - save_cache: + name: Save Toolchain Cache + key: deps-{{ checksum "toolchain_key" }} + paths: + - ~/cache/<< parameters.toolchain >> + build: parameters: build-system: @@ -50,42 +75,107 @@ jobs: family: type: string - docker: - - image: cimg/base:current - resource_class: medium+ steps: - checkout + - run: + name: Get Dependencies + command: | + python tools/get_deps.py << parameters.family >> + + # Install ninja if cmake build system + if [ << parameters.build-system >> == "cmake" ]; then + NINJA_URL=https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-linux.zip + wget $NINJA_URL -O ninja-linux.zip + unzip ninja-linux.zip -d ~/bin + fi + + # rx-gcc is 32-bit binary + if [[ << parameters.toolchain >> == rx-gcc ]]; then + sudo dpkg --add-architecture i386 + sudo apt update + sudo apt install libc6:i386 libstdc++6:i386 zlib1g:i386 + fi + + # Install Pico SDK + if [ << parameters.family >> == "rp2040" ]; then + git clone --depth 1 https://github.com/raspberrypi/pico-sdk.git ~/pico-sdk + echo "export PICO_SDK_PATH=~/pico-sdk" >> $BASH_ENV + fi + - when: - condition: << parameters.build-system >> == 'cmake' + condition: + not: + equal: [esp-idf, << parameters.toolchain >>] steps: - - run: - name: Install Ninja - command: | - # Install Ninja - NINJA_URL=https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-linux.zip - wget $NINJA_URL -O ninja-linux.zip - unzip ninja-linux.zip -d ~/bin - - setup-toolchain: - toolchain: << parameters.toolchain >> - - get-deps: - family: << parameters.family >> + - setup-toolchain: + toolchain: << parameters.toolchain >> + - run: name: Build command: | - # Only build one board per family for non PRs i.e commit to master - ONE_PER_FAMILY="" - if [ -z "$CIRCLE_PULL_REQUEST" ]; then - ONE_PER_FAMILY="--one-per-family" + if [ << parameters.toolchain >> == esp-idf ]; then + docker run --rm -v $PWD:/project -w /project espressif/idf:v5.3.2 python tools/build.py << parameters.family >> + else + # Toolchain option default is gcc + if [ << parameters.toolchain >> == arm-clang ]; then + TOOLCHAIN_OPTION="--toolchain clang" + elif [ << parameters.toolchain >> == arm-iar ]; then + TOOLCHAIN_OPTION="--toolchain iar" + echo IAR_LMS_CLOUD_URL=$IAR_LMS_CLOUD_URL + iccarm --version + elif [ << parameters.toolchain >> == arm-gcc ]; then + TOOLCHAIN_OPTION="--toolchain gcc" + fi + + python tools/build.py -s << parameters.build-system >> $TOOLCHAIN_OPTION << parameters.family >> fi - # Toolchain option default is gcc - if [ "<< parameters.toolchain >>" == "arm-clang" ]; then - TOOLCHAIN_OPTION="--toolchain clang" - elif [ "<< parameters.toolchain >>" == "arm-gcc" ]; then - TOOLCHAIN_OPTION="--toolchain gcc" - fi +jobs: + # Build using docker + build: + parameters: + resource_class: + type: string + default: medium+ + build-system: + type: string + toolchain: + type: string + family: + type: string - python tools/build.py $ONE_PER_FAMILY -s << parameters.build-system >> $TOOLCHAIN_OPTION << parameters.family >> + docker: + - image: cimg/base:current + resource_class: << parameters.resource_class >> + + steps: + - build: + build-system: << parameters.build-system >> + toolchain: << parameters.toolchain >> + family: << parameters.family >> + + # Build using VM + build-vm: + parameters: + resource_class: + type: string + default: large + build-system: + type: string + toolchain: + type: string + family: + type: string + + machine: + image: ubuntu-2404:current + resource_class: << parameters.resource_class >> + + steps: + - build: + build-system: << parameters.build-system >> + toolchain: << parameters.toolchain >> + family: << parameters.family >> workflows: build: @@ -93,6 +183,14 @@ workflows: # - build: # matrix: # parameters: -# toolchain: ['arm-clang'] +# toolchain: [ 'arm-gcc' ] +# build-system: [ 'cmake' ] +# family: [ 'nrf' ] +# resource_class: ['large'] +# - build-vm: +# matrix: +# parameters: +# toolchain: ['esp-idf'] # build-system: ['cmake'] -# family: ['imxrt'] +# family: ['-bespressif_kaluga_1'] +# resource_class: ['large'] diff --git a/.github/actions/get_deps/action.yml b/.github/actions/get_deps/action.yml index eea241c6c..ae9e7bbef 100644 --- a/.github/actions/get_deps/action.yml +++ b/.github/actions/get_deps/action.yml @@ -13,7 +13,7 @@ runs: uses: actions/checkout@v4 with: repository: raspberrypi/pico-sdk - ref: develop + ref: master path: pico-sdk - name: Linux dependencies diff --git a/.github/actions/setup_toolchain/action.yml b/.github/actions/setup_toolchain/action.yml index d173d6903..8305daa24 100644 --- a/.github/actions/setup_toolchain/action.yml +++ b/.github/actions/setup_toolchain/action.yml @@ -4,9 +4,6 @@ inputs: toolchain: description: 'Toolchain name' required: true - toolchain_version: - description: 'Toolchain version' - required: false outputs: build_option: @@ -20,14 +17,13 @@ runs: if: inputs.toolchain == 'arm-gcc' uses: carlosperate/arm-none-eabi-gcc-action@v1 with: - release: '12.3.Rel1' + release: '13.2.Rel1' - name: Pull ESP-IDF docker if: inputs.toolchain == 'esp-idf' uses: ./.github/actions/setup_toolchain/espressif with: toolchain: ${{ inputs.toolchain }} - toolchain_version: ${{ inputs.toolchain_version }} - name: Get Toolchain URL if: >- @@ -38,12 +34,10 @@ runs: run: | TOOLCHAIN_JSON='{ "aarch64-gcc": "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", - "arm-clang": "https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/releases/download/release-17.0.1/LLVMEmbeddedToolchainForArm-17.0.1-Linux-x86_64.tar.xz", - "arm-iar": "", - "arm-gcc": "", + "arm-clang": "https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/releases/download/release-19.1.1/LLVM-ET-Arm-19.1.1-Linux-x86_64.tar.xz", "msp430-gcc": "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", "riscv-gcc": "https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack/releases/download/v13.2.0-2/xpack-riscv-none-elf-gcc-13.2.0-2-linux-x64.tar.gz", - "rx-gcc": "http://gcc-renesas.com/downloads/get.php?f=rx/8.3.0.202004-gnurx/gcc-8.3.0.202004-GNURX-ELF.run" + "rx-gcc": "https://github.com/hathach/rx_device/releases/download/0.0.1/gcc-8.3.0.202411-GNURX-ELF.run" }' TOOLCHAIN_URL=$(echo $TOOLCHAIN_JSON | jq -r '.["${{ inputs.toolchain }}"]') echo "toolchain_url=$TOOLCHAIN_URL" diff --git a/.github/actions/setup_toolchain/espressif/action.yml b/.github/actions/setup_toolchain/espressif/action.yml index 3129329dd..b50ffd41d 100644 --- a/.github/actions/setup_toolchain/espressif/action.yml +++ b/.github/actions/setup_toolchain/espressif/action.yml @@ -5,8 +5,9 @@ inputs: description: 'Toolchain name' required: true toolchain_version: - description: 'Toolchain URL or version' - required: true + description: 'Toolchain version' + required: false + default: 'v5.3.2' runs: using: "composite" @@ -39,3 +40,9 @@ runs: du -sh $DOCKER_ESP_IDF docker load --input $DOCKER_ESP_IDF shell: bash + + - name: Tag Local Image + run: | + docker tag espressif/idf:${{ inputs.toolchain_version }} espressif/idf:tinyusb + docker images + shell: bash diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fde9400a7..547763bd8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,7 +51,6 @@ jobs: # Build CMake # --------------------------------------- cmake: - # if: false needs: set-matrix uses: ./.github/workflows/build_util.yml strategy: @@ -60,55 +59,44 @@ jobs: toolchain: # - 'arm-clang' is built by circle-ci in PR - 'aarch64-gcc' + - 'arm-gcc' - 'msp430-gcc' - 'riscv-gcc' with: build-system: 'cmake' toolchain: ${{ matrix.toolchain }} - build-args: ${{ toJSON(fromJSON(needs.set-matrix.outputs.json)[matrix.toolchain].family) }} - one-per-family: ${{ github.event_name != 'pull_request' }} + build-args: ${{ toJSON(fromJSON(needs.set-matrix.outputs.json)[matrix.toolchain]) }} + one-per-family: ${{ github.event_name == 'push' }} # --------------------------------------- - # Build CMake arm-gcc - # only build with push, for PR: all board is built by circle-ci - # --------------------------------------- - cmake-arm-gcc: - if: github.event_name == 'push' - needs: set-matrix - uses: ./.github/workflows/build_util.yml - with: - build-system: 'cmake' - toolchain: 'arm-gcc' - build-args: ${{ toJSON(fromJSON(needs.set-matrix.outputs.json)['arm-gcc'].family) }} - one-per-family: true - - # --------------------------------------- - # Build Make + # Build Make (built by circle-ci in PR, only build on push here) # --------------------------------------- make: - # if: false + if: github.event_name == 'push' needs: set-matrix uses: ./.github/workflows/build_util.yml strategy: fail-fast: false matrix: toolchain: - # 'arm-clang' would be built by circle-ci - - 'aarch64-gcc' + # 'arm-clang' - 'arm-gcc' + - 'aarch64-gcc' - 'msp430-gcc' - 'riscv-gcc' - 'rx-gcc' + - 'esp-idf' # build-system is ignored with: build-system: 'make' toolchain: ${{ matrix.toolchain }} - build-args: ${{ toJSON(fromJSON(needs.set-matrix.outputs.json)[matrix.toolchain].family) }} - one-per-family: ${{ github.event_name != 'pull_request' }} + build-args: ${{ toJSON(fromJSON(needs.set-matrix.outputs.json)[matrix.toolchain]) }} + one-per-family: true # --------------------------------------- # Build Make on Windows/MacOS # --------------------------------------- make-os: + if: github.event_name == 'pull_request' uses: ./.github/workflows/build_util.yml strategy: fail-fast: false @@ -121,34 +109,18 @@ jobs: build-args: '["stm32h7"]' one-per-family: true - # --------------------------------------- - # Build Espressif - # --------------------------------------- - espressif: - # if: false - uses: ./.github/workflows/build_util.yml - strategy: - fail-fast: false - matrix: - board: - - 'espressif_kaluga_1' - - 'espressif_s3_devkitm' - with: - build-system: 'cmake' - toolchain: 'esp-idf' - toolchain_version: 'v5.1.1' - build-args: '["-b${{ matrix.board }}"]' - # --------------------------------------- # Build IAR on HFP self-hosted + # Since IAR Token secret is not passed to forked PR, only build on PR from the same repo # --------------------------------------- arm-iar: - # if: false - if: github.repository_owner == 'hathach' + if: github.repository_owner == 'hathach' && github.event_name == 'push' needs: set-matrix runs-on: [self-hosted, Linux, X64, hifiphile] env: - BUILD_ARGS: ${{ join(fromJSON(needs.set-matrix.outputs.json)['arm-iar'].family, ' ') }} + BUILD_ARGS: ${{ join(fromJSON(needs.set-matrix.outputs.json)['arm-iar'], ' ') }} + IAR_LMS_CLOUD_URL: ${{ vars.IAR_LMS_CLOUD_URL }} + IAR_LMS_BEARER_TOKEN: ${{ secrets.IAR_LMS_BEARER_TOKEN }} steps: - name: Clean workspace run: | @@ -156,6 +128,11 @@ jobs: rm -rf "${{ github.workspace }}" mkdir -p "${{ github.workspace }}" + - name: Toolchain version + run: | + echo IAR_LMS_CLOUD_URL=$IAR_LMS_CLOUD_URL + iccarm --version + - name: Checkout TinyUSB uses: actions/checkout@v4 @@ -165,7 +142,23 @@ jobs: - name: Build run: python3 tools/build.py --one-per-family --toolchain iar $BUILD_ARGS - - name: Test on actual hardware (hardware in the loop) - if: github.event_name == 'pull_request' + # --------------------------------------- + # Zephyr + # --------------------------------------- + zephyr: + if: github.event_name == 'push' + runs-on: ubuntu-latest + steps: + - name: Checkout TinyUSB + uses: actions/checkout@v4 + + - name: Setup Zephyr project + uses: zephyrproject-rtos/action-zephyr-setup@v1 + with: + app-path: examples + toolchains: arm-zephyr-eabi + + - name: Build run: | - python3 test/hil/hil_test.py hfp.json + west build -b pca10056 -d examples/device/cdc_msc/build examples/device/cdc_msc -- -DRTOS=zephyr + west build -b pca10056 -d examples/device/msc_dual_lun/build examples/device/msc_dual_lun -- -DRTOS=zephyr diff --git a/.github/workflows/build_util.yml b/.github/workflows/build_util.yml index e983f06d1..2de68c6f3 100644 --- a/.github/workflows/build_util.yml +++ b/.github/workflows/build_util.yml @@ -9,9 +9,6 @@ on: toolchain: required: true type: string - toolchain_version: - required: false - type: string build-args: required: true type: string @@ -19,6 +16,10 @@ on: required: false default: false type: boolean + upload-artifacts: + required: false + default: false + type: boolean os: required: false type: string @@ -40,7 +41,6 @@ jobs: uses: ./.github/actions/setup_toolchain with: toolchain: ${{ inputs.toolchain }} - toolchain_version: ${{ inputs.toolchain_version }} - name: Get Dependencies uses: ./.github/actions/get_deps @@ -60,8 +60,22 @@ jobs: - name: Build run: | if [ "${{ inputs.toolchain }}" == "esp-idf" ]; then - docker run --rm -v $PWD:/project -w /project espressif/idf:${{ inputs.toolchain_version }} python3 tools/build.py ${{ matrix.arg }} + docker run --rm -v $PWD:/project -w /project espressif/idf:tinyusb python tools/build.py ${{ matrix.arg }} else python tools/build.py -s ${{ inputs.build-system }} ${{ steps.setup-toolchain.outputs.build_option }} ${{ steps.set-one-per-family.outputs.build_option }} ${{ matrix.arg }} fi shell: bash + + - name: Upload Artifacts for Hardware Testing + if: ${{ inputs.upload-artifacts }} + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.arg }} + path: | + cmake-build/cmake-build-*/*/*/*.elf + cmake-build/cmake-build-*/*/*/*.bin + cmake-build/cmake-build-*/*/*/*.bin + cmake-build/cmake-build-*/*/*/bootloader/bootloader.bin + cmake-build/cmake-build-*/*/*/partition_table/partition-table.bin + cmake-build/cmake-build-*/*/*/config.env + cmake-build/cmake-build-*/*/*/flash_args diff --git a/.github/workflows/ci_set_matrix.py b/.github/workflows/ci_set_matrix.py old mode 100644 new mode 100755 index a56bd4214..410508246 --- a/.github/workflows/ci_set_matrix.py +++ b/.github/workflows/ci_set_matrix.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 import json # toolchain, url @@ -6,6 +7,7 @@ toolchain_list = [ "arm-clang", "arm-iar", "arm-gcc", + "esp-idf", "msp430-gcc", "riscv-gcc", "rx-gcc" @@ -22,6 +24,7 @@ family_list = { "lpc11 lpc13 lpc15": ["arm-gcc", "arm-clang"], "lpc17 lpc18 lpc40 lpc43": ["arm-gcc", "arm-clang"], "lpc51 lpc54 lpc55": ["arm-gcc", "arm-clang"], + "max32650 max32666 max32690 max78002": ["arm-gcc"], "mcx": ["arm-gcc"], "mm32": ["arm-gcc"], "msp430": ["msp430-gcc"], @@ -30,15 +33,20 @@ family_list = { "ra": ["arm-gcc"], "rp2040": ["arm-gcc"], "rx": ["rx-gcc"], - "samd11 samd21 saml2x": ["arm-gcc", "arm-clang"], + "samd11 saml2x": ["arm-gcc", "arm-clang"], + "samd21": ["arm-gcc", "arm-clang"], "samd5x_e5x samg": ["arm-gcc", "arm-clang"], - "stm32f0 stm32f1 stm32f2 stm32f3": ["arm-gcc", "arm-clang", "arm-iar"], + "stm32c0 stm32f0 stm32f1 stm32f2 stm32f3": ["arm-gcc", "arm-clang", "arm-iar"], "stm32f4": ["arm-gcc", "arm-clang", "arm-iar"], "stm32f7": ["arm-gcc", "arm-clang", "arm-iar"], "stm32g0 stm32g4 stm32h5": ["arm-gcc", "arm-clang", "arm-iar"], "stm32h7": ["arm-gcc", "arm-clang", "arm-iar"], - "stm32l0 stm32l4 stm32u5 stm32wb": ["arm-gcc", "arm-clang", "arm-iar"], + "stm32l0 stm32l4": ["arm-gcc", "arm-clang", "arm-iar"], + "stm32u5 stm32wb": ["arm-gcc", "arm-clang", "arm-iar"], "xmc4000": ["arm-gcc"], + "-bespressif_kaluga_1": ["esp-idf"], + "-bespressif_s3_devkitm": ["esp-idf"], + "-bespressif_p4_function_ev": ["esp-idf"], } @@ -47,15 +55,7 @@ def set_matrix_json(): for toolchain in toolchain_list: filtered_families = [family for family, supported_toolchain in family_list.items() if toolchain in supported_toolchain] - - # always add board in hfp.json for arm-iar - if toolchain == 'arm-iar': - with open('test/hil/hfp.json') as f: - hfp_data = json.load(f) - hfp_boards = [f"-b{board['name']}" for board in hfp_data['boards']] - filtered_families = filtered_families + hfp_boards - - matrix[toolchain] = {"family": filtered_families} + matrix[toolchain] = filtered_families print(json.dumps(matrix)) diff --git a/.github/workflows/hil_test.yml b/.github/workflows/hil_test.yml index d02f13e05..c890933ec 100644 --- a/.github/workflows/hil_test.yml +++ b/.github/workflows/hil_test.yml @@ -18,69 +18,52 @@ concurrency: cancel-in-progress: true env: - HIL_JSON: test/hil/rpi.json + HIL_JSON: test/hil/tinyusb.json jobs: - # --------------------------------------- - # Build Non Espressif - # --------------------------------------- - build: - if: github.repository_owner == 'hathach' + set-matrix: runs-on: ubuntu-latest outputs: - BOARDS_LIST: ${{ steps.parse_hil_json.outputs.BOARDS_LIST }} + json: ${{ steps.set-matrix-json.outputs.matrix }} steps: - name: Checkout TinyUSB uses: actions/checkout@v4 - - name: Parse HIL json - id: parse_hil_json + - name: Generate matrix json + id: set-matrix-json run: | - sudo apt install -y jq + MATRIX_JSON=$(python test/hil/hil_ci_set_matrix.py ${{ env.HIL_JSON }}) + echo "matrix=$MATRIX_JSON" + echo "matrix=$MATRIX_JSON" >> $GITHUB_OUTPUT - # Non-Espresif boards - BOARDS_LIST=$(jq -r '.boards[] | select(.flasher != "esptool") | "-b " + .name' ${{ env.HIL_JSON }} | tr '\n' ' ') - echo "BOARDS_LIST=$BOARDS_LIST" - echo "BOARDS_LIST=$BOARDS_LIST" >> $GITHUB_ENV - echo "BOARDS_LIST=$BOARDS_LIST" >> $GITHUB_OUTPUT - - - name: Setup arm-gcc toolchain - uses: ./.github/actions/setup_toolchain - with: - toolchain: 'arm-gcc' - - - name: Setup risv-gcc toolchain - uses: ./.github/actions/setup_toolchain - with: - toolchain: 'riscv-gcc' - - - name: Get Dependencies - uses: ./.github/actions/get_deps - with: - arg: ${{ env.BOARDS_LIST }} - - - name: Build - run: python tools/build.py $BOARDS_LIST - - - name: Upload Artifacts for Hardware Testing - uses: actions/upload-artifact@v4 - with: - name: hil_rpi - path: | - cmake-build/cmake-build-*/*/*/*.elf - cmake-build/cmake-build-*/*/*/*.bin + # --------------------------------------- + # Build arm-gcc + # --------------------------------------- + build: + if: github.repository_owner == 'hathach' + needs: set-matrix + uses: ./.github/workflows/build_util.yml + strategy: + fail-fast: false + matrix: + toolchain: + - 'arm-gcc' + - 'esp-idf' + with: + build-system: 'cmake' + toolchain: ${{ matrix.toolchain }} + build-args: ${{ toJSON(fromJSON(needs.set-matrix.outputs.json)[matrix.toolchain]) }} + one-per-family: true + upload-artifacts: true # --------------------------------------- # Hardware in the loop (HIL) - # self-hosted running on an RPI. For attached hardware checkout test/hil/rpi.json + # self-hosted on local VM, for attached hardware checkout HIL_JSON # --------------------------------------- - hil-rpi: + hil-tinyusb: if: github.repository_owner == 'hathach' - needs: - - build - runs-on: [self-hosted, ARM64, rpi, hardware-in-the-loop] - env: - BOARDS_LIST: "${{ needs.build-esp.outputs.BOARDS_LIST }} ${{ needs.build.outputs.BOARDS_LIST }}" + needs: build + runs-on: [self-hosted, X64, hathach, hardware-in-the-loop] steps: - name: Clean workspace run: | @@ -88,13 +71,6 @@ jobs: rm -rf "${{ github.workspace }}" mkdir -p "${{ github.workspace }}" - # USB bus on rpi is not stable, reset it before testing -# - name: Reset USB bus -# run: | -# echo "1-2" | sudo tee /sys/bus/usb/drivers/usb/unbind -# sleep 5 -# echo "1-2" | sudo tee /sys/bus/usb/drivers/usb/bind - - name: Checkout TinyUSB uses: actions/checkout@v4 with: @@ -108,8 +84,47 @@ jobs: - name: Test on actual hardware run: | - echo "BOARDS_LIST=$BOARDS_LIST" - echo "::group::{cmake-build contents}" - tree cmake-build - echo "::endgroup::" - python3 test/hil/hil_test.py $BOARDS_LIST ${{ env.HIL_JSON }} + ls cmake-build/ + python3 test/hil/hil_test.py ${{ env.HIL_JSON }} + + # --------------------------------------- + # Hardware in the loop (HIL) + # self-hosted by HFP, build with IAR toolchain, for attached hardware checkout test/hil/hfp.json + # Since IAR Token secret is not passed to forked PR, only build on PR from the same repo + # --------------------------------------- + hil-hfp: + if: github.repository_owner == 'hathach' && github.event.pull_request.head.repo.fork == false + runs-on: [self-hosted, Linux, X64, hifiphile] + env: + IAR_LMS_CLOUD_URL: ${{ vars.IAR_LMS_CLOUD_URL }} + IAR_LMS_BEARER_TOKEN: ${{ secrets.IAR_LMS_BEARER_TOKEN }} + steps: + - name: Clean workspace + run: | + echo "Cleaning up previous run" + rm -rf "${{ github.workspace }}" + mkdir -p "${{ github.workspace }}" + + - name: Toolchain version + run: | + echo IAR_LMS_CLOUD_URL=$IAR_LMS_CLOUD_URL + iccarm --version + + - name: Checkout TinyUSB + uses: actions/checkout@v4 + + - name: Get build boards + run: | + MATRIX_JSON=$(python test/hil/hil_ci_set_matrix.py test/hil/hfp.json) + BUILD_ARGS=$(echo $MATRIX_JSON | jq -r '.["arm-gcc"] | join(" ")') + echo "BUILD_ARGS=$BUILD_ARGS" + echo "BUILD_ARGS=$BUILD_ARGS" >> $GITHUB_ENV + + - name: Get Dependencies + run: python3 tools/get_deps.py $BUILD_ARGS + + - name: Build + run: python3 tools/build.py --toolchain iar $BUILD_ARGS + + - name: Test on actual hardware (hardware in the loop) + run: python3 test/hil/hil_test.py hfp.json diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 379a22ee2..ed0efd66e 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -29,10 +29,12 @@ jobs: #ceedling test:all - name: Run pre-commit - uses: pre-commit/action@v3.0.0 + uses: pre-commit/action@v3.0.1 - name: Build Fuzzer run: | + sudo apt install libc++-dev libc++abi-dev + clang --version export CC=clang export CXX=clang++ fuzz_harness=$(ls -d test/fuzz/device/*/) diff --git a/.gitignore b/.gitignore index f2150a26f..5638a09db 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,28 @@ html latex +*.a *.d *.o *.P -*.map *.axf *.bin +*.elf +*.env +*.ind +*.log +*.map +*.obj *.jlink *.emSession -*.elf -*.ind -.env +*.ninja* +*.eww +*.ewp +*.ewt +*.ewd +*.hex +cmake_install.cmake +CMakeCache.txt +settings/ .settings/ .vscode/ .gdb_history @@ -32,3 +44,11 @@ __pycache__ cmake-build-* sdkconfig .PVS-Studio +.vscode/ +build +CMakeFiles +Debug +RelWithDebInfo +Release +BrowseInfo +.cmake_build diff --git a/.idea/cmake.xml b/.idea/cmake.xml index 729309ebb..7365e13a8 100644 --- a/.idea/cmake.xml +++ b/.idea/cmake.xml @@ -2,40 +2,33 @@ - - + + + + + + + - + + + - + - - - - - - - - - - - - - - - + @@ -49,7 +42,28 @@ - + + + + + + + + + + + + + + + + + + + + + + @@ -65,22 +79,66 @@ + + - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -89,48 +147,13 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - @@ -140,6 +163,10 @@ + + + + \ No newline at end of file diff --git a/.idea/debugServers/rp2040.xml b/.idea/debugServers/rp2040.xml new file mode 100644 index 000000000..f451611f3 --- /dev/null +++ b/.idea/debugServers/rp2040.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/debugServers/rp2350.xml b/.idea/debugServers/rp2350.xml new file mode 100644 index 000000000..5e092f3c4 --- /dev/null +++ b/.idea/debugServers/rp2350.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/debugServers/rt1060.xml b/.idea/debugServers/rt1060.xml new file mode 100644 index 000000000..3325cc81f --- /dev/null +++ b/.idea/debugServers/rt1060.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/debugServers/rt1064.xml b/.idea/debugServers/rt1064.xml new file mode 100644 index 000000000..4dc38ef63 --- /dev/null +++ b/.idea/debugServers/rt1064.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/debugServers/sam21.xml b/.idea/debugServers/sam21.xml new file mode 100644 index 000000000..d8763b33b --- /dev/null +++ b/.idea/debugServers/sam21.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/debugServers/sam51.xml b/.idea/debugServers/sam51.xml new file mode 100644 index 000000000..0d15ff856 --- /dev/null +++ b/.idea/debugServers/sam51.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations/k64f.xml b/.idea/runConfigurations/k64f.xml new file mode 100644 index 000000000..6db0dd74e --- /dev/null +++ b/.idea/runConfigurations/k64f.xml @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations/kl25.xml b/.idea/runConfigurations/kl25.xml index 96c208dde..bb7e1707b 100644 --- a/.idea/runConfigurations/kl25.xml +++ b/.idea/runConfigurations/kl25.xml @@ -1,7 +1,8 @@ - - + + +