?? flash.c
字號:
//====================================================================
// File Name : flash.c
// Function : S3C2442 Flash Program
// Program : Kong, In Wook (KIW)
// Date : May 30, 2002
// Version : 0.0
// History
// 0.0 : Programming start (May 30,2002) -> KIW
// Arrangement source code(8/01/2002)-> SOP
// Edited for SMDK2442(07/07/2003) -> Junon
//====================================================================
#include <string.h>
#include "def.h"
#include "option.h"
#include "2413addr.h"
#include "Console.h"
#include "MMUCache.h"
#include "am29f800.h"
#include "strata32.h"
static int DownloadData(void);
//#if 1
// removed because of multiple definition
U32 downloadAddress;
U32 downloadProgramSize;
//#else
// U32 downloadAddress;
// U32 downloadProgramSize;
//#endif
//==========================================================================================
void *flashType[][2]=
{
(void *)ProgramAM29F800, "AM29LV800BB x1 ",
// (void *)Program28F640J3A, "28F640J3A x2 ",
(void *)Program28F128J3A, "28F128J3A(16MB) x2 ",
(void *)Erase28F128J3A, "Erase 28F128J3A ", // added by junon 10/29
0,0
};
//==========================================================================================
void ProgramFlash(void)
{
int i=0,whichFlash;
char key;
printf("\n[ NOR Flash Memory Writer Ver 0.1 ]\n\n");
printf("The program buffer : 0x31000000 ~ 0x31ff0000\n");
downloadAddress=0x31000000;
downloadProgramSize=0x0;
//MMU_Init();
ChangeRomCacheStatus(RW_NCNB);
while(1)
{ //display menu
printf("%c : %s",'a'+i,flashType[i][1]);
i++;
if((int)(flashType[i][0])==0)
{
printf("\n");
break;
}
if((i%4)==0)
printf("\n");
}
printf("Select the type of a flash memory ? ");
whichFlash=getchar()-'a';
printf("%c\n",(whichFlash+'a'));
//printf("\n");
if( i<0 || (i>=(sizeof(flashType)/8)) )
return;
printf("Do you want to download through UART0 from 0x%x? [y/n] : ",downloadAddress);
key=getchar();
printf("%c\n",key);
if(key=='y')
{
if(!DownloadData())
return;
}
( (void (*)(void))(flashType[whichFlash][0]) )();
}
//==========================================================================================
static int DownloadData(void)
{
int i,tmp;
U16 checkSum=0,dnCS;
U32 fileSize=10;
U8 *downPt;
downPt=(U8 *)downloadAddress;
printf("\ndownloadAddress = %x\n",downloadAddress);
printf("Download the plain binary file(.BHC) to be written\n");
printf("The file format : <n+6>(4)+(n)+CS(2)\n");
printf("To transmit .BIN file : wkocm2 xxx.BIN /1 /d:1\n");
printf("Download methods : COM:8Bit,NP,1STOP\n");
printf("\nSTATUS : ");
rINTMSK=BIT_ALLMSK;
tmp=RdURXH1(); //To remove overrun error state.
i=0;
while(i<fileSize)
{
while(!(rUTRSTAT1&0x1));
*(downPt+i)=RdURXH1();
if(i==3)
{
fileSize=*((U8 *)(downloadAddress+0))+
(*((U8 *)(downloadAddress+1))<<8)+
(*((U8 *)(downloadAddress+2))<<16)+
(*((U8 *)(downloadAddress+3))<<24);
}
if((i%1000)==0)
WrUTXH1('#');
i++;
}
downloadProgramSize=fileSize-6;
for(i=4;i<(fileSize-2);i++)
{
checkSum+=*((U8 *)(i+downloadAddress));
}
dnCS=*((U8 *)(downloadAddress+fileSize-2))+
(*( (U8 *)(downloadAddress+fileSize-1) )<<8);
if(checkSum!=dnCS)
{
printf("Checksum Error!!! MEM : %x DN : %x\n",checkSum,dnCS);
return 0;
}
printf("\nDownload O.K.\n");
return 1;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -