def __init__(self, oadcInstance): self.ser = None self.dev = None self.scope = None self.getParams().addChildren([ { 'name': "CW Firmware Preferences", 'tip': "Configure ChipWhisperer FW Paths", 'type': "menu", "action": lambda _: self.getFwLoaderConfigGUI().show() }, # Can' use Config... name with MacOS { 'name': "Download CW Firmware", 'tip': "Download Firmware+FPGA To Hardware", 'type': "menu", "action": lambda _: self.cwFirmwareConfig.loadRequired() }, ]) if (openadc_qt is None) or (usb is None): missingInfo = "" if openadc_qt is None: missingInfo += "openadc.qt " if usb is None: missingInfo += " usb" raise ImportError("Needed imports for ChipWhisperer missing: %s" % missingInfo) else: self.cwFirmwareConfig = FWLoaderConfig(CWLite_Loader()) self.cwFirmwareConfig1200 = FWLoaderConfig(CW1200_Loader()) self.scope = oadcInstance
def __init__(self, oadcInstance): self.getParams().addChildren([ { 'name': 'CW Firmware Preferences', 'tip': 'Configure ChipWhisperer FW Paths', 'type': "menu", "action": lambda _: self.getFwLoaderConfigGUI.show() }, { 'name': 'Download CW Firmware', 'tip': 'Download Firmware+FPGA To Hardware', 'type': "menu", "action": lambda _: self.getCwFirmwareConfig.loadRequired() }, ]) self.ser = None if (openadc_qt is None) or (usb is None): missingInfo = "" if openadc_qt is None: missingInfo += "openadc.qt " if usb is None: missingInfo += " usb" raise ImportError("Needed imports for ChipWhisperer missing: %s" % missingInfo) else: self.scope = oadcInstance self.cwFirmwareConfig = FWLoaderConfig(CWCRev2_Loader())
def __init__(self, oadcInstance): self.ser = None self.dev = None self.scope = None self.last_id = None self.getParams().addChildren([ { 'name': "CW Firmware Preferences", 'tip': "Configure ChipWhisperer FW Paths", 'type': "menu", "action": lambda _: self.getFwLoaderConfigGUI().show() }, # Can' use Config... name with MacOS { 'name': "Download CW Firmware", 'tip': "Download Firmware+FPGA To Hardware", 'type': "menu", "action": lambda _: self.cwFirmwareConfig[self.last_id].loadRequired() }, { 'name': "Serial Number", 'key': 'cwsn', 'type': "list", 'values': { "Auto": None }, 'value': "Auto" }, ]) if (openadc_qt is None) or (usb is None): missingInfo = "" if openadc_qt is None: missingInfo += "openadc.qt " if usb is None: missingInfo += " usb" raise ImportError("Needed imports for ChipWhisperer missing: %s" % missingInfo) else: self.cwFirmwareConfig = { 0xACE2: FWLoaderConfig(CWLite_Loader()), 0xACE3: FWLoaderConfig(CW1200_Loader()) } self.scope = oadcInstance
def __init__(self, oadcInstance): self.ser = None self.dev = None self.scope = None self.last_id = None if (openadc_qt is None) or (usb is None): missingInfo = "" if openadc_qt is None: missingInfo += "openadc.qt " if usb is None: missingInfo += " usb" raise ImportError("Needed imports for ChipWhisperer missing: %s" % missingInfo) else: self.cwFirmwareConfig = { 0xACE2: FWLoaderConfig(CWLite_Loader()), 0xACE3: FWLoaderConfig(CW1200_Loader()) } self.scope = oadcInstance
class OpenADCInterface_ZTEX(Parameterized): _name = "ChipWhisperer Rev2" def __init__(self, oadcInstance): self.getParams().addChildren([ { 'name': 'CW Firmware Preferences', 'tip': 'Configure ChipWhisperer FW Paths', 'type': "menu", "action": lambda _: self.getFwLoaderConfigGUI.show() }, { 'name': 'Download CW Firmware', 'tip': 'Download Firmware+FPGA To Hardware', 'type': "menu", "action": lambda _: self.getCwFirmwareConfig.loadRequired() }, ]) self.ser = None if (openadc_qt is None) or (usb is None): missingInfo = "" if openadc_qt is None: missingInfo += "openadc.qt " if usb is None: missingInfo += " usb" raise ImportError("Needed imports for ChipWhisperer missing: %s" % missingInfo) else: self.scope = oadcInstance self.cwFirmwareConfig = FWLoaderConfig(CWCRev2_Loader()) def con(self): if self.ser is None: # Download firmware if required self.cwFirmwareConfig.loadRequired() try: dev = usb.core.find(idVendor=0x221A, idProduct=0x0100) except IOError as e: exctype, value = sys.exc_info()[:2] raise IOError("FX2 Port " + str(exctype) + str(value)) if dev is None: raise IOError("FX2 Port. Could not open USB Device") dev.set_configuration() self.dev = dev self.writeEP = 0x06 self.readEP = 0x82 self.interface = 0 self.ser = self try: self.scope.con(self.ser) logging.info('OpenADC Found, Connecting') except IOError as e: exctype, value = sys.exc_info()[:2] raise IOError( "OpenADC Error (FX2 Port): " + (str(exctype) + str(value)) + " - Did you download firmware/FPGA data to ChipWhisperer?") def dis(self): self.ser = None def __del__(self): pass def read(self, N=0, debug=False): try: # self.interface removed from call for latest API compatibility data = self.dev.read(self.readEP, N, timeout=100) except IOError: return [] data = bytearray(data) if debug: print("RX: ", end=' ') for b in data: print("%02x " % b, end=' ') print("") return data def write(self, data, debug=False): data = bytearray(data) if debug: print("TX: ", end=' ') for b in data: print("%02x " % b, end=' ') print("") # self.interface removed from call for latest API compatibility self.dev.write(self.writeEP, data, timeout=500) def getFwLoaderConfigGUI(self): if not hasattr(self, 'fwLoaderConfigGUI'): self.fwLoaderConfigGUI = FWLoaderConfigGUI(self.cwFirmwareConfig) return self.fwLoaderConfigGUI
def getFWConfig(self): try: return self.cwFirmwareConfig[self.last_id] except KeyError as e: return FWLoaderConfig(CWLite_Loader())
class OpenADCInterface_NAEUSBChip(Parameterized, Plugin): _name = "NewAE USB (CWLite/CW1200)" def __init__(self, oadcInstance): self.ser = None self.dev = None self.scope = None self.getParams().addChildren([ { 'name': "CW Firmware Preferences", 'tip': "Configure ChipWhisperer FW Paths", 'type': "menu", "action": lambda _: self.getFwLoaderConfigGUI().show() }, # Can' use Config... name with MacOS { 'name': "Download CW Firmware", 'tip': "Download Firmware+FPGA To Hardware", 'type': "menu", "action": lambda _: self.cwFirmwareConfig.loadRequired() }, ]) if (openadc_qt is None) or (usb is None): missingInfo = "" if openadc_qt is None: missingInfo += "openadc.qt " if usb is None: missingInfo += " usb" raise ImportError("Needed imports for ChipWhisperer missing: %s" % missingInfo) else: self.cwFirmwareConfig = FWLoaderConfig(CWLite_Loader()) self.cwFirmwareConfig1200 = FWLoaderConfig(CW1200_Loader()) self.scope = oadcInstance def con(self): if self.ser is None: self.dev = CWL.CWLiteUSB() self.getParams().append(self.dev.getParams()) try: found_id = self.dev.con(idProduct=[0xACE2, 0xACE3]) except IOError: raise Warning( 'Could not connect to "%s". It may have been disconnected or is being used by another tool.' % self.getName()) if (found_id == 0xACE3): logging.warning( 'Found CW1200. FPGA dialog being switched, if you made changes they are lost. ' 'If you need a different bitstream loaded, edit the dialog now and reconnect.' ) self.cwFirmwareConfig = self.cwFirmwareConfig1200 self.cwFirmwareConfig.setInterface(self.dev.fpga) try: self.cwFirmwareConfig.loadRequired() except: self.dev.dis() self.dev.usbdev().close() raise self.ser = self.dev.usbdev() try: self.scope.con(self.ser) logging.info('OpenADC Found, Connecting') except IOError, e: exctype, value = sys.exc_info()[:2] raise IOError("OpenADC: " + (str(exctype) + str(value)))