X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FGoodFETCC.py;h=abbe115ee1e0b8f758f2db81541081cc67695f80;hp=bfe28227e2404d5edcfec2e48d42e70c8450e74f;hb=44e1187885bbf7caa7cafccf7cc41d0ec3963721;hpb=82265795487b76cf55ec1e8bc10b31d25e2cbc9e diff --git a/client/GoodFETCC.py b/client/GoodFETCC.py index bfe2822..abbe115 100644 --- a/client/GoodFETCC.py +++ b/client/GoodFETCC.py @@ -17,26 +17,24 @@ class GoodFETCC(GoodFET): """A GoodFET variant for use with Chipcon 8051 Zigbee SoC.""" APP=0x30; - - - smartrfpath="/opt/smartrf7"; def loadsymbols(self): try: self.SRF_loadsymbols(); except: if self.verbose>0: print "SmartRF not found at %s." % self.smartrfpath; def SRF_chipdom(self,chip="cc1110", doc="register_definition.xml"): + """Loads the chip XML definitions from SmartRF7.""" fn="%s/config/xml/%s/%s" % (self.smartrfpath,chip,doc); #print "Opening %s" % fn; return xml.dom.minidom.parse(fn) def CMDrs(self,args=[]): """Chip command to grab the radio state.""" - try: - self.SRF_radiostate(); - except: - print "Error printing radio state."; - print "SmartRF not found at %s." % self.smartrfpath; + #try: + self.SRF_radiostate(); + #except: + # print "Error printing radio state."; + # print "SmartRF not found at %s." % self.smartrfpath; def SRF_bitfieldstr(self,bf): name="unused"; start=0; @@ -125,15 +123,32 @@ class GoodFETCC(GoodFET): hz=freq*396.728515625; return hz; + + def RF_getchannel(self): + """Get the hex channel.""" + #FIXME CC1110 specific + freq=0; + try: + freq2=self.peekbysym("FREQ2"); + freq1=self.peekbysym("FREQ1"); + freq0=self.peekbysym("FREQ0"); + freq=(freq2<<16)+(freq1<<8)+freq0; + except: + freq=0; + + return freq; + + lastshellcode="none"; - def shellcodefile(self,filename,wait=1): + def shellcodefile(self,filename,wait=1, alwaysreload=0): """Run a fragment of shellcode by name.""" #FIXME: should identify chip model number, use shellcode for that chip. - if self.lastshellcode!=filename: + if self.lastshellcode!=filename or alwaysreload>0: self.lastshellcode=filename; file=__file__; file=file.replace("GoodFETCC.pyc","GoodFETCC.py"); + #TODO make this generic path=file.replace("GoodFETCC.py","shellcode/chipcon/cc1110/"); filename=path+filename; @@ -275,8 +290,9 @@ class GoodFETCC(GoodFET): self.pokebysym("ADDR" , 0x01) # Device address. self.pokebysym("PKTLEN" , 0xFF) # Packet length. - self.pokebysym("SYNC1",0xD3); - self.pokebysym("SYNC0",0x91); + #Sync word hack + self.pokebysym("SYNC1",0x83); + self.pokebysym("SYNC0",0xFE); return; def config_iclicker(self,band="lf"): #Mike Ossmann figured most of this out, with help from neighbors. @@ -368,6 +384,7 @@ class GoodFETCC(GoodFET): else: #Got a frequency, not a band. self.RF_setfreq(eval(band)); + #data rate #~1 #self.pokebysym("MDMCFG4" , 0x85) @@ -379,13 +396,24 @@ class GoodFETCC(GoodFET): #self.pokebysym("MDMCFG4" , 0xf6) #self.pokebysym("MDMCFG3" , 0x83) + #4.8 kbaud + #print "Warning: Default to 4.8kbaud."; + #self.pokebysym("MDMCFG4" , 0xf7) + #self.pokebysym("MDMCFG3" , 0x83) #9.6 kbaud - print "Warning: Default to 9.6kbaud."; + #print "Warning: Default to 9.6kbaud."; + # + self.pokebysym("MDMCFG4" , 0xf8) self.pokebysym("MDMCFG3" , 0x83) + self.pokebysym("MDMCFG2" , 0x34) # OOK, carrier-sense, no-manchester + + #Kind aright for keeloq + print "Warning: Guessing baud rate."; + #self.pokebysym("MDMCFG4" , 0xf6) + #self.pokebysym("MDMCFG3" , 0x93) + #self.pokebysym("MDMCFG2" , 0x3C) # OOK, carrier-sense, manchester - - self.pokebysym("MDMCFG2" , 0x34) # OOK, carrier-sense in leiu of sync. self.pokebysym("MDMCFG1" , 0x00) # Modem configuration. self.pokebysym("MDMCFG0" , 0xF8) # Modem configuration. self.pokebysym("CHANNR" , 0x00) # Channel number. @@ -409,7 +437,7 @@ class GoodFETCC(GoodFET): #self.pokebysym("PKTCTRL0" , 0x05) # Packet automation control, w/ checksum. self.pokebysym("PKTCTRL0" , 0x00) # Packet automation control, w/o checksum, fixed length self.pokebysym("ADDR" , 0x01) # Device address. - self.pokebysym("PKTLEN" , 0x20) # Packet length. + self.pokebysym("PKTLEN" , 0xFF) # Packet length. self.pokebysym("SYNC1",0xD3); self.pokebysym("SYNC0",0x91); @@ -565,7 +593,7 @@ class GoodFETCC(GoodFET): except: if self.verbose>0: print "RSSI reg doesn't exist."; try: - #RSSI doesn't exist on 2.4GHz devices. Maybe RSSIL and RSSIH? + #RSSI doesn't exist on some 2.4GHz devices. Maybe RSSIL and RSSIH? rssilreg=self.symbols.get("RSSIL"); rssil=self.CCpeekdatabyte(rssilreg); rssihreg=self.symbols.get("RSSIL"); @@ -676,8 +704,10 @@ class GoodFETCC(GoodFET): 0x8900:"cc2431", 0x8100:"cc2510", 0x9100:"cc2511", - 0xA500:"cc2530", #page 52 of SWRU191 + 0xA500:"cc2530", #page 57 of SWRU191B 0xB500:"cc2531", + 0x9500:"CC2533", + 0x8D00:"CC2540", 0xFF00:"CCmissing"}; CCpagesizes={0x01: 1024, #"CC1110", 0x11: 1024, #"CC1111", @@ -685,8 +715,10 @@ class GoodFETCC(GoodFET): 0x89: 2048, #"CC2431", 0x81: 1024, #"CC2510", 0x91: 1024, #"CC2511", - 0xA5: 2048, #"CC2530", #page 52 of SWRU191 + 0xA5: 2048, #"CC2530", #page 57 of SWRU191B 0xB5: 2048, #"CC2531", + 0x95: 2048, #"CC2533", + 0x8D: 2048, #"CC2540", 0xFF: 0 } #"CCmissing"}; def infostring(self): return self.CCidentstr();