]> hackdaworld.org Git - my-code/arm.git/commitdiff
fixed firmware to ram load (should work now!)
authorhackbard <hackbard@staubsauger.localdomain>
Sat, 4 Aug 2007 23:48:39 +0000 (01:48 +0200)
committerhackbard <hackbard@staubsauger.localdomain>
Sat, 4 Aug 2007 23:48:39 +0000 (01:48 +0200)
betty/lpcload.c

index 6ec118628d38eb537e43662cc408256159427bce..0d2f9c85ddd9bfd9f5394c556a38ee666d707aa8 100644 (file)
@@ -317,7 +317,7 @@ int go(t_lpc *lpc) {
 
        snprintf(buf,BUFSIZE,"G %d A\r\n",lpc->roff);
        len=strlen(buf);
 
        snprintf(buf,BUFSIZE,"G %d A\r\n",lpc->roff);
        len=strlen(buf);
-       ret=txrx(lpc,buf,ret,TXRX_TYPE_CMD);
+       ret=txrx(lpc,buf,len,TXRX_TYPE_CMD);
 
        return ret;
 }
 
        return ret;
 }
@@ -349,7 +349,7 @@ int write_to_ram(t_lpc *lpc,char *buf,u32 addr,int len) {
        }
 
        /* make it a multiple of 3 (reason: uuencode) */
        }
 
        /* make it a multiple of 3 (reason: uuencode) */
-       nlen=(len/3+1)*3;
+       nlen=(!(len%3))?len:((len/3+1)*3);
        if(nlen>BUFSIZE) {
                printf("ram write: too much data\n");
                return -1;
        if(nlen>BUFSIZE) {
                printf("ram write: too much data\n");
                return -1;
@@ -376,7 +376,8 @@ int write_to_ram(t_lpc *lpc,char *buf,u32 addr,int len) {
        while(bcnt<nlen) {
 
                /* uuencode / prepare data bytes */
        while(bcnt<nlen) {
 
                /* uuencode / prepare data bytes */
-               uuencode((u8 *)(buf+bcnt),(u8 *)(txrxbuf),bcnt==nlen-3?len%3:3);
+               uuencode((u8 *)(buf+bcnt),(u8 *)(txrxbuf),
+                        (bcnt==nlen-3)?(len%3?len%3:3):3);
                txrxbuf[5]='\r';
                txrxbuf[6]='\n';
 
                txrxbuf[5]='\r';
                txrxbuf[6]='\n';
 
@@ -384,7 +385,7 @@ int write_to_ram(t_lpc *lpc,char *buf,u32 addr,int len) {
                checksum+=((u8)buf[bcnt]+(u8)buf[bcnt+1]+(u8)buf[bcnt+2]);
 
                /* send a data line */
                checksum+=((u8)buf[bcnt]+(u8)buf[bcnt+1]+(u8)buf[bcnt+2]);
 
                /* send a data line */
-               txrx(lpc,txrxbuf,6,TXRX_TYPE_DATA);
+               txrx(lpc,txrxbuf,7,TXRX_TYPE_DATA);
 
                /* increase counters */
                lcount+=1;
 
                /* increase counters */
                lcount+=1;
@@ -546,10 +547,13 @@ int main(int argc,char **argv) {
        firmware_to_ram(&lpc);
 
        /* unlock go cmd */
        firmware_to_ram(&lpc);
 
        /* unlock go cmd */
+       printf("unlock go command ...\n");
        unlock_go(&lpc);
 
        /* go! */
        unlock_go(&lpc);
 
        /* go! */
+       printf("go ...\n");
        go(&lpc);
        go(&lpc);
+       printf("\n");
 
 end:
        close(lpc.sfd);
 
 end:
        close(lpc.sfd);