def con(self, PID=0xC610, sn=None, program_fpga=True, bitstream_file=None): """Connect to PhyWhisperer-USB. Raises error if multiple detected Args: PID (int, optional): USB PID of PhyWhisperer, defaults to 0xC610 (NewAE standard). sn (int, option): Serial Number of PhyWhisperer, required when multiple PhyWhisperers are connected. program_fpga (bool, option): Specifies whether or not to program the FPGA with the default firmware when we connect. Set to False if using custom bitstream. """ self.usb = NAE.NAEUSB() self.usb.con(idProduct=[PID], serial_number=sn) self._llint = LLINT.PhyWhispererUSB(self.usb) if program_fpga: if bitstream_file is None: with ZipFile(getsome("phywhisperer-firmware.zip")) as myzip: with myzip.open('phywhisperer_top.bit') as bitstream: self._llint.FPGAProgram(bitstream) pass else: print("Programming custom bit stream '%s'" % bitstream_file) with open(bitstream_file,"rb") as bitstream: self._llint.FPGAProgram(bitstream) self.write_reg(self.REG_COUNT_WRITES, [1])
def con(self, PID=0xC521, sn=None, program_fpga=True): """Connect to PhyWhisperer-USB. Raises error if multiple detected PID : int Product ID of PhyWhisperer sn : int Serial Number of PhyWhisperer, required when multiple PhyWhisperers are connected. program_fpga : bool Specifies whether or not to program the FPGA with the default firmware when we connect """ self.usb = NAE.NAEUSB() self.usb.con(idProduct=[PID], serial_number=sn) self._llint = LLINT.PhyWhispererUSB(self.usb) if program_fpga: from phywhisperer.firmware.phywhisperer import getsome with ZipFile(getsome("phywhisperer-firmware.zip")) as myzip: with myzip.open('phywhisperer_top.bit') as bitstream: self._llint.FPGAProgram(bitstream) pass pass