Anatolij Gustschin | ffd955c | 2020-05-26 12:03:21 +0200 | [diff] [blame] | 1 | setenv stdout serial,vidconsole |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 2 | echo "check U-Boot" ; |
| 3 | setenv offset 0x400 |
| 4 | if ${fs}load ${dtype} ${disk}:1 12000000 u-boot.imx || ${fs}load ${dtype} ${disk}:1 12000000 u-boot.nopadding ; then |
| 5 | echo "read $filesize bytes from SD card" ; |
| 6 | if sf probe || sf probe || \ |
| 7 | sf probe 1 27000000 || sf probe 1 27000000 ; then |
| 8 | echo "probed SPI ROM" ; |
Wolfgang Denk | 93e1459 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 9 | if sf read 0x12400000 $offset $filesize ; then |
| 10 | if cmp.b 0x12000000 0x12400000 $filesize ; then |
| 11 | echo "------- U-Boot versions match" ; |
| 12 | else |
| 13 | echo "Need U-Boot upgrade" ; |
| 14 | echo "Program in 5 seconds" ; |
| 15 | for n in 5 4 3 2 1 ; do |
| 16 | echo $n ; |
| 17 | sleep 1 ; |
| 18 | done |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 19 | echo "erasing" ; |
Eric Nelson | 8f8b894 | 2013-10-09 12:25:15 -0700 | [diff] [blame] | 20 | sf erase 0 0xC0000 ; |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 21 | # two steps to prevent bricking |
| 22 | echo "programming" ; |
Wolfgang Denk | 93e1459 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 23 | sf write 0x12000000 $offset $filesize ; |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 24 | echo "verifying" ; |
Wolfgang Denk | 93e1459 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 25 | if sf read 0x12400000 $offset $filesize ; then |
| 26 | if cmp.b 0x12000000 0x12400000 $filesize ; then |
| 27 | while echo "---- U-Boot upgraded. reset" ; do |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 28 | sleep 120 |
| 29 | done |
Wolfgang Denk | 93e1459 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 30 | else |
| 31 | echo "Read verification error" ; |
| 32 | fi |
| 33 | else |
| 34 | echo "Error re-reading EEPROM" ; |
| 35 | fi |
| 36 | fi |
| 37 | else |
| 38 | echo "Error reading boot loader from EEPROM" ; |
| 39 | fi |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 40 | else |
Wolfgang Denk | 93e1459 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 41 | echo "Error initializing EEPROM" ; |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 42 | fi ; |
| 43 | else |
| 44 | echo "No U-Boot image found on SD card" ; |
| 45 | fi |