fwdump working now, adapted fwbc fw (reading/transmitting flash should work now!)
[my-code/arm.git] / betty / fwbc.c
index 9682ee8..1694055 100644 (file)
 #define MMAP_RAM               0x02
 #define MMAP_EXT               0x03
 
+/* band 0/2 addr */
+#define BANK0                  0x80000000
+#define BANK2                  0x82000000
+
 /*
  * type definitions
  */
 
 typedef unsigned char u8;
+typedef unsigned short u16;
 typedef unsigned int u32;
 
 /*
@@ -49,29 +54,50 @@ void uart0_send_char(char send);
 
 int main(void) {
 
+       /* variables */
+
+       u16 *flash;
+       u32 i;
+       u8 start;
+
        /* memory mapping of interrupt vectors to static ram */
 
        //mmap_init(MMAP_RAM);
 
        /* uart initialization */
 
-#ifdef USE_FUNCTIONS
        //uart0_init();
-#else
+
        PINSEL0=0x05;                   // pin select -> tx, rx
        UART0_FCR=0x07;                 // enable fifo
        UART0_LCR=0x83;                 // set dlab + word length
        UART0_DLL=0x10;                 // br: 9600 @ 10/4 mhz
        UART0_DLM=0x00;
        UART0_LCR=0x03;                 // unset dlab
-#endif
 
        /* external memory init */
 
-       while(1) {
+       //BCFG0=;
+       //BCFG2=;
+       flash=(u16 *)BANK0;
+
+       /* wait for fwdump to send transmit start character */
+       start=0;
+       while(start!=0x23) {
+               while(!(UART0_LSR&(1<<0)))
+                       continue;
+               start=UART0_RBR;
+       }
+
+       /* transmit 1 mb of data */
+       for(i=0;i<524288;i++) {
+               while(!(UART0_LSR&(1<<5)))
+                       continue;
+               UART0_THR=((*flash&0xff00)>>8);
                while(!(UART0_LSR&(1<<5)))
                        continue;
-               UART0_THR=0x23;
+               UART0_THR=(*flash&0xff);
+               flash++;
        }
 
        return 0;