"""Read the target's lockbits."""
self.writecmd(self.AVRAPP,0x82,0,None);
return ord(self.data[0]);
+ def setlockbits(self,bits=0x00):
+ """Read the target's lockbits."""
+ self.writecmd(self.AVRAPP,0x92,1,[bits]);
+ return self.lockbits();
+
def eeprompeek(self, adr):
"""Read a byte of the target's EEPROM."""
self.writecmd(self.AVRAPP,0x81 ,2,
print "Usage: %s verb [objects]\n" % sys.argv[0];
print "%s test" % sys.argv[0];
print "%s info" % sys.argv[0];
- print "%s lockbits" % sys.argv[0];
+ print "%s lockbits [value]" % sys.argv[0];
#print "%s dump $foo.hex [0x$start 0x$stop]" % sys.argv[0];
print "%s erase" % sys.argv[0];
#print "%s flash $foo.hex [0x$start 0x$stop]" % sys.argv[0];
client.erase();
if(sys.argv[1]=="lockbits"):
print "Lockbits are 0x%02x" % client.lockbits();
+ if(len(sys.argv)>2):
+ print "Lockbits set 0x%02x" % client.setlockbits(int(sys.argv[2],16));
#if(sys.argv[1]=="lock"):
#if(sys.argv[1]=="unlock"):
u8 avr_lockbits(){
return avrexchange(0x58, 0, 0, 0);
}
+//! Write lock bits.
+void avr_setlock(u8 bits){
+ debugstr("Setting lock bits.");
+ avrexchange(0xAC,0xE0,0x00,
+ bits);
+}
//! Read a byte of EEPROM.
u8 avr_peekeeprom(u16 adr){
cmddata[0]=avr_lockbits();
txdata(app,verb,1);
break;
-
+ case AVR_POKELOCK:
+ avr_setlock(cmddata[0]);
+ txdata(app,verb,0);
+ break;
case AVR_POKEEEPROM:
avr_pokeeeprom(cmddataword[0], cmddata[2]);
//no break here.
void avr_erase();
//! Read lock bits.
u8 avr_lockbits();
+//! Write lock bits.
+void avr_setlock(u8 bits);
+
//! Read a byte of Flash
u8 avr_peekflash(u16 adr);
#define AVR_POKEEEPROM 0x91
//! Read lock bits.
#define AVR_PEEKLOCK 0x82
+//! Write lock its.
+#define AVR_POKELOCK 0x92
//! Read signature.
#define AVR_PEEKSIG 0x83
//! Read fuse bits.