#define BANK2 (1<<3)
#define BL (1<<4)
#define FLASHFW (1<<5)
+#define BINARY (1<<6)
#define BANK0_ADDR 0x80000000
#define BANK2_ADDR 0x82000000
printf(" -Dx <filename>\n");
printf(" x=0: bank0, x=2: bank2, x=b: bootloader\n");
printf(" -w <firmware which goes to flash>\n");
+ printf(" -b (if firmware for flash is a binary)\n");
printf(" -v\n");
}
len-=2;
}
+
+ /*
+ cnt=0;
+ cksml=0;
+ while(len) {
+ ret=write(lpc->sfd,buf+cnt,len);
+ if(ret<0) {
+ perror("transmit flash content (w)");
+ return ret;
+ }
+ for(i=cnt;i<cnt+ret;i++)
+ cksml+=buf[i];
+ len-=ret;
+ cnt+=ret;
+ }
+ */
+
/* check ack */
while(1) {
ret=read(lpc->sfd,&cksmr,1);
else
return -1;
+ /* another evil hack to support binary format */
+ if((lpc->info&BINARY)&&(memtype==FLASH)) {
+ addr=0;
+ ret=1;
+ while(ret) {
+ ret=read(fd,buf,16);
+ if(ret!=16) {
+ printf("D'OH ...\n");
+ return -1;
+ }
+ buf[16]='s'; // skip
+ for(temp=0;temp<16;temp++)
+ if((u8)buf[temp]!=0xff)
+ buf[16]='w'; // write
+ printf("addr:%08x\r",addr+lpc->roff);
+ fflush(stdout);
+ if(buf[16]=='w')
+ write_to_flash(lpc,(u8 *)buf,addr,16);
+ addr+=16;
+ }
+ return 0;
+ }
+
/* read a line */
ret=1;
while(ret) {
strncpy(lpc.ffwfile,argv[++i],127);
lpc.info|=FLASHFW;
break;
+ case 'b':
+ lpc.info|=BINARY;
+ break;
default:
usage();
return -1;