X-Git-Url: https://hackdaworld.org/gitweb/?p=my-code%2Farm.git;a=blobdiff_plain;f=betty%2Flpcload.c;fp=betty%2Flpcload.c;h=19d5a5b2904aebc9dcdc242090ecd506331b4c95;hp=f7911a89e2730f0ccc0f51b825f1a85cd37713d3;hb=ed474ffa00e2e35babccb09d039a7a65939097a0;hpb=d24fd4a34d026918724fad1ddbb0da1de9d28c63 diff --git a/betty/lpcload.c b/betty/lpcload.c index f7911a8..19d5a5b 100644 --- a/betty/lpcload.c +++ b/betty/lpcload.c @@ -26,7 +26,7 @@ #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! @@ -128,7 +128,6 @@ int open_serial_device(t_lpc *lpc) { // input options -> enable flow control - //term.c_iflag&=~(IXON|IXOFF|IXANY|INLCR|ICRNL); term.c_iflag&=~(INLCR|ICRNL|IXANY); term.c_iflag|=(IXON|IXOFF); @@ -139,15 +138,38 @@ int open_serial_device(t_lpc *lpc) { // 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 */ @@ -670,7 +692,7 @@ int main(int argc,char **argv) { break; } else if(argv[i][2]=='b') { - lpc.info|=BANK0; + lpc.info|=BL; strncpy(lpc.bl,argv[++i],127); break; } @@ -724,6 +746,10 @@ int main(int argc,char **argv) { /* 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);