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

📄 sjf2410.c

📁 s3c2410 arm平台下的烧写工具源代码
💻 C
字号:
/********************************************************************************** 
 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(S3C2410_MAX_CELLS -> S3C2410_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 SMDK2410 board.
 8. The programming speed is enhanced.
 **********************************************************************************/
/*******************************************
 Revision history
 2002.06.10:purnnamu:ver 0.1
  -first release
 2002.06.21:purnnamu:ver 0.11
  -trivial display error is fixed.
 2002.08.20:purnnamu:ver 0.3
  -Strata flash is supported.
 2002.08.20:purnnamu:ver 0.4
  -AM29LV800BB flash is supported.
 *******************************************/

#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include "def.h"
#include "pin2410.h"
#include "jtag.h"
#include "ppt.h"
#include "k9s1208.h"
#include "strata32.h"
#include "am29f800.h"
#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    ",
    "28F128J3A prog  ",
    "AM29LV800 Prog  ",
    "Memory Rd/Wr    ",
    "HY29lv160bt	",
	"AM29lv160dt    ",
    "Exit            ",
    0
};

void main(int argc,char *argv[])
{
    char num=0;
    int i;
    	
    printf("\n");
    printf("+------------------------------------+\n");
    printf("|     SEC JTAG FLASH(SJF) v 0.4      |\n");
    printf("|     (S3C2410X & SMDK2410 B/D)      |\n");
    printf("+------------------------------------+\n");
    printf("Usage: SJF /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;
	}
    }

    OpenPpt();
    	
    if(srcFileName[0]!='\0')
	OpenImageFile(srcFileName);
	
    JTAG_ReadId();

    S2410_InitCell();
	
    printf("\n[SJF Main Menu]\n");
    i=0;
    while(1)
    {   //display menu
	printf("%2d:%s",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;
	}
       	K9S1208_Menu();
	break;

    case 1:
	if(srcFileName[0]==0)
	{
	    printf("ERROR:Source file name is not valid.\n");
	    return;
	}
       	Program28F128J3A();
	break;

    case 2:
	if(srcFileName[0]==0)
	{
	    printf("ERROR:Source file name is not valid.\n");
	    return;
	}
       	ProgramAM29F800();
	break;

    case 3:
	MRW_Menu();
	break;

	case 4 :ProgramHY29lv160();

	case 5 :ProgramAM29lv160dt();
	

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