yy    Ԩ          *1<эǨg=     /config #!/bin/sh

machine=phyflex-imx6
serverip=
user=

# use 'dhcp' to do dhcp in barebox and in kernel
# use 'none' if you want to skip kernel ip autoconfiguration
#ip=dhcp

# or set your networking parameters here
eth0.ipaddr=192.168.3.11
eth0.netmask=255.255.255.0
eth0.gateway=192.168.3.10
eth0.serverip=192.168.3.10

# can be either 'nfs', 'tftp', 'disk', 'nor' or 'nand'
kernel_loc=nand
# can be either 'net', 'disk', 'nor', 'nand' or 'initrd'
rootfs_loc=nand

# can be either 'jffs2' or 'ubifs'
#rootfsimage=root-$machine.$rootfs_type

# The image type of the kernel. Can be uimage, zimage, raw, or raw_lzo
kernel_part=disk0.0
kernelimage=zImage

if [ -n $user ]; then
	kernelimage="$user"-"$kernelimage"
	nfsroot="$serverip:/home/$user/nfsroot/$machine"
	rootfsimage="$user"-"$rootfsimage"
else
	nfsroot="$serverip:/path/to/nfs/root"
fi

autoboot_timeout=3

#bootargs="console=ttymxc3,115200 video=mxcfb0:dev=ldb,LDB-VGA,if=RGB666"
#bootargs="console=ttymxc3,115200 video=mxcfb0:dev=hdmi,1280x1024M@60,if=RGB24"
bootargs="console=ttymxc3,115200 vmalloc=256M board_mx6q_phyflex.hdmi_enable=1"

#disk_parts="1M(barebox)ro,1M(bareboxenv),4M(kernel),-(root)"

rootfs_part_linux_dev=mmcblk0p2
rootfs_type=ext3

rootfs_mtdblock_nand=4
rootfs_type=ubifs

# set a fancy prompt (if support is compiled in)
PS1="\e[1;32mbarebox@\e[1;31m\h:\w\e[0m "
   ǨgN  
   /bin/init   #!/bin/sh

PATH=/env/bin
export PATH

. /env/config
if [ -e /dev/nor0 -a -n "$nor_parts" ]; then
	addpart /dev/nor0 $nor_parts
fi

if [ -e /dev/disk0 -a -n "$disk_parts" ]; then
	addpart /dev/disk0 $disk_parts
fi

if [ -e /dev/nand0 -a -n "$nand_parts" ]; then
	addpart /dev/nand0 $nand_parts

	# Uh, oh, hush first expands wildcards and then starts executing
	# commands. What a bug!
	source /env/bin/hush_hack
fi

if [ -f /env/bin/init_board ]; then
	. /env/bin/init_board
fi

echo
echo -n "Hit any key to stop autoboot: "
timeout -a $autoboot_timeout
if [ $? != 0 ]; then
	exit
fi

boot
  Ǩg1     /bin/_update_help   #!/bin/sh

echo "usage: update -t <kernel|rootfs|barebox|bareboxenv|xload> -d <nor|nand> [-m tftp|xmodem] [-f imagename] -c"
echo "update tools."
echo ""
echo "options"
echo " -c     to check the crc32 for the image and flashed one"
echo ""
echo "default mode is tftp"
echo "type update -t kernel -d <nor|nand|disk> [-m tftp|xmodem|nfs] [-f imagename] to update kernel into flash"
echo "type update -t rootfs -d <nor|nand> [-m tftp|xmodem|nfs] [-f imagename] to update rootfs into flash"
echo "type update -t barebox -d <nor|nand> [-m tftp|xmodem|nfs] [-f imagename] to update barebox into flash"
echo "type update -t bareboxenv -d <nor|nand> [-m tftp|xmodem|nfs] [-f imagename] to update bareboxenv into flash"
echo "type update -t xload -d <nor|nand> [-m tftp|xmodem|nfs] [-f imagename] to update xload into flash"
   Ǩg	  
   /bin/boot   #!/bin/sh

. /env/config

if [ x$kernel_loc = xnet ]; then
	kernel_loc=tftp
fi

while getopt "hk:r:i:m:" Option
do
if [ ${Option} = k ]; then
	kernel_loc=${OPTARG}
elif [ ${Option} = r ]; then
	rootfs_loc=${OPTARG}
elif [ ${Option} = i ]; then
	ip=${OPTARG}
elif [ ${Option} = m ]; then
	mode=${OPTARG}
else
	. /env/bin/_boot_help
	exit 0
fi
done

if [ x$mode = xnand ]; then
	rootfs_loc=nand
	kernel_loc=nand
elif [ x$mode = xnor ]; then
	rootfs_loc=nor
	kernel_loc=nor
elif [ x$mode = xnfs ]; then
	rootfs_loc=net
	kernel_loc=nfs
elif [ x$mode = xtftp ]; then
	rootfs_loc=net
	kernel_loc=tftp
elif [ x$mode = xdisk ]; then
	rootfs_loc=disk
	kernel_loc=disk
fi

if [ x$ip = xdhcp ]; then
	bootargs="$bootargs ip=dhcp"
elif [ x$ip = xnone ]; then
	bootargs="$bootargs ip=none"
else
	bootargs="$bootargs ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask::eth0:"
fi


if [ x$rootfs_loc = xnet ]; then
	bootargs="$bootargs root=/dev/nfs nfsroot=$nfsroot,v3,tcp noinitrd"
elif [ x$rootfs_loc = xdisk ]; then
	bootargs="$bootargs root=/dev/$rootfs_part_linux_dev rootfstype=$rootfs_type noinitrd rootwait"
elif [ x$rootfs_loc = xinitrd ]; then
	bootargs="$bootargs root=/dev/ram0 rdinit=/sbin/init"
