flashing works, sample betty fw announcing itself :)
authorhackbard <hackbard@staubsauger.localdomain>
Sun, 2 Sep 2007 12:27:51 +0000 (14:27 +0200)
committerhackbard <hackbard@staubsauger.localdomain>
Sun, 2 Sep 2007 12:27:51 +0000 (14:27 +0200)
betty/betty.c
betty/fwflash.c
betty/lpcload.c

index 68c86f7..f3e08ce 100644 (file)
@@ -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;
 }
index ebf7190..7c9551f 100644 (file)
@@ -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);
index 9f60d88..d1bfd54 100644 (file)
@@ -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;