CWNANO SCA-01 Lab 2_1

Wow,
So I was just here typing this problem up when I went back to try again and it worked so I deleted the post. As soon as I did the problem came back.

I did run the ChipWhisperer Setup Test.ipynb and it worked just fine.

I copied the Hardware code to the MAIN.
I didnt copy the creating a director but I did run it

I copied

SCOPETYPE = 'CWNANO'
PLATFORM = 'CWNANO'

Building the firmware
Then for connecitng to hardware I split it into three sections. it errors on section 2 or hangs on section 1. Like I said I reboot the VM and came back it hung the first time and then I reset the kernel and replugged the usb in and it work. Now it doesnt work at all. just fir SnG I restarted the kernel again and unplugged the USB and plugged it back in and it hangs on Section 1. I have 27 CWNANOs I can try others but I get the same for both of the two I have tried already.

section 1:

import chipwhisperer as cw
try:
    if not scope.connectStatus:
        scope.con()
except NameError:
    scope = cw.scope()

Section 2:

try:
    target = cw.target(scope)
except IOError:
    print("INFO: Caught exception on reconnecting to target - attempting to reconnect to scope first.")
    print("INFO: This is a work-around when USB has died without Python knowing. Ignore errors above this line.")
    scope = cw.scope()
    target = cw.target(scope)

print("INFO: Found ChipWhispereršŸ˜")

The error reads like the USB is hung: If it is do I need to reboot the VM between every retest? That would be painful

---------------------------------------------------------------------------
USBErrorNoDevice                          Traceback (most recent call last)
Input In [20], in <cell line: 1>()
      1 try:
----> 2     target = cw.target(scope)
      3 except IOError:
      4     print("INFO: Caught exception on reconnecting to target - attempting to reconnect to scope first.")

File ~/work/projects/chipwhisperer/software/chipwhisperer/__init__.py:365, in target(scope, target_type, **kwargs)
    350 """Create a target object and connect to it.
    351 
    352 Args:
   (...)
    362     Connected target object specified by target_type.
    363 """
    364 rtn = target_type()
--> 365 rtn.con(scope, **kwargs)
    367 # need to check
    368 if type(rtn) in (targets.SimpleSerial, targets.SimpleSerial2) \
    369     and scope and scope._getNAEUSB().check_feature("SERIAL_200_BUFFER"):

File ~/work/projects/chipwhisperer/software/chipwhisperer/capture/targets/_base.py:65, in TargetTemplate.con(self, scope, **kwargs)
     63 try:
     64     self.connectStatus = True
---> 65     self._con(scope, **kwargs)
     66 except:
     67     self.dis()

File ~/work/projects/chipwhisperer/software/chipwhisperer/capture/targets/SimpleSerial.py:184, in SimpleSerial._con(self, scope, **kwargs)
    181 def _con(self, scope = None, **kwargs):
    182     if not scope or not hasattr(scope, "qtadc"): Warning("You need a scope with OpenADC connected to use this Target")
--> 184     self.ser.con(scope)
    185     # 'x' flushes everything & sets system back to idle
    186     self.ser.write("xxxxxxxxxxxxxxxxxxxxxxxx")

File ~/work/projects/chipwhisperer/software/chipwhisperer/capture/targets/simpleserial_readers/cwlite.py:63, in SimpleSerial_ChipWhispererLite.con(self, scope)
     61     ser = scope._cwusb
     62     self.cwlite_usart = scope.usart
---> 63 self.cwlite_usart.init(baud=self._baud)

File ~/work/projects/chipwhisperer/software/chipwhisperer/hardware/naeusb/serial.py:102, in USART.init(self, baud, stopbits, parity)
     99 cmdbuf.append(parity)
    100 cmdbuf.append(8)  # Data bits
--> 102 self._usartTxCmd(self.USART_CMD_INIT, cmdbuf)
    103 self._usartTxCmd(self.USART_CMD_ENABLE)
    104 target_logger.info("Serial baud rate = {}".format(baud))

File ~/work/projects/chipwhisperer/software/chipwhisperer/hardware/naeusb/serial.py:220, in USART._usartTxCmd(self, cmd, data)
    215 """
    216 Send a command to the USART interface (internal function).
    217 """
    219 # windex selects interface
--> 220 self._usb.sendCtrl(self.CMD_USART0_CONFIG, (self._usart_num << 8) | cmd, data)

File ~/work/projects/chipwhisperer/software/chipwhisperer/hardware/naeusb/naeusb.py:728, in NAEUSB.sendCtrl(self, cmd, value, data)
    724 """
    725 Send data over control endpoint
    726 """
    727 # Vendor-specific, OUT, interface control transfer
