r922 - trunk/src/host/sjf2410-linux

werner at sita.openmoko.org werner at sita.openmoko.org
Thu Feb 8 20:20:16 CET 2007


Author: werner
Date: 2007-02-08 20:20:12 +0100 (Thu, 08 Feb 2007)
New Revision: 922

Modified:
   trunk/src/host/sjf2410-linux/k9s1208.c
   trunk/src/host/sjf2410-linux/mem_rdwr.h
   trunk/src/host/sjf2410-linux/sjf2410.c
   trunk/src/host/sjf2410-linux/sjf2410.h
Log:
sjf2410.c (ErrorBanner): removed unused declaration
sjf2410.c (main): added Unix-style options
sjf2410.c (main): updated online help
sjf2410.c, k9s1208.c: moved file access decisions to second level menu
sjf2410.c: renamed srcFileName to FileName, for clarity
sjf2410.c (main): local version suffix is now "moko2" instead of "hmw1"
sjf2410.c, k9s1208.c: replaced compile-time setting BAD_CHECK with run-time
  switch /b (testing needed)
k9s1208.c (K9S1208_Program): flush stdout after progress indication
k9s1208.c (K9S1208_Read): added progress indication
k9s1208.c (K9S1208_Read): added start and length input, without any 
  plausibility checking, consistent with the good style of the rest of sjf2410
sjf2410.h, mem_rdwr.h: file now ends with newline
k9s1208.c (K9S1208_PrintBlock): removed extra printf argument



Modified: trunk/src/host/sjf2410-linux/k9s1208.c
===================================================================
--- trunk/src/host/sjf2410-linux/k9s1208.c	2007-02-08 19:15:33 UTC (rev 921)
+++ trunk/src/host/sjf2410-linux/k9s1208.c	2007-02-08 19:20:12 UTC (rev 922)
@@ -9,7 +9,6 @@
 #include "sjf2410.h"
 
 
-#define BAD_CHECK	(0)
 #define ECC_CHECK	(0)
 
 //*************** JTAG dependent functions ***************
@@ -33,10 +32,14 @@
 static void NF_Init(void);
 //*******************************************************
 
+void OpenImageFile(char *filename);
+
 void K9S1208_PrintBlock(void);
 void K9S1208_Program(void);
 void K9S1208_Read(void);
 
+extern int bad_check;
+extern char FileName[];
 
 static U32 targetBlock;	    // Block number (0 ~ 4095)
 static U32 targetSize;	    // Total byte size 
@@ -111,6 +114,12 @@
     U8 *srcPt;
     U32 progSize=0;
 
+    if (!*FileName) {
+	    printf("need a file name (-f file_name)\n");
+	    return;
+    }
+    OpenImageFile(FileName);
+
     printf("\n[SMC(K9S1208V0M) NAND Flash Writing Program]\n");
     
     printf("\nSource size:0h~%xh\n",imageSize-1);
@@ -130,14 +139,13 @@
 	}
 	noLoad=0;
 	
-#if BAD_CHECK       
-	if(NF_IsBadBlock(blockIndex) && blockIndex!=0 )	// 1:bad 0:good
+	if(bad_check && NF_IsBadBlock(blockIndex) && blockIndex!=0 )
+		// 1:bad 0:good
         {
 	    blockIndex++;   // for next block
 	    noLoad=1;
 	    continue;
 	}
-#endif
 	if(!NF_EraseBlock(blockIndex))
 	{
 	    blockIndex++;   // for next block
@@ -146,6 +154,7 @@
 	}
 
 	printf("E");
+	fflush(stdout);
 	srcPt=blockBuf;
 
 	for(i=0;i<32;i++)
@@ -158,6 +167,7 @@
 
 	    srcPt+=512;	// Increase buffer addr one pase size
 	    printf("p");
+	    fflush(stdout);
 	}
 	printf("\n");
 
@@ -177,23 +187,41 @@
 
 void K9S1208_Read(void)
 {
+	int sourceBlock,numBlocks;
 	int of, block, page;
 	unsigned char buffer[512];
 
+	if (!*FileName) {
+		printf("need a file name (-f file_name)\n");
+		return;
+	}
+
 	printf("\n[SMC(K9S1208V0M) NAND Flash Reading Program]\n");
 
-	of = creat("flash-read.bin", 0660);
+	of = creat(FileName, 0660);
 	if (of < 0) {
 		printf("error opening out file");
 		return;
 	}
+	printf("\nSource size:0h~%xh\n",imageSize-1);
+	printf("\nAvailable target block number: 0~4095\n");
+	printf("Input source block number:");
+	scanf("%d",&sourceBlock);
+	printf("\nAvailable source blocks (length): 0~%d\n",4096-sourceBlock);
+	printf("Input source blocks (length):");
+	scanf("%d",&numBlocks);
+	printf("STATUS:");
 
-	for (block = 0; block < 4096; block++) {
+	for (block = sourceBlock; block < sourceBlock+numBlocks; block++) {
 		for (page = 0; page < 32; page++) {
 			NF_ReadPage(block, page, buffer,NULL);
 			write(of, buffer, 512);
+			printf("r");
+			fflush(stdout);
 		}
+		printf("\n");
 	}
+	printf("\n");
 
 	close(of);
 }
@@ -228,7 +256,7 @@
 	    printf("\n%3xh:",i);
         printf("%02x ",buffer[i]);
     }
