Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- MEDIA=/opt/recovery
- OS=Yocto
- UBOOT_IMAGE=u-boot.bin
- KERNEL_IMAGE=uImage
- ROOTFS_IMAGE=rootfs.ubi.img
- ANDROID_BOOT=boot.img
- ANDROID_RECOVERY=recovery.img
- ANDROID_SYSTEM=android_root.img
- UBI_SUB_PAGE_SIZE=2048
- UBI_VID_HDR_OFFSET=2048
- install_bootloader()
- {
- if [ ! -f $MEDIA/$OS/$UBOOT_IMAGE ]
- then
- echo "\"$MEDIA/$OS/$UBOOT_IMAGE\"" does not exist! exit.
- exit 1
- fi
- echo "Installing U-Boot ..."
- flash_eraseall /dev/mtd0 2>/dev/null
- kobs-ng init $MEDIA/$OS/$UBOOT_IMAGE --search_exponent=1 -v > /dev/null
- }
- install_kernel()
- {
- if [ ! -f $MEDIA/$OS/$KERNEL_IMAGE ]
- then
- echo "\"$MEDIA/$OS/$KERNEL_IMAGE\"" does not exist! exit.
- exit 1
- fi
- echo "Installing Kernel ..."
- flash_eraseall /dev/mtd1 2>/dev/null
- nandwrite -p /dev/mtd1 $MEDIA/$OS/$KERNEL_IMAGE > /dev/null
- }
- install_rootfs()
- {
- if [ ! -f $MEDIA/$OS/$ROOTFS_IMAGE ]
- then
- echo "\"$MEDIA/$OS/$ROOTFS_IMAGE\"" does not exist! exit.
- exit 1
- fi
- echo "Installing UBI rootfs ..."
- flash_eraseall /dev/mtd2 2>/dev/null
- ubiformat /dev/mtd2 -f $MEDIA/$OS/$ROOTFS_IMAGE -s $UBI_SUB_PAGE_SIZE -O $UBI_VID_HDR_OFFSET
- }
- install_android_system()
- {
- if [ ! -f $MEDIA/$OS/$ANDROID_SYSTEM ]
- then
- echo "\"$MEDIA/$OS/$ANDROID_SYSTEM\"" does not exist! exit.
- exit 1
- fi
- echo "Installing system.img ..."
- flash_eraseall /dev/mtd5 2>/dev/null
- ubiformat /dev/mtd5 -f $MEDIA/$OS/$ANDROID_SYSTEM -s $UBI_SUB_PAGE_SIZE -O $UBI_VID_HDR_OFFSET
- }
- install_android_boot()
- {
- if [ ! -f $MEDIA/$OS/$ANDROID_BOOT ]
- then
- echo "\"$MEDIA/$OS/$ANDROID_BOOT\"" does not exist! exit.
- exit 1
- fi
- echo "Installing boot.img ..."
- flash_eraseall /dev/mtd3 2>/dev/null
- nandwrite -p /dev/mtd3 $MEDIA/$OS/$ANDROID_BOOT > /dev/null
- }
- install_android_recovery()
- {
- if [ ! -f $MEDIA/$OS/$ANDROID_RECOVERY ]
- then
- echo "\"$MEDIA/$OS/$ANDROID_RECOVERY\"" does not exist! exit.
- exit 1
- fi
- echo "Installing recovery.img ..."
- flash_eraseall /dev/mtd4 2>/dev/null
- nandwrite -p /dev/mtd4 $MEDIA/$OS/$ANDROID_RECOVERY > /dev/null
- }
- usage()
- {
- cat << EOF
- usage: $0 options
- This script install Linux/Android binaries in VAR-SOM-MX6 NAND.
- OPTIONS:
- -h Show this message
- -o <Linux|Android|Ubuntu|Yocto> OS type (defualt: Linux).
- EOF
- }
- while getopts .ho:c. OPTION
- do
- case $OPTION in
- h)
- usage
- exit 1
- ;;
- o)
- OS=$OPTARG
- ;;
- ?)
- usage
- exit 1
- ;;
- esac
- done
- if [[ "$OS" != "Linux" ]] && [[ "$OS" != "Android" ]] && [[ "$OS" != "Ubuntu" ]] && [[ "$OS" != "Yocto" ]]
- then
- usage
- exit 1
- fi
- echo "*** VAR-SOM-MX6 NAND RECOVERY ***"
- echo "Installing $OS on NAND ..."
- #if [ `cat /proc/cpuinfo |grep processor | wc -l` = 1 ] ; then
- # UBOOT_IMAGE=u-boot.solo.bin
- # ANDROID_BOOT=boot.solo.img
- #fi
- if [ `dmesg |grep MT29F8G08ABABAWP | wc -l` = 1 ] ; then
- # this is 1GB NAND (MT29F8G08ABABAWP)
- ROOTFS_IMAGE=rootfs_1G_NAND.ubi.img
- ANDROID_SYSTEM=android_root_1G_NAND.img
- UBI_SUB_PAGE_SIZE=4096
- UBI_VID_HDR_OFFSET=4096
- fi
- install_bootloader
- if [ "$OS" != "Android" ] ; then
- install_kernel
- install_rootfs
- else
- install_android_boot
- install_android_recovery
- install_android_system
- fi
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement