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 <damien@micropython.org>
This commit is contained in:
Damien George 2021-11-05 11:02:30 +11:00
parent fa873ce67c
commit 1bd47db688
4 changed files with 62 additions and 73 deletions

View File

@ -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

53
tools/autobuild/build-boards.sh Executable file
View File

@ -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 <fw-tag> <dest-dir> <check-file> <exts...>"
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
}

View File

@ -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 <fw-tag> <dest-dir>"
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

View File

@ -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 <fw-tag> <dest-dir>"
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