Always check for tftp status on download. Don't continue to
format and/or program new image if an error in tftp download.

Signed-off-by: Michael Durrant <mdurr...@arcturusnetworks.com>
Signed-off-by: Oleksandr G Zhadan <ol...@arcturusnetworks.com>
---

 include/configs/UCP1020.h | 135 ++++++++++++++++++++++++++++------------------
 1 file changed, 84 insertions(+), 51 deletions(-)

diff --git a/include/configs/UCP1020.h b/include/configs/UCP1020.h
index 57e0c6c..282b68f 100644
--- a/include/configs/UCP1020.h
+++ b/include/configs/UCP1020.h
@@ -659,24 +659,28 @@
 "fileaddr=0x01000000\0"                                                        
\
 "filesize=0x00080000\0"                                                        
\
 "flashmbr=sf probe 0; "                                                        
\
-       "tftp $loadaddr $mbr; "                                         \
+       "if tftp $loadaddr $mbr; then "                                 \
        "sf erase $mbr_offset +$filesize; "                             \
-       "sf write $loadaddr $mbr_offset $filesize\0"                    \
-"flashrecovery=tftp $recoveryaddr $cramfsfile; "                       \
+       "sf write $loadaddr $mbr_offset $filesize; "                    \
+       "else echo $tftp_error_msg; fi\0"                               \
+"flashrecovery=if tftp $recoveryaddr $cramfsfile; then "               \
        "protect off $nor_recoveryaddr +$filesize; "                    \
        "erase $nor_recoveryaddr +$filesize; "                          \
        "cp.b $recoveryaddr $nor_recoveryaddr $filesize; "              \
-       "protect on $nor_recoveryaddr +$filesize\0 "                    \
-"flashuboot=tftp $ubootaddr $ubootfile; "                              \
+       "protect on $nor_recoveryaddr +$filesize; "                     \
+       "else echo $tftp_error_msg; fi\0"                               \
+"flashuboot=if tftp $ubootaddr $ubootfile; then "                      \
        "protect off $nor_ubootaddr +$filesize; "                       \
        "erase $nor_ubootaddr +$filesize; "                             \
        "cp.b $ubootaddr $nor_ubootaddr $filesize; "                    \
-       "protect on $nor_ubootaddr +$filesize\0 "                       \
-"flashworking=tftp $workingaddr $cramfsfile; "                         \
+       "protect on $nor_ubootaddr +$filesize; "                        \
+       "else echo $tftp_error_msg; fi\0"                               \
+"flashworking=if tftp $workingaddr $cramfsfile; then "                 \
        "protect off $nor_workingaddr +$filesize; "                     \
        "erase $nor_workingaddr +$filesize; "                           \
        "cp.b $workingaddr $nor_workingaddr $filesize; "                \
-       "protect on $nor_workingaddr +$filesize\0 "                     \
+       "protect on $nor_workingaddr +$filesize; "                      \
+       "else echo $tftp_error_msg; fi\0"                               \
 "hwconfig=usb1:dr_mode=host,phy_type=ulpi\0 "                          \
 "kerneladdr=0x01100000\0"                                              \
 "kernelfile=uImage\0"                                                  \
@@ -717,10 +721,13 @@
        "run spi__cramfs\0"                                             \
 "ramboot=setenv bootargs root=/dev/ram ramdisk_size=$ramdisk_size ro"  \
        " console=$consoledev,$baudrate $othbootargs; "                 \
-       "tftp $rootfsaddr $rootfsfile; "                                \
-       "tftp $loadaddr $kernelfile; "                                  \
-       "tftp $dtbaddr $dtbfile; "                                      \
-       "bootm $loadaddr $rootfsaddr $dtbaddr\0"                        \
+       "if tftp $rootfsaddr $rootfsfile; then "                        \
+       "if tftp $loadaddr $kernelfile; then "                          \
+       "if tftp $dtbaddr $dtbfile; then "                              \
+       "bootm $loadaddr $rootfsaddr $dtbaddr; "                        \
+       "else echo $tftp_error_msg; fi "                                \
+       "else echo $tftp_error_msg; fi"                                 \
+       "else echo $tftp_error_msg; fi\0"                               \
 "ramdisk_size=120000\0"                                                        
\
 "ramdiskfile=rootfs.ext2.gz.uboot\0"                                   \
 "recoveryaddr=0x02F00000\0"                                            \
@@ -756,12 +763,14 @@
 "spi__mbrd=fatload mmc $mmcpart $loadaddr $mbr; "                      \
        "sf probe 0; sf erase 0 +$filesize; "                           \
        "sf write $loadaddr 0 $filesize\0"                              \
