From 87b9b5bf63d0b3998f834d69eff7d3ce6ae7fc4f Mon Sep 17 00:00:00 2001 From: Han Gao Date: Thu, 20 Jul 2023 07:06:27 +0800 Subject: [PATCH] feat: add build-ci & multi-chips kernel build Signed-off-by: Han Gao --- .github/workflows/kernel-build.yml | 108 +++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 .github/workflows/kernel-build.yml diff --git a/.github/workflows/kernel-build.yml b/.github/workflows/kernel-build.yml new file mode 100644 index 0000000000000..e2bc2d2151037 --- /dev/null +++ b/.github/workflows/kernel-build.yml @@ -0,0 +1,108 @@ +name: sophgo-kernel + +on: + push: + pull_request: + workflow_dispatch: + schedule: + - cron: "0 2 * * *" + +jobs: + build-kernel: + strategy: + fail-fast: false + matrix: + include: + - name: thead-gcc + toolchain_tripe: riscv64-unknown-linux-gnu- + board: pioneer + - name: gcc-12 + toolchain_tripe: riscv64-linux-gnu- + board: pioneer + - name: thead-gcc + toolchain_tripe: riscv64-unknown-linux-gnu- + board: pisces + - name: gcc-12 + toolchain_tripe: riscv64-linux-gnu- + board: pisces + + runs-on: ubuntu-22.04 + env: + xuetie_toolchain: https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1663142514282 + toolchain_file_name: Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1-20220906.tar.gz + wget_alias: 'wget --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 -t 0' + ARCH: riscv + KBUILD_BUILD_USER: riscv + KBUILD_BUILD_HOST: riscv-builder + KDEB_COMPRESS: xz + board: ${{ matrix.board }} + CROSS_COMPILE: ${{ matrix.toolchain_tripe }} + + steps: + - name: Update Apt Cache + run: sudo apt update + + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + # this might remove tools that are actually needed, + # if set to "true" but frees about 6 GB + tool-cache: true + # all of these default to true, but feel free to set to + # "false" if necessary for your workflow + android: true + dotnet: true + haskell: true + large-packages: true + docker-images: true + swap-storage: true + + - name: Checkout + uses: actions/checkout@v4 + with: + path: kernel + + - name: Install software + run: | + sudo apt install -y gdisk dosfstools g++-12-riscv64-linux-gnu build-essential \ + libncurses-dev gawk flex bison openssl libssl-dev tree \ + dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf \ + device-tree-compiler xz-utils devscripts ccache debhelper + sudo update-alternatives --install \ + /usr/bin/riscv64-linux-gnu-gcc riscv64-gcc /usr/bin/riscv64-linux-gnu-gcc-12 10 + sudo update-alternatives --install \ + /usr/bin/riscv64-linux-gnu-g++ riscv64-g++ /usr/bin/riscv64-linux-gnu-g++-12 10 + + - name: Compile Kernel && Install + run: | + mkdir -p artifact + ${wget_alias} ${xuetie_toolchain}/${toolchain_file_name} + tar -xvf ${toolchain_file_name} -C /opt + pushd kernel + export PATH="/opt/Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1/bin:$PATH" + export KDEB_PKGVERSION="$(date "+%Y.%m.%d.%H.%M")+$(git rev-parse --short HEAD)" + make sophgo_mango_ubuntu_defconfig + if [[ ${{ matrix.name }} = "thead-gcc" ]]; then + echo "_xtheadc kernel" + echo "CONFIG_THEAD_ISA=y" >> .config + fi + if [[ ${{ matrix.board }} = "pisces" ]]; then + echo "pisces kernel" + sed -i 's/# CONFIG_SOPHGO_MULTI_CHIP_CLOCK_SYNC is not set/CONFIG_SOPHGO_MULTI_CHIP_CLOCK_SYNC=y/' .config + fi + echo "CONFIG_VECTOR=y" >> .config + make -j$(nproc) dtbs + make -j$(nproc) bindeb-pkg LOCALVERSION="-${board}" + sudo cp -v arch/riscv/boot/dts/sophgo/*.dtb ../artifact + sudo cp -v ../*.deb ../artifact + popd + + - name: compress + run: tar -zcvf sophgo-kernel-${{ matrix.name }}-${{ matrix.board }}.tar.gz artifact + + - name: 'Upload Artifact' + uses: actions/upload-artifact@v3 + with: + name: sophgo-kernel-${{ matrix.name }}-${{ matrix.board }}.tar.gz + path: sophgo-kernel-${{ matrix.name }}-${{ matrix.board }}.tar.gz + retention-days: 20