From: hackbard Date: Wed, 15 Aug 2007 12:13:44 +0000 (+0200) Subject: added bootloader dump support, fwdump controls which memory to dump X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63b32f389164de54b110cb6441e1569aee466a82;p=my-code%2Farm.git added bootloader dump support, fwdump controls which memory to dump --- diff --git a/betty/fwbc.c b/betty/fwbc.c index e8fea0d..a617d24 100644 --- a/betty/fwbc.c +++ b/betty/fwbc.c @@ -27,9 +27,10 @@ #define MMAP_RAM 0x02 #define MMAP_EXT 0x03 -/* band 0/2 addr */ +/* band 0/2 & bootloader addr */ #define BANK0 0x80000000 #define BANK2 0x82000000 +#define BOOTLOADER 0x7fffe000 /* * type definitions @@ -56,8 +57,9 @@ int main(void) { /* variables */ - u16 *flash; - u32 i; + u16 *mem; + u32 *bl; + u32 i,len; u8 start; /* memory mapping of interrupt vectors to static ram */ @@ -79,25 +81,59 @@ int main(void) { BCFG0=0x1000FBEF; // no boot[1:0] influence? (thnx colibri) // BCFG2 should be fine as is - flash=(u16 *)BANK0; /* wait for fwdump to send transmit start character */ - start=0; - while(start!=0x23) { + start=0x23; + while(1) { while(!(UART0_LSR&(1<<0))) continue; start=UART0_RBR; + if(start=='0') { + mem=(u16 *)BANK0; + len=0x80000; + break; + } + if(start=='2') { + mem=(u16 *)BANK2; + len=0x80000; + break; + } + if(start=='b') { + BCFG0=0x1000FBEF; // 32 bit width + bl=(u32 *)BOOTLOADER; + len=0x800; + break; + } } /* transmit 1 mb of data */ - for(i=0;i<524288;i++) { + for(i=0;i>8); - flash++; + if(start=='b') + UART0_THR=((*bl&0xff00)>>8); + else { + UART0_THR=((*mem&0xff00)>>8); + mem++; + } + + if(start=='b') { + while(!(UART0_LSR&(1<<5))) + continue; + UART0_THR=((*bl&0xff0000)>>16); + while(!(UART0_LSR&(1<<5))) + continue; + UART0_THR=((*bl&0xff000000)>>24); + bl++; + } } return 0; diff --git a/betty/fwdump.c b/betty/fwdump.c index a3c7ed4..db07910 100644 --- a/betty/fwdump.c +++ b/betty/fwdump.c @@ -90,8 +90,17 @@ int main(int argc,char **argv) { unsigned char buf[BUFSIZE]; int cnt,size,ret; - if(argc!=3) { - printf("usage: %s \n",argv[0]); + if(argc!=4) { + printf("usage: %s \n",argv[0]); + printf("\nmem:\n"); + printf("0: bank0\n"); + printf("2: bank2\n"); + printf("b: bootoader\n"); + return -1; + } + + if((argv[3][0]!='0')&(argv[3][0]!='2')&(argv[3][0]!='b')) { + printf("unsupported mem type!\n"); return -1; } @@ -103,7 +112,7 @@ int main(int argc,char **argv) { return -1; /* send start byte */ - buf[0]=0x23; + buf[0]=argv[3][0]; ret=write(sfd,buf,1); if(ret!=1) { perror("write start byte");