From 634110e78748517c3ea3fdc2d1599695510fd3b1 Mon Sep 17 00:00:00 2001 From: zador-blood-stained Date: Sun, 6 Aug 2017 16:52:24 +0300 Subject: [PATCH] Split ATF compilation into a separate function --- config/sources/sun50iw1.conf | 7 ++ config/sources/sunxi64_common.inc | 6 ++ lib/build-all.sh | 3 +- lib/compilation.sh | 72 ++++++++++++++++++- lib/configuration.sh | 1 + lib/main.sh | 8 +++ .../set-lpddr3-dram-voltage.patch} | 6 +- .../set-lpddr3-dram-voltage.patch} | 6 +- .../atf-sun50iw2}/add-pc2-shutdown.patch | 6 +- 9 files changed, 102 insertions(+), 13 deletions(-) rename patch/{u-boot/u-boot-sun50i-dev/board_pine64so/atf-set-lpddr3-dram-voltage.patch => atf/atf-sun50iw1/board_pine64so/set-lpddr3-dram-voltage.patch} (72%) rename patch/{u-boot/u-boot-sun50i-dev/board_pinebook-a64/atf-set-lpddr3-dram-voltage.patch => atf/atf-sun50iw1/board_pinebook-a64/set-lpddr3-dram-voltage.patch} (72%) rename patch/{u-boot/u-boot-sun50i-dev => atf/atf-sun50iw2}/add-pc2-shutdown.patch (88%) diff --git a/config/sources/sun50iw1.conf b/config/sources/sun50iw1.conf index c5c14b121..9c4c74b5b 100644 --- a/config/sources/sun50iw1.conf +++ b/config/sources/sun50iw1.conf @@ -7,6 +7,13 @@ case $BRANCH in default) # for backwards compatibility LINUXFAMILY=pine64 + + ATFSOURCE='https://github.com/longsleep/arm-trusted-firmware' + ATFDIR='arm-trusted-firmware-sunxi-bsp' + ATFBRANCH='branch:allwinner-a64-bsp' + ATF_USE_GCC='> 6.0' + ATF_TARGET_MAP='PLAT=sun50iw1p1 DEBUG=1 bl31;;build/sun50iw1p1/debug/bl31.bin' + BOOTSOURCE='https://github.com/armbian/u-boot-pine64-legacy.git' BOOTDIR='u-boot-pine64' BOOTBRANCH='branch:master' diff --git a/config/sources/sunxi64_common.inc b/config/sources/sunxi64_common.inc index 254051880..80328c57f 100644 --- a/config/sources/sunxi64_common.inc +++ b/config/sources/sunxi64_common.inc @@ -9,6 +9,12 @@ case $BRANCH in ;; dev) + ATFSOURCE='https://github.com/apritzel/arm-trusted-firmware' + ATFDIR='arm-trusted-firmware-sunxi-mainline' + ATFBRANCH='branch:allwinner-stable' + ATF_USE_GCC='> 6.0' + ATF_TARGET_MAP='PLAT=sun50iw1p1 DEBUG=1 bl31;;build/sun50iw1p1/debug/bl31.bin' + BOOTSOURCE='https://github.com/zador-blood-stained/u-boot-sun50i.git' BOOTDIR='u-boot-sun50i' BOOTBRANCH='branch:master' diff --git a/lib/build-all.sh b/lib/build-all.sh index 37bbb994c..d7ccd76d8 100644 --- a/lib/build-all.sh +++ b/lib/build-all.sh @@ -200,7 +200,8 @@ for line in "${buildlist[@]}"; do CPUMIN CPUMAX UBOOT_VER KERNEL_VER GOVERNOR BOOTSIZE BOOTFS_TYPE UBOOT_TOOLCHAIN KERNEL_TOOLCHAIN PACKAGE_LIST_EXCLUDE KERNEL_IMAGE_TYPE \ write_uboot_platform family_tweaks family_tweaks_bsp setup_write_uboot_platform BOOTSCRIPT UBOOT_TARGET_MAP LOCALVERSION UBOOT_COMPILER KERNEL_COMPILER \ MODULES MODULES_NEXT MODULES_DEV INITRD_ARCH HAS_UUID_SUPPORT BOOTENV_FILE BOOTDELAY MODULES_BLACKLIST MODULES_BLACKLIST_NEXT \ - MODULES_BLACKLIST_DEV MOUNT SDCARD BOOTPATCHDIR KERNELPATCHDIR buildtext RELEASE IMAGE_TYPE OVERLAY_PREFIX ASOUND_STATE + MODULES_BLACKLIST_DEV MOUNT SDCARD BOOTPATCHDIR KERNELPATCHDIR buildtext RELEASE IMAGE_TYPE OVERLAY_PREFIX ASOUND_STATE \ + ATF_COMPILER ATF_USE_GCC ATFSOURCE ATFDIR ATFBRANCH ATFSOURCEDIR read BOARD BRANCH RELEASE BUILD_DESKTOP <<< $line n=$[$n+1] diff --git a/lib/compilation.sh b/lib/compilation.sh index bfee5ae86..d82d6e046 100644 --- a/lib/compilation.sh +++ b/lib/compilation.sh @@ -8,6 +8,7 @@ # https://github.com/armbian/build/ # Functions: +# compile_atf # compile_uboot # compile_kernel # compile_sunxi_tools @@ -21,6 +22,66 @@ # userpatch_create # overlayfs_wrapper +compile_atf() +{ + if [[ $CLEAN_LEVEL == *make* ]]; then + display_alert "Cleaning" "$ATFSOURCEDIR" "info" + (cd $SRC/cache/sources/$ATFSOURCEDIR; make clean > /dev/null 2>&1) + fi + + if [[ $USE_OVERLAYFS == yes ]]; then + local atfdir=$(overlayfs_wrapper "wrap" "$SRC/cache/sources/$ATFSOURCEDIR" "atf_${LINUXFAMILY}_${BRANCH}") + else + local atfdir="$SRC/cache/sources/$ATFSOURCEDIR" + fi + cd "$atfdir" + + display_alert "Compiling ATF" "" "info" + + local toolchain="" + if [[ -n $ATF_USE_GCC ]]; then + toolchain=$(find_toolchain "$ATF_COMPILER" "$ATF_USE_GCC") + [[ -z $toolchain ]] && exit_with_error "Could not find required toolchain" "${ATF_COMPILER}gcc $ATF_USE_GCC" + fi + + display_alert "Compiler version" "${ATF_COMPILER}gcc $(eval ${toolchain:+env PATH=$toolchain:$PATH} ${ATF_COMPILER}gcc -dumpversion)" "info" + + local target_make=$(cut -d';' -f1 <<< $ATF_TARGET_MAP) + local target_patchdir=$(cut -d';' -f2 <<< $ATF_TARGET_MAP) + local target_files=$(cut -d';' -f3 <<< $ATF_TARGET_MAP) + + [[ $FORCE_CHECKOUT == yes ]] && advanced_patch "atf" "atf-${LINUXFAMILY}" "$BOARD" "$target_patchdir" "$BRANCH" "${LINUXFAMILY}-${BOARD}-${BRANCH}" + + # create patch for manual source changes + [[ $CREATE_PATCHES == yes ]] && userpatch_create "atf" + + eval CCACHE_BASEDIR="$(pwd)" ${toolchain:+env PATH=$toolchain:$PATH} \ + 'make $target_make $CTHREADS CROSS_COMPILE="$CCACHE $ATF_COMPILER"' 2>&1 \ + ${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/debug/compilation.log'} \ + ${OUTPUT_DIALOG:+' | dialog --backtitle "$backtitle" --progressbox "Compiling ATF..." $TTY_Y $TTY_X'} \ + ${OUTPUT_VERYSILENT:+' >/dev/null 2>/dev/null'} + + [[ ${PIPESTATUS[0]} -ne 0 ]] && exit_with_error "ATF compilation failed" + + local atftempdir=$SRC/.tmp/atf-${LINUXFAMILY}-${BOARD}-${BRANCH} + mkdir -p $atftempdir + + # copy files to temp directory + for f in $target_files; do + local f_src=$(cut -d':' -f1 <<< $f) + if [[ $f == *:* ]]; then + local f_dst=$(cut -d':' -f2 <<< $f) + else + local f_dst=$(basename $f_src) + fi + [[ ! -f $f_src ]] && exit_with_error "ATF file not found" "$(basename $f_src)" + cp $f_src $atftempdir/$f_dst + done + + # copy license file to pack it to u-boot package later + [[ -f license.md ]] && cp license.md $atftempdir/ +} + compile_uboot() { # not optimal, but extra cleaning before overlayfs_wrapper should keep sources directory clean @@ -73,6 +134,11 @@ compile_uboot() # create patch for manual source changes [[ $CREATE_PATCHES == yes ]] && userpatch_create "u-boot" + if [[ -n $ATFSOURCE ]]; then + local atftempdir=$SRC/.tmp/atf-${LINUXFAMILY}-${BOARD}-${BRANCH} + cp -Rv $atftempdir/*.bin . + fi + eval CCACHE_BASEDIR="$(pwd)" ${toolchain:+env PATH=$toolchain:$PATH} \ 'make $CTHREADS $BOOTCONFIG CROSS_COMPILE="$CCACHE $UBOOT_COMPILER"' 2>&1 \ ${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/debug/compilation.log'} \ @@ -150,11 +216,12 @@ compile_uboot() # copy license files from typical locations [[ -f COPYING ]] && cp COPYING $SRC/.tmp/$uboot_name/usr/lib/u-boot/LICENSE [[ -f Licenses/README ]] && cp Licenses/README $SRC/.tmp/$uboot_name/usr/lib/u-boot/LICENSE - [[ -f arm-trusted-firmware/license.md ]] && cp arm-trusted-firmware/license.md $SRC/.tmp/$uboot_name/usr/lib/u-boot/LICENSE.atf + [[ -n $atftempdir && -f $atftempdir/license.md ]] && cp $atftempdir/license.md $SRC/.tmp/$uboot_name/usr/lib/u-boot/LICENSE.atf display_alert "Building deb" "${uboot_name}.deb" "info" (cd $SRC/.tmp/; eval 'dpkg -b $uboot_name 2>&1' ${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/debug/compilation.log'}) rm -rf $SRC/.tmp/$uboot_name + [[ -n $$atftempdir ]] && rm -rf $atftempdir [[ ! -f $SRC/.tmp/${uboot_name}.deb ]] && exit_with_error "Building u-boot package failed" @@ -304,7 +371,6 @@ compile_kernel() compile_sunxi_tools() { - fetch_from_repo "https://github.com/linux-sunxi/sunxi-tools.git" "sunxi-tools" "branch:master" # Compile and install only if git commit hash changed cd $SRC/cache/sources/sunxi-tools # need to check if /usr/local/bin/sunxi-fexc to detect new Docker containers with old cached sources @@ -360,7 +426,7 @@ find_toolchain() # advanced_patch # # parameters: -# : u-boot, kernel +# : u-boot, kernel, atf # : u-boot: u-boot, u-boot-neo; kernel: sun4i-default, sunxi-next, ... # : cubieboard, cubieboard2, cubietruck, ... # : optional subdirectory diff --git a/lib/configuration.sh b/lib/configuration.sh index ef50d4066..7cde8ec6a 100644 --- a/lib/configuration.sh +++ b/lib/configuration.sh @@ -81,6 +81,7 @@ case $ARCH in arm64) [[ -z $KERNEL_COMPILER ]] && KERNEL_COMPILER="aarch64-linux-gnu-" [[ -z $UBOOT_COMPILER ]] && UBOOT_COMPILER="aarch64-linux-gnu-" + ATF_COMPILER="aarch64-linux-gnu-" [[ -z $INITRD_ARCH ]] && INITRD_ARCH=arm64 QEMU_BINARY="qemu-aarch64-static" ARCHITECTURE=arm64 diff --git a/lib/main.sh b/lib/main.sh index 160e7e363..d18c73ff4 100644 --- a/lib/main.sh +++ b/lib/main.sh @@ -252,6 +252,11 @@ if [[ $IGNORE_UPDATES != yes ]]; then BOOTSOURCEDIR=$BOOTDIR/${BOOTBRANCH##*:} fetch_from_repo "$KERNELSOURCE" "$KERNELDIR" "$KERNELBRANCH" "yes" LINUXSOURCEDIR=$KERNELDIR/${KERNELBRANCH##*:} + if [[ -n $ATFSOURCE ]]; then + fetch_from_repo "$ATFSOURCE" "$ATFDIR" "$ATFBRANCH" "yes" + ATFSOURCEDIR=$ATFDIR/${ATFBRANCH##*:} + fi + fetch_from_repo "https://github.com/linux-sunxi/sunxi-tools" "sunxi-tools" "branch:master" fetch_from_repo "https://github.com/armbian/config" "armbian-config" "branch:dev" fi @@ -271,6 +276,9 @@ done # Compile u-boot if packed .deb does not exist if [[ ! -f $DEST/debs/${CHOSEN_UBOOT}_${REVISION}_${ARCH}.deb ]]; then + if [[ -n $ATFSOURCE ]]; then + compile_atf + fi compile_uboot fi diff --git a/patch/u-boot/u-boot-sun50i-dev/board_pine64so/atf-set-lpddr3-dram-voltage.patch b/patch/atf/atf-sun50iw1/board_pine64so/set-lpddr3-dram-voltage.patch similarity index 72% rename from patch/u-boot/u-boot-sun50i-dev/board_pine64so/atf-set-lpddr3-dram-voltage.patch rename to patch/atf/atf-sun50iw1/board_pine64so/set-lpddr3-dram-voltage.patch index 9b5b814e2..41d419d11 100644 --- a/patch/u-boot/u-boot-sun50i-dev/board_pine64so/atf-set-lpddr3-dram-voltage.patch +++ b/patch/atf/atf-sun50iw1/board_pine64so/set-lpddr3-dram-voltage.patch @@ -1,7 +1,7 @@ -diff --git a/arm-trusted-firmware/plat/sun50iw1p1/sunxi_power.c b/arm-trusted-firmware/plat/sun50iw1p1/sunxi_power.c +diff --git a/plat/sun50iw1p1/sunxi_power.c b/plat/sun50iw1p1/sunxi_power.c index 0c2487e..30708f4 100644 ---- a/arm-trusted-firmware/plat/sun50iw1p1/sunxi_power.c -+++ b/arm-trusted-firmware/plat/sun50iw1p1/sunxi_power.c +--- a/plat/sun50iw1p1/sunxi_power.c ++++ b/plat/sun50iw1p1/sunxi_power.c @@ -258,12 +258,10 @@ static int pmic_setup(void) * changes. This should be further confined once we are able to * reliably detect a Pine64 board. diff --git a/patch/u-boot/u-boot-sun50i-dev/board_pinebook-a64/atf-set-lpddr3-dram-voltage.patch b/patch/atf/atf-sun50iw1/board_pinebook-a64/set-lpddr3-dram-voltage.patch similarity index 72% rename from patch/u-boot/u-boot-sun50i-dev/board_pinebook-a64/atf-set-lpddr3-dram-voltage.patch rename to patch/atf/atf-sun50iw1/board_pinebook-a64/set-lpddr3-dram-voltage.patch index 9b5b814e2..41d419d11 100644 --- a/patch/u-boot/u-boot-sun50i-dev/board_pinebook-a64/atf-set-lpddr3-dram-voltage.patch +++ b/patch/atf/atf-sun50iw1/board_pinebook-a64/set-lpddr3-dram-voltage.patch @@ -1,7 +1,7 @@ -diff --git a/arm-trusted-firmware/plat/sun50iw1p1/sunxi_power.c b/arm-trusted-firmware/plat/sun50iw1p1/sunxi_power.c +diff --git a/plat/sun50iw1p1/sunxi_power.c b/plat/sun50iw1p1/sunxi_power.c index 0c2487e..30708f4 100644 ---- a/arm-trusted-firmware/plat/sun50iw1p1/sunxi_power.c -+++ b/arm-trusted-firmware/plat/sun50iw1p1/sunxi_power.c +--- a/plat/sun50iw1p1/sunxi_power.c ++++ b/plat/sun50iw1p1/sunxi_power.c @@ -258,12 +258,10 @@ static int pmic_setup(void) * changes. This should be further confined once we are able to * reliably detect a Pine64 board. diff --git a/patch/u-boot/u-boot-sun50i-dev/add-pc2-shutdown.patch b/patch/atf/atf-sun50iw2/add-pc2-shutdown.patch similarity index 88% rename from patch/u-boot/u-boot-sun50i-dev/add-pc2-shutdown.patch rename to patch/atf/atf-sun50iw2/add-pc2-shutdown.patch index 356bf70ef..b1d9dcbbc 100644 --- a/patch/u-boot/u-boot-sun50i-dev/add-pc2-shutdown.patch +++ b/patch/atf/atf-sun50iw2/add-pc2-shutdown.patch @@ -1,7 +1,7 @@ -diff --git a/arm-trusted-firmware/plat/sun50iw1p1/plat_pm.c b/arm-trusted-firmware/plat/sun50iw1p1/plat_pm.c +diff --git a/plat/sun50iw1p1/plat_pm.c b/plat/sun50iw1p1/plat_pm.c index ec26248..ed53871 100644 ---- a/arm-trusted-firmware/plat/sun50iw1p1/plat_pm.c -+++ b/arm-trusted-firmware/plat/sun50iw1p1/plat_pm.c +--- a/plat/sun50iw1p1/plat_pm.c ++++ b/plat/sun50iw1p1/plat_pm.c @@ -254,7 +254,59 @@ static int32_t sunxi_affinst_suspend_finish(uint64_t mpidr, ******************************************************************************/ static void __dead2 sunxi_system_off(void)