ChipWhispere Lite Windows - Device not found?

share me the command which you are using to update,

also add this line in beginning

from serial import Serial

def get_at91_ports():
from serial.tools import list_ports

at91_ports = [port.device for port in list_ports.comports() if (port.vid, port.pid) == (0x03EB, 0x6124)]
return at91_ports

import chipwhisperer as cw
def program_sam_firmware(hardware_type=None):
at91_ports = get_at91_ports()
if len(at91_ports) == 0:
raise OSError(“Could not find bootloader serial port, please see Updating Firmware — ChipWhisperer 5.7.0 documentation”)
if len(at91_ports) > 1:
raise OSError(“Found multiple bootloaders, please specify com port. See Updating Firmware — ChipWhisperer 5.7.0 documentation”)

serial_port = at91_ports[0]
print("Found {}".format(serial_port))
prog = cw.SAMFWLoader(None)
prog.program(serial_port, hardware_type=hardware_type)

program_sam_firmware(“cwlite”)

There is definitely something from anaconda messing this up too…

def get_at91_ports():
    from serial.tools import list_ports

    at91_ports = [port.device for port in list_ports.comports() if (port.vid, port.pid) == (0x03EB, 0x6124)]
    return at91_ports

import chipwhisperer as cw
def program_sam_firmware(hardware_type=None):
    at91_ports = get_at91_ports()
    if len(at91_ports) == 0:
        raise OSError("Could not find bootloader serial port, please see https://chipwhisperer.readthedocs.io/en/latest/firmware.html")
    if len(at91_ports) > 1:
        raise OSError("Found multiple bootloaders, please specify com port. See https://chipwhisperer.readthedocs.io/en/latest/firmware.html")

    serial_port = at91_ports[0]
    print("Found {}".format(serial_port))
    prog = cw.SAMFWLoader(None)
    prog.program(serial_port, hardware_type=hardware_type)

program_sam_firmware("cwlite")

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_704/466076287.py in <module>
----> 1 from serial import Serial
      2 def get_at91_ports():
      3     from serial.tools import list_ports
      4 
      5     at91_ports = [port.device for port in list_ports.comports() if (port.vid, port.pid) == (0x03EB, 0x6124)]

ImportError: cannot import name 'Serial' from 'serial' (C:\Users\custard\anaconda3\lib\site-packages\serial\__init__.py)

are you using this in jupyter notebook?
if yes,
then just use this command

1.Shorting erase pins(jp2) on the CW. The blue/red LED pair turn quite dim
2.Reflashing the CW using

import chipwhisperer as cw
cw.program_sam_firmware(hardware_type='cwlite')

3.Going to Device Manager → Universal Serial Bus Devices → Chip Whisperer Lite → Uninstall Device
4.Upgrading CW firmware using

import chipwhisperer as cw
scope = cw.scope()
scope.upgrade_firmware()

1.Shorting erase pins(jp2) on the CW. The blue/red LED pair turn quite dim
2.Reflashing the CW using

import chipwhisperer as cw
cw.program_sam_firmware(hardware_type='cwlite')

Found COM12
Loading cwlite firmware…
Opened!
Connecting…

AttributeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_704/565863851.py in
1 import chipwhisperer as cw
----> 2 cw.program_sam_firmware(hardware_type=‘cwlite’)

~\anaconda3\lib\site-packages\chipwhisperer-5.6.1-py3.9.egg\chipwhisperer_init_.py in program_sam_firmware(serial_port, hardware_type, fw_path)
100 print(“Found {}”.format(serial_port))
101 prog = SAMFWLoader(None)
→ 102 prog.program(serial_port, hardware_type=hardware_type, fw_path=fw_path)
103
104 def program_target(scope : scopes.ScopeTypes, prog_type, fw_path : str, **kwargs):

~\anaconda3\lib\site-packages\chipwhisperer-5.6.1-py3.9.egg\chipwhisperer\capture\scopes\cwhardware\ChipWhispererSAM3Update.py in program(self, port, fw_path, hardware_type, bypass_warning)
264
265 self.logfunc(“Opened!\nConnecting…”)
→ 266 sam.con(port)
267 self.logfunc(“Connected!\nErasing…”)
268 sam.erase()

