summaryrefslogtreecommitdiff
path: root/board/boundarydevices/common/6x_upgrade.txt
blob: e012ff97ac3d8d915f5b4693d81b286a02900c4a (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
if itest.s a$uboot_defconfig == a; then
        echo "Please set uboot_defconfig to the appropriate value"
        exit
fi

offset=0x400
a_uImage1=0x12000000
a_uImage2=0x12400000

if itest.s x6SX == "x${cpu}" || itest.s x7D == "x${cpu}"; then
	a_uImage1=0x82000000
	a_uImage2=0x82400000
fi

setenv stdout serial,vga
echo "check U-Boot" ;

if load ${dtype} ${disk}:1 ${a_uImage1} u-boot.$uboot_defconfig ; then
else
	echo "No U-Boot image found on SD card" ;
	exit
fi
echo "read $filesize bytes from SD card" ;
if sf probe || sf probe || sf probe 1 27000000 || sf probe 1 27000000 ; then
	echo "probed SPI ROM" ;
else
	echo "Error initializing EEPROM" ;
	exit
fi ;
if sf read ${a_uImage2} $offset $filesize ; then
else
	echo "Error reading boot loader from EEPROM" ;
	exit
fi
if cmp.b ${a_uImage1} ${a_uImage2} $filesize ; then
	echo "------- U-Boot versions match" ;
	exit
fi
echo "Need U-Boot upgrade" ;
echo "Program in 5 seconds" ;
for n in 5 4 3 2 1 ; do
	echo $n ;
	sleep 1 ;
done
echo "erasing" ;
sf erase 0 0xC0000 ;

# two steps to prevent bricking
echo "programming" ;
setexpr a1 ${a_uImage1} + 0x400
setexpr o1 ${offset} + 0x400
setexpr s1 ${filesize} - 0x400
sf write ${a1} ${o1} ${s1} ;
sf write ${a_uImage1} $offset 0x400 ;

echo "verifying" ;
if sf read ${a_uImage2} $offset $filesize ; then
else
	echo "Error re-reading EEPROM" ;
	exit
fi
if cmp.b ${a_uImage1} ${a_uImage2} $filesize ; then
else
	echo "Read verification error" ;
	exit
fi
while echo "---- U-Boot upgraded. reset" ; do
	sleep 120
done