From: travisutk Date: Wed, 26 Aug 2009 01:06:04 +0000 (+0000) Subject: Trying to get 2618 going. X-Git-Url: http://git.rot13.org/?p=goodfet;a=commitdiff_plain;h=c5a56b2284ba0cd554cb44ed221eb91489607b9e Trying to get 2618 going. Bootloader troubles abound, so I'm forking tos-bsl/msp430-bsl. git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@89 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- diff --git a/client/GoodFET.py b/client/GoodFET.py index 8d588ed..2311062 100755 --- a/client/GoodFET.py +++ b/client/GoodFET.py @@ -13,7 +13,7 @@ class GoodFET: def __init__(self, *args, **kargs): self.data=[0]; def timeout(self): - print "timout\n"; + print "timeout\n"; def serInit(self, port=None): """Open the serial port""" @@ -28,7 +28,13 @@ class GoodFET: self.serialport = serial.Serial( port, + #300, + #2400, + #4800, #9600, + #19200, + #38400, + #57600, 115200, parity = serial.PARITY_NONE ) @@ -41,8 +47,8 @@ class GoodFET: #time.sleep(1); self.readcmd(); #Read the first command. if(self.verb!=0x7F): - print "Verb is wrong. Incorrect firmware?"; - + print "Verb %02x is wrong. Incorrect firmware?" % self.verb; + print "Connected." def writecmd(self, app, verb, count, data): """Write a command and some data to the GoodFET.""" self.serialport.write(chr(app)); @@ -90,8 +96,17 @@ class GoodFET: """Determine how many bytes of RAM are unused by looking for 0xBEEF..""" self.writecmd(0,0x91,0,self.data); return ord(self.data[0])+(ord(self.data[1])<<8); + + #Baud rates. + baudrates=[115200, + 9600, + 19200, + 38400, + 57600, + 115200]; def setBaud(self,baud): - rates=[9600, 9600, 19200, 38400]; + """Change the baud rate. TODO fix this.""" + rates=self.baudrates; self.data=[baud]; print "Changing FET baud." self.serialport.write(chr(0x00)); @@ -107,6 +122,21 @@ class GoodFET: print "Baud is now %i." % rates[baud]; return; + def readbyte(self): + return ord(self.serialport.read(1)); + def findbaud(self): + for r in self.baudrates: + print "\nTrying %i" % r; + self.serialport.setBaudrate(r); + #time.sleep(1); + self.serialport.flushInput() + self.serialport.flushOutput() + + for i in range(1,10): + self.readbyte(); + + print "Read %02x %02x %02x %02x" % ( + self.readbyte(),self.readbyte(),self.readbyte(),self.readbyte()); def monitortest(self): """Self-test several functions through the monitor.""" print "Performing monitor self-test."; diff --git a/client/goodfet.monitor b/client/goodfet.monitor index 249454f..e3a0477 100755 --- a/client/goodfet.monitor +++ b/client/goodfet.monitor @@ -28,6 +28,8 @@ if(sys.argv[1]=="ramdepth"): print "0x%04x RAM bytes free." % client.monitor_ram_depth(); if(sys.argv[1]=="test"): client.monitortest(); +if(sys.argv[1]=="findbaud"): + client.findbaud(); if(sys.argv[1]=="dump"): f = sys.argv[2]; start=0x0200; diff --git a/firmware/Makefile b/firmware/Makefile index 8b7eed7..5bc3555 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -1,6 +1,6 @@ PORT=/dev/ttyUSB0 -BSL=msp430-bsl --invert-reset --invert-test -c $(PORT) --speed=38400 +BSL=../../contrib/tos-bsl --invert-reset --invert-test -c $(PORT) --speed=38400 #mcu=msp430x2618 mcu=msp430x1612 diff --git a/firmware/goodfet.c b/firmware/goodfet.c index 594d7db..8cd782e 100644 --- a/firmware/goodfet.c +++ b/firmware/goodfet.c @@ -23,6 +23,9 @@ void init(){ msp430_init_dco(); msp430_init_uart(); + + + //Enable Interrupts. //eint(); } @@ -67,6 +70,14 @@ int main(void) //Ready //txdata(MONITOR,OK,0); + //while (1){ + // txdata(0xFF,0xff,0x0); + // delay(1000); + //} + //delay(0xffff); + //while(*((int*)0x1001)); + //while(1) + // txdata(0xFF,0xFF,0); txstring(MONITOR,OK,"http://goodfet.sf.net/"); //Command loop. There's no end! diff --git a/firmware/lib/msp430x2618.c b/firmware/lib/msp430x2618.c index 02ee1c0..ac17e0d 100644 --- a/firmware/lib/msp430x2618.c +++ b/firmware/lib/msp430x2618.c @@ -25,18 +25,25 @@ unsigned char serial_rx(){ //! Receive a byte. unsigned char serial1_rx(){ //TODO + return 00; } - //! Transmit a byte. void serial_tx(unsigned char x){ - while ((IFG2 & UCA0TXIFG) == 0); //loop unti lbuffer is free + while ((IFG2 & UCA0TXIFG) == 0); //loop until buffer is free + UCA0TXBUF = x; /* send the character */ + while(!(IFG2 & UCA0TXIFG)); +} +//! Transmit a byte. +void serial_tx_old(unsigned char x){ + while ((IFG2 & UCA0TXIFG) == 0); //loop until buffer is free UCA0TXBUF = x; /* send the character */ while(!(IFG2 & UCA0TXIFG)); } //! Transmit a byte on the second UART. void serial1_tx(unsigned char x){ + } //! Set the baud rate. @@ -88,36 +95,40 @@ void setbaud1(unsigned char rate){ } -//host.h says 0x2B for DCO=4.9MHZ -//Divide by four for accuracy. //19200 -#define BAUD0EN 0x41 -#define BAUD1EN 0x03 +#define BAUD0EN 0x1b +#define BAUD1EN 0x00 void msp430_init_uart(){ - // Serial on P3.4, P3.5 + + // Serial on P3.4, P3.5 P3SEL |= BIT4 + BIT5; P3DIR |= BIT4; - - //UCA0CTL1 |= UCSWRST; /* disable UART */ + + //UCA0CTL1 |= UCSWRST; /* disable UART */ UCA0CTL0 = 0x00; - //UCA0CTL0 |= UCMSB ; - UCA0CTL1 |= UCSSEL_2; // SMCLK - UCA0BR0 = BAUD0EN; // 115200 + //UCA0CTL0 |= UCMSB ; + UCA0CTL1 |= UCSSEL_2; // SMCLK + UCA0BR0 = BAUD0EN; // 115200 UCA0BR1 = BAUD1EN; - UCA0MCTL = 0; // Modulation UCBRSx = 5 - UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine** - -} + UCA0MCTL = 0; // Modulation UCBRSx = 5 + UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine** + + //Leave this commented! + //Interrupt is handled by target code, not by bootloader. + //IE2 |= UCA0RXIE; +} + +//external resistor +#define DCOR 1 void msp430_init_dco() { BCSCTL1 = CALBC1_16MHZ; - DCOCTL = CALDCO_16MHZ; - + DCOCTL = CALDCO_16MHZ; return; } diff --git a/firmware/tests/blink/Makefile b/firmware/tests/blink/Makefile index 85a9828..f8131f7 100644 --- a/firmware/tests/blink/Makefile +++ b/firmware/tests/blink/Makefile @@ -3,9 +3,9 @@ PORT=/dev/ttyUSB0 BSL=tos-bsl --invert-reset --invert-test -c $(PORT) #mcu=msp430x1611 -mcu=msp430x1612 +mcu=msp430x2618 -GCCINC=-T ../../ldscripts/161x.x +#GCCINC=-T ../../ldscripts/161x.x CC=msp430-gcc -g -mmcu=$(mcu) -DGCC $(GCCINC) -I ../../include diff --git a/firmware/tests/echo/Makefile b/firmware/tests/echo/Makefile index 1e5bbe8..bcb9a93 100644 --- a/firmware/tests/echo/Makefile +++ b/firmware/tests/echo/Makefile @@ -3,14 +3,14 @@ PORT=/dev/ttyUSB0 BSL=tos-bsl --invert-reset --invert-test -c $(PORT) #mcu=msp430x1611 -mcu=msp430x1612 +mcu=msp430x2618 #ldscript is wonky -GCCINC=-T ../../ldscripts/161x.x +#GCCINC=-T ../../ldscripts/161x.x CC=msp430-gcc -g -mmcu=$(mcu) -DGCC $(GCCINC) -I ../../include -libs=../../lib/msp430f1612.c +libs=../../lib/msp430x2618.c app=echo install: $(app) diff --git a/firmware/tests/echo/echo.c b/firmware/tests/echo/echo.c index 57fd760..5938488 100644 --- a/firmware/tests/echo/echo.c +++ b/firmware/tests/echo/echo.c @@ -36,7 +36,7 @@ int main(void) PLEDOUT^=PLEDPIN; // Blink //while(1) serial_tx(serial_rx()); - while(1) serial_tx(serial_rx()); + while(1) serial_tx('G'); while(1){ i = 10000;