/************************************************************************************* NAME: strata32.c DESC: Strata Flash Programming code through 2410 JTAG HISTORY: JUN.14.2002:LSJ : ported for 2410 Aug.19.2002:purnnamu: ported for 2410 JTAG version. Nov.15.2002:purnnamu: - Fast programming by removing _RESET() in programming loop and omitting nGCS1 deassertion - E28F128 ClearLockBit function is added at sector erase step. *************************************************************************************/ #include #include //#include #include "def.h" #include "pin2410.h" #include "jtag.h" //#include "K9S1208.h" #include "sjf2410.h" #include "mem_rdwr.h" //I have not tested yet about fast programming. But, it will reduce the programming time. //IF the problem is occurred, let FAST_ROM_PROGRAM 0. #define FAST_ROM_PROGRAM 1 #define TARGET_ADDR_28F128 0x08000000 // nGCS1, 128MB area static U32 srcAddr; static U32 targetOffset; static U32 targetAddress; static U32 targetSize; static int error_erase=0; // Read Status Register, SR.5 static int error_program=0; // Read Status Register, SR.4 static int Strata_ProgFlash(U32 realAddr,U32 data); static void Strata_EraseSector(int targetAddr); static int Strata_CheckID(int targetAddr); static int Strata_CheckDevice(int targetAddr); static int Strata_CheckBlockLock(int targetAddr); static int Strata_ClearBlockLock(int targetAddr); static int Strata_BlankCheck(int targetAddr,int targetSize); static int _WAIT(void); #if FAST_ROM_PROGRAM #define _WR(addr,data) MRW_Wr32QQ(addr,data,0,0xf) #else #define _WR(addr,data) MRW_Wr32Q(addr,data,0,0xf) #endif #define _RD(addr) MRW_Rd32Q(addr,0,0xf) #define _RESET() MRW_Wr32Q(targetAddress,0x00ff00ff,0,0xf) void Program28F128J3A(void) { int i; U32 temp; MRW_JtagInit(); printf("\n[28F128J3A Flash JTAG Programmer]\n"); printf("\n*** Very Important Notes ***\n"); printf("1. 28F128J3A must be located at 0x08000000.\n" " J6 : connect 2-3 pins, J9 : connect 1-2 pins\n" " J33 : Open, J34 : Short\n"); printf("2. After programming, 28F128J3A may be located at 0x0.\n" " J6 : connect 1-2 pins, J9 : connect 2-3 pins\n" " J33 : Short, J34 : Open\n"); targetAddress=TARGET_ADDR_28F128; targetSize=imageSize; printf("\nSource size = %xh\n",targetSize); printf("\nAvailable Target Offset Address: \n"); printf("0x0,0x20000,0x40000, ..., 0x1ce0000\n"); printf("Input target address offset [0x?] : "); scanf("%x",&targetOffset); printf("Target base address(0x08000000) = 0x%x\n",targetAddress); printf("Target offset (0x0) = 0x%x\n",targetOffset); printf("Target size (0x20000*n) = 0x%x\n",targetSize); if ( (Strata_CheckID(targetAddress) & 0xffff) != 0x0089 ) // ID number = 0x0089 { printf("Identification check error !!\n"); return ; } if ( (Strata_CheckDevice(targetAddress) & 0xffff) != 0x0018 ) // Device number=0x0018 { printf("Device check error !!\n"); return ; } printf("\nErase the sector from 0x%x.\n", targetAddress+targetOffset); for(i=0;i