-"tftpflash=tftpboot $loadaddr $uboot; "                                        
\
+"tftp_error_msg=tftp download error...\0"                              \
+"tftpflash=if tftp $loadaddr $uboot; then "                            \
        "protect off " __stringify(CONFIG_SYS_TEXT_BASE_NOR) " +$filesize; " \
        "erase " __stringify(CONFIG_SYS_TEXT_BASE_NOR) " +$filesize; "  \
        "cp.b $loadaddr " __stringify(CONFIG_SYS_TEXT_BASE_NOR) " $filesize; " \
        "protect on " __stringify(CONFIG_SYS_TEXT_BASE_NOR) " +$filesize; " \
-       "cmp.b $loadaddr " __stringify(CONFIG_SYS_TEXT_BASE_NOR) " $filesize\0"\
+       "cmp.b $loadaddr " __stringify(CONFIG_SYS_TEXT_BASE_NOR) " $filesize; "\
+       "else echo $tftp_error_msg; fi\0"                               \
 "uboot= " __stringify(CONFIG_UBOOTPATH) "\0"                           \
 "ubootaddr=0x01000000\0"                                               \
 "ubootfile=u-boot.bin\0"                                               \
@@ -789,24 +798,28 @@
 "fileaddr=0x01000000\0"                                                        
\
 "filesize=0x00080000\0"                                                        
\
 "flashmbr=sf probe 0; "                                                        
\
-       "tftp $loadaddr $mbr; "                                         \
+       "if tftp $loadaddr $mbr; then "                                 \
        "sf erase $mbr_offset +$filesize; "                             \
-       "sf write $loadaddr $mbr_offset $filesize\0"                    \
-"flashrecovery=tftp $recoveryaddr $cramfsfile; "                       \
+       "sf write $loadaddr $mbr_offset $filesize; "                    \
+       "else echo $tftp_error_msg; fi\0"                               \
+"flashrecovery=if tftp $recoveryaddr $cramfsfile; then "               \
        "protect off $nor_recoveryaddr +$filesize; "                    \
        "erase $nor_recoveryaddr +$filesize; "                          \
        "cp.b $recoveryaddr $nor_recoveryaddr $filesize; "              \
-       "protect on $nor_recoveryaddr +$filesize\0 "                    \
-"flashuboot=tftp $ubootaddr $ubootfile; "                              \
+       "protect on $nor_recoveryaddr +$filesize "                      \
+       "else echo $tftp_error_msg; fi\0"                               \
+"flashuboot=ig tftp $ubootaddr $ubootfile; then ;"                     \
        "protect off $nor_ubootaddr +$filesize; "                       \
        "erase $nor_ubootaddr +$filesize; "                             \
        "cp.b $ubootaddr $nor_ubootaddr $filesize; "                    \
-       "protect on $nor_ubootaddr +$filesize\0 "                       \
-"flashworking=tftp $workingaddr $cramfsfile; "                         \
+       "protect on $nor_ubootaddr +$filesize; "                        \
+       "else echo $tftp_error_msg; fi\0"                               \
+"flashworking=if tftp $workingaddr $cramfsfile; then "                 \
        "protect off $nor_workingaddr +$filesize; "                     \
        "erase $nor_workingaddr +$filesize; "                           \
        "cp.b $workingaddr $nor_workingaddr $filesize; "                \
-       "protect on $nor_workingaddr +$filesize\0 "                     \
+       "protect on $nor_workingaddr +$filesize; "                      \
+       "else echo $tftp_error_msg; fi\0"                               \
 "hwconfig=usb1:dr_mode=host,phy_type=ulpi\0 "                          \
 "kerneladdr=0x01100000\0"                                              \
 "kernelfile=uImage\0"                                                  \
@@ -836,10 +849,13 @@
 "othbootargs=quiet\0"                                                  \
 "ramboot=setenv bootargs root=/dev/ram ramdisk_size=$ramdisk_size ro"  \
        " console=$consoledev,$baudrate $othbootargs; "                 \
-       "tftp $rootfsaddr $rootfsfile; "                                \
-       "tftp $loadaddr $kernelfile; "                                  \
-       "tftp $dtbaddr $dtbfile; "                                      \
-       "bootm $loadaddr $rootfsaddr $dtbaddr\0"                        \
+       "if tftp $rootfsaddr $rootfsfile; then "                        \
+       "if tftp $loadaddr $kernelfile; then "                          \
+       "if tftp $dtbaddr $dtbfile; then "                              \
+       "bootm $loadaddr $rootfsaddr $dtbaddr; "                        \
+       "else echo $tftp_error_msg; fi "                                \
+       "else echo $tftp_error_msg; fi"                                 \
+       "else echo $tftp_error_msg; fi\0"                               \
 "ramdisk_size=120000\0"                                                        
\
 "ramdiskfile=rootfs.ext2.gz.uboot\0"                                   \
 "recoveryaddr=0x02F00000\0"                                            \
