diff --git a/common.sh b/common.sh index 1cb2d66ff2..6512790801 100644 --- a/common.sh +++ b/common.sh @@ -77,6 +77,7 @@ compile_uboot() [[ \$DEVICE == /dev/null ]] && exit 0 [[ -z \$DEVICE ]] && DEVICE="/dev/mmcblk0" [[ \$(type -t setup_write_uboot_platform) == function ]] && setup_write_uboot_platform + echo "Updating u-boot on device \$DEVICE" >&2 write_uboot_platform \$DIR \$DEVICE exit 0 EOF diff --git a/config/bootscripts/boot-sunxi.cmd b/config/bootscripts/boot-sunxi.cmd index 4a24fb4720..b389e9bdbe 100644 --- a/config/bootscripts/boot-sunxi.cmd +++ b/config/bootscripts/boot-sunxi.cmd @@ -19,7 +19,11 @@ fi if test "${console}" = "display" || test "${console}" = "both"; then setenv consoleargs "console=tty1"; fi if test "${console}" = "serial" || test "${console}" = "both"; then setenv consoleargs "${consoleargs} console=ttyS0,115200"; fi -setenv bootargs "root=${rootdev} rootwait rootfstype=${rootfstype} ${consoleargs} cgroup_enable=memory swapaccount=1 hdmi.audio=EDID:0 disp.screen0_output_mode=${disp_mode} panic=10 consoleblank=0 enforcing=0 loglevel=${verbosity} ${extraargs} ${extraboardargs}" +# get PARTUUID of first partition on SD/eMMC it was loaded from +# mmc 0 is always mapped to device u-boot (2016.09+) was loaded from +part uuid mmc 0:1 partuuid + +setenv bootargs "root=${rootdev} rootwait rootfstype=${rootfstype} ${consoleargs} cgroup_enable=memory swapaccount=1 hdmi.audio=EDID:0 disp.screen0_output_mode=${disp_mode} panic=10 consoleblank=0 enforcing=0 loglevel=${verbosity} ubootpart=${partuuid} ${extraargs} ${extraboardargs}" 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 diff --git a/config/sources/sunxi_common.inc b/config/sources/sunxi_common.inc index ca0bea57fb..d181eb5256 100644 --- a/config/sources/sunxi_common.inc +++ b/config/sources/sunxi_common.inc @@ -32,15 +32,23 @@ write_uboot_platform() setup_write_uboot_platform() { - # This may cause overwriting u-boot for android or other non-Armbian OS installed on eMMC - # so don't run this function by default - [[ ! -f /var/lib/armbian/allow_uboot_update ]] && return - for dev in $(lsblk -d -n -p -o NAME); do - if grep -q 'eGON.BT0' <(dd if=$dev bs=32 skip=256 count=1 status=none); then - # Assuming that only one device with SPL signature is present - echo "SPL signature found on $dev" >&2 - DEVICE=$dev - break - fi - done + if grep -q "ubootpart" /proc/cmdline; then + local tmp=$(cat /proc/cmdline) + tmp="${tmp##*ubootpart=}" + tmp="${tmp%% *}" + [[ -n $tmp ]] && local part=$(findfs PARTUUID=$tmp 2>/dev/null) + [[ -n $part ]] && local dev=$(lsblk -n -o PKNAME $part 2>/dev/null) + [[ -n $dev ]] && DEVICE="/dev/$dev" + elif [[ -f /var/lib/armbian/force_search_uboot ]]; then + # This may cause overwriting u-boot for android or other non-Armbian OS installed on eMMC + # so don't run this function by default + for dev in $(lsblk -d -n -p -o NAME); do + if grep -q 'eGON.BT0' <(dd if=$dev bs=32 skip=256 count=1 status=none); then + # Assuming that only one device with SPL signature is present + echo "SPL signature found on $dev" >&2 + DEVICE=$dev + break + fi + done + fi }