2 * fwbc.c - broadcast the betty tv original firmware via uart0
3 * use fwdump to write it onto your computers harddisk
5 * author: hackbard@hackdaworld.org
20 #define OSC_CLOCK 10000000
23 #define P_CLOCK (OSC_CLOCK/P_DIV)
30 /* band 0/2 & bootloader addr */
31 #define BANK0 0x80000000
32 #define BANK2 0x82000000
33 #define BOOTLOADER 0x7fffe000
39 typedef unsigned char u8;
40 typedef unsigned short u16;
41 typedef unsigned int u32;
47 void mmap_init(u8 memtype);
48 void uart0_init(void);
49 void uart0_send_string(char *txbuf);
50 void uart0_send_char(char send);
65 /* memory mapping of interrupt vectors to static ram */
67 //mmap_init(MMAP_RAM);
69 /* uart initialization */
73 PINSEL0=0x05; // pin select -> tx, rx
74 UART0_FCR=0x07; // enable fifo
75 UART0_LCR=0x83; // set dlab + word length
76 UART0_DLL=0x10; // br: 9600 @ 10/4 mhz
78 UART0_LCR=0x03; // unset dlab
80 /* external memory init */
82 BCFG0=0x1000FBEF; // no boot[1:0] influence? (thnx colibri)
83 // BCFG2 should be fine as is
87 /* wait for fwdump to send transmit start character */
90 while(!(UART0_LSR&(1<<0)))
104 BCFG0=0x1000FBEF; // 32 bit width
105 bl=(u32 *)BOOTLOADER;
111 /* transmit 1 mb of data */
112 for(i=0;i<len;i++) { // care for endianness
114 while(!(UART0_LSR&(1<<5)))
117 UART0_THR=(*bl&0xff);
119 UART0_THR=(*mem&0xff);
121 while(!(UART0_LSR&(1<<5)))
124 UART0_THR=((*bl&0xff00)>>8);
126 UART0_THR=((*mem&0xff00)>>8);
131 while(!(UART0_LSR&(1<<5)))
133 UART0_THR=((*bl&0xff0000)>>16);
134 while(!(UART0_LSR&(1<<5)))
136 UART0_THR=((*bl&0xff000000)>>24);
150 void mmap_init(u8 memtype) {
155 void uart0_init(void) {
157 PINSEL0=0x05; // pin select -> tx, rx
158 UART0_FCR=0x07; // enable fifo
159 UART0_LCR=0x83; // set dlab + word length
160 UART0_DLL=0x10; // br: 9600 @ 10/4 mhz
162 UART0_LCR=0x03; // unset dlab
165 void uart0_send_string(char *txbuf) {
172 UART0_THR=txbuf[i++];
176 while(!(UART0_LSR&(1<<6))) {}
179 void uart0_send_char(char send) {
181 while(!(UART0_LSR&(1<<5)))