@@ -850,12 +866,14 @@
 "rootfsfile=rootfs.ext2.gz.uboot\0"                                    \
 "rootpath=/opt/nfsroot\0"                                              \
 "silent=1\0"                                                           \
-"tftpflash=tftpboot $loadaddr $uboot; "                                        
\
+"tftp_error_msg=tftp download error...\0"                              \
+"tftpflash=if tftpboot $loadaddr $uboot; then "                                
\
        "protect off " __stringify(CONFIG_SYS_TEXT_BASE_NOR) " +$filesize; " \
        "erase " __stringify(CONFIG_SYS_TEXT_BASE_NOR) " +$filesize; "  \
        "cp.b $loadaddr " __stringify(CONFIG_SYS_TEXT_BASE_NOR) " $filesize; " \
        "protect on " __stringify(CONFIG_SYS_TEXT_BASE_NOR) " +$filesize; " \
-       "cmp.b $loadaddr " __stringify(CONFIG_SYS_TEXT_BASE_NOR) " $filesize\0"\
+       "cmp.b $loadaddr " __stringify(CONFIG_SYS_TEXT_BASE_NOR) " $filesize; "\
+       "else echo $tftp_error_msg; fi\0"                               \
 "uboot= " __stringify(CONFIG_UBOOTPATH) "\0"                           \
 "ubootaddr=0x01000000\0"                                               \
 "ubootfile=u-boot.bin\0"                                               \
@@ -878,10 +896,11 @@
 "fileaddr=0x01000000\0"                                                        
\
 "filesize=0x00080000\0"                                                        
\
 "flashmbr=sf probe 0; "                                                        
\
-       "tftp $loadaddr $mbr; "                                         \
+       "if tftp $loadaddr $mbr; else "                                 \
        "sf erase $mbr_offset +$filesize; "                             \
-       "sf write $loadaddr $mbr_offset $filesize\0"                    \
-"flashuboot=tftp $loadaddr $ubootfile; "                               \
+       "sf write $loadaddr $mbr_offset $filesize; "                    \
+       "else echo $tftp_error_msg; fi\0"                               \
+"flashuboot=if tftp $loadaddr $ubootfile; "                            \
        "protect off $nor_ubootaddr0 +$filesize; "                      \
        "erase $nor_ubootaddr0 +$filesize; "                            \
        "cp.b $loadaddr $nor_ubootaddr0 $filesize; "                    \
@@ -889,7 +908,8 @@
        "protect off $nor_ubootaddr1 +$filesize; "                      \
        "erase $nor_ubootaddr1 +$filesize; "                            \
        "cp.b $loadaddr $nor_ubootaddr1 $filesize; "                    \
-       "protect on $nor_ubootaddr1 +$filesize\0 "                      \
+       "protect on $nor_ubootaddr1 +$filesize; "                       \
+       "else echo $tftp_error_msg; fi\0"                               \
 "format0=protect off $part0base +$part0size; "                         \
        "erase $part0base +$part0size\0"                                \
 "format1=protect off $part1base +$part1size; "                         \
@@ -925,30 +945,36 @@
 "part3size=0x00F80000\0"                                               \
 "partENVbase=0xEC080000\0"                                             \
 "partENVsize=0x00080000\0"                                             \
-"program0=tftp part0-000000.bin; "                                     \
+"program0=if tftp part0-000000.bin; then "                             \
        "protect off $part0base +$filesize; "                           \
        "erase $part0base +$filesize; "                                 \
        "cp.b $loadaddr $part0base $filesize; "                         \
        "echo Verifying...; "                                           \
-       "cmp.b $loadaddr $part0base $filesize\0"                        \
-"program1=tftp part1-000000.bin; "                                     \
+       "cmp.b $loadaddr $part0base $filesize; "                        \
+       "else echo $tftp_error_msg; fi\0"                               \
+"program1=if tftp part1-000000.bin; then "                             \
        "protect off $part1base +$filesize; "                           \
        "erase $part1base +$filesize; "                                 \
        "cp.b $loadaddr $part1base $filesize; "                         \
        "echo Verifying...; "                                           \
-       "cmp.b $loadaddr $part1base $filesize\0"                        \
-"program2=tftp part2-000000.bin; "                                     \
+       "cmp.b $loadaddr $part1base $filesize; "                        \
+       "else echo $tftp_error_msg; fi\0"                               \
+"program2=if tftp part2-000000.bin; then "                             \
        "protect off $part2base +$filesize; "                           \
        "erase $part2base +$filesize; "                                 \
        "cp.b $loadaddr $part2base $filesize; "                         \
        "echo Verifying...; "                                           \
