mmc: with bootloader in flash, there is chance the boot device is not /dev/mmcblk0

Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
pull/22/head
Robert Nelson 12 years ago
parent 0d7cc022cc
commit 17bbd2574b

@ -12,6 +12,12 @@ if [ ! -f /boot/uboot/SOC.sh ] ; then
fi fi
. /boot/uboot/SOC.sh . /boot/uboot/SOC.sh
if [ -f /boot/uboot/bootdrive ] ; then
bootdrive=$(cat /boot/uboot/bootdrive)
else
bootdrive=/dev/mmcblk0
fi
if [ ! -d /boot/uboot/backup/ ] ; then if [ ! -d /boot/uboot/backup/ ] ; then
mkdir -p /boot/uboot/backup/ mkdir -p /boot/uboot/backup/
fi fi
@ -22,9 +28,9 @@ fdisk -l >> /var/log/netinstall.log
#Set boot flag on: /dev/mmcblk0: #Set boot flag on: /dev/mmcblk0:
if [ -f /sbin/parted ] ; then if [ -f /sbin/parted ] ; then
/sbin/parted /dev/mmcblk0 set 1 boot on || true /sbin/parted ${bootdrive} set 1 boot on || true
else else
echo "ERROR: [/sbin/parted /dev/mmcblk0 set 1 boot on] failed" >> /var/log/netinstall.log echo "ERROR: [/sbin/parted ${bootdrive} set 1 boot on] failed" >> /var/log/netinstall.log
fi fi
#Find Target Partition and FileSystem #Find Target Partition and FileSystem
@ -78,9 +84,9 @@ else
fi fi
if [ "x${boot_fstype}" = "xext2" ] ; then if [ "x${boot_fstype}" = "xext2" ] ; then
echo "/dev/mmcblk0p1 /boot/uboot ext2 defaults 0 2" >> /etc/fstab echo "${bootdrive}p1 /boot/uboot ext2 defaults 0 2" >> /etc/fstab
else else
echo "/dev/mmcblk0p1 /boot/uboot auto defaults 0 0" >> /etc/fstab echo "${bootdrive}p1 /boot/uboot auto defaults 0 0" >> /etc/fstab
fi fi
if [ "x${usbnet_mem}" != "x" ] ; then if [ "x${usbnet_mem}" != "x" ] ; then

@ -12,6 +12,12 @@ if [ ! -f /boot/uboot/SOC.sh ] ; then
fi fi
. /boot/uboot/SOC.sh . /boot/uboot/SOC.sh
if [ -f /boot/uboot/bootdrive ] ; then
bootdrive=$(cat /boot/uboot/bootdrive)
else
bootdrive=/dev/mmcblk0
fi
if [ ! -d /boot/uboot/backup/ ] ; then if [ ! -d /boot/uboot/backup/ ] ; then
mkdir -p /boot/uboot/backup/ mkdir -p /boot/uboot/backup/
fi fi
@ -22,9 +28,9 @@ fdisk -l >> /var/log/netinstall.log
#Set boot flag on: /dev/mmcblk0: #Set boot flag on: /dev/mmcblk0:
if [ -f /sbin/parted ] ; then if [ -f /sbin/parted ] ; then
/sbin/parted /dev/mmcblk0 set 1 boot on || true /sbin/parted ${bootdrive} set 1 boot on || true
else else
echo "ERROR: [/sbin/parted /dev/mmcblk0 set 1 boot on] failed" >> /var/log/netinstall.log echo "ERROR: [/sbin/parted ${bootdrive} set 1 boot on] failed" >> /var/log/netinstall.log
fi fi
#Find Target Partition and FileSystem #Find Target Partition and FileSystem
@ -89,7 +95,7 @@ fi
if [ "${dd_uboot_seek}" ] && [ "${dd_uboot_bs}" ] ; then if [ "${dd_uboot_seek}" ] && [ "${dd_uboot_bs}" ] ; then
if [ -f /boot/uboot/backup/u-boot.imx ] ; then if [ -f /boot/uboot/backup/u-boot.imx ] ; then
dd if=/boot/uboot/backup/u-boot.imx of=/dev/mmcblk0 seek=${dd_uboot_seek} bs=${dd_uboot_bs} dd if=/boot/uboot/backup/u-boot.imx of=${bootdrive} seek=${dd_uboot_seek} bs=${dd_uboot_bs}
fi fi
fi fi
@ -129,9 +135,9 @@ else
fi fi
if [ "x${boot_fstype}" = "xext2" ] ; then if [ "x${boot_fstype}" = "xext2" ] ; then
echo "/dev/mmcblk0p1 /boot/uboot ext2 defaults 0 2" >> /etc/fstab echo "${bootdrive}p1 /boot/uboot ext2 defaults 0 2" >> /etc/fstab
else else
echo "/dev/mmcblk0p1 /boot/uboot auto defaults 0 0" >> /etc/fstab echo "${bootdrive}p1 /boot/uboot auto defaults 0 0" >> /etc/fstab
fi fi
if [ "x${usbnet_mem}" != "x" ] ; then if [ "x${usbnet_mem}" != "x" ] ; then

