From: hackbard Date: Sun, 29 Jul 2007 10:25:54 +0000 (+0200) Subject: ram write (not yet finished) X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e98e1b46f919aaa0eadb3a74ada0e4f6220a589c;p=my-code%2Farm.git ram write (not yet finished) --- diff --git a/betty/lpcload.c b/betty/lpcload.c index ff78d96..8bd8530 100644 --- a/betty/lpcload.c +++ b/betty/lpcload.c @@ -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; }