CWNANO setup issues

Hi

I’m getting started with a CWNANO, and am having difficulty with the Jupyter course Lab 2_1A - Instruction Power Differences. I get through the (HARDWARE) tutorial part, but when it’s done I don’t seem to be able to pass the capture test:

wave = capture_trace()
print(“:heavy_check_mark: OK to continue!”)

Instead I get an error:


KeyError Traceback (most recent call last)
~/.pyenv/versions/3.7.7/envs/cw/lib/python3.7/site-packages/pyusb-1.1.1-py3.7.egg/usb/core.py in get_interface_and_endpoint(self, device, endpoint_address)
235 try:
→ 236 return self._ep_info[endpoint_address]
237 except KeyError:

KeyError: None

During handling of the above exception, another exception occurred:

TypeError Traceback (most recent call last)
in
----> 1 wave = capture_trace()
2 print(“:heavy_check_mark: OK to continue!”)

in capture_trace(_ignored)
2 ktp = cw.ktp.Basic()
3 key, text = ktp.next()
----> 4 return cw.capture_trace(scope, target, text).wave

~/work/projects/chipwhisperer/software/chipwhisperer/init.py in capture_trace(scope, target, plaintext, key, ack)
336 target.simpleserial_write(‘p’, plaintext)
337
→ 338 ret = scope.capture()
339
340 i = 0

~/work/projects/chipwhisperer/software/chipwhisperer/capture/scopes/cwnano.py in capture(self)
694 return True
695
→ 696 self._lasttrace = self._cwusb.cmdReadMem(0, self.adc.samples)
697
698 # can just keep rerunning this until it works I think

~/work/projects/chipwhisperer/software/chipwhisperer/hardware/naeusb/naeusb.py in cmdReadMem(self, addr, dlen)
798 “”"
799
→ 800 return self.usbseralizer.cmdReadMem(addr, dlen)
801
802 def cmdWriteMem(self, addr, data):

~/work/projects/chipwhisperer/software/chipwhisperer/hardware/naeusb/naeusb.py in cmdReadMem(self, addr, dlen)
202 cmdpacket = self.make_cmd(self.CMD_READ_MEM, payload)
203
→ 204 return self.process_rx(self.txrx(tx=cmdpacket))
205
206 def cmdWriteMem(self, addr, data):

~/work/projects/chipwhisperer/software/chipwhisperer/hardware/naeusb/naeusb.py in txrx(self, tx)
311 addr = payload[0]
312 dlen = payload[1]
→ 313 response = self.cmdReadMem(addr, dlen)
314 naeusb_logger.debug(“CMD_READ_MEM: addr: {:08X}, dlen: {:08X}, response: {}”.format(addr, dlen, response))
315 elif cmd == self.CMD_WRITE_MEM:

~/work/projects/chipwhisperer/software/chipwhisperer/hardware/naeusb/naeusb.py in cmdReadMem(self, addr, dlen)
531 # Get data
532 if cmd == self.CMD_READMEM_BULK:
→ 533 data = self.usbdev().read(self.rep, dlen, timeout=self._timeout)
534 # XXX Husky debug:
535 naeusb_logger.info(‘YYY BULK rep=%d, dlen=%d, got len=%d’ % (self.rep, dlen, len(data)))

~/.pyenv/versions/3.7.7/envs/cw/lib/python3.7/site-packages/pyusb-1.1.1-py3.7.egg/usb/core.py in read(self, endpoint, size_or_buffer, timeout)
1009 }
1010
→ 1011 intf, ep = self._ctx.setup_request(self, endpoint)
1012 fn = fn_map[util.endpoint_type(ep.bmAttributes)]
1013

~/.pyenv/versions/3.7.7/envs/cw/lib/python3.7/site-packages/pyusb-1.1.1-py3.7.egg/usb/core.py in wrapper(self, *args, **kwargs)
111 try:
112 self.lock.acquire()
→ 113 return f(self, *args, **kwargs)
114 finally:
115 self.lock.release()

~/.pyenv/versions/3.7.7/envs/cw/lib/python3.7/site-packages/pyusb-1.1.1-py3.7.egg/usb/core.py in setup_request(self, device, endpoint)
226 endpoint_address = endpoint
227
→ 228 intf, ep = self.get_interface_and_endpoint(device, endpoint_address)
229 self.managed_claim_interface(device, intf)
230 return (intf, ep)

~/.pyenv/versions/3.7.7/envs/cw/lib/python3.7/site-packages/pyusb-1.1.1-py3.7.egg/usb/core.py in wrapper(self, *args, **kwargs)
111 try:
112 self.lock.acquire()
→ 113 return f(self, *args, **kwargs)
114 finally:
115 self.lock.release()

~/.pyenv/versions/3.7.7/envs/cw/lib/python3.7/site-packages/pyusb-1.1.1-py3.7.egg/usb/core.py in get_interface_and_endpoint(self, device, endpoint_address)
242 return intf, ep
243
→ 244 raise ValueError('Invalid endpoint address ’ + hex(endpoint_address))
245
246 @synchronized

TypeError: ‘NoneType’ object cannot be interpreted as an integer

I’m running VMware on a Mac, running the prebuilt VM from release 5.5.2, and I’ve updated the firmware to 0.30. Any suggestions on where I might be going wrong?

Many thanks
Dan

If it’s any help when I add in some print statements I get:

def capture_trace(_ignored=None):
ktp = cw.ktp.Basic()
key, text = ktp.next()
print(scope)
print(target)
print(text)
return cw.capture_trace(scope, target, text).wave

Which prints out:

ChipWhisperer Nano Device
fw_version =
major = 0
minor = 30
debug = 0
io =
tio1 = None
tio2 = None
tio3 = None
tio4 = None
pdid = True
pdic = False
nrst = True
clkout = 7500000.0
cdc_settings = array(‘B’, [1, 1])
adc =
clk_src = int
clk_freq = 7500000.0
samples = 5000
glitch =
repeat = 0
ext_offset = 0

SimpleSerial Settings =
output_len = 16
baud = 38400
simpleserial_last_read =
simpleserial_last_sent = paf89fd9e9ec253fd3f92b446840fc44b

CWbytearray(b’e7 1d c4 3f cc a7 bf 7d 0c d6 ce f2 8d cc 32 54’)

Hi,

Try running the following line before you try to capture a trace:

scope._cwusb.usbtx.rep = 0x81
scope._cwusb.usbtx.wep = 0x02

This issue has been been fixed on develop and will be included in 5.6.1.

Alex

Hi Alex

That’s great, it worked first time :slight_smile:

Thanks for the speedy response!
D