#!/bin/sh

UBOOT="/root/u-boot-sunxi-with-spl.bin"
if [ -f $UBOOT ]; then
	fw_printenv > /dev/null 2>&1
	if [ $? == 0 ]; then
		echo "Updating u-boot in MMC"
		dd if=$UBOOT of=/dev/mmcblk0p1 conv=notrunc
	else
		echo "Updating u-boot in SPI flash"
		flash_erase /dev/mtd0 0 0
		dd if=$UBOOT of=/dev/mtd0 conv=notrunc
	fi
fi

echo "Done."