--> 728 self.usbserializer.sendCtrl(cmd, value, data)

File ~/work/projects/chipwhisperer/software/chipwhisperer/hardware/naeusb/naeusb.py:473, in NAEUSB_Backend.sendCtrl(self, cmd, value, data)
    469 # Vendor-specific, OUT, interface control transfer
    470 naeusb_logger.debug("WRITE_CTRL: bmRequestType: {:02X}, \
    471             bRequest: {:02X}, wValue: {:04X}, wIndex: {:04X}, data: {}".format(0x41, cmd, \
    472                 value, 0, data))
--> 473 self.handle.controlWrite(0x41, cmd, value, 0, data, timeout=self._timeout)

File ~/.pyenv/versions/3.9.7/envs/cw/lib/python3.9/site-packages/libusb1-3.0.0-py3.9.egg/usb1/__init__.py:1330, in USBDeviceHandle.controlWrite(self, request_type, request, value, index, data, timeout)
   1328 # pylint: enable=undefined-variable
   1329 data, _ = create_initialised_buffer(data)
-> 1330 return self._controlTransfer(request_type, request, value, index, data,
   1331                              sizeof(data), timeout)

File ~/.pyenv/versions/3.9.7/envs/cw/lib/python3.9/site-packages/libusb1-3.0.0-py3.9.egg/usb1/__init__.py:1307, in USBDeviceHandle._controlTransfer(self, request_type, request, value, index, data, length, timeout)
   1301 def _controlTransfer(
   1302         self, request_type, request, value, index, data, length, timeout):
   1303     result = libusb1.libusb_control_transfer(
   1304         self.__handle, request_type, request, value, index, data, length,
   1305         timeout,
   1306     )
-> 1307     mayRaiseUSBError(result)
   1308     return result

File ~/.pyenv/versions/3.9.7/envs/cw/lib/python3.9/site-packages/libusb1-3.0.0-py3.9.egg/usb1/__init__.py:127, in mayRaiseUSBError(value, __raiseUSBError)
    121 def mayRaiseUSBError(
    122         value,
    123         # Avoid globals lookup on call to work during interpreter shutdown.
    124         __raiseUSBError=raiseUSBError,
    125     ):
    126     if value < 0:
--> 127         __raiseUSBError(value)
    128     return value

File ~/.pyenv/versions/3.9.7/envs/cw/lib/python3.9/site-packages/libusb1-3.0.0-py3.9.egg/usb1/__init__.py:119, in raiseUSBError(value, __STATUS_TO_EXCEPTION_DICT, __USBError)
    113 def raiseUSBError(
    114         value,
    115         # Avoid globals lookup on call to work during interpreter shutdown.
    116         __STATUS_TO_EXCEPTION_DICT=STATUS_TO_EXCEPTION_DICT,
    117         __USBError=USBError,
    118     ): # pylint: disable=dangerous-default-value
--> 119     raise __STATUS_TO_EXCEPTION_DICT.get(value, __USBError)(value)

USBErrorNoDevice: LIBUSB_ERROR_NO_DEVICE [-4]

section 3:

if "STM" in PLATFORM or PLATFORM == "CWLITEARM" or PLATFORM == "CWNANO":
    prog = cw.programmers.STM32FProgrammer
elif PLATFORM == "CW303" or PLATFORM == "CWLITEXMEGA":
    prog = cw.programmers.XMEGAProgrammer
else:
    prog = None
    
import time
time.sleep(0.05)
scope.default_setup()
def reset_target(scope):
    if PLATFORM == "CW303" or PLATFORM == "CWLITEXMEGA":
        scope.io.pdic = 'low'
        time.sleep(0.05)
        scope.io.pdic = 'high_z' #XMEGA doesn't like pdic driven high
        time.sleep(0.05)
    else:  
        scope.io.nrst = 'low'
        time.sleep(0.05)
        scope.io.nrst = 'high_z'
        time.sleep(0.05):

This is a couple minutes later:
image

Hi,

Sorry for the late reply here.

Can you try the following:

  1. Restart the VM
  2. Log into the VM (user/pass are both vagrant)
  3. Access jupyter from your web browser, then cause the error youā€™re describing to happen.
  4. From the command line, run the following: sudo dmesg > work/projects/chipwhisperer/jupyter/dmesg.txt.
  5. Access jupyter from your web browser (localhost:8888) and use that to download dmesg.txt
  6. Upload dmesg.txt.

Alex