From: hackbard Date: Tue, 4 Sep 2007 00:06:05 +0000 (+0200) Subject: no byte reply anymore (due to ack and tcflush) -> incredible speedup! X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=3e0847553a5d514589116f8cf933d454a0db491c;p=my-code%2Farm.git no byte reply anymore (due to ack and tcflush) -> incredible speedup! --- diff --git a/betty/fwflash.c b/betty/fwflash.c index fd8d31b..85a64fa 100644 --- a/betty/fwflash.c +++ b/betty/fwflash.c @@ -272,8 +272,11 @@ void flash_chip_erase(u8 bank) { else status=B2F; - if(status&0x80) + if(status&0x80) { + /* send an ack */ + uart0_send_byte(status); break; + } } } @@ -351,11 +354,9 @@ int receive_data_and_write_to_flash(u32 addr,u32 datalen) { ret=0; for(i=0;isfd,buf+cnt+i,1); - if(ret<0) { - perror("transmit flash content (w)"); - return ret; - } - if(ret==1) - break; - } - while(1) { - ret=read(lpc->sfd,&check,1); - if(ret<0) { - perror("transmit flash content (r)"); - return ret; - } - if(ret==1) - break; - } - if(buf[cnt+i]!=check) - printf("FATAL: write to flash (transfer)\n"); - } - cksml+=buf[cnt]; - cksml+=buf[cnt+1]; - cnt+=2; - len-=2; - } - - - /* - cnt=0; - cksml=0; while(len) { ret=write(lpc->sfd,buf+cnt,len); if(ret<0) { @@ -619,7 +588,7 @@ int write_to_flash(t_lpc *lpc,u8 *buf,u32 addr,int len) { len-=ret; cnt+=ret; } - */ + /* check ack */ while(1) { @@ -931,6 +900,10 @@ int main(int argc,char **argv) { if(lpc.info&FLASHFW) { printf("writing firmware to flash ...\n"); send_cmd(lpc.sfd,0,'0',CMD_CHIP_ERASE); + /* ack */ + ret=0; + while(!ret) + read(lpc.sfd,&ret,1); lpc.roff=BANK0_ADDR; firmware_to_mem(&lpc,FLASH); }