#Do nothing.
a=1;
+ baud=115200;
+ if(os.environ.get("platform")=='arduino'):
+ baud=19200; #Slower, for now.
self.serialport = serial.Serial(
port,
#9600,
- 115200,
+ baud,
parity = serial.PARITY_NONE,
timeout=timeout
)
attempts=0;
connected=0;
while connected==0:
+ #print "Got %s" % self.data;
while self.verb!=0x7F or self.data!="http://goodfet.sf.net/":
if attemptlimit is not None and attempts >= attemptlimit:
return
if(os.environ.get("platform")=='telosb'):
#print "TelosB Reset";
self.telosBReset();
+
+
#self.serialport.write(chr(0x80));
#self.serialport.write(chr(0x80));
#self.serialport.write(chr(0x80));
attempts=attempts+1;
self.readcmd(); #Read the first command.
#Here we have a connection, but maybe not a good one.
+ #print "We have a connection."
connected=1;
olds=self.infostring();
clocking=self.monitorclocking();
+ #if(os.environ.get("platform")!='arduino'):
for foo in range(1,30):
if not self.monitorecho():
- if self.verbose: print "Comm error on %i try, resyncing out of %s." % (foo,
- clocking);
- connected=0;
- break;
+ if self.verbose:
+ print "Comm error on %i try, resyncing out of %s." % (foo,
+ clocking);
+ connected=0;
+ break;
if self.verbose: print "Connected after %02i attempts." % attempts;
self.mon_connected();
self.serialport.setTimeout(12);
data="The quick brown fox jumped over the lazy dog.";
self.writecmd(self.MONITORAPP,0x81,len(data),data);
if self.data!=data:
- if self.verbose: print "Comm error recognized by monitorecho().";
+ print "Comm error recognized by monitorecho(), got:\n%s" % self.data;
return 0;
return 1;
self.MONpoke16(0x56, clock);
def monitorgetclock(self):
"""Get the clocking value."""
+ if(os.environ.get("platform")=='arduino'):
+ return 0xDEAD;
+ #Check for MSP430 before peeking this.
return self.MONpeek16(0x56);
# The following functions ought to be implemented in
# every client.
def infostring(self):
- a=self.MONpeek8(0xff0);
- b=self.MONpeek8(0xff1);
- return "%02x%02x" % (a,b);
+ if(os.environ.get("platform")=='arduino'):
+ return "Arduino";
+ else:
+ a=self.MONpeek8(0xff0);
+ b=self.MONpeek8(0xff1);
+ return "%02x%02x" % (a,b);
def lock(self):
print "Locking Unsupported.";
def erase(self):
platform?=goodfet
#N.B., gcc WILL NOT BITCH if this file doesn't exist.
-GCCINC?=-T ldscripts/$(mcu).x
+GCCINC?=
#GCC?=avr-gcc
-GCC?=msp430-gcc
+GCC?=msp430-gcc -T ldscripts/$(mcu).x
CCEXTRA?= -D$(mcu) -D$(platform) -Dplatform=$(platform) -DGCC $(GCCINC) -I include -I platforms
CC=$(GCC) -Wall -Os -fno-strict-aliasing -g -mmcu=$(mcu) $(CCEXTRA)
break;
case PEEK:
+ #ifdef MSP430
cmddata[0]=memorybyte[cmddataword[0]];
+ #else
+ debugstr("Monitor peeks are unsupported on this platform.");
+ #endif
txdata(app,verb,1);
break;
case POKE:
+ #ifdef MSP430
//Todo, make word or byte.
memorybyte[cmddataword[0]] = cmddata[2];
cmddata[0] = memorybyte[cmddataword[0]];
+ #else
+ debugstr("Monitor pokes are unsupported on this platform.");
+ #endif
txdata(app,verb,1);
break;
--- /dev/null
+These are configuration scripts which may be sourced to preconfigure
+the environment for a particular hardware platform.
+
--- /dev/null
+export mcu=atmega168
+export GCC=avr-gcc
+export config=monitor
+export platform=arduino
+echo "Call this as 'source configs/arduino.sh'"
+echo "Assumes an 8MHz Atmega328P by default."
+echo "This port is utterly untested."
//! Handle a command.
void handle(uint8_t const app,
- uint8_t const verb,
- uint32_t const len)
-{
- int i;
-
- //debugstr("GoodFET");
- PLEDOUT&=~PLEDPIN;
-
- // find the app and call the handle fn
- for(i = 0; i < num_apps; i++)
- {
- if(apps[i]->app == app)
- {
- // call the app's handle fn
- (*(apps[i]->handle))(app, verb, len);
-
- // exit early
- return;
- }
- }
-
- // if we get here, then the desired app is not copiled in
- // this firmware
- debugstr("App missing.");
- debughex(app);
- txdata(app, NOK, 0);
+ uint8_t const verb,
+ uint32_t const len){
+ int i;
+
+ //debugstr("GoodFET");
+ PLEDOUT&=~PLEDPIN;
+
+ // find the app and call the handle fn
+ for(i = 0; i < num_apps; i++){
+ if(apps[i]->app == app){
+ // call the app's handle fn
+ (*(apps[i]->handle))(app, verb, len);
+
+ // exit early
+ return;
+ }
+ }
+
+ // if we get here, then the desired app is not copiled in
+ // this firmware
+ debugstr("App missing.");
+ debughex(app);
+ txdata(app, NOK, 0);
}
void (*reboot_function)(void) = (void *) 0xFFFE;
init();
-
+
txstring(MONITOR,OK,"http://goodfet.sf.net/");
-
+ #ifdef ECHOTEST
+ while(1) serial0_tx(serial0_rx());
+ #endif
+
//Command loop. There's no end!
while(1)
{
// or
// WDTCTL = WDTPW + WDTCNTCL + WDTSSEL + 0x00;
// but instead we'll jump to our reboot function pointer
+ #ifdef MSP430
(*reboot_function)();
+ #else
+ debugstr("Rebooting not supported on this platform.");
+ #endif
}
continue;
}
verb = serial_rx();
- //len=serial_rx();
len = rxword();
//Read data, looking for buffer overflow.y
#include "platform.h"
#ifdef ARDUINO
+#include <avr/interrupt.h>
#include <util/delay.h>
//! Arduino setup code.
void arduino_init(){
- /* set PORTB for output*/
+ //LED port as output.
DDRB = 0xFF;
+ //Disabled interrupts.
+ cli();
+
avr_init_uart0();
}
}
#define F_CPU 8000000L
-#define BAUD 115200L
+ //#define BAUD 115200L
+#define BAUD 9600L
#include <util/setbaud.h>
UBRR0H = UBRRH_VALUE;
UBRR0L = UBRRL_VALUE;
void avr_init_uart0(){
+ PORTD = _BV(PD2);
setbaud0(0);
+ _delay_ms(500); //takes a bit to stabilize
}
}
TBCTL = 0x0204; // Reset Timer B, till next time
#else
- #warning "Function unimplemented for this platform."
+ debugstr("delay_ms unimplemented");
#endif
}
}
TBCTL = 0x0204; // Reset Timer B, till next time
#else
- #warning "Function unimplemented for this platform."
+ debugstr("delay_us unimplemented");
#endif
}
asm( "nop" );
TBCTL = 0x0204; // Reset Timer B, till next time
#else
- #warning "Function unimplemented for this platform."
+ debugstr("delay_ticks unimplemented");
#endif
}