mirror of https://github.com/OpenIPC/firmware.git
445 lines
14 KiB
YAML
445 lines
14 KiB
YAML
name: build
|
|
|
|
on:
|
|
pull_request:
|
|
types:
|
|
- synchronize
|
|
- reopened
|
|
- opened
|
|
push:
|
|
branches:
|
|
- 'master'
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: ${{github.head_ref || github.run_id}}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
MAX_KERNEL_SIZE: 0x200000
|
|
MAX_ROOTFS_SIZE: 0x500000
|
|
MAX_KERNEL_SIZE_ULTIMATE: 0x300000
|
|
MAX_ROOTFS_SIZE_ULTIMATE: 0xA00000
|
|
TG_OPTIONS: -s --connect-timeout 30 --retry 10 --http1.1 --verbose
|
|
TAG_NAME: latest
|
|
|
|
jobs:
|
|
toolchain:
|
|
name: Toolchain
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
platform:
|
|
- ak3918ev300
|
|
- dm36x
|
|
- fh8852v100
|
|
- fh8852v200
|
|
- gk7102
|
|
- gm8136
|
|
- hi3516cv100
|
|
- hi3516cv200
|
|
- hi3516cv300
|
|
- hi3516cv500
|
|
- hi3516ev200
|
|
- hi3519v101
|
|
- hi3536cv100
|
|
- msc313e
|
|
- msc316dc
|
|
- msc316dm
|
|
- nt98562
|
|
- rv1126
|
|
- s3l
|
|
- ssc335
|
|
- ssc338q
|
|
- t31
|
|
- t40
|
|
- xm510
|
|
- xm530
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Determine toolchain
|
|
run: |
|
|
BOARD=${{matrix.platform}}_lite
|
|
make BOARD=${BOARD} prepare
|
|
GCC=$(make BOARD=${BOARD} toolname)
|
|
echo GCC=${GCC} >> ${GITHUB_ENV}
|
|
URL=https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAG_NAME}/${GCC}.tgz
|
|
echo ${URL}
|
|
if ! wget --spider ${URL} 2> /dev/null; then
|
|
echo BUILD=true >> ${GITHUB_ENV}
|
|
fi
|
|
|
|
- name: Build toolchain
|
|
if: env.BUILD == 'true'
|
|
run: |
|
|
make BOARD=${{matrix.platform}}_lite br-sdk
|
|
SDK_FILE=$(find output/images -name *_sdk-buildroot.tar.gz)
|
|
mv ${SDK_FILE} ${GCC}.tgz
|
|
|
|
- name: Upload toolchain
|
|
if: ${{github.event_name != 'pull_request' && env.BUILD == 'true'}}
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
tag_name: temporary_tag
|
|
files: ${{env.GCC}}.tgz
|
|
|
|
buildroot:
|
|
name: Firmware
|
|
needs: toolchain
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
platform:
|
|
- hi3516cv100
|
|
- hi3518cv100
|
|
- hi3518ev100
|
|
- hi3516av100
|
|
- hi3516dv100
|
|
- hi3516cv200
|
|
- hi3518ev200
|
|
- hi3519v101
|
|
- hi3516av200
|
|
- hi3516cv300
|
|
- hi3516ev100
|
|
- hi3516cv500
|
|
- hi3516dv300
|
|
- hi3516av300
|
|
- hi3516ev200
|
|
- hi3516ev300
|
|
- hi3518ev300
|
|
- hi3516dv200
|
|
- hi3536cv100
|
|
- hi3536dv100
|
|
- gk7205v200
|
|
- gk7205v210
|
|
- gk7205v300
|
|
- gk7202v300
|
|
- gk7605v100
|
|
- t31
|
|
- t40
|
|
release:
|
|
- lite
|
|
- ultimate
|
|
include:
|
|
- platform: hi3518ev200
|
|
release: mini
|
|
- platform: hi3516cv300
|
|
release: mini
|
|
- platform: hi3516ev200
|
|
release: fpv
|
|
- platform: hi3516ev300
|
|
release: fpv
|
|
- platform: gk7205v200
|
|
release: fpv
|
|
- platform: gk7205v300
|
|
release: fpv
|
|
- platform: hi3516ev200
|
|
release: lte
|
|
- platform: hi3516ev300
|
|
release: lte
|
|
- platform: gk7205v200
|
|
release: lte
|
|
- platform: gk7205v300
|
|
release: lte
|
|
|
|
# Original SDK test
|
|
- platform: gk7205v200
|
|
release: original
|
|
custom: onlyci
|
|
|
|
# MVP
|
|
- platform: fh8852v100
|
|
release: lite
|
|
- platform: fh8852v200
|
|
release: lite
|
|
- platform: gm8136
|
|
release: lite
|
|
- platform: nt98562
|
|
release: lite
|
|
- platform: nt98566
|
|
release: lite
|
|
- platform: rv1109
|
|
release: lite
|
|
- platform: rv1126
|
|
release: lite
|
|
- platform: ssc335
|
|
release: lite
|
|
- platform: ssc335de
|
|
release: lite
|
|
- platform: ssc337
|
|
release: lite
|
|
- platform: ssc337de
|
|
release: lite
|
|
- platform: ssc338q
|
|
release: lite
|
|
- platform: t10
|
|
release: lite
|
|
- platform: t20
|
|
release: lite
|
|
- platform: t21
|
|
release: lite
|
|
- platform: t30
|
|
release: lite
|
|
- platform: xm510
|
|
release: lite
|
|
- platform: xm530
|
|
release: lite
|
|
- platform: xm550
|
|
release: lite
|
|
|
|
# TODO
|
|
- platform: ak3916ev300
|
|
release: lite
|
|
custom: onlyci
|
|
- platform: ak3918ev300
|
|
release: lite
|
|
custom: onlyci
|
|
- platform: dm36x
|
|
release: lite
|
|
custom: onlyci
|
|
- platform: gk7102
|
|
release: lite
|
|
- platform: gk7102s
|
|
release: lite
|
|
- platform: msc313e
|
|
release: lite
|
|
custom: onlyci
|
|
- platform: msc316dc
|
|
release: lite
|
|
custom: onlyci
|
|
- platform: msc316dm
|
|
release: lite
|
|
custom: onlyci
|
|
- platform: s3l
|
|
release: lite
|
|
custom: onlyci
|
|
- platform: ssc325
|
|
release: lite
|
|
custom: onlyci
|
|
|
|
exclude:
|
|
- platform: hi3516cv100
|
|
release: ultimate
|
|
- platform: hi3518cv100
|
|
release: ultimate
|
|
- platform: hi3518ev100
|
|
release: ultimate
|
|
- platform: hi3516cv200
|
|
release: ultimate
|
|
- platform: hi3519v101
|
|
release: ultimate
|
|
- platform: hi3516ev100
|
|
release: ultimate
|
|
- platform: hi3516cv500
|
|
release: ultimate
|
|
- platform: hi3516dv300
|
|
release: ultimate
|
|
- platform: hi3516av300
|
|
release: ultimate
|
|
- platform: hi3516dv200
|
|
release: ultimate
|
|
- platform: hi3536cv100
|
|
release: ultimate
|
|
- platform: hi3536dv100
|
|
release: ultimate
|
|
- platform: gk7605v100
|
|
release: ultimate
|
|
- platform: gk7205v210
|
|
release: ultimate
|
|
- platform: gk7202v300
|
|
release: ultimate
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Determine toolchain
|
|
run: |
|
|
BOARD=${{matrix.platform}}_lite
|
|
make BOARD=${BOARD} prepare
|
|
GCC=$(make BOARD=${BOARD} toolname)
|
|
echo GCC=${GCC} >> ${GITHUB_ENV}
|
|
URL=https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAG_NAME}/${GCC}.tgz
|
|
echo ${URL}
|
|
wget -q -c --retry-on-http-error=503 --timeout=15 ${URL}
|
|
|
|
- name: Setup ccache
|
|
if: github.event_name != 'pull_request'
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: /tmp/ccache
|
|
key: ${{env.GCC}}
|
|
|
|
- name: Restore ccache
|
|
if: github.event_name == 'pull_request'
|
|
uses: actions/cache/restore@v3
|
|
with:
|
|
path: /tmp/ccache
|
|
key: ${{env.GCC}}
|
|
|
|
- name: Build firmware
|
|
run: |
|
|
BOARD=${{matrix.platform}}_${{matrix.release}}
|
|
CONFIG=$(find br-ext-chip-* -name ${BOARD}_defconfig)
|
|
SDK=/tmp/extsdk
|
|
mkdir -p ${SDK}
|
|
tar xf ${GCC}.tgz --strip-components=1 -C ${SDK}
|
|
|
|
EXT=BR2_TOOLCHAIN_EXTERNAL
|
|
echo ${EXT}=y >> ${CONFIG}
|
|
echo ${EXT}_CUSTOM=y >> ${CONFIG}
|
|
echo ${EXT}_PREINSTALLED=y >> ${CONFIG}
|
|
echo ${EXT}_CXX=y >> ${CONFIG}
|
|
echo ${EXT}_PATH=\"${SDK}\" >> ${CONFIG}
|
|
|
|
PREFIX=$(ls -d ${SDK}/*openipc* | xargs basename)
|
|
LIBC=$(echo ${GCC} | cut -d "-" -f 3)
|
|
KVER=$(echo ${GCC} | cut -d "-" -f 4)
|
|
echo ${EXT}_CUSTOM_PREFIX=\"${PREFIX}\" >> ${CONFIG}
|
|
echo ${EXT}_CUSTOM_${LIBC^^}=y >> ${CONFIG}
|
|
echo ${EXT}_HEADERS_${KVER}=y >> ${CONFIG}
|
|
|
|
if [ ${LIBC} = "glibc" ]; then
|
|
RPC=${SDK}/${PREFIX}/sysroot/usr/include/rpc/rpc.h
|
|
check() { test -f $RPC && echo y || echo n; }
|
|
echo ${EXT}_INET_RPC=$(check) >> ${CONFIG}
|
|
elif [ ${LIBC} = "uclibc" ]; then
|
|
CFG=${SDK}/${PREFIX}/sysroot/usr/include/bits/uClibc_config.h
|
|
check() { grep -q "${1} 1" ${CFG} && echo y || echo n; }
|
|
echo ${EXT}_LOCALE=$(check __UCLIBC_HAS_LOCALE__) >> ${CONFIG}
|
|
echo ${EXT}_HAS_THREADS_DEBUG=$(check __PTHREADS_DEBUG_SUPPORT__) >> ${CONFIG}
|
|
echo ${EXT}_HAS_SSP=y >> ${CONFIG}
|
|
fi
|
|
|
|
echo BR2_CCACHE=y >> ${CONFIG}
|
|
echo BR2_CCACHE_DIR=\"/tmp/ccache\" >> ${CONFIG}
|
|
cat ${CONFIG}
|
|
|
|
GIT_HASH=$(git rev-parse --short ${GITHUB_SHA})
|
|
export GIT_HASH=${GIT_HASH}
|
|
export BRANCH=${GITHUB_REF_NAME}
|
|
echo GIT_HASH=${GIT_HASH} >> $GITHUB_ENV
|
|
|
|
make BOARD=${BOARD} all
|
|
IMAGES_DIR=${GITHUB_WORKSPACE}/output/images
|
|
pushd output/images
|
|
|
|
check_exceeded() {
|
|
ACTUAL=$(stat --printf="%s" ${1})
|
|
echo Debug ${1}: ${ACTUAL} vs ${2}...
|
|
if [ ${ACTUAL} -gt ${2} ]; then
|
|
OVERRUN=$((${ACTUAL}-${2}))
|
|
echo TG_NOTIFY=Warning, ${1} size exceeded by ${OVERRUN}... ${{matrix.platform}}_${{matrix.release}} >> $GITHUB_ENV
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
if [ -f uImage ]; then
|
|
# TODO: doesn't fit to lite
|
|
case ${{matrix.platform}} in
|
|
hi3516cv500|hi3516dv300|hi3516av300|ssc338q)
|
|
MAX_KERNEL_SIZE=${MAX_KERNEL_SIZE_ULTIMATE}
|
|
MAX_ROOTFS_SIZE=${MAX_ROOTFS_SIZE_ULTIMATE}
|
|
;;
|
|
esac
|
|
|
|
case ${{matrix.release}} in
|
|
lite|fpv|lte)
|
|
check_exceeded uImage ${MAX_KERNEL_SIZE}
|
|
check_exceeded rootfs.squashfs ${MAX_ROOTFS_SIZE}
|
|
;;
|
|
ultimate)
|
|
check_exceeded uImage ${MAX_KERNEL_SIZE_ULTIMATE}
|
|
check_exceeded rootfs.squashfs ${MAX_ROOTFS_SIZE_ULTIMATE}
|
|
;;
|
|
esac
|
|
|
|
NORFW_FILE=${IMAGES_DIR}/openipc.${{matrix.platform}}-nor-${{matrix.release}}.tgz
|
|
echo NORFW_FILE=${NORFW_FILE} >> ${GITHUB_ENV}
|
|
|
|
mv uImage uImage.${{matrix.platform}}
|
|
mv rootfs.squashfs rootfs.squashfs.${{matrix.platform}}
|
|
md5sum rootfs.squashfs.${{matrix.platform}} > rootfs.squashfs.${{matrix.platform}}.md5sum
|
|
md5sum uImage.${{matrix.platform}} > uImage.${{matrix.platform}}.md5sum
|
|
tar czf ${NORFW_FILE} uImage* *rootfs.squashfs.${{matrix.platform}}*
|
|
fi
|
|
|
|
if [ -f rootfs.ubifs ]; then
|
|
NANDFW_FILE=${IMAGES_DIR}/openipc.${{matrix.platform}}-nand-${{matrix.release}}.tgz
|
|
echo NANDFW_FILE=${NANDFW_FILE} >> ${GITHUB_ENV}
|
|
|
|
mv rootfs.ubi rootfs.ubi.${{matrix.platform}}
|
|
mv rootfs.ubifs rootfs.ubifs.${{matrix.platform}}
|
|
md5sum rootfs.ubifs.${{matrix.platform}} > rootfs.ubifs.${{matrix.platform}}.md5sum
|
|
case ${{matrix.platform}} in
|
|
rv*)
|
|
mv zboot.img boot.img.${{matrix.platform}}
|
|
md5sum boot.img.${{matrix.platform}} > boot.img.${{matrix.platform}}.md5sum
|
|
tar czf ${NANDFW_FILE} boot.img* *rootfs.ubi*.${{matrix.platform}}*
|
|
;;
|
|
*)
|
|
tar czf ${NANDFW_FILE} uImage* *rootfs.ubi*.${{matrix.platform}}*
|
|
;;
|
|
esac
|
|
fi
|
|
popd
|
|
|
|
- name: Upload firmware
|
|
if: ${{github.event_name != 'pull_request' && matrix.custom != 'onlyci'}}
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
tag_name: temporary_tag
|
|
files: |
|
|
${{env.NORFW_FILE}}
|
|
${{env.NANDFW_FILE}}
|
|
|
|
- name: Send error message to telegram channel
|
|
env:
|
|
TG_TOKEN: ${{secrets.TELEGRAM_TOKEN_BOT_OPENIPC}}
|
|
TG_CHANNEL: ${{secrets.TELEGRAM_CHANNEL_OPENIPC_DEV}}
|
|
if: ${{failure() && github.event_name != 'pull_request'}}
|
|
run: |
|
|
TG_NOTIFY="${TG_NOTIFY:=Warning, Buildroot compiling error... ${{matrix.platform}}_${{matrix.release}}}"
|
|
TG_HEADER=$(echo -e "\r\n$TG_NOTIFY \r\n\r\nCommit: $GIT_HASH \r\nBranch: $GITHUB_REF_NAME \r\nTag: $TAG_NAME \r\n\r\n\xE2\x9A\xA0 GitHub Actions")
|
|
curl $TG_OPTIONS -H "Content-Type: multipart/form-data" -X POST https://api.telegram.org/bot$TG_TOKEN/sendMessage \
|
|
-F chat_id=$TG_CHANNEL -F text="$TG_HEADER"
|
|
exit 2
|
|
|
|
- name: Send binary file to telegram channel
|
|
if: ${{github.event_name != 'pull_request' && matrix.custom != 'onlyci' && env.NORFW_FILE != ''}}
|
|
env:
|
|
TG_TOKEN: ${{secrets.TELEGRAM_TOKEN_BOT_OPENIPC}}
|
|
TG_CHANNEL: ${{secrets.TELEGRAM_CHANNEL_OPENIPC_DEV}}
|
|
run: |
|
|
TG_HEADER=$(echo -e "\r\nCommit: $GIT_HASH \r\nBranch: $GITHUB_REF_NAME \r\nTag: $TAG_NAME \r\n\r\n\xE2\x9C\x85 GitHub Actions")
|
|
curl $TG_OPTIONS -H "Content-Type: multipart/form-data" -X POST https://api.telegram.org/bot$TG_TOKEN/sendDocument \
|
|
-F chat_id=$TG_CHANNEL -F document="@$NORFW_FILE" -F caption="$TG_HEADER"
|
|
|
|
ci-build-check:
|
|
if: always()
|
|
runs-on: ubuntu-latest
|
|
name: CI buildcheck
|
|
needs: buildroot
|
|
steps:
|
|
- run: |
|
|
result=${{needs.buildroot.result}}
|
|
if [[ ${result} = "success" || ${result} = "skipped" ]]; then
|
|
exit 0
|
|
else
|
|
exit 1
|
|
fi
|