Browse Source

more bug fixes and updates

loboris 9 years ago
parent
commit
91eb4be006
100 changed files with 1397 additions and 949 deletions
  1. 124 86
      C2/initramfs/ramfs/backup.script
  2. BIN
      C2/initramfs/ramfs/bin/sed
  3. 83 48
      C2/initramfs/ramfs/init
  4. 409 320
      C2/initramfs/ramfs/install.script
  5. 0 4
      C2/initramfs/ramfs/multi/boot.ini.android
  6. 7 7
      C2/initramfs/ramfs/multi/boot.ini.linux
  7. 7 7
      C2/initramfs/ramfs/multi/boot.ini.linux2
  8. BIN
      C2/initramfs/ramfs/sbin/fsck.fat
  9. 1 0
      C2/initramfs/ramfs/sbin/fsck.msdos
  10. 1 0
      C2/initramfs/ramfs/sbin/fsck.vfat
  11. 1 1
      C2/multiboot/boot.ini.multi
  12. BIN
      C2/multiboot/uInitrd.multi
  13. 124 86
      XU4/initramfs/ramfs/backup.script
  14. 83 48
      XU4/initramfs/ramfs/init
  15. 409 320
      XU4/initramfs/ramfs/install.script
  16. 16 6
      XU4/initramfs/ramfs/multi/boot.ini.android
  17. 1 0
      XU4/initramfs/ramfs/sbin/dosfsck
  18. BIN
      XU4/initramfs/ramfs/sbin/fsck.fat
  19. 115 0
      XU4/multiboot/boot.ini.inst
  20. 16 16
      XU4/multiboot/boot.ini.multi
  21. BIN
      XU4/multiboot/boot.scr.multi
  22. BIN
      XU4/multiboot/uInitrd.multi
  23. BIN
      bin/[
  24. BIN
      bin/[[
  25. BIN
      bin/acpid
  26. BIN
      bin/ash
  27. BIN
      bin/awk
  28. BIN
      bin/basename
  29. BIN
      bin/bash
  30. BIN
      bin/blockdev
  31. BIN
      bin/btrfs
  32. BIN
      bin/btrfs-zero-log
  33. BIN
      bin/busybox
  34. BIN
      bin/cat
  35. BIN
      bin/chmod
  36. BIN
      bin/chown
  37. BIN
      bin/chroot
  38. BIN
      bin/chvt
  39. BIN
      bin/clear
  40. BIN
      bin/cmp
  41. BIN
      bin/cp
  42. BIN
      bin/cpio
  43. BIN
      bin/cut
  44. BIN
      bin/date
  45. BIN
      bin/dd
  46. BIN
      bin/deallocvt
  47. BIN
      bin/devmem
  48. BIN
      bin/df
  49. BIN
      bin/dmesg
  50. BIN
      bin/dnsdomainname
  51. BIN
      bin/du
  52. BIN
      bin/dumpkmap
  53. BIN
      bin/dux
  54. BIN
      bin/echo
  55. BIN
      bin/egrep
  56. BIN
      bin/env
  57. BIN
      bin/expr
  58. BIN
      bin/false
  59. BIN
      bin/fbset
  60. BIN
      bin/fdflush
  61. BIN
      bin/fdisk
  62. BIN
      bin/fgrep
  63. BIN
      bin/find
  64. BIN
      bin/fstrim
  65. BIN
      bin/fstype
  66. BIN
      bin/grep
  67. BIN
      bin/gunzip
  68. BIN
      bin/gzip
  69. BIN
      bin/halt
  70. BIN
      bin/hostname
  71. BIN
      bin/hwclock
  72. BIN
      bin/ifconfig
  73. BIN
      bin/img2simg
  74. BIN
      bin/ip
  75. BIN
      bin/ipconfig
  76. BIN
      bin/kbd_mode
  77. BIN
      bin/kill
  78. BIN
      bin/kmod
  79. BIN
      bin/ln
  80. BIN
      bin/loadfont
  81. BIN
      bin/loadkeys
  82. BIN
      bin/loadkmap
  83. BIN
      bin/losetup
  84. BIN
      bin/ls
  85. BIN
      bin/lsx
  86. BIN
      bin/lzop
  87. BIN
      bin/lzopcat
  88. BIN
      bin/make_ext4fs
  89. BIN
      bin/minips
  90. BIN
      bin/mkdir
  91. BIN
      bin/mkfifo
  92. BIN
      bin/mkfs
  93. BIN
      bin/mkfs.btrfs
  94. BIN
      bin/mkfs.ext4
  95. BIN
      bin/mkfs.fat
  96. BIN
      bin/mkfs.vfat
  97. BIN
      bin/mknod
  98. BIN
      bin/mkswap
  99. BIN
      bin/mktemp
  100. BIN
      bin/modinfo

+ 124 - 86
C2/initramfs/ramfs/backup.script

@@ -2,6 +2,7 @@
 
 sd_multi="no"
 card_no="0"
+multiboot_label="sd"
 
 #--------------------------------------------------
 disp_header() {
@@ -24,8 +25,12 @@ disp_header() {
 #--------------------------------------------------
 
 #------------------------------------------------------------------------------------------------------------
+# arg1: full path to image file
+# arg2: description
+# arg3: backup type, 'andro' or 'linux'
+# source partition is mounted on /mnt1
+
 make_image() {
-	# source partition is mounted on /mnt1
 	mkdir /imgmnt >> ${log_file} 2>&1
 
 	printf "    Backup: \033[32m%s\033[37m ... preparing image... " "${2}"
@@ -88,56 +93,60 @@ make_image() {
 backup_android() {
 	printf "\n    Backup: \033[32m\033[1mAndroid\033[22m\033[37m\n"
 
-	# backup system partition, allready mounted on /mnt1
+	# === backup system partition, already mounted on /mnt1 ===
 	mkdir /mnt2/${BKP_PREFIX}_backup >> ${log_file} 2>&1
 	mkdir /mnt2/${BKP_PREFIX}_backup/android >> ${log_file} 2>&1
 	rm -rf /mnt2/${BKP_PREFIX}_backup/android/* >> ${log_file} 2>&1
+	mkdir /mnt2/${BKP_PREFIX}_backup/android/userdir >> ${log_file} 2>&1
 
 	make_image "/mnt2/${BKP_PREFIX}_backup/android/system.raw.img" "Android system" "andro"
-	if [ $? -eq 0 ]; then
+	if [ $? -ne 0 ]; then
 		umount /mnt1 >> ${log_file} 2>&1
+		return 1
+	fi
 
-		# backup data partition
-		if [ "${sd_multi}" = "yes" ]; then
-			/bin/mountx /dev/mmcblk${card_no}p5 /mnt1 >> ${log_file} 2>&1
-		else
-			/bin/mountx /dev/mmcblk${card_no}p4 /mnt1 >> ${log_file} 2>&1
-		fi
-		if [ $? -ne 0 ]; then
-			umount /mnt1 >> ${log_file} 2>&1
-			printf "    ERROR mounting data partition\n"
-			return 1
-		fi
-
-		make_image "/mnt2/${BKP_PREFIX}_backup/android/data.raw.img" "Android data" "andro"
-		if [ $? -eq 0 ]; then
-			umount /mnt1 >> ${log_file} 2>&1
+	umount /mnt1 >> ${log_file} 2>&1
+	# === backup data partition ===
+	if [ "${sd_multi}" = "yes" ]; then
+		/bin/mountx /dev/disk/by-label/${multiboot_label}data /mnt1 >> ${log_file} 2>&1
+	else
+		# Original Odroid android
+		/bin/mountx /dev/mmcblk${card_no}p${ADATA_PART_ORIG} /mnt1 >> ${log_file} 2>&1
+	fi
+	if [ $? -ne 0 ]; then
+		umount /mnt1 >> ${log_file} 2>&1
+		printf "    ERROR mounting data partition\n"
+		return 1
+	fi
 
-			# backup cache partition
-			/bin/mountx /dev/mmcblk${card_no}p3 /mnt1 >> ${log_file} 2>&1
-			if [ $? -ne 0 ]; then
-				umount /mnt1 >> ${log_file} 2>&1
-				printf "    ERROR mounting cache partition\n"
-				return 1
-			fi
+	make_image "/mnt2/${BKP_PREFIX}_backup/android/data.raw.img" "Android data" "andro"
+	if [ $? -ne 0 ]; then
+		umount /mnt1 >> ${log_file} 2>&1
+		return 1
+	fi
 
-			make_image "/mnt2/${BKP_PREFIX}_backup/android/cache.raw.img" "Android cache" "andro"
-			if [ $? -ne 0 ]; then
-				umount /mnt1 >> ${log_file} 2>&1
-				return 1
-			fi
-		else
-			umount /mnt1 >> ${log_file} 2>&1
-			return 1
-		fi
+	umount /mnt1 >> ${log_file} 2>&1
+	# === backup cache partition ===
+	if [ "${sd_multi}" = "yes" ]; then
+		/bin/mountx /dev/disk/by-label/${multiboot_label}cache /mnt1 >> ${log_file} 2>&1
 	else
+		# Original Odroid android
+		/bin/mountx /dev/mmcblk${card_no}p${ACACHE_PART_ORIG} /mnt1 >> ${log_file} 2>&1
+	fi
+	if [ $? -ne 0 ]; then
 		umount /mnt1 >> ${log_file} 2>&1
+		printf "    ERROR mounting cache partition\n"
 		return 1
 	fi
 
-	umount /mnt1 >> ${log_file} 2>&1
+	make_image "/mnt2/${BKP_PREFIX}_backup/android/cache.raw.img" "Android cache" "andro"
+	if [ $? -ne 0 ]; then
+		umount /mnt1 >> ${log_file} 2>&1
+		return 1
+	fi
 
-	# Mount boot card and copy android boot files
+	umount /mnt1 >> ${log_file} 2>&1
+	# === Mount boot card and copy android user data and boot files ===
 	printf "    Backup: \033[32mCopy boot files\033[37m ... "
 	mount -t vfat /dev/mmcblk${card_no}p1 /mnt1 >> ${log_file} 2>&1
 	if [ $? -ne 0 ]; then
@@ -145,11 +154,10 @@ backup_android() {
 		return 1
 	fi
 
-	cp -rf /mnt1/* /mnt2/${BKP_PREFIX}_backup/android >> ${log_file} 2>&1
-	rm -f /mnt2/${BKP_PREFIX}_backup/android/${ODROID_IMAGE} >> ${log_file} 2>&1
-	rm -f /mnt2/${BKP_PREFIX}_backup/android/${ODROID_DTB} >> ${log_file} 2>&1
-	rm -rf /mnt2/${BKP_PREFIX}_backup/android/multiboot/* >> ${log_file} 2>&1
-	rmdir /mnt2/${BKP_PREFIX}_backup/android/multiboot >> ${log_file} 2>&1
+	cp -rf /mnt1/* /mnt2/${BKP_PREFIX}_backup/android/userdir >> ${log_file} 2>&1
+	rm -rf /mnt2/${BKP_PREFIX}_backup/android/userdir/multiboot/* >> ${log_file} 2>&1
+	rmdir /mnt2/${BKP_PREFIX}_backup/android/userdir/multiboot >> ${log_file} 2>&1
+	rm -f /mnt2/${BKP_PREFIX}_backup/android/userdir/boot.ini >> ${log_file} 2>&1
 
 	if [ "${sd_multi}" = "yes" ]; then
 		cp /mnt1/multiboot/${ODROID_IMAGE}.android /mnt2/${BKP_PREFIX}_backup/android/${ODROID_IMAGE} >> ${log_file} 2>&1
@@ -157,21 +165,48 @@ backup_android() {
 			printf "ERROR: Image\n"
 			return 1
 		fi
-		cp /mnt1/multiboot/${ODROID_DTB}.android /mnt2/${BKP_PREFIX}_backup/android/${ODROID_DTB} >> ${log_file} 2>&1
-		if [ $? -ne 0 ]; then
-			printf "ERROR: dtb\n"
-			return 1
+		if [ "${O_BOARD}" = "C2" ]; then
+			cp /mnt1/multiboot/${ODROID_DTB}.android /mnt2/${BKP_PREFIX}_backup/android/${ODROID_DTB} >> ${log_file} 2>&1
+			if [ $? -ne 0 ]; then
+				printf "ERROR: dtb\n"
+				return 1
+			fi
 		fi
 	else
-		cp /mnt1/${ODROID_IMAGE} /mnt2/${BKP_PREFIX}_backup/android >> ${log_file} 2>&1
-		if [ $? -ne 0 ]; then
-			printf "ERROR: Image\n"
-			return 1
+		# Original Odroid android, extract kernel/dtp from the card
+		if [ -f /mnt1/${ODROID_IMAGE} ]; then
+			cp /mnt1/${ODROID_IMAGE} /mnt2/${BKP_PREFIX}_backup/android >> ${log_file} 2>&1
+			if [ $? -ne 0 ]; then
+				printf "ERROR: Kernel\n"
+				return 1
+			fi
+		else
+			if [ "${O_BOARD}" = "C2" ]; then
+				dd if=/dev/mmcblk${card_no} of=/mnt2/${BKP_PREFIX}_backup/android/${ODROID_IMAGE} bs=512 skip=1632 count=32768 >> ${log_file} 2>&1
+			else
+				dd if=/dev/mmcblk${card_no} of=/mnt2/${BKP_PREFIX}_backup/android/${ODROID_IMAGE} bs=512 skip=1263 count=16384 >> ${log_file} 2>&1
+			fi
+			if [ $? -ne 0 ]; then
+				printf "ERROR: Kernel\n"
+				return 1
+			fi
+			sync
 		fi
-		cp /mnt1/${ODROID_DTB} /mnt2/${BKP_PREFIX}_backup/android >> ${log_file} 2>&1
-		if [ $? -ne 0 ]; then
-			printf "ERROR: dtb\n"
-			return 1
+		if [ -f /mnt1/${ODROID_DTB} ]; then
+			cp /mnt1/${ODROID_DTB} /mnt2/${BKP_PREFIX}_backup/android >> ${log_file} 2>&1
+			if [ $? -ne 0 ]; then
+				printf "ERROR: dtb\n"
+				return 1
+			fi
+		else
+			if [ "${O_BOARD}" = "C2" ]; then
+				dd if=/dev/mmcblk${card_no} of=/mnt2/${BKP_PREFIX}_backup/android/${ODROID_DTB} bs=512 skip=1504 count=128 >> ${log_file} 2>&1
+				if [ $? -ne 0 ]; then
+					printf "ERROR: dtb\n"
+					return 1
+				fi
+				sync
+			fi
 		fi
 	fi
 	umount /mnt1 >> ${log_file} 2>&1
@@ -187,7 +222,7 @@ backup_android() {
 backup_linux() {
 	printf "\n    Backup: \033[32m\033[1mLinux%s\033[22m\033[37m\n" "${1}"
 
-	# backup Linux partition, allready mounted on /mnt1
+	# backup Linux partition, already mounted on /mnt1
 	mkdir /mnt2/${BKP_PREFIX}_backup >> ${log_file} 2>&1
 	mkdir /mnt2/${BKP_PREFIX}_backup/linux${1} >> ${log_file} 2>&1
 	rm -rf /mnt2/${BKP_PREFIX}_backup/linux${1}/* >> ${log_file} 2>&1
@@ -254,7 +289,7 @@ backup_linux() {
 backup_oelec() {
 	printf "\n    Backup: \033[32m\033[1mOpenElec\033[22m\033[37m\n"
 
-	# backup oelec partition, allready mounted on /mnt1
+	# === backup oelec partition, allready mounted on /mnt1 ===
 	mkdir /mnt2/${BKP_PREFIX}_backup >> ${log_file} 2>&1
 	mkdir /mnt2/${BKP_PREFIX}_backup/oelec >> ${log_file} 2>&1
 	rm -rf /mnt2/${BKP_PREFIX}_backup/oelec/* >> ${log_file} 2>&1
@@ -270,7 +305,7 @@ backup_oelec() {
 
 	umount /mnt1 >> ${log_file} 2>&1
 
-	# Mount boot card and copy OpenElec boot files
+	# === Mount boot card and copy OpenElec boot files ===
 	printf "    Backup: \033[32mCopy OpenElec files\033[37m ... "
 	mount -t vfat /dev/mmcblk${card_no}p1 /mnt1 >> ${log_file} 2>&1
 	if [ $? -ne 0 ]; then
@@ -438,10 +473,10 @@ log_file="/mnt2/backup.log"
 #log_file="ls/dev/null"
 
 # Check source drive
-if [ -b /dev/mmcblk1 ]; then
+if [ "${NUMCARDS}" = "2" ]; then
 	printf "    \033[33mTwo cards detected, select which one to use for backup\033[37m\n\n"
-	printf "    \033[32m\033[1m0\033[22m EMMC Card\033[37m\n"
-	printf "    \033[32m\033[1m1\033[22m SD Card\033[37m\n\n"
+	printf "    \033[32m\033[1m0\033[22m Boot card (%s)\033[37m\n" "${BOOT_CARDTYPE}"
+	printf "    \033[32m\033[1m1\033[22m Other card (%s)\033[37m\n\n" "${OTHER_CARDTYPE}"
 
 	_delay=30
 	while [ $_delay -gt 0 ]; do
@@ -450,9 +485,12 @@ if [ -b /dev/mmcblk1 ]; then
 		if read -n 1 -t 1 -s B; then
 			_delay=30
 			if [ "${B}" = "0" ]; then
+				card_no="${BOOT_CARDDEV}"
+				card_type="${BOOT_CARDTYPE}"
 				break
 			elif [ "${B}" = "1" ]; then
-				card_no="1"
+				card_no="${OTHER_CARDDEV}"
+				card_type="${OTHER_CARDTYPE}"
 				break
 			fi
 		else
@@ -462,31 +500,28 @@ if [ -b /dev/mmcblk1 ]; then
 	disp_header
 fi
 
-# Display backup info
+# === Display backup info ===
 printf "    \033[32mBackup from "
 
-card_type="SD"
-if [ -b /dev/disk/by-label/sduserdata ] || [ -b /dev/disk/by-label/emuserdata ]; then
+if [ "${card_type}" = "SD" ]; then
+	multiboot_label="sd"
+else
+	multiboot_label="em"
+fi
+
+# === Check if the backup is from multiboot card ===
+# shellcheck disable=SC2010
+tmp_crdtype=`ls -l /dev/disk/by-label | grep mmcblk${card_no}p1 | awk '{print $4}'`
+if [ "${tmp_crdtype}" = "${multiboot_label}userdata" ]; then
 	sd_multi="yes"
-	# shellcheck disable=SC2010
-	tmp_crdtype=`ls -l /dev/disk/by-label | grep mmcblk${card_no}p1 | awk '{print $4}'`
-	[ "${tmp_crdtype}" = "emuserdata" ] && card_type="EMMC"
 	printf "\033[1mMultiBoot\033[22m %s card " "${card_type}"
 else
-	if [ -b /dev/mmcblk1 ] && [ "${card_no}" = "0" ]; then
-		card_type="EMMC"
-	elif [ -b /dev/mmcblk1 ] && [ "${card_no}" = "1" ]; then
-		card_type="SD"
-	else
-		card_type="SD/EMMC"
-	fi
 	printf "\033[1mOriginal Odroid\033[22m %s card " "${card_type}"
 fi
-
 printf " to \033[1mUSB partition #%s\033[22m\033[37m\n\n" "${usb_part}"
 
 
-# Mount partition 2 (Android system or Linux)
+# === Mount partition 2 (Android system or Linux) ===
 /bin/mountx /dev/mmcblk${card_no}p2 /mnt1 >> ${log_file} 2>&1
 if [ $? -ne 0 ]; then
 	umount /mnt2 > /dev/null 2>&1
@@ -494,7 +529,7 @@ if [ $? -ne 0 ]; then
 	exit_script
 fi
 
-# Wait for confirmation
+# === Wait for backup confirmation ===
 _delay=30
 while [ $_delay -gt 0 ]; do
 	printf "    \033[33mReady for backup, press \033[1mY\033[22m to continue, \033[1mE\033[22m to exit (%s)  \033[37m\r" "${_delay}"
@@ -517,10 +552,11 @@ while [ $_delay -gt 0 ]; do
 done
 if [ $_delay -eq 0 ]; then
 	printf "\r\033[2K"
+	umount /mnt2 > /dev/null 2>&1
 	exit_script
 fi
 
-# Ckeck if it is Android partition
+# === Ckeck if it is Android partition ===
 if [ -f /mnt1/${ODROID_FSTAB} ]; then
 	backup_android
 else
@@ -533,11 +569,13 @@ else
 fi
 
 umount /mnt1 >> ${log_file} 2>&1
+
+# === For multiboot card backup, continue to backup other operating systems ===
 if [ "${sd_multi}" = "yes" ]; then
-	if [ -b /dev/disk/by-label/sdlinux ] || [ -b /dev/disk/by-label/emlinux ]; then
+	if [ -b /dev/disk/by-label/${multiboot_label}linux ]; then
 		printf "\n"
-		# Backup multiboot Linux
-		/bin/mountx /dev/mmcblk${card_no}p7 /mnt1 >> ${log_file} 2>&1
+		# === Backup multiboot Linux ===
+		/bin/mountx /dev/disk/by-label/${multiboot_label}linux /mnt1 >> ${log_file} 2>&1
 		if [ $? -ne 0 ]; then
 			printf "    ERROR mounting Linux partition\n"
 			exit_script
@@ -548,10 +586,10 @@ if [ "${sd_multi}" = "yes" ]; then
 	fi
 	umount /mnt1 >> ${log_file} 2>&1
 
-	if [ -b /dev/disk/by-label/sdlinux2 ] || [ -b /dev/disk/by-label/emlinux2 ]; then
+	if [ -b /dev/disk/by-label/${multiboot_label}linux2 ]; then
 		printf "\n"
-		# Backup multiboot Linux2
-		/bin/mountx /dev/mmcblk${card_no}p8 /mnt1 >> ${log_file} 2>&1
+		# === Backup multiboot Linux2 ===
+		/bin/mountx /dev/disk/by-label/${multiboot_label}linux2 /mnt1 >> ${log_file} 2>&1
 		if [ $? -eq 0 ]; then
 			if [ -f /mnt1/etc/fstab ]; then
 				backup_linux "2"
@@ -559,10 +597,10 @@ if [ "${sd_multi}" = "yes" ]; then
 		fi
 	fi
 
-	if [ -b /dev/disk/by-label/sdaux ] || [ -b /dev/disk/by-label/emaux ]; then
+	if [ -b /dev/disk/by-label/${multiboot_label}aux ]; then
 		printf "\n"
-		# Backup multiboot OpenElec
-		/bin/mountx /dev/mmcblk${card_no}p6 /mnt1 >> ${log_file} 2>&1
+		# === Backup multiboot OpenElec ===
+		/bin/mountx /dev/disk/by-label/${multiboot_label}aux /mnt1 >> ${log_file} 2>&1
 		if [ $? -eq 0 ]; then
 			backup_oelec
 		fi

BIN
C2/initramfs/ramfs/bin/sed


+ 83 - 48
C2/initramfs/ramfs/init

@@ -179,17 +179,6 @@ mount_bottom
 nfs_bottom
 local_bottom
 
-#maybe_break bottom
-# We expect udev's init-bottom script to move /dev to ${rootmnt}/dev
-#run_scripts /scripts/init-bottom
-
-# Move /run to the root
-#mount -n -o move /run ${rootmnt}/run
-
-#validate_init() {
-#	run-init -n "${rootmnt}" "${1}"
-#}
-
 
 chown 0:0 /bin/*
 chown 0:0 /sbin/*
@@ -208,6 +197,16 @@ export ODROID_IMAGE="Kernel"
 export ODROID_ASYSTEMIMAGE="androsystem.img"
 export BKP_PREFIX="OD"
 export NUMCARDS="1"
+export UPGRADE_ANDROID="no"
+
+export ASYSTEM_PART="2"
+export ADATA_PART="5"
+export ACACHE_PART="3"
+export ADATA_PART_ORIG="3"
+export ACACHE_PART_ORIG="4"
+export LINUX_PART="7"
+export LINUX2_PART="8"
+export OELEC_PART="6"
 
 _desc=""
 _ini_prefix="multiboot"
@@ -249,20 +248,26 @@ boot_fail="yes"
 # === Set the variables depending on used Odroid board  ===
 if [ -f /ODROID_C2 ]; then
 	O_BOARD="C2"
+	ADATA_PART_ORIG="4"
+	ACACHE_PART_ORIG="3"
 	ODROID_DTB="meson64_odroidc2.dtb"
 	ODROID_FSTAB="fstab.odroidc2"
 	ODROID_IMAGE="Image"
 	ODROID_ASYSTEMIMAGE="rootsystem.img"
 	BKP_PREFIX="C2"
-	BOOT_CARDTYPE="SD"
 	BOOT_CARDDEV="0"
 	if [ -b /dev/mmcblk1p1 ]; then
+		BOOT_CARDTYPE="EMMC"
 		NUMCARDS="2"
 		OTHER_CARDDEV="1"
-		OTHER_CARDTYPE="EMMC"
+		OTHER_CARDTYPE="SD"
+	else
+		BOOT_CARDTYPE="${CARD_TYPE}"
 	fi
 elif [ -f /ODROID_XU ]; then
 	O_BOARD="XU"
+	ADATA_PART_ORIG="3"
+	ACACHE_PART_ORIG="4"
 	ODROID_DTB="exynos5422-odroidxu3.dtb"
 	ODROID_FSTAB="fstab.odroidxu3"
 	ODROID_IMAGE="zImage"
@@ -317,38 +322,46 @@ get_descr() {
 #-----------------------------------------------------------------------------------------------------------------------
 change_afstab() {
 	# === Configure Android fstab to mount the right partitions ===
-	if [ -f /mnt_a/${ODROID_FSTAB}${1} ]; then
-		if [ "${2}" = "yes" ]; then
+	if [ -f /mnt_a/${ODROID_FSTAB} ]; then
+		if [ "${1}" = "yes" ]; then
 			# Two cards, boot to Android on NON Boot card
 			if [ "${O_BOARD}" = "C2" ]; then
-				cat /mnt_a/${ODROID_FSTAB}${1} | sed "s/\/dev\/block\/mmcblk0/\/dev\/block\/mmcblk1/g" > _fstab_
+				sed -i "s/\/dev\/block\/mmcblk0/\/dev\/block\/mmcblk1/g" /mnt_a/${ODROID_FSTAB}
 			else
 				if [ "${OTHER_CARDTYPE}" = "SD" ]; then
-					cat /mnt_a/${ODROID_FSTAB}${1} | sed "s/\/dev\/block\/mmcblk0/\/dev\/block\/mmcblk1/g" > _fstab_
+					cp /mnt_a/${ODROID_FSTAB}.other /mnt_a/${ODROID_FSTAB}
+					sed -i "s/setenv akernel zImage/setenv akernel \/multiboot\/zImage.andro_1/g" /mnt1/boot.ini
 				else
-					cat /mnt_a/${ODROID_FSTAB}${1} | sed "s/\/dev\/block\/mmcblk1/\/dev\/block\/mmcblk0/g" > _fstab_
+					cp /mnt_a/${ODROID_FSTAB}.orig /mnt_a/${ODROID_FSTAB}
+					sed -i "s/setenv akernel zImage/setenv akernel \/multiboot\/zImage.android/g" /mnt1/boot.ini
 				fi
 			fi
 		else
+			# One or two cards, boot to Android on Boot card
 			if [ "${O_BOARD}" = "C2" ]; then
-				cat /mnt_a/${ODROID_FSTAB}${1} | sed "s/\/dev\/block\/mmcblk1/\/dev\/block\/mmcblk0/g" > _fstab_
+				# Restore boot device if modified earlier
+				sed -i "s/\/dev\/block\/mmcblk1/\/dev\/block\/mmcblk0/g" /mnt_a/${ODROID_FSTAB}
 			else
 				if [ "${NUMCARDS}" = "1" ]; then
-					cat /mnt_a/${ODROID_FSTAB}${1} | sed "s/\/dev\/block\/mmcblk1/\/dev\/block\/mmcblk0/g" > _fstab_
+					cp /mnt_a/${ODROID_FSTAB}.orig /mnt_a/${ODROID_FSTAB}
+					sed -i "s/setenv akernel zImage/setenv akernel \/multiboot\/zImage.android/g" /mnt1/boot.ini
 				else
 					# Two cards, boot to Android on Boot card
-					if [ "${BOOT_CARDTYPE}" = "SD" ]; then
-						cat /mnt_a/${ODROID_FSTAB}${1} | sed "s/\/dev\/block\/mmcblk0/\/dev\/block\/mmcblk1/g" > _fstab_
+					if [ "${BOOT_CARDTYPE}" = "SD" ] && [ "${BOOT_CARDDEV}" = "1" ]; then
+						cp /mnt_a/${ODROID_FSTAB}.other /mnt_a/${ODROID_FSTAB}
+						sed -i "s/setenv akernel zImage/setenv akernel \/multiboot\/zImage.andro_1/g" /mnt1/boot.ini
 					else
-						cat /mnt_a/${ODROID_FSTAB}${1} | sed "s/\/dev\/block\/mmcblk1/\/dev\/block\/mmcblk0/g" > _fstab_
+						cp /mnt_a/${ODROID_FSTAB}.orig /mnt_a/${ODROID_FSTAB}
+						sed -i "s/setenv akernel zImage/setenv akernel \/multiboot\/zImage.android/g" /mnt1/boot.ini
 					fi
 				fi
 			fi
 		fi
-		cp _fstab_ /mnt_a/${ODROID_FSTAB}${1} > /dev/null 2>&1
-		rm _fstab_ > /dev/null 2>&1
-	elif [ "${1}" = "" ]; then
-		printf "\033[31m\033[1m %s not found\033[22m\033[37m" "${ODROID_FSTAB}${1}"
+		if [ "${O_BOARD}" = "XU" ]; then
+			cp -f /mnt_a/${ODROID_FSTAB} /mnt_a/${ODROID_FSTAB}.sdboot
+		fi
+	else
+		printf "\033[31m\033[1m %s not found\033[22m\033[37m" "${ODROID_FSTAB}"
 		cp /mnt1/${_ini_prefix}/boot.ini.multi /mnt1/boot.ini > /dev/null 2>&1
 		[ "${O_BOARD}" = "XU" ] && cp /mnt1/${_ini_prefix}/boot.scr.multi /mnt1/boot.scr > /dev/null 2>&1
 		sleep 3
@@ -372,6 +385,7 @@ do_boot() {
 	local _oncard=""
 	_actmount="mnt1"
 	if [ "${3}" = "2" ]; then
+		# Operating system on NON BOOT card
 		_actmount="mnt2"
 		change_drive="yes"
 	fi
@@ -401,26 +415,20 @@ do_boot() {
 		sleep 1
 
 		if [ "${change_drive}" = "yes" ]; then
-			# === boot.ini from NON-BOOT card, prepare for boot from BOOT card ===
+			# === boot.ini from NON-BOOT card, prepare it for boot from BOOT card ===
 			if [ "${O_BOARD}" = "C2" ]; then
 				# for kernel/initrd/dtb loading
-				cat /mnt1/boot.ini | sed "s/fatload mmc 0:1/fatload mmc 1:1/g" > _bini_
-				cp _bini_ /mnt1/boot.ini
-				rm _bini_
+				sed -i "s/fatload mmc 0:1/fatload mmc 1:1/g" /mnt1/boot.ini
 				# for boot.ini loading from /multiboot (it was changed with previous sed operation!)
-				cat /mnt1/boot.ini | sed "s/1:1 0x60000000/0:1 0x60000000/g" > _bini_
-				cp _bini_ /mnt1/boot.ini
-				rm _bini_
+				sed -i "s/1:1 0x60000000/0:1 0x60000000/g" /mnt1/boot.ini
 			else
 				# for kernel/initrd/dtb loading
-				cat /mnt1/boot.ini | sed "s/setenv change_osdev no/setenv change_osdev yes/g" > _bini_
-				cp _bini_ /mnt1/boot.ini
-				rm _bini_
+				sed -i "s/setenv change_osdev no/setenv change_osdev yes/g" /mnt1/boot.ini
 			fi
 		fi
 
 		if [ "${1}" = "boot.ini.android" ]; then
-			# === mount android system partition to prepare android fstab ===
+			# === mount destination android system partition to prepare android fstab ===
 			mkdir /mnt_a > /dev/null 2>&1
 			if [ "${change_drive}" = "yes" ]; then
 				mount -t ext4 /dev/mmcblk${OTHER_CARDDEV}p2 /mnt_a > /dev/null 2>&1
@@ -437,18 +445,14 @@ do_boot() {
 			fi
 
 			# === Configure Android fstab to mount the right partitions ===
-			change_afstab "" "${change_drive}"
+			change_afstab "${change_drive}"
 			[ $? -ne 0 ] && return 1
-			change_afstab ".sdcard" "${change_drive}"
-			change_afstab ".sdboot" "${change_drive}"
 			umount /mnt_a > /dev/null 2>&1
 			# =============================================================
 
 			if [ "${O_BOARD}" = "C2" ] && [ "${change_drive}" = "yes" ]; then
 				# on C2 prepare boot.ini for boot from sdcard, not needed on XU
-				cat /mnt1/boot.ini | sed "s/root=\/dev\/mmcblk0p2/root=\/dev\/mmcblk1p2/g" > _bini_
-				cp _bini_ /mnt1/boot.ini
-				rm _bini_
+				sed -i "s/root=\/dev\/mmcblk0p2/root=\/dev\/mmcblk1p2/g" /mnt1/boot.ini
 			fi
 		fi
 
@@ -463,10 +467,23 @@ do_boot() {
 				umount /mnt_a > /dev/null 2>&1
 				return 1
 			fi
+			if [ -f /mnt1/multiboot/newscr ]; then
+				mkimage -C none -A arm -T script -d /mnt1/multiboot/boot.ini.multi /mnt1/multiboot/boot.scr.multi > /dev/null 2>&1
+				if [ $? -ne 0 ]; then
+					printf "\033[31m\033[1m mkimage (boot.scr.multi) ERROR\033[22m\033[37m"
+					cp /mnt1/${_ini_prefix}/boot.ini.multi /mnt1/boot.ini > /dev/null 2>&1
+					cp /mnt1/${_ini_prefix}/boot.scr.multi /mnt1/boot.scr > /dev/null 2>&1
+					sleep 3
+					umount /mnt_a > /dev/null 2>&1
+					return 1
+				fi
+				rm -f /mnt1/multiboot/newscr > /dev/null 2>&1
+			fi
 		fi
 		sleep 1
 		umount /mnt1
 		umount /mnt2 > /dev/null 2>&1
+		fsck.fat -aw /dev/mmcblk${BOOT_CARDDEV}p1 > /dev/null 2>&1
 		reboot
 	fi
 }
@@ -808,6 +825,7 @@ while true; do
 				sleep 1
 				# ============================
 				# Execute the installer script
+				UPGRADE_ANDROID="no"
 				/install.script
 				# ============================
 				A="Z"
@@ -820,9 +838,23 @@ while true; do
 			fi
 		elif [ "${A}" = "U" ]; then
 			# === ANDROID UPGRADE ====
-			printf "\r\033[2K"
-			printf "    NOT SUPPORTED"
-			sleep 4
+			if [ -f /install.script ]; then
+				umount /mnt1  > /dev/null 2>&1
+				umount /mnt2  > /dev/null 2>&1
+				sleep 1
+				# =========================
+				# Execute the backup script
+				UPGRADE_ANDROID="yes"
+				/install.script
+				# =========================
+				A="Z"
+				os_detect
+				_boot_delay=$BOOTDELAY
+			else
+				printf "\r\033[2K"
+				printf "    BACKUP SCRIPT NOT FOUND!"
+				sleep 4
+			fi
 		elif [ "${A}" = "X" ]; then
 			# === ENTER BUSYBOX ===
 			clear
@@ -850,12 +882,15 @@ while true; do
 			B="X"
 			while [ $_reboot_delay -gt 0 ]; do
 				printf "\r\033[2K"
-				printf "    \033[33m\033[1mREBOOT in %s sec, press \033[22ma\033[1m to abort \033[22m\033[37m\r" "$_reboot_delay"
+				printf "    \033[33m\033[1mREBOOT in %s sec, press \033[22ma\033[1m to abort, \033[22mr\033[1m to reboot \033[22m\033[37m\r" "$_reboot_delay"
 				if read -n 1 -t 1 -s B; then
 					_reboot_delay=10
 					if [ "${B}" = "a" ] || [ "${B}" = "A" ]; then
 						printf "\r\033[2K"
 						break
+					elif [ "${B}" = "r" ] || [ "${B}" = "R" ]; then
+						_reboot_delay=0
+						break
 					fi
 				else
 					let _reboot_delay=_reboot_delay-1

File diff suppressed because it is too large
+ 409 - 320
C2/initramfs/ramfs/install.script


+ 0 - 4
C2/initramfs/ramfs/multi/boot.ini.android

@@ -99,10 +99,6 @@ fatload mmc 0:1 0x60000000 multiboot/boot.ini.multi
 fatwrite mmc 0:1 0x60000000 boot.ini ${filesize}
 # =================================================
 
-#movi read dtb 0 ${dtbaddr}
-#movi read boot 0 ${loadaddr}
-#booti ${loadaddr} - ${dtbaddr}
-
 setenv kernel  "fatload mmc 0:1 0x11000000 multiboot/Image.android"
 setenv dtb     "fatload mmc 0:1 0x1000000  multiboot/meson64_odroidc2.dtb.android"
 setenv bootseq "booti 0x11000000 - 0x1000000"

+ 7 - 7
C2/initramfs/ramfs/multi/boot.ini.linux

@@ -92,6 +92,13 @@ setenv nographics "0"
 
 ###########################################
 
+# =================================================
+# = RESTORE boot.ini FOR MULTIBOOT, DO NOT CHANGE =
+# =================================================
+fatload mmc 0:1 0x60000000 multiboot/boot.ini.multi
+fatwrite mmc 0:1 0x60000000 boot.ini ${filesize}
+# =================================================
+
 # Boot Arguments
 setenv bootargs "root=LABEL=XXlinux rootwait ro ${condev} no_console_suspend hdmimode=${m} m_bpp=${m_bpp} vout=${vout} fsck.repair=yes net.ifnames=0 elevator=noop disablehpd=${hpd}"
 
@@ -114,11 +121,4 @@ if test "${nographics}" = "1"; then fdt rm /meson-fb; fdt rm /amhdmitx; fdt rm /
 if test "${nographics}" = "1"; then fdt rm /meson-vout; fdt rm /mesonstream; fdt rm /meson-fb; fi
 if test "${nographics}" = "1"; then fdt rm /deinterlace; fdt rm /codec_mm; fi
 
-# =================================================
-# = RESTORE boot.ini FOR MULTIBOOT, DO NOT CHANGE =
-# =================================================
-fatload mmc 0:1 0x60000000 multiboot/boot.ini.multi
-fatwrite mmc 0:1 0x60000000 boot.ini ${filesize}
-# =================================================
-
 booti ${loadaddr} ${initrd_loadaddr} ${dtb_loadaddr}

+ 7 - 7
C2/initramfs/ramfs/multi/boot.ini.linux2

@@ -92,6 +92,13 @@ setenv nographics "0"
 
 ###########################################
 
+# =================================================
+# = RESTORE boot.ini FOR MULTIBOOT, DO NOT CHANGE =
+# =================================================
+fatload mmc 0:1 0x60000000 multiboot/boot.ini.multi
+fatwrite mmc 0:1 0x60000000 boot.ini ${filesize}
+# =================================================
+
 # Boot Arguments
 setenv bootargs "root=LABEL=XXlinux rootwait ro ${condev} no_console_suspend hdmimode=${m} m_bpp=${m_bpp} vout=${vout} fsck.repair=yes net.ifnames=0 elevator=noop disablehpd=${hpd}"
 
@@ -114,11 +121,4 @@ if test "${nographics}" = "1"; then fdt rm /meson-fb; fdt rm /amhdmitx; fdt rm /
 if test "${nographics}" = "1"; then fdt rm /meson-vout; fdt rm /mesonstream; fdt rm /meson-fb; fi
 if test "${nographics}" = "1"; then fdt rm /deinterlace; fdt rm /codec_mm; fi
 
-# =================================================
-# = RESTORE boot.ini FOR MULTIBOOT, DO NOT CHANGE =
-# =================================================
-fatload mmc 0:1 0x60000000 multiboot/boot.ini.multi
-fatwrite mmc 0:1 0x60000000 boot.ini ${filesize}
-# =================================================
-
 booti ${loadaddr} ${initrd_loadaddr} ${dtb_loadaddr}

BIN
C2/initramfs/ramfs/sbin/fsck.fat


+ 1 - 0
C2/initramfs/ramfs/sbin/fsck.msdos

@@ -0,0 +1 @@
+fsck.fat

+ 1 - 0
C2/initramfs/ramfs/sbin/fsck.vfat

@@ -0,0 +1 @@
+fsck.fat

+ 1 - 1
C2/multiboot/boot.ini.multi

@@ -19,7 +19,7 @@ setenv DEFAULT_OS "1"
 # !! DO NOT CHANGE !!                                           =                                        
 # (will be changed automaticaly when installed on EMMC)         =
 # ------------------------------------------------------------- =
-setenv CARD_TYPE "SD"
+setenv CARD_TYPE SD
 # ===============================================================
 
 

BIN
C2/multiboot/uInitrd.multi


+ 124 - 86
XU4/initramfs/ramfs/backup.script

@@ -2,6 +2,7 @@
 
 sd_multi="no"
 card_no="0"
+multiboot_label="sd"
 
 #--------------------------------------------------
 disp_header() {
@@ -24,8 +25,12 @@ disp_header() {
 #--------------------------------------------------
 
 #------------------------------------------------------------------------------------------------------------
+# arg1: full path to image file
+# arg2: description
+# arg3: backup type, 'andro' or 'linux'
+# source partition is mounted on /mnt1
+
 make_image() {
-	# source partition is mounted on /mnt1
 	mkdir /imgmnt >> ${log_file} 2>&1
 
 	printf "    Backup: \033[32m%s\033[37m ... preparing image... " "${2}"
@@ -88,56 +93,60 @@ make_image() {
 backup_android() {
 	printf "\n    Backup: \033[32m\033[1mAndroid\033[22m\033[37m\n"
 
-	# backup system partition, allready mounted on /mnt1
+	# === backup system partition, already mounted on /mnt1 ===
 	mkdir /mnt2/${BKP_PREFIX}_backup >> ${log_file} 2>&1
 	mkdir /mnt2/${BKP_PREFIX}_backup/android >> ${log_file} 2>&1
 	rm -rf /mnt2/${BKP_PREFIX}_backup/android/* >> ${log_file} 2>&1
+	mkdir /mnt2/${BKP_PREFIX}_backup/android/userdir >> ${log_file} 2>&1
 
 	make_image "/mnt2/${BKP_PREFIX}_backup/android/system.raw.img" "Android system" "andro"
-	if [ $? -eq 0 ]; then
+	if [ $? -ne 0 ]; then
 		umount /mnt1 >> ${log_file} 2>&1
+		return 1
+	fi
 
-		# backup data partition
-		if [ "${sd_multi}" = "yes" ]; then
-			/bin/mountx /dev/mmcblk${card_no}p5 /mnt1 >> ${log_file} 2>&1
-		else
-			/bin/mountx /dev/mmcblk${card_no}p4 /mnt1 >> ${log_file} 2>&1
-		fi
-		if [ $? -ne 0 ]; then
-			umount /mnt1 >> ${log_file} 2>&1
-			printf "    ERROR mounting data partition\n"
-			return 1
-		fi
-
-		make_image "/mnt2/${BKP_PREFIX}_backup/android/data.raw.img" "Android data" "andro"
-		if [ $? -eq 0 ]; then
-			umount /mnt1 >> ${log_file} 2>&1
+	umount /mnt1 >> ${log_file} 2>&1
+	# === backup data partition ===
+	if [ "${sd_multi}" = "yes" ]; then
+		/bin/mountx /dev/disk/by-label/${multiboot_label}data /mnt1 >> ${log_file} 2>&1
+	else
+		# Original Odroid android
+		/bin/mountx /dev/mmcblk${card_no}p${ADATA_PART_ORIG} /mnt1 >> ${log_file} 2>&1
+	fi
+	if [ $? -ne 0 ]; then
+		umount /mnt1 >> ${log_file} 2>&1
+		printf "    ERROR mounting data partition\n"
+		return 1
+	fi
 
-			# backup cache partition
-			/bin/mountx /dev/mmcblk${card_no}p3 /mnt1 >> ${log_file} 2>&1
-			if [ $? -ne 0 ]; then
-				umount /mnt1 >> ${log_file} 2>&1
-				printf "    ERROR mounting cache partition\n"
-				return 1
-			fi
+	make_image "/mnt2/${BKP_PREFIX}_backup/android/data.raw.img" "Android data" "andro"
+	if [ $? -ne 0 ]; then
+		umount /mnt1 >> ${log_file} 2>&1
+		return 1
+	fi
 
-			make_image "/mnt2/${BKP_PREFIX}_backup/android/cache.raw.img" "Android cache" "andro"
-			if [ $? -ne 0 ]; then
-				umount /mnt1 >> ${log_file} 2>&1
-				return 1
-			fi
-		else
-			umount /mnt1 >> ${log_file} 2>&1
-			return 1
-		fi
+	umount /mnt1 >> ${log_file} 2>&1
+	# === backup cache partition ===
+	if [ "${sd_multi}" = "yes" ]; then
+		/bin/mountx /dev/disk/by-label/${multiboot_label}cache /mnt1 >> ${log_file} 2>&1
 	else
+		# Original Odroid android
+		/bin/mountx /dev/mmcblk${card_no}p${ACACHE_PART_ORIG} /mnt1 >> ${log_file} 2>&1
+	fi
+	if [ $? -ne 0 ]; then
 		umount /mnt1 >> ${log_file} 2>&1
+		printf "    ERROR mounting cache partition\n"
 		return 1
 	fi
 
-	umount /mnt1 >> ${log_file} 2>&1
+	make_image "/mnt2/${BKP_PREFIX}_backup/android/cache.raw.img" "Android cache" "andro"
+	if [ $? -ne 0 ]; then
+		umount /mnt1 >> ${log_file} 2>&1
+		return 1
+	fi
 
-	# Mount boot card and copy android boot files
+	umount /mnt1 >> ${log_file} 2>&1
+	# === Mount boot card and copy android user data and boot files ===
 	printf "    Backup: \033[32mCopy boot files\033[37m ... "
 	mount -t vfat /dev/mmcblk${card_no}p1 /mnt1 >> ${log_file} 2>&1
 	if [ $? -ne 0 ]; then
@@ -145,11 +154,10 @@ backup_android() {
 		return 1
 	fi
 
-	cp -rf /mnt1/* /mnt2/${BKP_PREFIX}_backup/android >> ${log_file} 2>&1
-	rm -f /mnt2/${BKP_PREFIX}_backup/android/${ODROID_IMAGE} >> ${log_file} 2>&1
-	rm -f /mnt2/${BKP_PREFIX}_backup/android/${ODROID_DTB} >> ${log_file} 2>&1
-	rm -rf /mnt2/${BKP_PREFIX}_backup/android/multiboot/* >> ${log_file} 2>&1
-	rmdir /mnt2/${BKP_PREFIX}_backup/android/multiboot >> ${log_file} 2>&1
+	cp -rf /mnt1/* /mnt2/${BKP_PREFIX}_backup/android/userdir >> ${log_file} 2>&1
+	rm -rf /mnt2/${BKP_PREFIX}_backup/android/userdir/multiboot/* >> ${log_file} 2>&1
+	rmdir /mnt2/${BKP_PREFIX}_backup/android/userdir/multiboot >> ${log_file} 2>&1
+	rm -f /mnt2/${BKP_PREFIX}_backup/android/userdir/boot.ini >> ${log_file} 2>&1
 
 	if [ "${sd_multi}" = "yes" ]; then
 		cp /mnt1/multiboot/${ODROID_IMAGE}.android /mnt2/${BKP_PREFIX}_backup/android/${ODROID_IMAGE} >> ${log_file} 2>&1
@@ -157,21 +165,48 @@ backup_android() {
 			printf "ERROR: Image\n"
 			return 1
 		fi
-		cp /mnt1/multiboot/${ODROID_DTB}.android /mnt2/${BKP_PREFIX}_backup/android/${ODROID_DTB} >> ${log_file} 2>&1
-		if [ $? -ne 0 ]; then
-			printf "ERROR: dtb\n"
-			return 1
+		if [ "${O_BOARD}" = "C2" ]; then
+			cp /mnt1/multiboot/${ODROID_DTB}.android /mnt2/${BKP_PREFIX}_backup/android/${ODROID_DTB} >> ${log_file} 2>&1
+			if [ $? -ne 0 ]; then
+				printf "ERROR: dtb\n"
+				return 1
+			fi
 		fi
 	else
-		cp /mnt1/${ODROID_IMAGE} /mnt2/${BKP_PREFIX}_backup/android >> ${log_file} 2>&1
-		if [ $? -ne 0 ]; then
-			printf "ERROR: Image\n"
-			return 1
+		# Original Odroid android, extract kernel/dtp from the card
+		if [ -f /mnt1/${ODROID_IMAGE} ]; then
+			cp /mnt1/${ODROID_IMAGE} /mnt2/${BKP_PREFIX}_backup/android >> ${log_file} 2>&1
+			if [ $? -ne 0 ]; then
+				printf "ERROR: Kernel\n"
+				return 1
+			fi
+		else
+			if [ "${O_BOARD}" = "C2" ]; then
+				dd if=/dev/mmcblk${card_no} of=/mnt2/${BKP_PREFIX}_backup/android/${ODROID_IMAGE} bs=512 skip=1632 count=32768 >> ${log_file} 2>&1
+			else
+				dd if=/dev/mmcblk${card_no} of=/mnt2/${BKP_PREFIX}_backup/android/${ODROID_IMAGE} bs=512 skip=1263 count=16384 >> ${log_file} 2>&1
+			fi
+			if [ $? -ne 0 ]; then
+				printf "ERROR: Kernel\n"
+				return 1
+			fi
+			sync
 		fi
-		cp /mnt1/${ODROID_DTB} /mnt2/${BKP_PREFIX}_backup/android >> ${log_file} 2>&1
-		if [ $? -ne 0 ]; then
-			printf "ERROR: dtb\n"
-			return 1
+		if [ -f /mnt1/${ODROID_DTB} ]; then
+			cp /mnt1/${ODROID_DTB} /mnt2/${BKP_PREFIX}_backup/android >> ${log_file} 2>&1
+			if [ $? -ne 0 ]; then
+				printf "ERROR: dtb\n"
+				return 1
+			fi
+		else
+			if [ "${O_BOARD}" = "C2" ]; then
+				dd if=/dev/mmcblk${card_no} of=/mnt2/${BKP_PREFIX}_backup/android/${ODROID_DTB} bs=512 skip=1504 count=128 >> ${log_file} 2>&1
+				if [ $? -ne 0 ]; then
+					printf "ERROR: dtb\n"
+					return 1
+				fi
+				sync
+			fi
 		fi
 	fi
 	umount /mnt1 >> ${log_file} 2>&1
@@ -187,7 +222,7 @@ backup_android() {
 backup_linux() {
 	printf "\n    Backup: \033[32m\033[1mLinux%s\033[22m\033[37m\n" "${1}"
 
-	# backup Linux partition, allready mounted on /mnt1
+	# backup Linux partition, already mounted on /mnt1
 	mkdir /mnt2/${BKP_PREFIX}_backup >> ${log_file} 2>&1
 	mkdir /mnt2/${BKP_PREFIX}_backup/linux${1} >> ${log_file} 2>&1
 	rm -rf /mnt2/${BKP_PREFIX}_backup/linux${1}/* >> ${log_file} 2>&1
@@ -254,7 +289,7 @@ backup_linux() {
 backup_oelec() {
 	printf "\n    Backup: \033[32m\033[1mOpenElec\033[22m\033[37m\n"
 
-	# backup oelec partition, allready mounted on /mnt1
+	# === backup oelec partition, allready mounted on /mnt1 ===
 	mkdir /mnt2/${BKP_PREFIX}_backup >> ${log_file} 2>&1
 	mkdir /mnt2/${BKP_PREFIX}_backup/oelec >> ${log_file} 2>&1
 	rm -rf /mnt2/${BKP_PREFIX}_backup/oelec/* >> ${log_file} 2>&1
@@ -270,7 +305,7 @@ backup_oelec() {
 
 	umount /mnt1 >> ${log_file} 2>&1
 
-	# Mount boot card and copy OpenElec boot files
+	# === Mount boot card and copy OpenElec boot files ===
 	printf "    Backup: \033[32mCopy OpenElec files\033[37m ... "
 	mount -t vfat /dev/mmcblk${card_no}p1 /mnt1 >> ${log_file} 2>&1
 	if [ $? -ne 0 ]; then
@@ -438,10 +473,10 @@ log_file="/mnt2/backup.log"
 #log_file="ls/dev/null"
 
 # Check source drive
-if [ -b /dev/mmcblk1 ]; then
+if [ "${NUMCARDS}" = "2" ]; then
 	printf "    \033[33mTwo cards detected, select which one to use for backup\033[37m\n\n"
-	printf "    \033[32m\033[1m0\033[22m EMMC Card\033[37m\n"
-	printf "    \033[32m\033[1m1\033[22m SD Card\033[37m\n\n"
+	printf "    \033[32m\033[1m0\033[22m Boot card (%s)\033[37m\n" "${BOOT_CARDTYPE}"
+	printf "    \033[32m\033[1m1\033[22m Other card (%s)\033[37m\n\n" "${OTHER_CARDTYPE}"
 
 	_delay=30
 	while [ $_delay -gt 0 ]; do
@@ -450,9 +485,12 @@ if [ -b /dev/mmcblk1 ]; then
 		if read -n 1 -t 1 -s B; then
 			_delay=30
 			if [ "${B}" = "0" ]; then
+				card_no="${BOOT_CARDDEV}"
+				card_type="${BOOT_CARDTYPE}"
 				break
 			elif [ "${B}" = "1" ]; then
-				card_no="1"
+				card_no="${OTHER_CARDDEV}"
+				card_type="${OTHER_CARDTYPE}"
 				break
 			fi
 		else
@@ -462,31 +500,28 @@ if [ -b /dev/mmcblk1 ]; then
 	disp_header
 fi
 
-# Display backup info
+# === Display backup info ===
 printf "    \033[32mBackup from "
 
-card_type="SD"
-if [ -b /dev/disk/by-label/sduserdata ] || [ -b /dev/disk/by-label/emuserdata ]; then
+if [ "${card_type}" = "SD" ]; then
+	multiboot_label="sd"
+else
+	multiboot_label="em"
+fi
+
+# === Check if the backup is from multiboot card ===
+# shellcheck disable=SC2010
+tmp_crdtype=`ls -l /dev/disk/by-label | grep mmcblk${card_no}p1 | awk '{print $4}'`
+if [ "${tmp_crdtype}" = "${multiboot_label}userdata" ]; then
 	sd_multi="yes"
-	# shellcheck disable=SC2010
-	tmp_crdtype=`ls -l /dev/disk/by-label | grep mmcblk${card_no}p1 | awk '{print $4}'`
-	[ "${tmp_crdtype}" = "emuserdata" ] && card_type="EMMC"
 	printf "\033[1mMultiBoot\033[22m %s card " "${card_type}"
 else
-	if [ -b /dev/mmcblk1 ] && [ "${card_no}" = "0" ]; then
-		card_type="EMMC"
-	elif [ -b /dev/mmcblk1 ] && [ "${card_no}" = "1" ]; then
-		card_type="SD"
-	else
-		card_type="SD/EMMC"
-	fi
 	printf "\033[1mOriginal Odroid\033[22m %s card " "${card_type}"
 fi
-
 printf " to \033[1mUSB partition #%s\033[22m\033[37m\n\n" "${usb_part}"
 
 
-# Mount partition 2 (Android system or Linux)
+# === Mount partition 2 (Android system or Linux) ===
 /bin/mountx /dev/mmcblk${card_no}p2 /mnt1 >> ${log_file} 2>&1
 if [ $? -ne 0 ]; then
 	umount /mnt2 > /dev/null 2>&1
@@ -494,7 +529,7 @@ if [ $? -ne 0 ]; then
 	exit_script
 fi
 
-# Wait for confirmation
+# === Wait for backup confirmation ===
 _delay=30
 while [ $_delay -gt 0 ]; do
 	printf "    \033[33mReady for backup, press \033[1mY\033[22m to continue, \033[1mE\033[22m to exit (%s)  \033[37m\r" "${_delay}"
@@ -517,10 +552,11 @@ while [ $_delay -gt 0 ]; do
 done
 if [ $_delay -eq 0 ]; then
 	printf "\r\033[2K"
+	umount /mnt2 > /dev/null 2>&1
 	exit_script
 fi
 
-# Ckeck if it is Android partition
+# === Ckeck if it is Android partition ===
 if [ -f /mnt1/${ODROID_FSTAB} ]; then
 	backup_android
 else
@@ -533,11 +569,13 @@ else
 fi
 
 umount /mnt1 >> ${log_file} 2>&1
+
+# === For multiboot card backup, continue to backup other operating systems ===
 if [ "${sd_multi}" = "yes" ]; then
-	if [ -b /dev/disk/by-label/sdlinux ] || [ -b /dev/disk/by-label/emlinux ]; then
+	if [ -b /dev/disk/by-label/${multiboot_label}linux ]; then
 		printf "\n"
-		# Backup multiboot Linux
-		/bin/mountx /dev/mmcblk${card_no}p7 /mnt1 >> ${log_file} 2>&1
+		# === Backup multiboot Linux ===
+		/bin/mountx /dev/disk/by-label/${multiboot_label}linux /mnt1 >> ${log_file} 2>&1
 		if [ $? -ne 0 ]; then
 			printf "    ERROR mounting Linux partition\n"
 			exit_script
@@ -548,10 +586,10 @@ if [ "${sd_multi}" = "yes" ]; then
 	fi
 	umount /mnt1 >> ${log_file} 2>&1
 
-	if [ -b /dev/disk/by-label/sdlinux2 ] || [ -b /dev/disk/by-label/emlinux2 ]; then
+	if [ -b /dev/disk/by-label/${multiboot_label}linux2 ]; then
 		printf "\n"
-		# Backup multiboot Linux2
-		/bin/mountx /dev/mmcblk${card_no}p8 /mnt1 >> ${log_file} 2>&1
+		# === Backup multiboot Linux2 ===
+		/bin/mountx /dev/disk/by-label/${multiboot_label}linux2 /mnt1 >> ${log_file} 2>&1
 		if [ $? -eq 0 ]; then
 			if [ -f /mnt1/etc/fstab ]; then
 				backup_linux "2"
@@ -559,10 +597,10 @@ if [ "${sd_multi}" = "yes" ]; then
 		fi
 	fi
 
-	if [ -b /dev/disk/by-label/sdaux ] || [ -b /dev/disk/by-label/emaux ]; then
+	if [ -b /dev/disk/by-label/${multiboot_label}aux ]; then
 		printf "\n"
-		# Backup multiboot OpenElec
-		/bin/mountx /dev/mmcblk${card_no}p6 /mnt1 >> ${log_file} 2>&1
+		# === Backup multiboot OpenElec ===
+		/bin/mountx /dev/disk/by-label/${multiboot_label}aux /mnt1 >> ${log_file} 2>&1
 		if [ $? -eq 0 ]; then
 			backup_oelec
 		fi

+ 83 - 48
XU4/initramfs/ramfs/init

@@ -179,17 +179,6 @@ mount_bottom
 nfs_bottom
 local_bottom
 
-#maybe_break bottom
-# We expect udev's init-bottom script to move /dev to ${rootmnt}/dev
-#run_scripts /scripts/init-bottom
-
-# Move /run to the root
-#mount -n -o move /run ${rootmnt}/run
-
-#validate_init() {
-#	run-init -n "${rootmnt}" "${1}"
-#}
-
 
 chown 0:0 /bin/*
 chown 0:0 /sbin/*
@@ -208,6 +197,16 @@ export ODROID_IMAGE="Kernel"
 export ODROID_ASYSTEMIMAGE="androsystem.img"
 export BKP_PREFIX="OD"
 export NUMCARDS="1"
+export UPGRADE_ANDROID="no"
+
+export ASYSTEM_PART="2"
+export ADATA_PART="5"
+export ACACHE_PART="3"
+export ADATA_PART_ORIG="3"
+export ACACHE_PART_ORIG="4"
+export LINUX_PART="7"
+export LINUX2_PART="8"
+export OELEC_PART="6"
 
 _desc=""
 _ini_prefix="multiboot"
@@ -249,20 +248,26 @@ boot_fail="yes"
 # === Set the variables depending on used Odroid board  ===
 if [ -f /ODROID_C2 ]; then
 	O_BOARD="C2"
+	ADATA_PART_ORIG="4"
+	ACACHE_PART_ORIG="3"
 	ODROID_DTB="meson64_odroidc2.dtb"
 	ODROID_FSTAB="fstab.odroidc2"
 	ODROID_IMAGE="Image"
 	ODROID_ASYSTEMIMAGE="rootsystem.img"
 	BKP_PREFIX="C2"
-	BOOT_CARDTYPE="SD"
 	BOOT_CARDDEV="0"
 	if [ -b /dev/mmcblk1p1 ]; then
+		BOOT_CARDTYPE="EMMC"
 		NUMCARDS="2"
 		OTHER_CARDDEV="1"
-		OTHER_CARDTYPE="EMMC"
+		OTHER_CARDTYPE="SD"
+	else
+		BOOT_CARDTYPE="${CARD_TYPE}"
 	fi
 elif [ -f /ODROID_XU ]; then
 	O_BOARD="XU"
+	ADATA_PART_ORIG="3"
+	ACACHE_PART_ORIG="4"
 	ODROID_DTB="exynos5422-odroidxu3.dtb"
 	ODROID_FSTAB="fstab.odroidxu3"
 	ODROID_IMAGE="zImage"
@@ -317,38 +322,46 @@ get_descr() {
 #-----------------------------------------------------------------------------------------------------------------------
 change_afstab() {
 	# === Configure Android fstab to mount the right partitions ===
-	if [ -f /mnt_a/${ODROID_FSTAB}${1} ]; then
-		if [ "${2}" = "yes" ]; then
+	if [ -f /mnt_a/${ODROID_FSTAB} ]; then
+		if [ "${1}" = "yes" ]; then
 			# Two cards, boot to Android on NON Boot card
 			if [ "${O_BOARD}" = "C2" ]; then
-				cat /mnt_a/${ODROID_FSTAB}${1} | sed "s/\/dev\/block\/mmcblk0/\/dev\/block\/mmcblk1/g" > _fstab_
+				sed -i "s/\/dev\/block\/mmcblk0/\/dev\/block\/mmcblk1/g" /mnt_a/${ODROID_FSTAB}
 			else
 				if [ "${OTHER_CARDTYPE}" = "SD" ]; then
-					cat /mnt_a/${ODROID_FSTAB}${1} | sed "s/\/dev\/block\/mmcblk0/\/dev\/block\/mmcblk1/g" > _fstab_
+					cp /mnt_a/${ODROID_FSTAB}.other /mnt_a/${ODROID_FSTAB}
+					sed -i "s/setenv akernel zImage/setenv akernel \/multiboot\/zImage.andro_1/g" /mnt1/boot.ini
 				else
-					cat /mnt_a/${ODROID_FSTAB}${1} | sed "s/\/dev\/block\/mmcblk1/\/dev\/block\/mmcblk0/g" > _fstab_
+					cp /mnt_a/${ODROID_FSTAB}.orig /mnt_a/${ODROID_FSTAB}
+					sed -i "s/setenv akernel zImage/setenv akernel \/multiboot\/zImage.android/g" /mnt1/boot.ini
 				fi
 			fi
 		else
+			# One or two cards, boot to Android on Boot card
 			if [ "${O_BOARD}" = "C2" ]; then
-				cat /mnt_a/${ODROID_FSTAB}${1} | sed "s/\/dev\/block\/mmcblk1/\/dev\/block\/mmcblk0/g" > _fstab_
+				# Restore boot device if modified earlier
+				sed -i "s/\/dev\/block\/mmcblk1/\/dev\/block\/mmcblk0/g" /mnt_a/${ODROID_FSTAB}
 			else
 				if [ "${NUMCARDS}" = "1" ]; then
-					cat /mnt_a/${ODROID_FSTAB}${1} | sed "s/\/dev\/block\/mmcblk1/\/dev\/block\/mmcblk0/g" > _fstab_
+					cp /mnt_a/${ODROID_FSTAB}.orig /mnt_a/${ODROID_FSTAB}
+					sed -i "s/setenv akernel zImage/setenv akernel \/multiboot\/zImage.android/g" /mnt1/boot.ini
 				else
 					# Two cards, boot to Android on Boot card
-					if [ "${BOOT_CARDTYPE}" = "SD" ]; then
-						cat /mnt_a/${ODROID_FSTAB}${1} | sed "s/\/dev\/block\/mmcblk0/\/dev\/block\/mmcblk1/g" > _fstab_
+					if [ "${BOOT_CARDTYPE}" = "SD" ] && [ "${BOOT_CARDDEV}" = "1" ]; then
+						cp /mnt_a/${ODROID_FSTAB}.other /mnt_a/${ODROID_FSTAB}
+						sed -i "s/setenv akernel zImage/setenv akernel \/multiboot\/zImage.andro_1/g" /mnt1/boot.ini
 					else
-						cat /mnt_a/${ODROID_FSTAB}${1} | sed "s/\/dev\/block\/mmcblk1/\/dev\/block\/mmcblk0/g" > _fstab_
+						cp /mnt_a/${ODROID_FSTAB}.orig /mnt_a/${ODROID_FSTAB}
+						sed -i "s/setenv akernel zImage/setenv akernel \/multiboot\/zImage.android/g" /mnt1/boot.ini
 					fi
 				fi
 			fi
 		fi
-		cp _fstab_ /mnt_a/${ODROID_FSTAB}${1} > /dev/null 2>&1
-		rm _fstab_ > /dev/null 2>&1
-	elif [ "${1}" = "" ]; then
-		printf "\033[31m\033[1m %s not found\033[22m\033[37m" "${ODROID_FSTAB}${1}"
+		if [ "${O_BOARD}" = "XU" ]; then
+			cp -f /mnt_a/${ODROID_FSTAB} /mnt_a/${ODROID_FSTAB}.sdboot
+		fi
+	else
+		printf "\033[31m\033[1m %s not found\033[22m\033[37m" "${ODROID_FSTAB}"
 		cp /mnt1/${_ini_prefix}/boot.ini.multi /mnt1/boot.ini > /dev/null 2>&1
 		[ "${O_BOARD}" = "XU" ] && cp /mnt1/${_ini_prefix}/boot.scr.multi /mnt1/boot.scr > /dev/null 2>&1
 		sleep 3
@@ -372,6 +385,7 @@ do_boot() {
 	local _oncard=""
 	_actmount="mnt1"
 	if [ "${3}" = "2" ]; then
+		# Operating system on NON BOOT card
 		_actmount="mnt2"
 		change_drive="yes"
 	fi
@@ -401,26 +415,20 @@ do_boot() {
 		sleep 1
 
 		if [ "${change_drive}" = "yes" ]; then
-			# === boot.ini from NON-BOOT card, prepare for boot from BOOT card ===
+			# === boot.ini from NON-BOOT card, prepare it for boot from BOOT card ===
 			if [ "${O_BOARD}" = "C2" ]; then
 				# for kernel/initrd/dtb loading
-				cat /mnt1/boot.ini | sed "s/fatload mmc 0:1/fatload mmc 1:1/g" > _bini_
-				cp _bini_ /mnt1/boot.ini
-				rm _bini_
+				sed -i "s/fatload mmc 0:1/fatload mmc 1:1/g" /mnt1/boot.ini
 				# for boot.ini loading from /multiboot (it was changed with previous sed operation!)
-				cat /mnt1/boot.ini | sed "s/1:1 0x60000000/0:1 0x60000000/g" > _bini_
-				cp _bini_ /mnt1/boot.ini
-				rm _bini_
+				sed -i "s/1:1 0x60000000/0:1 0x60000000/g" /mnt1/boot.ini
 			else
 				# for kernel/initrd/dtb loading
-				cat /mnt1/boot.ini | sed "s/setenv change_osdev no/setenv change_osdev yes/g" > _bini_
-				cp _bini_ /mnt1/boot.ini
-				rm _bini_
+				sed -i "s/setenv change_osdev no/setenv change_osdev yes/g" /mnt1/boot.ini
 			fi
 		fi
 
 		if [ "${1}" = "boot.ini.android" ]; then
-			# === mount android system partition to prepare android fstab ===
+			# === mount destination android system partition to prepare android fstab ===
 			mkdir /mnt_a > /dev/null 2>&1
 			if [ "${change_drive}" = "yes" ]; then
 				mount -t ext4 /dev/mmcblk${OTHER_CARDDEV}p2 /mnt_a > /dev/null 2>&1
@@ -437,18 +445,14 @@ do_boot() {
 			fi
 
 			# === Configure Android fstab to mount the right partitions ===
-			change_afstab "" "${change_drive}"
+			change_afstab "${change_drive}"
 			[ $? -ne 0 ] && return 1
-			change_afstab ".sdcard" "${change_drive}"
-			change_afstab ".sdboot" "${change_drive}"
 			umount /mnt_a > /dev/null 2>&1
 			# =============================================================
 
 			if [ "${O_BOARD}" = "C2" ] && [ "${change_drive}" = "yes" ]; then
 				# on C2 prepare boot.ini for boot from sdcard, not needed on XU
-				cat /mnt1/boot.ini | sed "s/root=\/dev\/mmcblk0p2/root=\/dev\/mmcblk1p2/g" > _bini_
-				cp _bini_ /mnt1/boot.ini
-				rm _bini_
+				sed -i "s/root=\/dev\/mmcblk0p2/root=\/dev\/mmcblk1p2/g" /mnt1/boot.ini
 			fi
 		fi
 
@@ -463,10 +467,23 @@ do_boot() {
 				umount /mnt_a > /dev/null 2>&1
 				return 1
 			fi
+			if [ -f /mnt1/multiboot/newscr ]; then
+				mkimage -C none -A arm -T script -d /mnt1/multiboot/boot.ini.multi /mnt1/multiboot/boot.scr.multi > /dev/null 2>&1
+				if [ $? -ne 0 ]; then
+					printf "\033[31m\033[1m mkimage (boot.scr.multi) ERROR\033[22m\033[37m"
+					cp /mnt1/${_ini_prefix}/boot.ini.multi /mnt1/boot.ini > /dev/null 2>&1
+					cp /mnt1/${_ini_prefix}/boot.scr.multi /mnt1/boot.scr > /dev/null 2>&1
+					sleep 3
+					umount /mnt_a > /dev/null 2>&1
+					return 1
+				fi
+				rm -f /mnt1/multiboot/newscr > /dev/null 2>&1
+			fi
 		fi
 		sleep 1
 		umount /mnt1
 		umount /mnt2 > /dev/null 2>&1
+		fsck.fat -aw /dev/mmcblk${BOOT_CARDDEV}p1 > /dev/null 2>&1
 		reboot
 	fi
 }
@@ -808,6 +825,7 @@ while true; do
 				sleep 1
 				# ============================
 				# Execute the installer script
+				UPGRADE_ANDROID="no"
 				/install.script
 				# ============================
 				A="Z"
@@ -820,9 +838,23 @@ while true; do
 			fi
 		elif [ "${A}" = "U" ]; then
 			# === ANDROID UPGRADE ====
-			printf "\r\033[2K"
-			printf "    NOT SUPPORTED"
-			sleep 4
+			if [ -f /install.script ]; then
+				umount /mnt1  > /dev/null 2>&1
+				umount /mnt2  > /dev/null 2>&1
+				sleep 1
+				# =========================
+				# Execute the backup script
+				UPGRADE_ANDROID="yes"
+				/install.script
+				# =========================
+				A="Z"
+				os_detect
+				_boot_delay=$BOOTDELAY
+			else
+				printf "\r\033[2K"
+				printf "    BACKUP SCRIPT NOT FOUND!"
+				sleep 4
+			fi
 		elif [ "${A}" = "X" ]; then
 			# === ENTER BUSYBOX ===
 			clear
@@ -850,12 +882,15 @@ while true; do
 			B="X"
 			while [ $_reboot_delay -gt 0 ]; do
 				printf "\r\033[2K"
-				printf "    \033[33m\033[1mREBOOT in %s sec, press \033[22ma\033[1m to abort \033[22m\033[37m\r" "$_reboot_delay"
+				printf "    \033[33m\033[1mREBOOT in %s sec, press \033[22ma\033[1m to abort, \033[22mr\033[1m to reboot \033[22m\033[37m\r" "$_reboot_delay"
 				if read -n 1 -t 1 -s B; then
 					_reboot_delay=10
 					if [ "${B}" = "a" ] || [ "${B}" = "A" ]; then
 						printf "\r\033[2K"
 						break
+					elif [ "${B}" = "r" ] || [ "${B}" = "R" ]; then
+						_reboot_delay=0
+						break
 					fi
 				else
 					let _reboot_delay=_reboot_delay-1

File diff suppressed because it is too large
+ 409 - 320
XU4/initramfs/ramfs/install.script


+ 16 - 6
XU4/initramfs/ramfs/multi/boot.ini.android

@@ -84,23 +84,31 @@ setenv edid "0"
  
 setenv hpd "1"
  
-setenv led_blink        "1"
+setenv led_blink "1"
  
-setenv bootargs     "fb_x_res=${fb_x_res} fb_y_res=${fb_y_res} hdmi_phy_res=${hdmi_phy_res} edid=${edid} hpd=${hpd} led_blink=${led_blink}"
+setenv bootargs "fb_x_res=${fb_x_res} fb_y_res=${fb_y_res} hdmi_phy_res=${hdmi_phy_res} edid=${edid} hpd=${hpd} led_blink=${led_blink}"
 
 # ========================================================
-# = RESTORE boot.scr FOR MULTIBOOT, DO NOT CHANGE        =
+# =     !! DO NOT CHANGE ANYTHING BELOW THIS LINE !!     =
 # ========================================================
+# =    RESTORE boot.scr FOR MULTIBOOT, DO NOT CHANGE     =
+# ========================================================
+setenv boot_mmc_type "unknown"
+setenv mmc_boot_device 9
+
 mmc list
 mmc dev
 
-setenv change_osdev no;
+setenv akernel zImage
+setenv change_osdev no
+setenv bootdev "0:1"
 
-setenv bootdev "0:1";
 if test "${mmc_boot_device}" = "0"; then
   setenv bootdev "0:1";
+  setenv boot_mmc_type "${boot_mmc0_type}";
 elif test "${mmc_boot_device}" = "1"; then
   setenv bootdev "1:1";
+  setenv boot_mmc_type "${boot_mmc1_type}";
 fi
 
 setenv os_dev "${bootdev}";
@@ -113,7 +121,9 @@ if test "${change_osdev}" = "yes"; then
 fi
 # ========================================================
 
-fatload mmc ${os_dev} 40008000 /multiboot/zImage.android
+echo "**** BOOT FROM: [${bootdev}] [${mmc_boot_device}:${boot_mmc_type}] TO: [${os_dev}] KERNEL: ${akernel} ***"
+
+fatload mmc ${os_dev} 40008000 ${akernel}
 
 # === RESTORE MULTIBOOT SCRIPT ===========================
 fatload mmc ${bootdev} 0x60000000 /multiboot/boot.scr.multi

+ 1 - 0
XU4/initramfs/ramfs/sbin/dosfsck

@@ -0,0 +1 @@
+fsck.fat

BIN
XU4/initramfs/ramfs/sbin/fsck.fat


+ 115 - 0
XU4/multiboot/boot.ini.inst

@@ -0,0 +1,115 @@
+ODROIDXU-UBOOT-CONFIG
+
+# ===============================================================
+#           USE THIS FILE ON ORIGINAL ODROID SD CARD            =
+#             TO BACKUP AND PREPARE FOR MULTIBOOT               =
+# ===============================================================
+
+# ===============================================================
+# =              Multi boot & install parameters                =
+# ===============================================================
+# Time (sec) to automatic boot if no key is pressed (min 5)     =
+# ------------------------------------------------------------- =
+setenv BOOT_DELAY "600"
+# ===============================================================
+# Menu item to boot if no key is pressed ("1" ~ "8")            =
+# ------------------------------------------------------------- =
+setenv DEFAULT_OS "1"
+#
+# ===============================================================
+
+
+# U-Boot Parameters
+setenv initrd_high "0xffffffff"
+setenv fdt_high "0xffffffff"
+
+# Mac address configuration
+setenv macaddr "00:1e:06:61:7a:39"
+
+setenv bootdev "0:1";
+setenv boot_mmc_type "SD";
+setenv mmc_boot_device 0
+
+#----------------------------------------
+# Set boot variables for kernel/initramfs
+#----------------------------------------
+setenv bootrootfs "console=tty0 quiet boot_card_type=${boot_mmc_type} boot_card_dev=${mmc_boot_device} instdelay=${INST_DELAY} default_boot=${DEFAULT_OS} no_console_suspend loglevel=0}"
+
+# boot commands
+setenv bootcmd "fatload mmc ${bootdev} 0x40008000 multiboot/zImage.multi; fatload mmc ${bootdev} 0x42000000 multiboot/uInitrd.multi; fatload mmc ${bootdev} 0x44000000 multiboot/exynos5422-odroidxu3.dtb.multi; bootz 0x40008000 0x42000000 0x44000000"
+
+# --- Screen Configuration for HDMI --- # 
+# ---------------------------------------
+# Uncomment only ONE line! Leave all commented for automatic selection.
+# Uncomment only the setenv line!
+# ---------------------------------------
+# ODROID-VU forced resolution
+# setenv videoconfig "video=HDMI-A-1:1280x800@60"
+# -----------------------------------------------
+# ODROID-VU forced EDID
+# setenv videoconfig "drm_kms_helper.edid_firmware=edid/1280x800.bin"
+# -----------------------------------------------
+# 1920x1080 (1080P) with monitor provided EDID information. (1080p-edid)
+# setenv videoconfig "video=HDMI-A-1:1920x1080@60"
+# -----------------------------------------------
+# 1920x1080 (1080P) without monitor data using generic information (1080p-noedid)
+# setenv videoconfig "drm_kms_helper.edid_firmware=edid/1920x1080.bin"
+# -----------------------------------------------
+# 1920x1080 50hz (1080P) with monitor provided EDID information. (1080p 50hz-edid)
+# setenv videoconfig "video=HDMI-A-1:1920x1080@50"
+# -----------------------------------------------
+# 1920x1080 50hz (1080P) without monitor data using generic information (1080p 50hz-noedid)
+# setenv videoconfig "drm_kms_helper.edid_firmware=edid/1920x1080_50hz.bin"
+# -----------------------------------------------
+# 1440x900 with monitor provided EDID information.
+# setenv videoconfig "video=HDMI-A-1:1440x900@60"
+# -----------------------------------------------
+# 1440x900 without monitor data using generic information 
+# setenv videoconfig "drm_kms_helper.edid_firmware=edid/1440x900.bin"
+# -----------------------------------------------
+# 1280x720 (720P) with monitor provided EDID information. (720p-edid)
+# setenv videoconfig "video=HDMI-A-1:1280x720@60"
+# -----------------------------------------------
+# 1280x720 (720P) without monitor data using generic information (720p-noedid)
+# setenv videoconfig "drm_kms_helper.edid_firmware=edid/1280x720.bin"
+# -----------------------------------------------
+# 1024x768 without monitor data using generic information
+# setenv videoconfig "drm_kms_helper.edid_firmware=edid/1024x768.bin"
+# -----------------------------------------------
+# 800x600 without monitor data using generic information 
+# setenv videoconfig "drm_kms_helper.edid_firmware=edid/800x600.bin"
+# -----------------------------------------------
+# 720x576 without monitor data using generic information 
+# setenv videoconfig "drm_kms_helper.edid_firmware=edid/720x576.bin"
+# -----------------------------------------------
+# 720x480 without monitor data using generic information 
+# setenv videoconfig "drm_kms_helper.edid_firmware=edid/720x480.bin"
+# -----------------------------------------------
+# 640x480 without monitor data using generic information
+# setenv videoconfig "drm_kms_helper.edid_firmware=edid/640x480.bin"
+
+
+
+# --- CPU Governor Setup ---
+# Uncomment only one line. New governor is set after 90secs after boot.
+# ------------------------------------------
+# - Performance (Keep all the CPU's at Maximum frequency)
+setenv governor "performance"
+# ------------------------------------------
+# - Ondemand
+# setenv governor "ondemand"
+# ------------------------------------------
+# - Interactive (Pretty much just like ondemand with more possible customization via sysfs.)
+# setenv governor "interactive"
+# ------------------------------------------
+# - Conservative (Like ondemand, but do the frequency transitions more slowly, great for battery powered applications)
+# setenv governor "conservative"
+# ------------------------------------------
+# - Powersave (Keeps the CPU's to the lowest possible temps)
+# setenv governor "powersave"
+
+# final boot args
+setenv bootargs "${bootrootfs} ${videoconfig} smsc95xx.macaddr=${macaddr} governor=${governor}"
+# drm.debug=0xff
+# Boot the board
+boot

+ 16 - 16
XU4/multiboot/boot.ini.multi

@@ -32,22 +32,22 @@ setenv mmc_boot_device 9
 mmc list
 mmc dev
 
-# ==========================================================================================================================
-# |   Inserted    | ------------------------------------------------------------------------------------------------------ |
-# | emmc | sdcard | switch | boot_mmc0_dev | boot_mmc0_type | boot_mmc1_dev | boot_mmc1_type | mmc_boot_device | boot_from |
-# ==========================================================================================================================
-# | yes  | no     |   SD   |       -       |      ----      |        -      |      ----      |         -       |    ----   |
-# --------------------------------------------------------------------------------------------------------------------------
-# | yes  | no     |  EMMC  |       0       |      eMMC      |        1      |      none      |         0       |    emmc   |
-# --------------------------------------------------------------------------------------------------------------------------
-# | no   | yes    |   SD   |       0       |       SD       |        1      |      none      |         0       |   sdcard  |
-# --------------------------------------------------------------------------------------------------------------------------
-# | no   | yes    |  EMMC  |       -       |      ----      |        -      |      ----      |         -       |    ----   |
-# --------------------------------------------------------------------------------------------------------------------------
-# | yes  | yes    |   SD   |       0       |       SD       |        1      |      eMMC      |         1       |    emmc   |!!
-# --------------------------------------------------------------------------------------------------------------------------
-# | yes  | yes    |  EMMC  |       0       |      eMMC      |        1      |       SD       |         1       |   sdcard  |!!
-# ==========================================================================================================================
+# ==========================================================================================================================================
+# |   Inserted    | ---------------------------------------------------------------------------------------------------------------------- |
+# | emmc | sdcard | switch | boot_mmc0_dev | boot_mmc0_type | boot_mmc1_dev | boot_mmc1_type | mmc_boot_device | boot_mmc_type | boot_from |
+# ==========================================================================================================================================
+# | yes  | no     |   SD   |       -       |      ----      |        -      |      ----      |         -       |       -       |    ----   |
+# ------------------------------------------------------------------------------------------------------------------------------------------
+# | yes  | no     |  EMMC  |       0       |      eMMC      |        1      |      none      |         0       |      eMMC     |    emmc   |
+# ------------------------------------------------------------------------------------------------------------------------------------------
+# | no   | yes    |   SD   |       0       |       SD       |        1      |      none      |         0       |       SD      |   sdcard  |
+# ------------------------------------------------------------------------------------------------------------------------------------------
+# | no   | yes    |  EMMC  |       -       |      ----      |        -      |      ----      |         -       |       -       |    ----   |
+# ------------------------------------------------------------------------------------------------------------------------------------------
+# | yes  | yes    |   SD   |       0       |       SD       |        1      |      eMMC      |         1       |      eMMC     |    emmc   |!!
+# ------------------------------------------------------------------------------------------------------------------------------------------
+# | yes  | yes    |  EMMC  |       0       |      eMMC      |        1      |       SD       |         1       |       SD      |   sdcard  |!!
+# ==========================================================================================================================================
 
 
 # =========================================================

BIN
XU4/multiboot/boot.scr.multi


BIN
XU4/multiboot/uInitrd.multi


BIN
bin/[


BIN
bin/[[


BIN
bin/acpid


BIN
bin/ash


BIN
bin/awk


BIN
bin/basename


BIN
bin/bash


BIN
bin/blockdev


BIN
bin/btrfs


BIN
bin/btrfs-zero-log


BIN
bin/busybox


BIN
bin/cat


BIN
bin/chmod


BIN
bin/chown


BIN
bin/chroot


BIN
bin/chvt


BIN
bin/clear


BIN
bin/cmp


BIN
bin/cp


BIN
bin/cpio


BIN
bin/cut


BIN
bin/date


BIN
bin/dd


BIN
bin/deallocvt


BIN
bin/devmem


BIN
bin/df


BIN
bin/dmesg


BIN
bin/dnsdomainname


BIN
bin/du


BIN
bin/dumpkmap


BIN
bin/dux


BIN
bin/echo


BIN
bin/egrep


BIN
bin/env


BIN
bin/expr


BIN
bin/false


BIN
bin/fbset


BIN
bin/fdflush


BIN
bin/fdisk


BIN
bin/fgrep


BIN
bin/find


BIN
bin/fstrim


BIN
bin/fstype


BIN
bin/grep


BIN
bin/gunzip


BIN
bin/gzip


BIN
bin/halt


BIN
bin/hostname


BIN
bin/hwclock


BIN
bin/ifconfig


BIN
bin/img2simg


BIN
bin/ip


BIN
bin/ipconfig


BIN
bin/kbd_mode


BIN
bin/kill


BIN
bin/kmod


BIN
bin/ln


BIN
bin/loadfont


BIN
bin/loadkeys


BIN
bin/loadkmap


BIN
bin/losetup


BIN
bin/ls


BIN
bin/lsx


BIN
bin/lzop


BIN
bin/lzopcat


BIN
bin/make_ext4fs


BIN
bin/minips


BIN
bin/mkdir


BIN
bin/mkfifo


BIN
bin/mkfs


BIN
bin/mkfs.btrfs


BIN
bin/mkfs.ext4


BIN
bin/mkfs.fat


BIN
bin/mkfs.vfat


BIN
bin/mknod


BIN
bin/mkswap


BIN
bin/mktemp


BIN
bin/modinfo


Some files were not shown because too many files changed in this diff