updated program evm and nand writer for getting the nand format support
authorAravind Batni <aravindbr@ti.com>
Wed, 29 Aug 2012 23:23:11 +0000 (19:23 -0400)
committerAravind Batni <aravindbr@ti.com>
Wed, 29 Aug 2012 23:23:11 +0000 (19:23 -0400)
program_evm/program_evm.js [changed mode: 0644->0755]
writer/nand/evmc6657l/bin/nand_writer_input.txt [changed mode: 0644->0755]
writer/nand/src/nandwriter.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index e5b9039..3bc06d2
@@ -381,41 +381,104 @@ if(writeAll || writerImages.match(/eeprom51/))
 //NAND
 if(writeAll || writerImages.match(/nand/))
 {
-
-       start_nand = localTime();
-       script.traceWrite("Writer:" + nandwriterbinary + "\r\n");
-       script.traceWrite("NAND:" + nand + "\r\n");
-       if (isFile(nand) && isFile(nandwriterbinary)) 
+    if (writerImages.match(/format/))
+    {
+       /* No action is taken for NAND since it is format*/
+    }
+       else
        {
-               debugSession.memory.loadProgram(nandwriterbinary);
-               var nPage = 0x0;
-       //      var nAddress = 0x80000000;
-               var sFilename = nand;
-               var nTypeSize = 32;
-               var bByteSwap = false;
-
-               try
-               {   
-                       script.traceWrite("Start loading nand.bin");
-                       debugSession.memory.loadRaw(nPage, nandNorAddress, sFilename, nTypeSize, bByteSwap);
+       start_nand = localTime();
+       script.traceWrite("Writer:" + nandwriterbinary + "\r\n");
+       script.traceWrite("NAND:" + nand + "\r\n");
+       if (isFile(nand) && isFile(nandwriterbinary)) 
+       {
+               debugSession.memory.loadProgram(nandwriterbinary);
+               var nPage = 0x0;
+       //      var nAddress = 0x80000000;
+               var sFilename = nand;
+               var nTypeSize = 32;
+               var bByteSwap = false;
+    
+               try
+               {   
+                       script.traceWrite("Start loading nand.bin");
+                       debugSession.memory.loadRaw(nPage, nandNorAddress, sFilename, nTypeSize, bByteSwap);
+    
+               }
+               catch (ex)
+               {
+                  errCode = getErrorCode(ex);
+                  script.traceWrite("Error code #" + errCode + ", could not load file " + sFilename +
+                                       " to target memory!");
+               }
+               script.traceWrite("Start programming NAND");
+               debugSession.target.run()
+               script.traceWrite("End programming NAND");
+               end_nand = localTime();
+       }
+       else
+       {
+               script.traceWrite("Required NAND files does not exist in " + board_binaries + "\n");
+        
+       }
+     }
+}
 
-               }
-               catch (ex)
-               {
-                  errCode = getErrorCode(ex);
-                  script.traceWrite("Error code #" + errCode + ", could not load file " + sFilename +
-                                       " to target memory!");
-               }
-               script.traceWrite("Start programming NAND");
-               debugSession.target.run()
-               script.traceWrite("End programming NAND");
-               end_nand = localTime();
-       }
+//FORMAT the flash
+if (writerImages.match(/format/))
+{
+//NAND Erase all
+    if (writerImages.match(/nand/))
+    {
+       start_nand = localTime();
+       script.traceWrite("Writer:" + nandwriterbinary + "\r\n");
+       if (isFile(nandwriterbinary)) 
+       {
+               debugSession.memory.loadProgram(nandwriterbinary);
+               var nPage = 0x0;
+               var nValue = 0x12345678;
+    
+               try
+               {   
+                       script.traceWrite("Formatting NAND device ... Initiated");
+                       // Get the address of that symbol
+                       var flag_address = debugSession.symbol.getAddress("nand_erase_flag")                    
+                       debugSession.memory.writeWord(nPage, flag_address, nValue);
+               }
+               catch (ex)
+               {
+                  errCode = getErrorCode(ex);
+                  script.traceWrite("Error code #" + errCode + ", could not set the nandwriter for erasing all nand blocks! ");
+               }
+               debugSession.target.run()
+               script.traceWrite("Formatting NAND device ...Completed");
+                       end_nand = localTime();
+       }
+       else
+       {
+               script.traceWrite("Required NAND binary does not exist in " + board_binaries + "\n");
+        
+       }
+    }
        else
-       {
-               script.traceWrite("Required NAND files does not exist in " + board_binaries + "\n");
-        
+       { 
+         /* No action is taken */
+         script.traceWrite("FLASH FORMAT - No Action is taken, please provide the supported format command string, e.g., format-nand");
        }
+
+    if (testEnv.cioFile != null)
+    {
+       // Stop CIO logging.
+       debugSession.endCIOLogging();
+    }
+    
+    debugSession.terminate();
+    debugServer.stop()
+    
+    // Stop logging and exit.
+    script.traceEnd();
+    java.lang.System.exit(0);
+       
 }
 
 //NOR
old mode 100644 (file)
new mode 100755 (executable)
index 009e6a1..75b6ee5
@@ -1,5 +1,5 @@
 file_name  = app.bin
-start_addr = 16384
+start_addr = 131072
 
 
 
old mode 100644 (file)
new mode 100755 (executable)
index 09897f2..83da160
 #include "types.h"
 
 /* NAND writer utility version */
-char version[] = "01.00.00.00";
+char version[] = "01.00.00.01";
 
 /* The input file name is hard coded */
 char *input_file = "nand_writer_input.txt";
 
 uint32_t swap_byte = 0;
+volatile uint32_t nand_erase_flag = 0;
 
 /* Parameters defined in the input_file */
 #define FILE_NAME      "file_name"
@@ -490,6 +491,25 @@ find_file_length
     return TRUE;
 }
 
+static Bool 
+nand_erase_all_blks(PLATFORM_DEVICE_info *p_device)
+{
+  uint32_t block;
+  uint32_t max_blks;
+
+  max_blks = p_device->block_count;
+  
+  for (block=0; block<max_blks;block++)
+  {
+      printf (".");
+      if (platform_device_erase_block(p_device->handle, block) != Platform_EOK)
+        return FALSE;
+  }
+
+  printf ("\nFormatted %d nand blocks \n", block);
+  return (TRUE);
+}
+
 /******************************************************************************
  * Function:    main  
  ******************************************************************************/
@@ -553,6 +573,22 @@ void main ()
         return;
     }
 
+    /* Check if we need to erase the nand completely */
+     if (nand_erase_flag == 0x12345678)
+     {
+        if (nand_erase_all_blks(p_device) == FALSE)
+        {
+           printf ("Formatting all nand blocks - failed \n");
+        }
+        else
+        {
+           printf ("Formatting all nand blocks - Successful\n");
+        }
+        platform_device_close(p_device->handle);
+        /* Operation Complete */
+        return;
+     }
+
     /* Open and find the length of the data file */
     fp = fopen (nandWriterInfo.file_name, "rb");
     if (fp == NULL)
@@ -571,7 +607,6 @@ void main ()
         platform_device_close(p_device->handle);
         return;
     }
-    
 
     /* Write the flash, verify the results. On read back failure mark
      * the block as bad and try rewriting again */