#define BANK2 0x82000000
#define BANK_SIZE 0x00100000
#define BOOTLOADER 0x7fffe000
-#define BL_SIZE 0x00000800
+#define BL_SIZE 0x00002000
/* flash cmd addresses - flash[0-18] <--> arm[1-19]*/
#define B0F555 (*((volatile unsigned long *)(BANK0|0xaaa))) // 0x555
MEMMAP=memtype;
}
+void pll_init(void) {
+
+ /* configuration */
+ PLLCFG=0x02; // multiplier = 2
+ PLLCON=0x03; // enable and set as clk source for the lpc
+ /* feed sequence */
+ PLLFEED=0xaa;
+ PLLFEED=0x55;
+ /* wait for lock */
+ while(!(PLLSTAT&(1<<10)))
+ continue;
+}
+
void uart0_init(void) {
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_DLL=0x04; // br: 38400 @ 10/4 mhz
UART0_DLM=0x00;
UART0_LCR=0x03; // unset dlab
/* memory mapping of interrupt vectors to static ram */
//mmap_init(MMAP_RAM);
+
+ /* pll initialization */
+ pll_init();
/* uart initialization */
uart0_init();
#define BANK2_ADDR 0x82000000
#define BANK_SIZE 0x00100000
#define BL_ADDR 0x7fffe000
-#define BL_SIZE 0x00000800
+#define BL_SIZE 0x00002000
#define CMD_READ 'R' // stay compatible to fwflash!
// input options -> enable flow control
- //term.c_iflag&=~(IXON|IXOFF|IXANY|INLCR|ICRNL);
term.c_iflag&=~(INLCR|ICRNL|IXANY);
term.c_iflag|=(IXON|IXOFF);
// more control options -> timeout / flow control
term.c_cc[VMIN]=0;
- term.c_cc[VTIME]=10; // 1 second timeout
- term.c_cc[VSTART]=0x11;
- term.c_cc[VSTOP]=0x13;
+ term.c_cc[VTIME]=20; // 2 seconds timeout
+ //term.c_cc[VSTART]=0x11;
+ //term.c_cc[VSTOP]=0x13;
tcsetattr(lpc->sfd,TCSANOW,&term);
return lpc->sfd;
}
+int reconfig_serial_device(t_lpc *lpc) {
+
+ struct termios term;
+ int ret;
+
+ /* reconfigure the serial device for our lousy loader tool */
+
+ tcgetattr(lpc->sfd,&term);
+
+ // disable flow control
+
+ term.c_iflag&=~(IXON|IXOFF|IXANY|INLCR|ICRNL);
+
+ // change baudrate
+
+ cfsetispeed(&term,B115200);
+ cfsetospeed(&term,B115200);
+
+ ret=tcsetattr(lpc->sfd,TCSANOW,&term);
+
+ return ret;
+}
+
int open_firmware(t_lpc *lpc) {
/* open firmware file */
break;
}
else if(argv[i][2]=='b') {
- lpc.info|=BANK0;
+ lpc.info|=BL;
strncpy(lpc.bl,argv[++i],127);
break;
}
/* flush the lpc2220 tx buf */
lpc_txbuf_flush(&lpc);
+ /* reconfigure the serial port */
+ if(reconfig_serial_device(&lpc)<0)
+ goto end;
+
/* download flash/bootloader content */
if(lpc.info&BANK0)
dump_files(lpc.sfd,lpc.b0fd,BANK0_ADDR,BANK_SIZE);