📄 sjf6410.c
字号:
/**********************************************************************************
The SJF6410 is based on SJF2440
The main difference between SJF6410 and SJF6410 is BSC(Boundary Scan Cell)Index.
**********************************************************************************/
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include "..\include\def.h"
#include "..\include\pin6410.h"
#include "..\include\jtag.h"
#include "..\include\ppt.h"
#include "..\include\k9s1208.h"
#include "..\include\k9f1g08.h"
#include "..\include\k9f2g08.h"
#include "..\include\k9g8g08.h"
#include "..\include\strata32.h"
#include "..\include\am29f800.h"
#include "..\include\mem_rdwr.h"
FILE *stream;
U32 imageSize;
char srcFileName[256];
void OpenImageFile(char *filename);
void OpenPpt(void);
void ErrorBanner(void);
extern ProgramOneNand(void);
static void *function[]=
{
"K9S1208 prog ",
"K9F1G08 prog ", // not tested
"K9G8G08 prog ", // not tested
"28F128J3A prog ", // not tested
"AM29LV800 Prog ", // not tested
"Memory Rd/Wr ", // not tested
"SC36410X5D Nand prog ",
"OneNand prog ", // not tested
"Exit ",
0
};
void main(int argc,char *argv[])
{
char num=0;
int i;
printf("\n");
printf("+------------------------------------+\n");
printf("| SEC JTAG FLASH(SJF) v 0.1 |\n");
printf("| (S3C6410X & SMDK6410 B/D) |\n");
printf("+------------------------------------+\n");
printf("Usage : SJF6410 /f:<filename> /d=<delay>\n");
delayLoopCount=100;
srcFileName[0]='\0';
for(i=1;i<argc;i++)
{
switch(argv[i][1])
{
case 'f':
strcpy(srcFileName,&(argv[i][3]));
break;
case 'd':
delayLoopCount=atoi(&argv[i][3]);
break;
case 'm':
break;
default:
printf("ERROR: unknown option /%c is detected.\n", argv[i][1]);
break;
}
}
//Open Parallel Port for JTAG Dongle Control
OpenPpt();
//Take Image File Handler
if(srcFileName[0]!='\0')
OpenImageFile(srcFileName);
//Read 6410 IDCODE Register Value
JTAG_ReadId();
//Initialize S6410 Boundary Scan Cell
S6410_InitCell();
printf("\n[SJF Main Menu]\n");
i=0;
while(1)
{
//display menu
printf(" %2d : %s\n",i,function[i]);
i++;
if((int)(function[i])==0)
{
printf("\n");
break;
}
//if((i%4)==0)
// printf("\n");
}
printf("Select the function to test:");
scanf("%d",&i);
switch(i)
{
case 0:
if(srcFileName[0]==0)
{
printf("ERROR:Source file name is not valid.\n");
return;
}
//Samsung NAND Flash Programming
K9S1208_Menu();
break;
case 1:
if(srcFileName[0]==0)
{
printf("ERROR:Source file name is not valid.\n");
return;
}
//Samsung NAND Flash Programming
//K9f1g08_Menu();
printf("This device was not tested.\n");
break;
case 2:
if(srcFileName[0]==0)
{
printf("ERROR:Source file name is not valid.\n");
return;
}
//Samsung NAND Flash Programming
//K9g8g08_Menu();
printf("This device was not tested.\n");
break;
case 3:
if(srcFileName[0]==0)
{
printf("ERROR:Source file name is not valid.\n");
return;
}
//Intel STRATA NOR Flash(32bit) Programming
//Program28F128J3A();
printf("This device was not tested.\n");
break;
case 4:
if(srcFileName[0]==0)
{
printf("ERROR:Source file name is not valid.\n");
return;
}
//AMD NOR Flash(16bit) Programming
ProgramAM29F800();
break;
case 5:
//Read/Write Specific External Memory RAddress
//MRW_Menu();
printf("This function is not supported.\n");
break;
case 6:
if(srcFileName[0]==0)
{
printf("ERROR:Source file name is not valid.\n");
return;
}
//Samsung 6410X52 MCP NAND Flash Programming
K9F2G08_Menu();
break;
case 7:
if(srcFileName[0]==0)
{
printf("ERROR:Source file name is not valid.\n");
return;
}
//OneNand Flash Programming
ProgramOneNand();
break;
default:
return;
break; //Exit menu
}
}
//////////////////////////////////////////////////////////
void OpenImageFile(char *filename)
{
U32 fileEnd,fileStart;
stream = fopen(filename,"rb");
if(stream==NULL)
{
printf("\nERROR:can't find the file.\n");
exit(0);
}
fseek(stream,0L,SEEK_END);
fileEnd=ftell(stream);
fseek(stream,0L,SEEK_SET);
fileStart=ftell(stream);
imageSize=fileEnd-fileStart; /* fileend == peof+1 */
}
int LoadImageFile(U8 *buf,int size)
{
int i,readSize=size;
for(i=0;i<size;i++)
{
if(feof(stream))
{
readSize=i;
for(;i<size;i++)buf[i]=0;
break;
}
buf[i] = fgetc(stream);
}
return readSize;
}
void OpenPpt(void)
{
if(!InstallGiveIo())
{
printf("ERROR: Couldn't open giveio.sys\n");
exit(0);
}
validPpt = GetValidPpt();
if(!validPpt)
{
printf("ERROR: Unable to find a parallel port\n");
exit(0);
}
SetPptCompMode();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -