From bfa7134e12aa0b8d7055dc8061c5c8d618416ad9 Mon Sep 17 00:00:00 2001 From: zador-blood-stained Date: Thu, 9 Mar 2017 00:13:25 +0300 Subject: [PATCH] Add overlay prefixes to sunxi boot script Add overlay "fixup" scripts support Rework sunxi boot script to use "prefix" env variable --- build-all.sh | 2 +- config/boards/bananapim3.wip | 1 + config/boards/lime-a33.conf | 3 ++- config/bootscripts/boot-sunxi.cmd | 33 +++++++++++++++++++++---------- config/sources/pine64.conf | 2 ++ config/sources/sun4i.conf | 2 ++ config/sources/sun50iw2.conf | 2 ++ config/sources/sun7i.conf | 2 ++ config/sources/sun8i.conf | 2 ++ distributions.sh | 3 +++ 10 files changed, 40 insertions(+), 12 deletions(-) diff --git a/build-all.sh b/build-all.sh index d49bcfd1db..a6fa10e673 100644 --- a/build-all.sh +++ b/build-all.sh @@ -199,7 +199,7 @@ for line in "${buildlist[@]}"; do CPUMIN CPUMAX UBOOT_VER KERNEL_VER GOVERNOR BOOTSIZE UBOOT_TOOLCHAIN KERNEL_TOOLCHAIN PACKAGE_LIST_EXCLUDE KERNEL_IMAGE_TYPE \ write_uboot_platform family_tweaks 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 buildtext RELEASE UBOOT_ALT_GCC KERNEL_ALT_GCC IMAGE_TYPE + MODULES_BLACKLIST_DEV MOUNT SDCARD BOOTPATCHDIR buildtext RELEASE UBOOT_ALT_GCC KERNEL_ALT_GCC IMAGE_TYPE OVERLAY_PREFIX read BOARD BRANCH RELEASE BUILD_DESKTOP <<< $line n=$[$n+1] diff --git a/config/boards/bananapim3.wip b/config/boards/bananapim3.wip index dcf27f6cb2..3a2efe1f88 100644 --- a/config/boards/bananapim3.wip +++ b/config/boards/bananapim3.wip @@ -7,6 +7,7 @@ MODULES_NEXT="" CLI_TARGET="" DESKTOP_TARGET="" KERNEL_TARGET="dev" +OVERLAY_PREFIX="sun8i-a83t" # BOARDRATING="" HARDWARE="https://linux-sunxi.org/Banana_Pi_M3" diff --git a/config/boards/lime-a33.conf b/config/boards/lime-a33.conf index df5e88130f..39dd1d1113 100644 --- a/config/boards/lime-a33.conf +++ b/config/boards/lime-a33.conf @@ -6,7 +6,8 @@ MODULES="hci_uart gpio_sunxi rfcomm hidp bonding spi_sun7i 8021q a20_tp" MODULES_NEXT="" CLI_TARGET="jessie:next" KERNEL_TARGET="next" +OVERLAY_PREFIX="sun8i-a33" # BOARDRATING="" HARDWARE="https://www.olimex.com/Products/OLinuXino/A33/A33-OLinuXino/open-source-hardware" -FORUMS="http://forum.armbian.com/index.php/forum/13-allwinner-h3" \ No newline at end of file +FORUMS="http://forum.armbian.com/index.php/forum/13-allwinner-h3" diff --git a/config/bootscripts/boot-sunxi.cmd b/config/bootscripts/boot-sunxi.cmd index 96956c379a..d638e4c8e0 100644 --- a/config/bootscripts/boot-sunxi.cmd +++ b/config/bootscripts/boot-sunxi.cmd @@ -21,7 +21,8 @@ itest.b *0x28 == 0x03 && echo "U-boot loaded from SPI" echo "Boot script loaded from ${devtype}" -if load ${devtype} 0 ${load_addr} /boot/armbianEnv.txt || load ${devtype} 0 ${load_addr} armbianEnv.txt; then +if test -e ${devtype} 0 ${prefix}armbianEnv.txt; then + load ${devtype} 0 ${load_addr} ${prefix}armbianEnv.txt env import -t ${load_addr} ${filesize} fi @@ -37,32 +38,44 @@ setenv bootargs "root=${rootdev} rootwait rootfstype=${rootfstype} ${consoleargs if test "${disp_mem_reserves}" = "off"; then setenv bootargs "${bootargs} sunxi_ve_mem_reserve=0 sunxi_g2d_mem_reserve=0 sunxi_fb_mem_reserve=16"; fi if test "${docker_optimizations}" = "on"; then setenv bootargs "${bootargs} cgroup_enable=memory swapaccount=1"; fi -load ${devtype} 0 ${ramdisk_addr_r} /boot/uInitrd || load ${devtype} 0 ${ramdisk_addr_r} uInitrd -load ${devtype} 0 ${kernel_addr_r} /boot/zImage || load ${devtype} 0 ${kernel_addr_r} zImage +load ${devtype} 0 ${ramdisk_addr_r} ${prefix}uInitrd +load ${devtype} 0 ${kernel_addr_r} ${prefix}zImage -if load ${devtype} 0 0x00000000 /boot/.next || load ${devtype} 0 0x00000000 .next; then - load ${devtype} 0 ${fdt_addr_r} /boot/dtb/${fdtfile} || load ${devtype} 0 ${fdt_addr_r} /dtb/${fdtfile} +if test -e ${devtype} 0 "${prefix}.next"; then + echo "Found mainline kernel configuration" + load ${devtype} 0 ${fdt_addr_r} ${prefix}dtb/${fdtfile} fdt addr ${fdt_addr_r} fdt resize for overlay_file in ${overlays}; do - if load ${devtype} 0 ${load_addr} boot/dtb/overlay/${overlay_file}.dtbo || load ${devtype} 0 ${load_addr} dtb/overlay/${overlay_file}.dtbo; then - echo "Applying kernel provided DT overlay ${overlay_file}.dtbo" + if load ${devtype} 0 ${load_addr} ${prefix}dtb/overlay/${overlay_prefix}-${overlay_file}.dtbo; then + echo "Applying kernel provided DT overlay ${overlay_prefix}-${overlay_file}.dtbo" fdt apply ${load_addr} || setenv overlay_error "true" fi done for overlay_file in ${user_overlays}; do - if load ${devtype} 0 ${load_addr} boot/overlay-user/${overlay_file}.dtbo || load ${devtype} 0 ${load_addr} overlay-user/${overlay_file}.dtbo; then + if load ${devtype} 0 ${load_addr} ${prefix}overlay-user/${overlay_file}.dtbo; then echo "Applying user provided DT overlay ${overlay_file}.dtbo" fdt apply ${load_addr} || setenv overlay_error "true" fi done if test "${overlay_error}" = "true"; then echo "Error applying DT overlays, restoring original DT" - load ${devtype} 0 ${fdt_addr_r} /boot/dtb/${fdtfile} || load ${devtype} 0 ${fdt_addr_r} /dtb/${fdtfile} + load ${devtype} 0 ${fdt_addr_r} ${prefix}dtb/${fdtfile} + else + if load ${devtype} 0 ${load_addr} ${prefix}dtb/overlay/${overlay_prefix}-fixup.scr; then + echo "Applying kernel provided DT fixup script (${overlay_prefix}-fixup.scr)" + source ${load_addr} + fi + if test -e ${devtype} 0 ${prefix}fixup.scr; then + load ${devtype} 0 ${load_addr} fixup.scr + echo "Applying user provided fixup script (fixup.scr)" + source ${load_addr} + fi fi bootz ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r} else - load ${devtype} 0 ${fdt_addr_r} /boot/script.bin || load ${devtype} 0 ${fdt_addr_r} script.bin + echo "Found legacy kernel configuration" + load ${devtype} 0 ${fdt_addr_r} ${prefix}script.bin bootz ${kernel_addr_r} ${ramdisk_addr_r} fi diff --git a/config/sources/pine64.conf b/config/sources/pine64.conf index 7db3711449..b2b2790016 100644 --- a/config/sources/pine64.conf +++ b/config/sources/pine64.conf @@ -1,6 +1,8 @@ source "${BASH_SOURCE%/*}/sunxi64_common.inc" +OVERLAY_PREFIX='sun50i-a64' + case $BRANCH in default) BOOTSOURCE='https://github.com/zador-blood-stained/u-boot-pine64-armbian.git' diff --git a/config/sources/sun4i.conf b/config/sources/sun4i.conf index 730243380c..b6e33aaa3f 100644 --- a/config/sources/sun4i.conf +++ b/config/sources/sun4i.conf @@ -1,6 +1,8 @@ source "${BASH_SOURCE%/*}/sunxi_common.inc" +OVERLAY_PREFIX='sun4i-a10' + case $BRANCH in default) KERNELSOURCE='https://github.com/linux-sunxi/linux-sunxi' diff --git a/config/sources/sun50iw2.conf b/config/sources/sun50iw2.conf index fb9b41fdee..6528396f17 100644 --- a/config/sources/sun50iw2.conf +++ b/config/sources/sun50iw2.conf @@ -1,6 +1,8 @@ source "${BASH_SOURCE%/*}/sunxi64_common.inc" +OVERLAY_PREFIX='sun50i-h5' + BOOTENV_FILE='sun50iw2-next.txt' [[ -z $CPUMIN ]] && CPUMIN=480000 diff --git a/config/sources/sun7i.conf b/config/sources/sun7i.conf index 4eca449105..3da3884635 100644 --- a/config/sources/sun7i.conf +++ b/config/sources/sun7i.conf @@ -1,6 +1,8 @@ source "${BASH_SOURCE%/*}/sunxi_common.inc" +OVERLAY_PREFIX='sun7i-a20' + case $BRANCH in default) KERNELSOURCE='https://github.com/linux-sunxi/linux-sunxi' diff --git a/config/sources/sun8i.conf b/config/sources/sun8i.conf index 1a70f3cebc..272d353075 100644 --- a/config/sources/sun8i.conf +++ b/config/sources/sun8i.conf @@ -1,6 +1,8 @@ source "${BASH_SOURCE%/*}/sunxi_common.inc" +[[ -z $OVERLAY_PREFIX ]] && OVERLAY_PREFIX='sun8i-h3' + case $BRANCH in default) BOOTENV_FILE='sun8i-default.txt' diff --git a/distributions.sh b/distributions.sh index 3a0107afde..2107995b32 100644 --- a/distributions.sh +++ b/distributions.sh @@ -85,6 +85,9 @@ install_common() fi fi + [[ -n $OVERLAY_PREFIX && -f $CACHEDIR/$SDCARD/boot/armbianEnv.txt ]] && \ + echo "overlay_prefix=$OVERLAY_PREFIX" >> $CACHEDIR/$SDCARD/boot/armbianEnv.txt + # initial date for fake-hwclock date -u '+%Y-%m-%d %H:%M:%S' > $CACHEDIR/$SDCARD/etc/fake-hwclock.data