⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sjf6400.c

📁 s3c6400(ARM11)的JTAG烧写软件
💻 C
字号:
/********************************************************************************** 
 The SJF6400 is based on SJF2440, which was written by Inwook Kong(purnnamu).  
 The main difference between SJF6400 and SJF6400 is BSC(Boundary Scan Cell)Index.
 Refer to S3C6400_070430.bsdl.
 Thanks to Inwook Kong. 
 
 Revision history
 2003.09.16: ver 0.1 (Y.H.Lee) S3C2440X
 2006.09.11: ver 0.2 (Junon.Jeon)
  - SEC JTAG FLASH Program for S3C6400X & SMDK6400 B/D.
  - K9S1208, AMD 29LV800BB and E28F128 StrataFlash programming is supported.
  - SJF6400 is derived from following SJF2440(SJF)...
**********************************************************************************/ 
   
/********************************************************************************** 
 The SJF is written by analyzing ezTAG program, which was written by Jaewook Cheong,
 SEC S/W Centor. 
 Special thanks to Jaewook Cheong and Dale Roberts(the author of GIVEIO.sys)

 In SJF, the following feature is updated from ezTAG

 1. The structure of JTAG functions is changed for speed-up.
 2. The indexs of the pins become coherent with the BSDL file.
 3. SAMPLE/PRELOAD is used for initializing outCellValue[].
 4. The array size error is fixed(S3C6400_MAX_CELLS -> S3C6400_MAX_CELL_INDEX+2)
 5. The array was not followed by '\0', which is fixed.
 6. JTAG_ID reading error is fixed.
 7. Support K9S1208 SMD card for the SMDK6400 board.
 8. The programming speed is enhanced.
 **********************************************************************************/


#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include "..\include\def.h"
#include "..\include\pin6400.h"
#include "..\include\jtag.h"
#include "..\include\ppt.h"
#include "..\include\k9s1208.h"
#include "..\include\k9f1g08.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);

static void *function[]=
{
    "K9S1208 prog    ",
	"K9F1G08 prog	 ",// not tested
	"K9G8G08 prog	 ",
    "28F128J3A prog  ",// not tested
    "AM29LV800 Prog  ",
    "Memory Rd/Wr    ",// 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("|     (S3C6400X & SMDK6400 B/D)      |\n");
    printf("+------------------------------------+\n");
    printf("Usage : SJF6400 /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;
		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 6400 IDCODE Register Value
    JTAG_ReadId();

    //Initialize S6400 Boundary Scan Cell
	S6400_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();
		break;

		case 2:
			if(srcFileName[0]==0)
			{
				printf("ERROR:Source file name is not valid.\n");
				return;
			}
       		//Intel STRATA NOR Flash(32bit) Programming 
			K9g8g08_Menu();
		break;

		case 3:
			if(srcFileName[0]==0)
			{
				printf("ERROR:Source file name is not valid.\n");
				return;
			}
       		//Intel STRATA NOR Flash(32bit) Programming 
			Program28F128J3A();
		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();
		break;

		default:
			return;
		break; //Exit menu
    }
    return;
}

//////////////////////////////////////////////////////////
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 + -