-       "cmp.b $loadaddr $part2base $filesize\0"                        \
+       "cmp.b $loadaddr $part2base $filesize; "                        \
+       "else echo $tftp_error_msg; fi\0"                               \
 "ramboot=setenv bootargs root=/dev/ram ramdisk_size=$ramdisk_size ro"  \
        "  console=$consoledev,$baudrate $othbootargs; "                \
-       "tftp $rootfsaddr $rootfsfile; "                                \
-       "tftp $loadaddr $kernelfile; "                                  \
-       "tftp $dtbaddr $dtbfile; "                                      \
-       "bootm $loadaddr $rootfsaddr $dtbaddr\0"                        \
+       "if tftp $rootfsaddr $rootfsfile; then "                        \
+       "if tftp $loadaddr $kernelfile; then "                          \
+       "if tftp $dtbaddr $dtbfile; then "                              \
+       "bootm $loadaddr $rootfsaddr $dtbaddr; "                        \
+       "else echo $tftp_error_msg; fi "                                \
+       "else echo $tftp_error_msg; fi "                                \
+       "else echo $tftp_error_msg; fi\0"                               \
 "ramdisk_size=120000\0"                                                        
\
 "ramdiskfile=rootfs.ext2.gz.uboot\0"                                   \
 "releasefpga=mw.l 0xffe0f000 0x00400000; mw.l 0xffe0f004 0x00000000; " \
@@ -965,12 +991,14 @@
        "cp.b $loadaddr 0xEC000000 $filesize; "                         \
        "cmp.b $loadaddr 0xEC000000 $filesize; "                        \
        "protect on 0xeC000000 +$filesize\0"                            \
-"tftpflash=tftpboot $loadaddr $uboot; "                                        
\
+"tftp_error_msg=tftp download error...\0"                              \
+"tftpflash=if tftpboot $loadaddr $uboot; then "                                
\
        "protect off " __stringify(CONFIG_SYS_TEXT_BASE_NOR) " +$filesize; " \
        "erase " __stringify(CONFIG_SYS_TEXT_BASE_NOR) " +$filesize; "  \
        "cp.b $loadaddr " __stringify(CONFIG_SYS_TEXT_BASE_NOR) " $filesize; " \
        "protect on " __stringify(CONFIG_SYS_TEXT_BASE_NOR) " +$filesize; " \
-       "cmp.b $loadaddr " __stringify(CONFIG_SYS_TEXT_BASE_NOR) " $filesize\0"\
+       "cmp.b $loadaddr " __stringify(CONFIG_SYS_TEXT_BASE_NOR) " $filesize; "\
+       "else echo $tftp_error_msg; fi\0"                               \
 "uboot= " __stringify(CONFIG_UBOOTPATH) "\0"                           \
 "ubootfile=u-boot.bin\0"                                               \
 "upgrade=run flashuboot\0"                                             \
@@ -980,9 +1008,11 @@
        "nfsroot=$serverip:$rootpath "                                  \
        "ip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname:$netdev:off " \
        "console=$consoledev,$baudrate $othbootargs;"                   \
-       "tftp $loadaddr $bootfile;"                                     \
-       "tftp $fdtaddr $fdtfile;"                                       \
-       "bootm $loadaddr - $fdtaddr\0"                                  \
+       "if tftp $loadaddr $bootfile; then "                            \
+       "if tftp $fdtaddr $fdtfile; then "                              \
+       "bootm $loadaddr - $fdtaddr; "                                  \
+       "else echo $tftp_error_msg; fi "                                \
+       "else echo $tftp_error_msg; fi\0"                               \
 "boot_hd = "                                                           \
        "setenv bootargs root=/dev/$bdev rw rootdelay=30 "              \
        "console=$consoledev,$baudrate $othbootargs;"                   \
@@ -1016,10 +1046,13 @@
        "setenv bootargs root=/dev/ram rw "                             \
        "console=$consoledev,$baudrate $othbootargs "                   \
        "ramdisk_size=$ramdisk_size;"                                   \
-       "tftp $ramdiskaddr $ramdiskfile;"                               \
-       "tftp $loadaddr $bootfile;"                                     \
-       "tftp $fdtaddr $fdtfile;"                                       \
-       "bootm $loadaddr $ramdiskaddr $fdtaddr\0"
+       "if tftp $ramdiskaddr $ramdiskfile; then "                      \
+       "if tftp $loadaddr $bootfile; then "                            \
+       "if tftp $fdtaddr $fdtfile; then "                              \
+       "bootm $loadaddr $ramdiskaddr $fdtaddr; "                       \
+       "else echo $tftp_error_msg; fi "                                \
+       "else echo $tftp_error_msg; fi "                                \
+       "else echo $tftp_error_msg; fi\0"
 
 #endif
 #endif
-- 
2.1.4

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to