From 1bd47db6881ce9fef5a787e9f4dfe74244c8d3cb Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 5 Nov 2021 11:02:30 +1100 Subject: [PATCH] tools/autobuild: Automatically build all mimxrt, rp2 and samd boards. Any board with a board.json file will be automatically built. Signed-off-by: Damien George --- tools/autobuild/autobuild.sh | 12 ++++-- tools/autobuild/build-boards.sh | 53 ++++++++++++++++++++++++++ tools/autobuild/build-mimxrt-latest.sh | 38 ------------------ tools/autobuild/build-rp2-latest.sh | 32 ---------------- 4 files changed, 62 insertions(+), 73 deletions(-) create mode 100755 tools/autobuild/build-boards.sh delete mode 100755 tools/autobuild/build-mimxrt-latest.sh delete mode 100755 tools/autobuild/build-rp2-latest.sh diff --git a/tools/autobuild/autobuild.sh b/tools/autobuild/autobuild.sh index a14c7890f7..bb77b178b9 100755 --- a/tools/autobuild/autobuild.sh +++ b/tools/autobuild/autobuild.sh @@ -39,6 +39,9 @@ fi # get directory of this script for access to other build scripts AUTODIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +# source additional functions +source ${AUTODIR}/build-boards.sh + # make local directory to put firmware LOCAL_FIRMWARE=/tmp/autobuild-firmware-$$ mkdir -p ${LOCAL_FIRMWARE} @@ -71,10 +74,13 @@ ${AUTODIR}/build-esp8266-latest.sh ${FW_TAG} ${LOCAL_FIRMWARE} cd ../esp32 ${AUTODIR}/build-esp32-latest.sh ${IDF_PATH_V42} ${FW_TAG} ${LOCAL_FIRMWARE} ${AUTODIR}/build-esp32-latest.sh ${IDF_PATH_V43} ${FW_TAG} ${LOCAL_FIRMWARE} -cd ../rp2 -${AUTODIR}/build-rp2-latest.sh ${FW_TAG} ${LOCAL_FIRMWARE} + cd ../mimxrt -${AUTODIR}/build-mimxrt-latest.sh ${FW_TAG} ${LOCAL_FIRMWARE} +build_mimxrt_boards ${FW_TAG} ${LOCAL_FIRMWARE} +cd ../rp2 +build_rp2_boards ${FW_TAG} ${LOCAL_FIRMWARE} +cd ../samd +build_samd_boards ${FW_TAG} ${LOCAL_FIRMWARE} popd diff --git a/tools/autobuild/build-boards.sh b/tools/autobuild/build-boards.sh new file mode 100755 index 0000000000..1ae795a7a7 --- /dev/null +++ b/tools/autobuild/build-boards.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# +# The functions in this file can be run independently to build boards. +# For example: +# +# $ source build-boards.sh +# $ MICROPY_AUTOBUILD_MAKE=make build_rp2_boards -latest /tmp + +function build_boards { + # check/get parameters + if [ $# -lt 4 ]; then + echo "usage: $0 " + return 1 + fi + + fw_tag=$1 + dest_dir=$2 + check_file=$3 + shift + shift + shift + + # check we are in the correct directory + if [ ! -r $check_file ]; then + echo "must be in directory containing $check_file" + return 1 + fi + + for board_json in $(find boards/ -name board.json); do + board=$(echo $board_json | awk -F '/' '{ print $2 }') + descr=$(cat $board_json | python3 -c "import json,sys; print(json.load(sys.stdin).get('id', '$board'))") + build_dir=/tmp/micropython-build-$board + + echo "building $descr $board" + $MICROPY_AUTOBUILD_MAKE BOARD=$board BUILD=$build_dir || return 1 + for ext in $@; do + mv $build_dir/firmware.$ext $dest_dir/$descr$fw_tag.$ext + done + rm -rf $build_dir + done +} + +function build_mimxrt_boards { + build_boards $1 $2 modmimxrt.c bin hex +} + +function build_rp2_boards { + build_boards $1 $2 modrp2.c uf2 +} + +function build_samd_boards { + build_boards $1 $2 samd_soc.c uf2 +} diff --git a/tools/autobuild/build-mimxrt-latest.sh b/tools/autobuild/build-mimxrt-latest.sh deleted file mode 100755 index fea5da81c5..0000000000 --- a/tools/autobuild/build-mimxrt-latest.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -# function for building firmware -function do_build() { - descr=$1 - board=$2 - ext=$3 - shift - shift - shift - echo "building $descr $board" - build_dir=/tmp/mimxrt-build-$board - $MICROPY_AUTOBUILD_MAKE $@ BOARD=$board BUILD=$build_dir || exit 1 - mv $build_dir/firmware.$ext $dest_dir/$descr$fw_tag.$ext - rm -rf $build_dir -} - -# check/get parameters -if [ $# != 2 ]; then - echo "usage: $0 " - exit 1 -fi - -fw_tag=$1 -dest_dir=$2 - -# check we are in the correct directory -if [ ! -r modmimxrt.c ]; then - echo "must be in mimxrt directory" - exit 1 -fi - -# build the boards -do_build TEENSY40 TEENSY40 hex -do_build TEENSY41 TEENSY41 hex -do_build MIMXRT1010_EVK MIMXRT1010_EVK bin -do_build MIMXRT1020_EVK MIMXRT1020_EVK bin -do_build MIMXRT1050_EVK MIMXRT1050_EVK bin diff --git a/tools/autobuild/build-rp2-latest.sh b/tools/autobuild/build-rp2-latest.sh deleted file mode 100755 index 5124686e21..0000000000 --- a/tools/autobuild/build-rp2-latest.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -# function for building firmware -function do_build() { - descr=$1 - board=$2 - shift - shift - echo "building $descr $board" - build_dir=/tmp/rp2-build-$board - $MICROPY_AUTOBUILD_MAKE $@ BOARD=$board BUILD=$build_dir || exit 1 - mv $build_dir/firmware.uf2 $dest_dir/$descr$fw_tag.uf2 - rm -rf $build_dir -} - -# check/get parameters -if [ $# != 2 ]; then - echo "usage: $0 " - exit 1 -fi - -fw_tag=$1 -dest_dir=$2 - -# check we are in the correct directory -if [ ! -r modrp2.c ]; then - echo "must be in rp2 directory" - exit 1 -fi - -# build the boards -do_build rp2-pico PICO