-    printf("\nS.A.:",i);
+    printf("\nS.A.:");
 
     for(i=512;i<512+16;i++)
     {
@@ -290,10 +318,9 @@
 {
     U32 blockPage=(block<<5);
 
-#if BAD_CHECK
-    if(NF_IsBadBlock(block) && block!=0) //block #0 can't be bad block for NAND boot
+    if(bad_check && NF_IsBadBlock(block) && block!=0)
+	//block #0 can't be bad block for NAND boot
 	return 0;
-#endif
 
     NF_nFCE_L();
     

Modified: trunk/src/host/sjf2410-linux/mem_rdwr.h
===================================================================
--- trunk/src/host/sjf2410-linux/mem_rdwr.h	2007-02-08 19:15:33 UTC (rev 921)
+++ trunk/src/host/sjf2410-linux/mem_rdwr.h	2007-02-08 19:20:12 UTC (rev 922)
@@ -32,4 +32,4 @@
 //*******************************************************
 
 
-#endif //__MEM_RDWR_H__
\ No newline at end of file
+#endif //__MEM_RDWR_H__

Modified: trunk/src/host/sjf2410-linux/sjf2410.c
===================================================================
--- trunk/src/host/sjf2410-linux/sjf2410.c	2007-02-08 19:15:33 UTC (rev 921)
+++ trunk/src/host/sjf2410-linux/sjf2410.c	2007-02-08 19:20:12 UTC (rev 922)
@@ -40,11 +40,11 @@
 FILE *stream;
 U32 imageSize;
 
-char srcFileName[256];
+char FileName[256];
+int bad_check = 0;
 void OpenImageFile(char *filename);
 void OpenPpt(void);
 
-void ErrorBanner(void);
 
 static void *function[]=
 {
@@ -56,30 +56,46 @@
     0
 };
 
+static char *next_arg(char **argv,int *i)
+{
+    if (argv[*i][2])
+	return argv[*i]+3;
+    (*i)++;
+    if (!argv[*i]) {
+	fprintf(stderr,"argument expected\n");
+	exit(1);
+    }
+    return argv[*i];
+}
+
 void main(int argc,char *argv[])
 {
     char num=0;
     int i;
     	
     printf("\n");
-    printf("+------------------------------------+\n");
-    printf("|     SEC JTAG FLASH(SJF) v 0.4hmw1  |\n");
-    printf("|     (S3C2410X & SMDK2410 B/D)      |\n");
-    printf("+------------------------------------+\n");
-    printf("Usage: SJF /f:<filename> /d=<delay>\n");
+    printf("+--------------------------------------+\n");
+    printf("|     SEC JTAG FLASH(SJF) v 0.4moko2   |\n");
+    printf("|     (S3C2410X & SMDK2410 B/D)        |\n");
+    printf("+--------------------------------------+\n");
+    //printf("Usage: SJF /f:<filename> /d=<delay> /b\n");
+    printf("Usage: SJF -f <filename>  -d <delay>  -b\n");
 
     delayLoopCount=100;
-    srcFileName[0]='\0';
+    FileName[0]='\0';
     for(i=1;i<argc;i++)
     {
 	switch(argv[i][1])
 	{
 	case 'f':
-	    strcpy(srcFileName,&(argv[i][3]));
+	    strcpy(FileName,next_arg(argv,&i));
 	    break;
 	case 'd':
-	    delayLoopCount=atoi(&argv[i][3]);
+	    delayLoopCount=atoi(next_arg(argv,&i));
 	    break;
+	case 'b':
+	    bad_check = 1;
+	    break;
 	default:
 	    printf("ERROR: unknown option /%c is detected.\n",argv[i][1]);
 	    break;
@@ -88,9 +104,6 @@
 
     OpenPpt();
     	
-    if(srcFileName[0]!='\0')
-	OpenImageFile(srcFileName);
-	
     JTAG_ReadId();
 
     S2410_InitCell();
@@ -115,29 +128,26 @@
     switch(i)
     {
     case 0:
-	if(srcFileName[0]==0)
-	{
-	    printf("ERROR:Source file name is not valid.\n");
-	    return;
-	}
        	K9S1208_Menu();
 	break;
 
     case 1:
-	if(srcFileName[0]==0)
+	if(FileName[0]==0)
 	{
 	    printf("ERROR:Source file name is not valid.\n");
 	    return;
 	}
+	OpenImageFile(FileName);
        	Program28F128J3A();
 	break;
 
     case 2:
-	if(srcFileName[0]==0)
+	if(FileName[0]==0)
 	{
 	    printf("ERROR:Source file name is not valid.\n");
 	    return;
 	}
+	OpenImageFile(FileName);
        	ProgramAM29F800();
 	break;
 

Modified: trunk/src/host/sjf2410-linux/sjf2410.h
===================================================================
--- trunk/src/host/sjf2410-linux/sjf2410.h	2007-02-08 19:15:33 UTC (rev 921)
+++ trunk/src/host/sjf2410-linux/sjf2410.h	2007-02-08 19:20:12 UTC (rev 922)
@@ -5,4 +5,4 @@
 
 extern U32 imageSize;
 
-#endif //__SJF_H__
\ No newline at end of file
+#endif //__SJF_H__





More information about the commitlog mailing list