Program_sam_firmware fails for CW nano

Hello,
I was following the tutorials for sca101, and everything was working perfectly with CW nano and I followed the password bypass tutorial and it was working as expected and I can guess the password.
Later, I couldn’t repeat what I did again and when running scope.capture() I always get the following error
(ChipWhisperer Scope WARNING|File cwnano.py:706) Timeout in cwnano capture()

On the forum it was mentioned if I reproram the firmware, it can fix this issue.
I used the following code to reprogram my cwnano, however I get timeout somewhere once it connect and attempt the upgrade.

Any help would be appreciated.

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) == (0x2b3e, 0xace0)]
    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("cwnano")

Error trace:

Found /dev/ttyACM0
Loading cwnano firmware…
Opened!
Connecting…
Traceback (most recent call last):
File “/home/sakr/study/ChipWhisper/reset.py”, line 20, in
program_sam_firmware(“cwnano”)
File “/home/sakr/study/ChipWhisper/reset.py”, line 18, in program_sam_firmware
prog.program(serial_port, hardware_type=hardware_type)
File “/home/sakr/tools/chipwhisperer/software/chipwhisperer/capture/scopes/cwhardware/ChipWhispererSAM3Update.py”, line 273, in program
sam.con(port)
File “/home/sakr/tools/chipwhisperer/software/chipwhisperer/hardware/naeusb/bootloader_sam3u.py”, line 250, in con
cid = self.chip_id()
File “/home/sakr/tools/chipwhisperer/software/chipwhisperer/hardware/naeusb/bootloader_sam3u.py”, line 316, in chip_id
cid = self.read_word(0x400e0740)
File “/home/sakr/tools/chipwhisperer/software/chipwhisperer/hardware/naeusb/bootloader_sam3u.py”, line 333, in read_word
raise IOError(“timeout”)
OSError: timeout

That likely wasn’t required. What was the state of the LEDs? What is it now?
Current Instructions for firmware issues are here; relying on old forum posts risks leading you astray.

the led is always like this, when I program the basic-passwdcheck, I don’t remember what was the state when it was working fine

what is usually the problem when it says timeout with capture.
(ChipWhisperer Scope WARNING|File cwnano.py:706) Timeout in cwnano capture()

Those target-side LEDs are driven by the firmware.
The green LED next to the USB connector should be blinking (at about once per second).
A capture timeout is usually caused by a communication issue between the capture side and target side. Typical causes are:

  • target FW isn’t programmed (doesn’t appear to be the case here), or the wrong FW is programmed (could be the case here, if you’ve been doing different labs and not re-programming the target when you change labs?)
  • there is a mismatch between the SimpleSerial protocol used by the target / capture sides: when you compile the firmware, there will be a line that says “SS_VER set to SS_VER_1_1” (or SS_VER_2_1); run print(target.baud), check that it’s 38400 if SS_VER_1_1, 230400 otherwise
  • you’ve changed the target clock rate and this is messing up the UART communication link

What I would do is:

  • restart your notebook
  • if you’re able to connect (scope = cw.scope()), then don’t worry about re-programming the Nano firmware (otherwise, follow the instructions here)
  • make sure that recompiling and programming the target firmware runs cleanly
  • if you still get the capture timeout, abandon your changes to the notebook (git checkout) and try again
1 Like