]> hackdaworld.org Git - my-code/arm.git/commitdiff
support for binaries usinf -b, BUT: dirty dirty slow slow fucked up code! i mean it!
authorhackbard <hackbard@staubsauger.localdomain>
Mon, 3 Sep 2007 05:37:20 +0000 (07:37 +0200)
committerhackbard <hackbard@staubsauger.localdomain>
Mon, 3 Sep 2007 05:37:20 +0000 (07:37 +0200)
betty/fwflash.c
betty/lpcload.c

index 7c9551f14f7837e9d0549233acd64e6c2aae00da..fd8d31bb47831d01db46ea9015448bd4f029fc0f 100644 (file)
@@ -313,6 +313,9 @@ int flash_write(u32 addr,u16 data) {
 
        u16 check;
 
+       if(data==0xffff)
+               return 0;
+
        *((unsigned volatile short *)addr)=0xa0;
        *((unsigned volatile short *)addr)=data;
        while(1) {
index d1bfd5473c6ee477bd83821d1d7f42bd80713f42..e1e12b75f1733e66d5bf18260b508671b8328787 100644 (file)
@@ -22,6 +22,7 @@
 #define BANK2                  (1<<3)
 #define BL                     (1<<4)
 #define FLASHFW                        (1<<5)
+#define BINARY                 (1<<6)
 
 #define BANK0_ADDR             0x80000000
 #define BANK2_ADDR             0x82000000
@@ -97,6 +98,7 @@ void usage(void) {
        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");
 
 }
@@ -602,6 +604,23 @@ int write_to_flash(t_lpc *lpc,u8 *buf,u32 addr,int len) {
                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);
@@ -638,6 +657,29 @@ int firmware_to_mem(t_lpc *lpc,u8 memtype) {
        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) {
@@ -825,6 +867,9 @@ int main(int argc,char **argv) {
                                strncpy(lpc.ffwfile,argv[++i],127);
                                lpc.info|=FLASHFW;
                                break;
+                       case 'b':
+                               lpc.info|=BINARY;
+                               break;
                        default:
                                usage();
                                return -1;