stop reading NAND on special EOF signature
authorGrazvydas Ignotas <notasas@gmail.com>
Tue, 27 Dec 2011 23:49:37 +0000 (01:49 +0200)
committerGrazvydas Ignotas <notasas@gmail.com>
Tue, 27 Dec 2011 23:49:37 +0000 (01:49 +0200)
lib/board.c

index 1c79d58..2381b69 100644 (file)
@@ -36,6 +36,8 @@
 #include <fat.h>
 #include <asm/arch/mem.h>
 
 #include <fat.h>
 #include <asm/arch/mem.h>
 
+#define END_MARK 0x646e65ff    /* end */
+
 const char version_string[] =
        "Texas Instruments X-Loader 1.5.1 (" __DATE__ " - " __TIME__ ")";
 
 const char version_string[] =
        "Texas Instruments X-Loader 1.5.1 (" __DATE__ " - " __TIME__ ")";
 
@@ -121,8 +123,11 @@ void start_armboot (void)
                                printf("Loading u-boot.bin from nand\n");
 #endif
                        for (i = NAND_UBOOT_START; i < NAND_UBOOT_END; i+= NAND_BLOCK_SIZE){
                                printf("Loading u-boot.bin from nand\n");
 #endif
                        for (i = NAND_UBOOT_START; i < NAND_UBOOT_END; i+= NAND_BLOCK_SIZE){
-                               if (!nand_read_block(buf, i))
+                               if (!nand_read_block(buf, i)){
                                        buf += NAND_BLOCK_SIZE; /* advance buf ptr */
                                        buf += NAND_BLOCK_SIZE; /* advance buf ptr */
+                                       if (*(int *)(buf - 8) == END_MARK && *(int *)(buf - 4) == END_MARK)
+                                               break;
+                               }
                        }
 #endif
                }
                        }
 #endif
                }