]> hackdaworld.org Git - my-code/arm.git/commitdiff
ram write (not yet finished)
authorhackbard <hackbard@staubsauger.localdomain>
Sun, 29 Jul 2007 10:25:54 +0000 (12:25 +0200)
committerhackbard <hackbard@staubsauger.localdomain>
Sun, 29 Jul 2007 10:25:54 +0000 (12:25 +0200)
betty/lpcload.c

index ff78d967950474371f8fec874cc217770a690891..8bd853010f225979c073ad24a3d5aaa630b693f6 100644 (file)
@@ -271,6 +271,49 @@ int read_bcv(t_lpc *lpc) {
        return 0;
 }
 
+int uuencode(char *in,char *out) {
+
+       out[0]=0x20+((in[0]>>2)&0x3f);
+       out[1]=0x20+(((in[0]<<4)|(in[1]>>4))&0x3f);
+       out[2]=0x20+(((in[1]<<2)|(in[2]>>6))&0x3f);
+       out[3]=0x20+(in[2]&0x3f);
+
+       return 0;
+}
+
+int write_to_ram(t_lpc *lpc,char *buf,int addr,int len) {
+
+       int lcount;
+       u8 checksum;
+
+       if(len%4) {
+               printf("ram write: not a multiple of 4\n");
+               return -1;
+       }
+
+       while(1) {
+               if(!(lcount%20)) {
+                       /* send checksum */
+                       if(lcount!=0) {
+                               
+                       }
+                       /* reset checksum */
+                       checksum=0;
+               }
+
+               lcount+=1;
+       }
+
+       return 0;
+}
+
+int firmware_to_ram(t_lpc *lpc) {
+
+
+
+       return 0;
+}
+
 int main(int argc,char **argv) {
 
        t_lpc lpc;
@@ -314,7 +357,8 @@ int main(int argc,char **argv) {
        }
 
        /* open serial port */
-       open_serial_device(&lpc);
+       if(open_serial_device(&lpc)<0)
+               goto end;
 
        /* boot loader init */
        printf("boot loader init ...\n");
@@ -329,9 +373,13 @@ int main(int argc,char **argv) {
        printf("boot code version: %02x %02x\n",lpc.bcv[0],lpc.bcv[1]);
 
        // to be continued ... (parsing fw file and poking it to ram)
+       if(open_firmware(&lpc)<0)
+               goto end;
+       firmware_to_ram(&lpc);
 
-//end:
+end:
        close(lpc.sfd);
+       close(lpc.fwfd);
 
        return 0;
 }