#!/bin/sh

. /env/config

if [ x${rootfs_boot_media} = xflash ];
then
		rootfs_img=/dev/nor0.rootfs_${active_cfg}

		if [ x${active_cfg} = x1 ];
		then
				rootfs_blkdev=/dev/mtdblock4
				cfg_1_ro="ro"
				cfg_2_ro=""
		else
				rootfs_blkdev=/dev/mtdblock6
				cfg_1_ro=""
				cfg_2_ro="ro"
		fi

		bootargs_rootfs="root=${rootfs_blkdev} rootfstype=squashfs ro"
elif [ x${rootfs_boot_media} = xnet ];
then
		bootargs_rootfs="root=/dev/nfs nfsroot=${eth0.serverip}:/srv/nfs/${board},v3,nolock,tcp ip=${eth0.ipaddr}"
else
		echo "ERROR: \$rootfs_boot_media invalid: ${rootfs_boot_media}"
		exit 1
fi

if [ x${kernel_boot_media} = xflash ];
then
		kernel_img=/dev/nor0.kernel_${active_cfg}
elif [ x${kernel_boot_media} = xnet ];
then
		cd /
		tftp ${board}/kernel.img || exit 1
		kernel_img=/kernel.img
else
		echo "ERROR: \$kernel_boot_media invalid: ${kernel_boot_media}"
		exit 1
fi

source /env/bin/set_nor_parts

bootargs_mtd="mtdparts=physmap-flash.0:${nor_parts}"

bootargs="${bootargs_common} ${bootargs_mtd} ${bootargs_rootfs}"

bootm ${kernel_img}