summaryrefslogtreecommitdiffstats
path: root/defaultenv/bin/update
blob: 6fd5e4ca269d6b88d0f3a500e7860ffb1e9956be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/sh

type=""
device_type=""
check=n
mode=tftp

. /env/config

while getopt "ht:d:f:m:c" Option
do
if [ ${Option} = t ]; then
	type=${OPTARG}
elif [ ${Option} = d ]; then
	device_type=${OPTARG}
elif [ ${Option} = f ]; then
	imagename=${OPTARG}
elif [ ${Option} = c ]; then
	check=y
elif [ ${Option} = m ]; then
	mode=${OPTARG}
else
	. /env/bin/_update_help
	exit 0
fi
done

if [ x${type} = xkernel ]; then
	image=$kernelimage
elif [ x${type} = xrootfs ]; then
	image=$rootfsimage
	type=root
elif [ x${type} = xbarebox ]; then
	image=$bareboximage
	if [ -z ${image} ]; then
		image=barebox.bin
	fi
elif [ x${type} = xbareboxenv ]; then
	image=$bareboxenvimage
	if [ -z ${image} ]; then
		image=bareboxenv.bin
	fi
elif [ x${type} = xxload ]; then
	image=$xloadimage
else
	. /env/bin/_update_help
	exit 1
fi

if [ -n ${imagename} ]; then
	image=${imagename}
fi

if [ x${device_type} = xnand ]; then
	part=/dev/nand0.${type}.bb
elif [ x${device_type} = xnor ]; then
	part=/dev/nor0.${type}
else
	. /env/bin/_update_help
	exit 1
fi

if [ x${mode} != xtftp -a x${mode} != xxmodem ] ; then
	echo "unsupported mode ${mode}."
	. /env/bin/_update_help
	exit 1
fi

. /env/bin/_update || exit 1
if [ x${check} = xy ]; then
	crc32 -f $image -F $part
else
	true
fi