From bd5e3ed15976ee135d76bcc8063e2f5970b79d7a Mon Sep 17 00:00:00 2001
From: Alexey Min <alexey.min@gmail.com>
Date: Sat, 21 Dec 2019 19:04:15 +0300
Subject: [PATCH] pine64-pinetab: fix emmc booting (!801)

---
 device/device-pine64-pinetab/APKBUILD         |  4 ++--
 device/device-pine64-pinetab/uboot-script.cmd | 12 +++++++++++-
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/device/device-pine64-pinetab/APKBUILD b/device/device-pine64-pinetab/APKBUILD
index bd5ad803c..af431c26e 100644
--- a/device/device-pine64-pinetab/APKBUILD
+++ b/device/device-pine64-pinetab/APKBUILD
@@ -2,7 +2,7 @@
 pkgname="device-pine64-pinetab"
 pkgdesc="PINE64 PineTab"
 pkgver=0.1
-pkgrel=9
+pkgrel=10
 url="https://postmarketos.org"
 license="MIT"
 arch="aarch64"
@@ -75,7 +75,7 @@ nonfree_firmware() {
 }
 
 sha512sums="cdcae98f3dbd995689777c44f42749539e7ac17295693e5b64e528bb8b32203ad2a6c75f774ab513779b773793b474c1d3ec53ee25621e2b1d62989772b675c5  deviceinfo
-8f15bb62704ad5379c6f77c5ea766e69587a11829539cc339b486b72e248e04cc6202b505f12846f6537f259412f7749ce50d0b15227da182afe17fe7dd303e5  uboot-script.cmd
+1f3108007bd443f86ed8af2b2d84705c52ffcf73809a90ef5e4a1f618b73ab39baf8f8139d578c88e66f589464f8c47d53f72bf46f14b8fa78d962ae10d7d6d2  uboot-script.cmd
 9e71c61bfa72b60e749c4dc04f17eb59d25de822765e81e65c937d6be5236d3951a652b69a1ab973abe6add9f34705be5dbaa98bbfa25daf7504dd50b28524c2  sway.conf
 8d1ef04911f1cfa7eda8185f4f4d807af23105a7c8f23d8c18f02afeccd8ab124de70c2e2760c154a3128fe3793447039fb0abf37aa496f597d27051e275033e  99-pinetab-keyboard.hwdb
 6374ef977eab14b71fa88057ebd52ca03035e387e5f41504598a990f24b2e92bccd2db476c545dc541000e08fccdecb6f1cd63e25b5835df706269e0384dacc7  weston.ini
diff --git a/device/device-pine64-pinetab/uboot-script.cmd b/device/device-pine64-pinetab/uboot-script.cmd
index 2088fb7d9..768e13929 100644
--- a/device/device-pine64-pinetab/uboot-script.cmd
+++ b/device/device-pine64-pinetab/uboot-script.cmd
@@ -1,4 +1,14 @@
-setenv bootargs init=/init.sh rw console=tty0 console=ttyS0,115200 no_console_suspend earlycon=uart,mmio32,0x01c28000 panic=10 consoleblank=0 loglevel=1 cma=256M fbcon=rotate:1 PMOS_NO_OUTPUT_REDIRECT
+if test ${mmc_bootdev} -eq 0 ; then
+	echo "Booting from SD";
+	setenv bootdev 0;
+else
+	echo "Booting from eMMC";
+	setenv bootdev 2;
+fi;
+
+
+setenv bootargs init=/init.sh rw console=tty0 console=ttyS0,115200 no_console_suspend earlycon=uart,mmio32,0x01c28000 panic=10 consoleblank=0 loglevel=1 cma=256M fbcon=rotate:1 PMOS_NO_OUTPUT_REDIRECT pmos_boot=/dev/mmcblk${bootdev}p1 pmos_root=/dev/mmcblk${bootdev}p2
+
 
 printenv