]> hackdaworld.org Git - my-code/arm.git/commitdiff
added bootloader dump support, fwdump controls which memory to dump
authorhackbard <hackbard@staubsauger.localdomain>
Wed, 15 Aug 2007 12:13:44 +0000 (14:13 +0200)
committerhackbard <hackbard@staubsauger.localdomain>
Wed, 15 Aug 2007 12:13:44 +0000 (14:13 +0200)
betty/fwbc.c
betty/fwdump.c

index e8fea0da70495e3ff944fa98820a5ad0bc51cd93..a617d247a09c6bb626f208aade90ba3fa23a3059 100644 (file)
 #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<len;i++) {                    // care for endianness
+
                while(!(UART0_LSR&(1<<5)))
                        continue;
-               UART0_THR=(*flash&0xff);                // care for endianness
+               if(start=='b')
+                       UART0_THR=(*bl&0xff);
+               else
+                       UART0_THR=(*mem&0xff);
+
                while(!(UART0_LSR&(1<<5)))
                        continue;
-               UART0_THR=((*flash&0xff00)>>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;
index a3c7ed4a26488e78aa9ea452a0671380aa189473..db0791042eb88ebade3a1c99fe9952f62e49cc91 100644 (file)
@@ -90,8 +90,17 @@ int main(int argc,char **argv) {
        unsigned char buf[BUFSIZE];
        int cnt,size,ret;
 
-       if(argc!=3) {
-               printf("usage: %s <serial port> <dump file>\n",argv[0]);
+       if(argc!=4) {
+               printf("usage: %s <serial port> <dump file> <mem>\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");