#!/bin/sh

. /env/config

if [ x$1 = xnand ]; then
	rootfs_loc=nand
	kernel_loc=nand
fi

if [ x$1 = xnet ]; then
	rootfs_loc=net
	kernel_loc=net
fi

if [ x$1 = xnor ]; then
	rootfs_loc=nor
	kernel_loc=nor
fi

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

if [ x$rootfs_loc = xnand ]; then
	bootargs="$bootargs root=$rootpart_nand rootfstype=jffs2"
elif [ x$rootfs_loc = xnor ]; then
	bootargs="$bootargs root=$rootpart_nor rootfstype=jffs2"
else
	bootargs="$bootargs root=/dev/nfs nfsroot=$eth0.serverip:$nfsroot,v3,tcp"
fi

bootargs="$bootargs mtdparts=\"physmap-flash.0:$nor_parts\""

if [ $kernel_loc = net ]; then
	if [ x$ip = xdhcp ]; then
		dhcp
	fi
	tftp $kernel uImage || exit 1
	bootm uImage
elif [ $kernel_loc = nor ]; then
	bootm /dev/nor0.kernel
else
	bootm /dev/nand0.kernel.bb
fi

