From afe6191925fbdac90169ed8a463bd9928276a863 Mon Sep 17 00:00:00 2001 From: hackbard Date: Sun, 2 Sep 2007 14:27:51 +0200 Subject: [PATCH] flashing works, sample betty fw announcing itself :) --- betty/betty.c | 8 ++++++-- betty/fwflash.c | 3 ++- betty/lpcload.c | 12 ++++++++---- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/betty/betty.c b/betty/betty.c index 68c86f7..f3e08ce 100644 --- a/betty/betty.c +++ b/betty/betty.c @@ -172,15 +172,19 @@ u8 uart0_get_byte(void) { int main() { - char buf="betty - live from the flash at 0x80000000! ;)\r\n"; + char buf[]="betty - live from the flash at 0x80000000! ;)\r\n"; + u8 byte; pll_init(); uart0_init(); ext_mem_bank_init(); pin_select_init(); - while(1) + while(1) { + byte=uart0_get_byte(); uart0_send_string(buf); + uart0_send_byte(byte); + } return 0; } diff --git a/betty/fwflash.c b/betty/fwflash.c index ebf7190..7c9551f 100644 --- a/betty/fwflash.c +++ b/betty/fwflash.c @@ -364,7 +364,8 @@ int receive_data_and_write_to_flash(u32 addr,u32 datalen) { unlock_bypass_reset(bank); /* modify cksm on purpose, so the user knows ... */ - cksm+=1; + if(ret==-1) + cksm+=1; /* send the cksm */ uart0_send_byte(cksm); diff --git a/betty/lpcload.c b/betty/lpcload.c index 9f60d88..d1bfd54 100644 --- a/betty/lpcload.c +++ b/betty/lpcload.c @@ -564,8 +564,11 @@ int write_to_flash(t_lpc *lpc,u8 *buf,u32 addr,int len) { u8 check; int i; + /* prepare addr */ + addr+=lpc->roff; + /* send cmd */ - send_cmd(lpc->sfd,addr+lpc->roff,len,CMD_WRITE); + send_cmd(lpc->sfd,addr,len,CMD_WRITE); /* transfer data */ cnt=0; @@ -591,7 +594,7 @@ int write_to_flash(t_lpc *lpc,u8 *buf,u32 addr,int len) { break; } if(buf[cnt+i]!=check) - printf("FATAL: write to flash: wrong transfer\n"); + printf("FATAL: write to flash (transfer)\n"); } cksml+=buf[cnt]; cksml+=buf[cnt+1]; @@ -611,9 +614,10 @@ int write_to_flash(t_lpc *lpc,u8 *buf,u32 addr,int len) { if(cksml!=cksmr) { printf("FATAL: wrong checksum or failure in flash write!\n"); if(cksml+1==cksmr) - printf(" -> most probably due to flash write!"); + printf(" -> most probably due to flash write!\n"); else - printf(" -> most probably due to failure in transfer!"); + printf(" -> most probably failure in transfer!\n"); + printf(" addr:0x%08x l:%02x r:%02x\n",addr,cksml,cksmr); } return 0; -- 2.20.1