From e98e1b46f919aaa0eadb3a74ada0e4f6220a589c Mon Sep 17 00:00:00 2001 From: hackbard Date: Sun, 29 Jul 2007 12:25:54 +0200 Subject: [PATCH] ram write (not yet finished) --- betty/lpcload.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) 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; } -- 2.39.2