From: hackbard Date: Sun, 29 Jul 2007 20:03:07 +0000 (+0200) Subject: added fwdump, basic data write implemented X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=203e912166256906b85dfe2db43508c2d2a381d1;p=my-code%2Farm.git added fwdump, basic data write implemented --- diff --git a/betty/fwdump.c b/betty/fwdump.c index 6bb250a..3769508 100644 --- a/betty/fwdump.c +++ b/betty/fwdump.c @@ -6,3 +6,10 @@ * */ +int main(int argc,char **argv) { + + + + return 0; +} + diff --git a/betty/lpcload.c b/betty/lpcload.c index 8bd8530..7c2db70 100644 --- a/betty/lpcload.c +++ b/betty/lpcload.c @@ -19,7 +19,8 @@ #define TXRX_TYPE_BAUD 0x01 #define TXRX_TYPE_SYNC 0x02 -#define TXRX_TYPE_DATA 0x03 +#define TXRX_TYPE_CMD 0x03 +#define TXRX_TYPE_DATA 0x04 #define CMD_SUCCESS "0\r\n" #define INVALID_COMMAND "1\r\n" @@ -125,7 +126,7 @@ int open_firmware(t_lpc *lpc) { return lpc->fwfd; } -int txrx(t_lpc *lpc,char *buf,int len,u8 type) { +int txrx(t_lpc *lpc,u8 *buf,int len,u8 type) { int ret,cnt; int i; @@ -165,6 +166,11 @@ int txrx(t_lpc *lpc,char *buf,int len,u8 type) { } } + /* return here if type is data */ + + if(type==TXRX_TYPE_DATA) + return cnt; + /* read */ if(lpc->info&VERBOSE) @@ -190,12 +196,11 @@ int txrx(t_lpc *lpc,char *buf,int len,u8 type) { } if(lpc->info&VERBOSE) printf(" (%d)\n",cnt); - len=cnt; buf[cnt]='\0'; /* check/strip return code if type is data */ - if(type==TXRX_TYPE_DATA) { + if(type==TXRX_TYPE_CMD) { ret=strlen(CMD_SUCCESS); if(!strncmp(buf,CMD_SUCCESS,ret)) { for(i=ret;ipartid=atoi(buf); return lpc->partid; @@ -258,11 +263,11 @@ int read_part_id(t_lpc *lpc) { int read_bcv(t_lpc *lpc) { - char buf[BUFSIZE]; + u8 buf[BUFSIZE]; char *ptr; memcpy(buf,"K\r\n",3); - txrx(lpc,buf,3,TXRX_TYPE_DATA); + txrx(lpc,buf,3,TXRX_TYPE_CMD); ptr=strtok(buf,"\r\n"); lpc->bcv[0]=strtol(ptr,NULL,16); ptr=strtok(NULL,"\r\n"); @@ -271,7 +276,7 @@ int read_bcv(t_lpc *lpc) { return 0; } -int uuencode(char *in,char *out) { +int uuencode(u8 *in,u8 *out) { out[0]=0x20+((in[0]>>2)&0x3f); out[1]=0x20+(((in[0]<<4)|(in[1]>>4))&0x3f); @@ -281,27 +286,84 @@ int uuencode(char *in,char *out) { return 0; } -int write_to_ram(t_lpc *lpc,char *buf,int addr,int len) { +int write_to_ram(t_lpc *lpc,u8 *buf,int addr,int len) { int lcount; u8 checksum; + u8 txrxbuf[BUFSIZE]; + int count,bcnt; + int nlen,slen; + int i; + /* check length */ if(len%4) { printf("ram write: not a multiple of 4\n"); return -1; } - while(1) { + /* make it a multiple of 3 (reason: uuencode) */ + nlen=(len/3+1)*3; + if(nlen>BUFSIZE) { + printf("ram write: too much data\n"); + return -1; + } + for(i=len;i