else
	if [ x$rootfs_loc = xnand ]; then
		rootfs_mtdblock=$rootfs_mtdblock_nand
	else
		rootfs_mtdblock=$rootfs_mtdblock_nor
	fi

	if [ x$rootfs_type = xubifs ]; then
		if [ -z $ubiroot ]; then
			ubiroot="root"
		fi
		bootargs="$bootargs root=ubi0:$ubiroot ubi.mtd=$rootfs_mtdblock"
	else
		bootargs="$bootargs root=/dev/mtdblock$rootfs_mtdblock"
	fi

	bootargs="$bootargs rootfstype=$rootfs_type noinitrd"
fi

if [ -n $nor_parts ]; then
	mtdparts="${mtdparts}physmap-flash.0:${nor_parts}"
fi

if [ -n $nand_parts ]; then
	if [ -n ${mtdparts} ]; then
		mtdparts="${mtdparts};"
	fi
	mtdparts="${mtdparts}${nand_device}:${nand_parts}"
fi

if [ -n $mtdparts ]; then
	bootargs="${bootargs} mtdparts=${mtdparts}"
fi

if [ x$kernel_loc = xnfs -o x$kernel_loc = xtftp ]; then
	if [ x$ip = xdhcp ]; then
		dhcp
	fi
	kdev=/image
	$kernel_loc $kernelimage $kdev || exit 1
elif [ x$kernel_loc = xnor ]; then
	kdev="/dev/nor0.kernel"
elif [ x$kernel_loc = xnand ]; then
	kdev="/dev/nand0.kernel.bb"
elif [ x$kernel_loc = xdisk ]; then
	mkdir /boot
	mount $kernel_part fat /boot
	kdev=/boot/$kernelimage
	#kdev="/dev/$kernel_part"
else
	echo "error: set kernel_loc to one of 'tftp', 'nfs', 'nand', 'nor' or 'disk'"
	exit 1
fi

echo "booting kernel from $kdev"

bootm $bootm_opt $kdev
 Ǩg      /bin/hush_hack  nand -a /dev/nand0.*
   ǨgR     /bin/update #!/bin/sh

type=""
device_type=""
check=n
mode=tftp

. /env/config

while getopt "ht:d:f:m:c" Option
do
if [ ${Option} = t ]; then
	type=${OPTARG}
elif [ ${Option} = d ]; then
	device_type=${OPTARG}
elif [ ${Option} = f ]; then
	imagename=${OPTARG}
elif [ ${Option} = c ]; then
	check=y
elif [ ${Option} = m ]; then
	mode=${OPTARG}
else
	. /env/bin/_update_help
	exit 0
fi
done

if [ x${type} = xkernel ]; then
	image=$kernelimage
	disk_part=$kernel_part
elif [ x${type} = xrootfs ]; then
	image=$rootfsimage
	type=root
elif [ x${type} = xbarebox ]; then
	image=$bareboximage
	if [ -z ${image} ]; then
		image=barebox.bin
	fi
elif [ x${type} = xbareboxenv ]; then
	image=$bareboxenvimage
	if [ -z ${image} ]; then
		image=bareboxenv.bin
	fi
elif [ x${type} = xxload ]; then
	image=$xloadimage
else
	. /env/bin/_update_help
	exit 1
fi

if [ -n ${imagename} ]; then
	image=${imagename}
fi

if [ x${device_type} = xnand ]; then
	part=/dev/nand0.${type}.bb
elif [ x${device_type} = xnor ]; then
	part=/dev/nor0.${type}
elif [ x${device_type} = xdisk ]; then
	part=/dev/${disk_part}
else
	. /env/bin/_update_help
	exit 1
fi

if [ x${mode} != xtftp -a x${mode} != xxmodem -a x${mode} != xnfs ]; then
	echo "unsupported mode ${mode}."
	. /env/bin/_update_help
	exit 1
fi

. /env/bin/_update || exit 1
if [ x${check} = xy ]; then
	crc32 -f $image -F $part
else
	true
fi
  Ǩg     /bin/_update    #!/bin/sh

if [ -z "$part" -o -z "$image" ]; then
	echo "define \$part and \$image"
	exit 1
fi

if [ ! -e "$part" ]; then
	echo "Partition $part does not exist"
	exit 1
fi

if [ x$mode = xtftp -o x$mode = xnfs ]; then
	if [ x$ip = xdhcp ]; then
		dhcp
	fi

	ping $eth0.serverip
	if [ $? -ne 0 ] ; then
		echo "Server did not reply! Update aborted."
		exit 1
	fi
	load=$mode
fi

if [ x$mode = xxmodem ]; then
	loadb -f $image -c
	if [ $? -ne 0 ] ; then
		echo "loadb failed or cancelled! Update aborted."
		exit 1
	fi
	load="cp -v"
fi

unprotect $part

echo
echo "erasing partition $part"
echo
erase $part || exit 1

echo
echo "flashing $image to $part"
echo
$load $image $part || exit 1

protect $part
  Ǩg;     /bin/_boot_help #!/bin/sh

echo "boot: boot [-m <mode>] [-k <kernel_option>] [-r <rootfs_option>] [-i <ip_mode>]"
echo ""
echo "options"
echo " - kernel        nand, nor, nfs, tftp, disk"
echo " - rootfs        nand, nor, net, disk"
echo " - ip            dhcp, none, empty"
echo ""
echo "mode option"
echo "   mode       kernel      rootfs"
echo "   nand       nand        nand"
echo "   nor        nor         nor"
echo "   nfs        nfs         net"
echo "   tftp       fttp        net"
echo "   disk       disk        disk"
echo ""
echo "default mode are used from the /env/config"
 