~\anaconda3\lib\site-packages\chipwhisperer-5.6.1-py3.9.egg\chipwhisperer\hardware\naeusb\bootloader_sam3u.py in con(self, port, usbmode)
42
43 def con(self, port, usbmode=True):
—> 44 ser = serial.Serial(
45 port=port,
46 baudrate=921600, # 115200

AttributeError: module ‘serial’ has no attribute ‘Serial’

This error output line from my previous message seems to hold the key to the issue.

ImportError: cannot import name ‘Serial’ from ‘serial’ (C:\Users\custard\anaconda3\lib\site-packages\serial_init_.py)

it’s something about the python installation me thinks.

i think anaconda making trouble,
if you are able to launch jupyter from chipwhisperer then remove anaconda and try it again. install jypyter manually if need

before this try this command

import chipwhisperer as cw
from serial import Serial
cw.program_sam_firmware(hardware_type='cwlite')

ImportError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_704/2101803368.py in
1 import chipwhisperer as cw
----> 2 from serial import Serial
3 cw.program_sam_firmware(hardware_type=‘cwlite’)

ImportError: cannot import name ‘Serial’ from ‘serial’ (C:\Users\custard\anaconda3\lib\site-packages\serial_init_.py)

Not super familiar with Anaconda, but try running the following in a CMD window that has access to the python you’re using. You can check where the python is via python -c 'import sys; print(sys.executable)':

python -m pip uninstall pyserial
python -m pip uninstall serial
python -m pip install pyserial

Alex

C:\Users\custard\ChipWhisperer5_64\cw\home\portable\WPy64-3771\python-3.7.7.amd64>python -m pip uninstall pyserial
WARNING: Skipping pyserial as it is not installed.

C:\Users\custard\ChipWhisperer5_64\cw\home\portable\WPy64-3771\python-3.7.7.amd64>python -m pip uninstall serial
WARNING: Skipping serial as it is not installed.

C:\Users\custard\ChipWhisperer5_64\cw\home\portable\WPy64-3771\python-3.7.7.amd64>python -m pip uninstall serial
WARNING: Skipping serial as it is not installed.

C:\Users\custard\ChipWhisperer5_64\cw\home\portable\WPy64-3771\python-3.7.7.amd64>python -m pip install pyserial
Collecting pyserial
Using cached pyserial-3.5-py2.py3-none-any.whl (90 kB)
ERROR: chipwhisperer 5.5.2 requires configobj, which is not installed.
ERROR: chipwhisperer 5.5.2 requires ECpy, which is not installed.
ERROR: chipwhisperer 5.5.2 requires fastdtw, which is not installed.
ERROR: chipwhisperer 5.5.2 requires pyusb, which is not installed.
Installing collected packages: pyserial
WARNING: The scripts pyserial-miniterm.exe and pyserial-ports.exe are installed in ‘C:\Users\custard\ChipWhisperer5_64\cw\home\portable\WPy64-3771\python-3.7.7.amd64\Scripts’ which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pyserial-3.5
WARNING: You are using pip version 20.1; however, version 22.0.4 is available.
You should consider upgrading via the ‘C:\Users\custard\ChipWhisperer5_64\cw\home\portable\WPy64-3771\python-3.7.7.amd64\python.exe -m pip install --upgrade pip’ command.

C:\Users\custard\ChipWhisperer5_64\cw\home\portable\WPy64-3771\python-3.7.7.amd64>

So I followed the direction:

WARNING: The scripts pyserial-miniterm.exe and pyserial-ports.exe are installed in ‘C:\Users\custard\ChipWhisperer5_64\cw\home\portable\WPy64-3771\python-3.7.7.amd64\Scripts’ which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

It looks like you’re using the Python install that comes with the CW installer. Do you want to use that one, or continue with the Anaconda install?

If you want to use the CW python, try grabbing the packages it says you’re missing:

python -m pip install configobj
python -m pip install ECpy
python -m pip install fastdtw
python -m pip install pyusb

I’d recommend starting Jupyter via C:\Users\custard\ChipWhisperer5_64\ChipWhisperer

Alex

Hi Alex,
I would really like to install Anaconda again, and use that python and jupyter install. I don’t have a clear understanding of whether that is possible, and if it is, I am not sure why it didn’t “just work” when I installed CW5.5.2 on my system (Anaconda was already installed).

Currently, Anaconda is not installed because I removed the anaconda installation to help try and resolve the issue with CW picking up that python as it was in the %PATH I guess.
This appears to be the cause of all my initial issues, looking back to the 3rd post in this discussion.

If you think it can work with Anaconda installed first, I’m very happy to start over with that and follow your directions.

cheers,
Paul

Hi Paul,

We should be able to get CW working via Anaconda, though it seems to be a bit finicky. Normally we just recommend the installer since installing Python, getting the compilers, figuring out path stuff, etc can be a bit rough on Windows. If you don’t have it yet, you’ll want to grab git bash: Git - Downloads. All the defaults should work here, with the exception Enable experimental support for pseudo consoles (on the last install page), which you’ll want to have checked.

Once you’ve got that installed, install Anaconda. Make sure you install for all users and check the option to add it to your system path, as not doing this seems to break some of the packages that come with Anaconda when we run Python through Git Bash. Open a Git Bash terminal and verify that python you’ve got access to is the one from Anaconda: python -c "import sys; print(sys.executable)". You’ll need to restart Git bash to have the new path apply.

Next, add the following paths from the ChipWhisperer install to your System variables Path:

  • \path\to\ChipWhisperer5_64\cw\home\portable\armgcc\gcc-arm-none-eabi-10-2020-q4-major\bin
  • \path\to\ChipWhisperer5_64\cw\home\portable\avrgcc\avr-gcc-10.1.0-x64-windows\bin

Next, in Git Bash, verify that you have access to compilers by running the following:: make --version, arm-none-eabi-gcc --version, and arm-gcc --version.

Navigate to \path\to\ChipWhisperer5_64\cw\home\portable\chipwhisperer and run the following commands to update and install ChipWhisperer:

git config --global --add safe.directory $(pwd)
git config --global --add safe.directory $(pwd)/jupyter
git fetch --all
git reset HEAD --hard
git submodule update --init jupyter
python setup.py develop --user
python -m pip install -r jupyter/requirements.txt --user

Once this is done, you should be able to run python -m jupyter notebook and have Jupyter open. The steps above also updated ChipWhisperer for you, so if you need to reflash your device, you should have access to cw.program_sam_firmware(). Your original issue with this part is because this function isn’t available on CW 5.5.2 (I’ve updated Updating Firmware — ChipWhisperer 5.6.1 documentation to make this more clear).

Let me know if you run into any issues with these steps.

Alex

Hi Alex,
Thank you for that detailed reply. I am ready to give that a try after work. However, given you also found that using the Anaconda install is finicky, I would be perfectly happy using CW with the resources/binaries which it ships with, so long as I can still have Anaconda installed on my system for other development.
I had initially presumed this was the intended use case, but as per my previous messages, the Chipwhisperer shortcut failed to launch anything, and the captured error mentions anaconda install stealing the focus. If this could be fixed more easily/reliably, then I am totally on board for that.

cheers,
Paul

Hi Paul,

Yeah, ChipWhisperer should be separate from other Python instances on your machine.

Just to check, have you tried running the ChipWhisperer shortcut that is in the actual install directory for ChipWhisperer? That one should definitely work on 5.5.2. If it doesn’t, can you try going to ChipWhisperer5_64\cw and running mintty.bat? From there, run jupyter notebook and let me know if you get any errors.

Alex

Hello Alex, sorry it’s been a few days since I could give this more time. I followed the exact steps in your last msg. Before I did anything though, I completely removed anaconda install from my PC and also the CW install. I totally removed the folders these were in. Then I installed Chipwhisperer.v5.5.2.Setup.64-bit.exe (from github). Then I tried the CW shortcut on the desktop, which didn’t start anything. The brief message that flashed up said

C:\Users\xxx\CHIPW~1\cw\home\portable\WPy64-3771\python-3.7.7.7.amd64\python.exe: No module named jupyter.main; ‘jupyter’ is a package and cannot be directly executed

So I then installed anaconda and tried again. Same result. So then I pressed on with your instructions. The Shortcut in the install folder gave the same result. Then I ran the mintty.bat (using a windows command shell) which opened a linux sort of shell. I ran “jupyter notebook” and got the following result. See attached image.

Please let me know what I can try next, I am out of ideas.
Cheers,
Paul

Hi Paul,

When you ran through the installer, you should’ve seen a small bash window pop up. Did you let that run to completion? Unfortunately, that version of the installer runs that part asynchronously to the rest of the installer, so it’s possible to close the installer before it’s fully finished.

Anyway, can you try navigating to cw/home/portable/chipwhisperer and running python -m pip install -r jupyter/requirements.txt? Once that’s done, try running jupyter notebook again. If it still doesn’t work, try python -m jupyter notebook.

Alex