#include #include #include #include"..\lib\7188.h" /* 1.run 7188.exe on PC 2.power on 7188 if it is not on 3.run ld3.exe download torom.exe 4.run torom.exe 5.Press ALT_R 6.wait download process finished 7.reset 7188 hardware(power off then power on) ** P.S. ROM-DISK.IMG must be in current directory Syntax: torom [/8|/9|/A|/B|/C|/D|/E] default download to segment 0xC000 (for 256K) or to segment 0x8000 (for 512K) with option can download to other segment, /8 download to segment 0x8000 (only for 512K) /9 download to segment 0x9000 (only for 512K) /A download to segment 0xA000 (only for 512K) /B download to segment 0xB000 (only for 512K) /C download to segment 0xC000 /D download to segment 0xD000 /E download to segment 0xE000 7188(D)/DOS can download 2 ROM-DISK max. If download 2 rom-disk.img to Flash Memory, ROM-DOS will find 2 ROM-DISK, that is DISK A: and DISK B:, so if use RAM-DISK, the disk number will be DISK C:(not DISK B:), at this time, user cannot just use command "ld3" to download program to ram-disk, must use "ld3 /c" to download program to RAM-DISK C: Ver 1.05 Use 7188s.lib ver. 1.13(support MXIC flash memory) */ /* ------------------------------------------------------------------- */ unsigned RomBase; char DataBuf[256]; void ToRom(int mode) { unsigned int i,j; unsigned RomOffset,count,Base=RomBase; unsigned char checksum; Init5DigitLed(); Show5DigitLed(2,16); Show5DigitLed(3,0); Show5DigitLed(4,0); Show5DigitLed(5,0); i=FlashReadId(); { char buf[20]; ToCom4Str("\n\r(1) Flash ID="); ToCom4(hex_to_ascii[(i>>12)&0xf]); ToCom4(hex_to_ascii[(i>>8)&0xf]); ToCom4(hex_to_ascii[(i>>4)&0xf]); ToCom4(hex_to_ascii[(i&0xf)]); } ToCom4Str("\n\r(2) Start to Download...."); ToCom4Str("\n\r(3) Wait PC to Download ROM-DISK."); if(mode==0) ToCom4Str("Press ALT_R in 7188.exe)"); else ToCom4Str("Press ALT_P in 7188.exe)"); Delay(150); Show5DigitLed(3,0); Show5DigitLed(4,0); Show5DigitLed(5,0); if(mode==0){ RestoreCom4(); InstallCom4(115200L,8,0); } RomOffset=0xffff; for (;;){ while (!IsCom4()) ; i=ReadCom4(); if(i=='Q'){ /* if receive 'Q' -->end of transfer */ break; } else if(i!='S'){ /* 'S' --> start of block , if != 'S' --> error */ if(count==0 && RomBase==Base){ RestoreCom4(); return 1; } else { ToCom4Str("Download to FlashRom Error,Please Use Init*"); break; } } /* read block size , count=blocksize-1 ,max blocksize=256 */ /* if blocksize < 256 --> the last block */ while (!IsCom4()) ; count=ReadCom4(); count&=0xff; count++; checksum=0; for(j=0;j>12)); } FlashWrite(RomBase,RomOffset,DataBuf[i]); } ToCom4(0xAA); /* if check sum OK,return 0xAA for OK */ } else { ToCom4(0x55); /* else if checksum error,return 0x55 for resend */ } } } main(int argc,char *argv[]) { void (far *Reset)(void)=(void (far *)(void))0xffff0000L; int mode=0,i; long baud=57600; unsigned tmp; int reset=1,type; switch((type=Is7188())){ default: puts("\nFlash ROM size unknown."); return; case 0: puts("\nTOROM must run on 7188."); return; case 256: RomBase=0xB000; break; case 512: RomBase=0x7000; break; } for(i=1;i