@ -803,23 +803,48 @@ flash_kernel_base_installer () {
mkdir -p /target/boot/uboot || true mkdir -p /target/boot/uboot || true
mkdir -p /target/lib/modules/\$(uname -r) || true mkdir -p /target/lib/modules/\$(uname -r) || true
mount /dev/mmcblk0p1 /target/boot/uboot #Some devices may have mmc cards in both slots...
unset got_boot_drive
if [ ! ${got_boot_drive} ] ; then
if [ -b /dev/mmcblk0p1 ] ; then
mount /dev/mmcblk0p1 /target/boot/uboot
if [ -f /target/boot/uboot/SOC.sh ] ; then
got_boot_drive=1
else
umount /target/boot/uboot
fi
fi
fi
#z = gzip (busybox tar) if [ ! ${got_boot_drive} ] ; then
tar -xzv -f /target/boot/uboot/\$(uname -r)-modules.tar.gz -C /target/lib/modules/\$(uname -r) if [ -b /dev/mmcblk1p1 ] ; then
mount /dev/mmcblk1p1 /target/boot/uboot
if [ -f /target/boot/uboot/SOC.sh ] ; then
got_boot_drive=1
else
umount /target/boot/uboot
fi
fi
fi
mount -o bind /sys /target/sys if [ ${got_boot_drive} ] ; then
cat /proc/mounts > /target/mounts #z = gzip (busybox tar)
chroot /target update-initramfs -c -k \$(uname -r) tar -xzv -f /target/boot/uboot/\$(uname -r)-modules.tar.gz -C /target/lib/modules/\$(uname -r)
rm -f /target/mounts || true
umount /target/sys
cp /target/boot/uboot/${fki_vmlinuz} /target/boot/${fki_vmlinuz} mount -o bind /sys /target/sys
cp /target/boot/initrd.img-\$(uname -r) /target/boot/${fki_initrd} cat /proc/mounts > /target/mounts
sync chroot /target update-initramfs -c -k \$(uname -r)
umount /target/boot/uboot rm -f /target/mounts || true
umount /target/sys
export FLASH_KERNEL_SKIP=true cp /target/boot/uboot/${fki_vmlinuz} /target/boot/${fki_vmlinuz}
cp /target/boot/initrd.img-\$(uname -r) /target/boot/${fki_initrd}
sync
umount /target/boot/uboot
export FLASH_KERNEL_SKIP=true
fi
__EOF__ __EOF__
@ -850,7 +875,33 @@ finish_installing_device () {
if [ -f /etc/rcn.conf ]; then if [ -f /etc/rcn.conf ]; then
mkdir -p /target/boot/uboot || true mkdir -p /target/boot/uboot || true
mount /dev/mmcblk0p1 /target/boot/uboot
#Some devices may have mmc cards in both slots...
unset got_boot_drive
if [ ! ${got_boot_drive} ] ; then
if [ -b /dev/mmcblk0p1 ] ; then
mount /dev/mmcblk0p1 /target/boot/uboot
if [ -f /target/boot/uboot/SOC.sh ] ; then
got_boot_drive=1
echo "/dev/mmcblk0" > /target/boot/uboot/bootdrive
else
umount /target/boot/uboot
fi
fi
fi
if [ ! ${got_boot_drive} ] ; then
if [ -b /dev/mmcblk1p1 ] ; then
mount /dev/mmcblk1p1 /target/boot/uboot
if [ -f /target/boot/uboot/SOC.sh ] ; then
got_boot_drive=1
echo "/dev/mmcblk1" > /target/boot/uboot/bootdrive
else
umount /target/boot/uboot
fi
fi
fi
if [ -d /lib/firmware/ ] ; then if [ -d /lib/firmware/ ] ; then
cp -rf /lib/firmware/ /target/lib/ || true cp -rf /lib/firmware/ /target/lib/ || true

Loading…
Cancel
Save