
echo "copying barebox to nand..."

mci0.probe=1
mkdir mnt

mount /dev/disk0.0 fat /mnt
if [ $? != 0 ]; then
	echo "failed to mount mmc card"
	exit 1
fi

if [ ! -f /mnt/mlo-nand.bin ]; then
	echo "mlo-nand.bin not found on mmc card"
	exit 1
fi

if [ ! -f /mnt/barebox.bin ]; then
	echo "barebox.bin not found on mmc card"
fi

gpmc_nand0.eccmode=bch8_hw_romcode
erase /dev/nand0.xload.bb
cp /mnt/mlo-nand.bin /dev/nand0.xload.bb

gpmc_nand0.eccmode=bch8_hw
erase /dev/nand0.barebox.bb
cp /mnt/barebox.bin /dev/nand0.barebox.bb

echo "success"

