From a6384b77f5bb48cd33cd99c5fbe982639a07f968 Mon Sep 17 00:00:00 2001 From: Johan Gunnarsson Date: Sun, 2 Jun 2019 10:59:22 +0200 Subject: [PATCH] build-boot: Refactor build boot scripts --- metascripts/rebuild-boots | 4 ++-- scripts/build-boot | 32 ++++++++++++++++++++++++++++++++ scripts/build-boot-rpi | 16 ++++------------ scripts/build-boot-sunxi | 34 ++++++++++++++++------------------ 4 files changed, 54 insertions(+), 32 deletions(-) create mode 100755 scripts/build-boot diff --git a/metascripts/rebuild-boots b/metascripts/rebuild-boots index dee7b64..f81c142 100755 --- a/metascripts/rebuild-boots +++ b/metascripts/rebuild-boots @@ -14,14 +14,14 @@ mkdir -p /tmp/debimg/log || exit D=$(mktemp -d -p "${LOG_DIR}" rebuild-boots-XXXXXX) IFS=, -grep -vE "^#|^\s*$" boards.csv | tail -n +2 | while read BOARD_ID MODEL MAKE CHIP DEFCONFIG TUPLE TYPE DTB _ +grep -vE "^#|^\s*$" boards.csv | tail -n +2 | while read BOARD_ID MODEL MAKE CHIP_ID DEFCONFIG TUPLE TYPE DTB _ do docker run --rm \ -v "${ARTIFACTS_DIR}":/artifacts \ -v "${CACHE_DIR}":/mnt/cache:ro \ -e U_BOOT_TARBALL=/mnt/cache/u-boot-latest.tar.bz2 \ debimg \ - build-boot-"${TYPE}" /artifacts/boot-"${BOARD_ID}" "${DEFCONFIG}" "${TUPLE}" \ + build-boot "${BOARD_ID}" "${CHIP_ID}" "${DEFCONFIG}" "${TUPLE}" \ >"${D}"/"log-${BOARD_ID}.txt" 2>&1 && rm "${D}"/"log-${BOARD_ID}.txt" done diff --git a/scripts/build-boot b/scripts/build-boot new file mode 100755 index 0000000..91ba959 --- /dev/null +++ b/scripts/build-boot @@ -0,0 +1,32 @@ +#!/bin/sh +# Build SD card image + +BOARD_ID="${1}" # For example "bananapi" +CHIP_ID="${2}" # For example "allwinner-a10" +DEFCONFIG="${3}" # For example "Bananapi_defconfig" +TUPLE="${4}" # For example "arm-linux-gnueabihf" + +set -e + +# Create fresh empty directory +TMP=$(mktemp -d tmp.XXXXXX) +cd "${TMP}" + +build-image tmp.img + +case "${CHIP_ID}" in +allwinner*) + build-boot-sunxi "${BOARD_ID}" "${CHIP_ID}" "${DEFCONFIG}" "${TUPLE}" + ;; +bcm2836|bcm2837) + build-boot-rpi "${BOARD_ID}" "${CHIP_ID}" "${DEFCONFIG}" "${TUPLE}" + ;; +*) + echo Unknown CHIP_ID + exit 1 + ;; +esac + +truncate -s 32M tmp.img +gzip tmp.img +cp tmp.img.gz "/artifacts/boot-${BOARD_ID}.bin.gz" diff --git a/scripts/build-boot-rpi b/scripts/build-boot-rpi index 438c368..123a171 100755 --- a/scripts/build-boot-rpi +++ b/scripts/build-boot-rpi @@ -1,17 +1,13 @@ #!/bin/sh # Build SD card image -IMAGE="${1}" # For example "boot-bananapi.bin" -DEFCONFIG="${2}" # For example "Bananapi_defconfig" -TUPLE="${3}" # For example "arm-linux-gnueabihf" +BOARD_ID="${1}" # For example "bananapi" +CHIP_ID="${2}" # For example "allwinner-a10" +DEFCONFIG="${3}" # For example "Bananapi_defconfig" +TUPLE="${4}" # For example "arm-linux-gnueabihf" set -e -# Create fresh empty directory -TMP=$(mktemp -d tmp.XXXXXX) -cd "${TMP}" - -build-image tmp.img build-u_boot "${DEFCONFIG}" "${TUPLE}" # Write Raspberry Pi boot config @@ -56,7 +52,3 @@ mcopy -v -i vfat.img u-boot/u-boot.bin config.txt fixup*.dat start*.elf bootcode # Copy FAT partition to image dd if=vfat.img of=tmp.img bs=1K seek=1K - -truncate -s 32M tmp.img -gzip tmp.img -cp tmp.img.gz "${IMAGE}.bin.gz" diff --git a/scripts/build-boot-sunxi b/scripts/build-boot-sunxi index 6037203..43ca3f8 100755 --- a/scripts/build-boot-sunxi +++ b/scripts/build-boot-sunxi @@ -1,29 +1,27 @@ #!/bin/sh # Build SD card image -IMAGE="${1}" # For example "boot-bananapi.bin" -DEFCONFIG="${2}" # For example "Bananapi_defconfig" -TUPLE="${3}" # For example "arm-linux-gnueabihf" -PLAT="${4}" # For example "sun50i_a64" +BOARD_ID="${1}" # For example "bananapi" +CHIP_ID="${2}" # For example "allwinner-a10" +DEFCONFIG="${3}" # For example "Bananapi_defconfig" +TUPLE="${4}" # For example "arm-linux-gnueabihf" set -e -# Create fresh empty directory -TMP=$(mktemp -d tmp.XXXXXX) -cd "${TMP}" +case "${CHIP_ID}" in +*a64|*h5) + build-atf sun50i_a64 "${TUPLE}" + export BL31="$(pwd)/arm-trusted-firmware/build/sun50i_a64/debug/bl31.bin" + ;; +*h6) + build-atf sun50i_h6 "${TUPLE}" + export BL31="$(pwd)/arm-trusted-firmware/build/sun50i_h6/debug/bl31.bin" + ;; +*) + ;; +esac -if [ "${TUPLE}" = "aarch64-linux-gnu" ] -then - build-atf "${PLAT}" "${TUPLE}" - export BL31="$(pwd)/arm-trusted-firmware/build/${PLAT}/debug/bl31.bin" -fi - -build-image tmp.img build-u_boot "${DEFCONFIG}" "${TUPLE}" # Copy U-Boot to 8192 bytes from start dd if=u-boot/u-boot-sunxi-with-spl.bin of=tmp.img bs=1K seek=8 - -truncate -s 32M tmp.img -gzip tmp.img -cp tmp.img.gz "${IMAGE}.bin.gz"