2015-09-11 11:39:53 +02:00
|
|
|
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
|
|
|
|
|
2016-03-03 15:57:17 +01:00
|
|
|
if itest.s x6SX == "x${cpu}" || itest.s x7D == "x${cpu}"; then
|
2015-09-11 11:39:53 +02:00
|
|
|
a_uImage1=0x82000000
|
|
|
|
a_uImage2=0x82400000
|
2014-09-23 15:28:31 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
setenv stdout serial,vga
|
2013-09-25 21:07:50 +02:00
|
|
|
echo "check U-Boot" ;
|
2015-09-11 11:39:53 +02:00
|
|
|
|
|
|
|
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
|
2012-09-24 22:42:58 +02:00
|
|
|
else
|
2015-09-11 11:39:53 +02:00
|
|
|
echo "Read verification error" ;
|
|
|
|
exit
|
2012-09-24 22:42:58 +02:00
|
|
|
fi
|
2015-09-11 11:39:53 +02:00
|
|
|
while echo "---- U-Boot upgraded. reset" ; do
|
|
|
|
sleep 120
|
|
|
|
done
|