import of upstream version 1.18a upstream
authorMichael Walle <michael@walle.cc>
Thu, 6 May 2010 18:39:33 +0000 (20:39 +0200)
committerMichael Walle <michael@walle.cc>
Thu, 6 May 2010 18:39:33 +0000 (20:39 +0200)
README
umon_main/target/common/spif.c

diff --git a/README b/README
index 40cc867..8e84ff6 100644 (file)
--- a/README
+++ b/README
@@ -56,11 +56,11 @@ If these instructions are followed, then in theory, this file will be
 the last committed file in the release; hence the Revision of this file
 (keyword below) can be used as the release point of reference...
 
-Revision: $Revision: 2383 $
+Revision: $Revision: 2387 $
 
 ######################
 #
 # SVN Revision-to-uMon release...
 #
 uMon1.17: Committed revision 1924 (Mar 13, 2009).
-uMon1.18: Committed revision 2382 (Jan 20, 2010).
+uMon1.18: Committed revision 2386 (Jan 23, 2010).
index cfe8b5f..9c37705 100644 (file)
@@ -62,7 +62,7 @@ char *SpifHelp[] = {
        " tfsstore                  copy TFSRAM to SPIF",
        " tfserase                  erase SPIF space allocated to TFS",
        " tfsrm {name}              remove file directly out of SPI flash",
-       " tfsadd {name} {src} {sz}  add file directly to SPI flash",
+       " tfsadd {name} [src sz]    add file directly to SPI flash",
 #endif
        " berase {addr bsize}       block erase (bsize=4K,32K,64K)",
        " read {addr dest len}      read block",
@@ -265,29 +265,49 @@ SpifCmd(int argc,char *argv[])
                char *arg4 = argv[optind+3];
                char *icomma, *fcomma;
 
-               if (argc != optind+4)
-                       return(CMD_PARAM_ERROR);
-
-               // Extract flags and info fields (if any) from the name...
                info = "";
                bflags = 0;
                name = arg2;
-               fcomma = strchr(name,',');
-               if (fcomma) {
-                       icomma = strchr(fcomma+1,',');
-                       if (icomma) {
-                               *icomma = 0;
-                               info = icomma+1;
+               addr = BASE_OF_SERIALTFS;
+
+               /* The incoming arguments can be either just the filename (in which
+                * case we assume the source is the file in TFS with the same name),
+                * or the filename, source address and size...
+                */
+               if (argc == optind+2) {                 // Just filename?
+                       if ((fp = tfsstat(name)) == (TFILE *)0) {
+                               printf("File '%s' not in TFS\n",name);
+                               return(CMD_FAILURE);
+                       }
+                       name = fp->name;
+                       info = fp->info;
+                       bflags = fp->flags;
+                       size = fp->filsize;
+                       src = (char *)(fp + 1);
+                       fp = &tfshdr;
+                       memset((char *)fp,0,TFSHDRSIZ);
+               }
+               else if (argc == optind+4) {    // Filename with addr and len
+                       // Extract flags and info fields (if any) from the name...
+                       fcomma = strchr(name,',');
+                       if (fcomma) {
+                               icomma = strchr(fcomma+1,',');
+                               if (icomma) {
+                                       *icomma = 0;
+                                       info = icomma+1;
+                               }
+                               *fcomma = 0;
+                               bflags = tfsctrl(TFS_FATOB,(long)(fcomma+1),0);
                        }
-                       *fcomma = 0;
-                       bflags = tfsctrl(TFS_FATOB,(long)(fcomma+1),0);
+       
+                       fp = &tfshdr;
+                       memset((char *)fp,0,TFSHDRSIZ);
+                       size = (int)strtol(arg4,0,0);
+                       src = (char *)strtoul(arg3,0,0);
                }
+               else
+                       return(CMD_PARAM_ERROR);
 
-               fp = &tfshdr;
-               memset((char *)fp,0,TFSHDRSIZ);
-               addr = BASE_OF_SERIALTFS;
-               size = (int)strtol(arg4,0,0);
-               src = (char *)strtoul(arg3,0,0);
                while(addr < END_OF_SERIALTFS) {
                        if ((rc = spifReadBlock(addr,(char *)fp,TFSHDRSIZ)) < 0)
                                break;
@@ -354,6 +374,8 @@ SpifCmd(int argc,char *argv[])
                                        fp->flags &= ~TFS_ACTIVE;
                                        spifWriteEnable();      
                                        spifGlobalUnprotect();  
+                                       spifWaitForReady();     
+                                       spifWriteEnable();      
                                        if ((rc = spifWriteBlock(addr,(char *)fp,TFSHDRSIZ)) < 0)
                                                printf(" write_hdr failed %d\n",rc);
                                        spifGlobalProtect();