2010-10-11 14:34:41 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
type=""
|
|
|
|
device_type=""
|
2010-10-11 14:34:42 +00:00
|
|
|
check=n
|
2010-10-11 14:34:43 +00:00
|
|
|
mode=tftp
|
2010-10-11 14:34:41 +00:00
|
|
|
|
2011-01-07 16:35:29 +00:00
|
|
|
. /env/config
|
|
|
|
|
2010-10-11 14:34:43 +00:00
|
|
|
while getopt "ht:d:f:m:c" Option
|
2010-10-11 14:34:41 +00:00
|
|
|
do
|
|
|
|
if [ ${Option} = t ]; then
|
|
|
|
type=${OPTARG}
|
|
|
|
elif [ ${Option} = d ]; then
|
|
|
|
device_type=${OPTARG}
|
|
|
|
elif [ ${Option} = f ]; then
|
|
|
|
imagename=${OPTARG}
|
2010-10-11 14:34:42 +00:00
|
|
|
elif [ ${Option} = c ]; then
|
|
|
|
check=y
|
2010-10-11 14:34:43 +00:00
|
|
|
elif [ ${Option} = m ]; then
|
|
|
|
mode=${OPTARG}
|
2010-10-11 14:34:41 +00:00
|
|
|
else
|
|
|
|
. /env/bin/_update_help
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ x${type} = xkernel ]; then
|
|
|
|
image=$kernelimage
|
2011-09-25 20:54:09 +00:00
|
|
|
disk_part=$kernel_part
|
2010-10-11 14:34:41 +00:00
|
|
|
elif [ x${type} = xrootfs ]; then
|
|
|
|
image=$rootfsimage
|
|
|
|
type=root
|
2010-10-11 14:34:44 +00:00
|
|
|
elif [ x${type} = xbarebox ]; then
|
|
|
|
image=$bareboximage
|
2011-09-25 20:54:04 +00:00
|
|
|
if [ -z ${image} ]; then
|
2010-11-26 19:58:36 +00:00
|
|
|
image=barebox.bin
|
2010-10-11 14:34:44 +00:00
|
|
|
fi
|
2011-01-07 16:35:30 +00:00
|
|
|
elif [ x${type} = xbareboxenv ]; then
|
|
|
|
image=$bareboxenvimage
|
2011-09-25 20:54:04 +00:00
|
|
|
if [ -z ${image} ]; then
|
2011-01-07 16:35:30 +00:00
|
|
|
image=bareboxenv.bin
|
|
|
|
fi
|
2011-06-10 09:49:50 +00:00
|
|
|
elif [ x${type} = xxload ]; then
|
|
|
|
image=$xloadimage
|
2010-10-11 14:34:41 +00:00
|
|
|
else
|
|
|
|
. /env/bin/_update_help
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2011-09-25 20:54:04 +00:00
|
|
|
if [ -n ${imagename} ]; then
|
2010-10-11 14:34:41 +00:00
|
|
|
image=${imagename}
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ x${device_type} = xnand ]; then
|
|
|
|
part=/dev/nand0.${type}.bb
|
|
|
|
elif [ x${device_type} = xnor ]; then
|
|
|
|
part=/dev/nor0.${type}
|
2011-09-25 20:54:09 +00:00
|
|
|
elif [ x${device_type} = xdisk ]; then
|
|
|
|
part=/dev/${disk_part}
|
2010-10-11 14:34:41 +00:00
|
|
|
else
|
|
|
|
. /env/bin/_update_help
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2012-01-24 10:51:04 +00:00
|
|
|
if [ x${mode} != xtftp -a x${mode} != xxmodem -a x${mode} != xnfs ]; then
|
2010-10-11 14:34:43 +00:00
|
|
|
echo "unsupported mode ${mode}."
|
|
|
|
. /env/bin/_update_help
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2011-02-04 12:50:49 +00:00
|
|
|
. /env/bin/_update || exit 1
|
2010-10-11 14:34:42 +00:00
|
|
|
if [ x${check} = xy ]; then
|
|
|
|
crc32 -f $image -F $part
|
2011-02-04 12:50:49 +00:00
|
|
|
else
|
|
|
|
true
|
2010-10-11 14:34:42 +00:00
|
|
|
fi
|