Problems with Programming Firmware

hello together,

i have the following problem.
when i run the code

SCOPETYPE = ‘OPENADC’
PLATFORM = ‘CWLITEXMEGA’
import chipwhisperer as cw
scope = cw.scope()
scope.default_setup()
prog = cw.programmers.XMEGAProgrammer
cw.program_target(scope, prog , “chipwhisperer/hardware/victims/firmware/basic-passwdcheck/basic-passwdcheck-{}.hex”.format(PLATFORM))

i get the following error code


OSError Traceback (most recent call last)
in
1 scope.default_setup()
2 prog = cw.programmers.XMEGAProgrammer
----> 3 cw.program_target(scope, prog , “chipwhisperer/hardware/victims/firmware/basic-passwdcheck/basic-passwdcheck-{}.hex”.format(PLATFORM))

~/Videos/chipwhisperer/software/chipwhisperer/init.py in program_target(scope, prog_type, fw_path, **kwargs)
60 prog._logging = None
61 prog.open()
—> 62 prog.find()
63 prog.erase()
64 prog.program(fw_path, memtype=“flash”, verify=True)

~/Videos/chipwhisperer/software/chipwhisperer/capture/api/programmers.py in func_wrapper(self, *args, **kwargs)
68 self.scope.io.nrst = ‘high_z’
69 try:
—> 70 val = func(self, *args, **kwargs)
71 finally:
72 logging.debug(‘Restoring pdic, pdid, and nrst pin configuration’)

~/Videos/chipwhisperer/software/chipwhisperer/capture/api/programmers.py in find(self, xmega)
223 def find(self, xmega=None):
224 xmega = self.xmegaprog()
–> 225 sig, chip = xmega.find()
226
227 # Print signature of unknown device

~/Videos/chipwhisperer/software/chipwhisperer/hardware/naeusb/programmer_xmega.py in find(self)
173 def find(self):
174 self.setParamTimeout(100)
–> 175 self.enablePDI(True)
176
177 # Read signature bytes

~/Videos/chipwhisperer/software/chipwhisperer/hardware/naeusb/programmer_xmega.py in enablePDI(self, status)
307 if status:
308 # self._xmegaDoWrite(self.XPROG_CMD_LEAVE_PROGMODE)
–> 309 self._xmegaDoWrite(self.XPROG_CMD_ENTER_PROGMODE)
310 self._pdienabled = True
311 else:

~/Videos/chipwhisperer/software/chipwhisperer/hardware/naeusb/programmer_xmega.py in _xmegaDoWrite(self, cmd, data, checkStatus)
502 status = self._xmegaDoRead(cmd=0x0020, dlen=3)
503 if status[1] != 0x00:
–> 504 raise IOError(“XMEGA Command %x failed: err=%x, timeout=%d” % (status[0], status[1], status[2]))
505
506 def _xmegaDoRead(self, cmd, dlen=1):

OSError: XMEGA Command 20 failed: err=1, timeout=1

can anybody help me? i don’t understand what is wrong.

ben

Hi Ben,

What ChipWhisperer target are you using (Lite Arm, Lite XMEGA, CW308 board, etc)?

Alex

Hi Alex,

i use Lite XMEGA

Ben

Hi Ben,

I’ve seen the shunt resistor cause issues with programming on some XMEGA boards. Can you try shorting the shunt resistor while trying to program the target? You should be able to do this by using a wire to connect JP6 or JP7 (either side on either will do) near measure/glitch to one of the pins labeled 3.3V on the other side of the target board.

Alex

image0

is this connection right?

Hi Ben,

I’m trying to do the course [Lab 2_1A - Instruction Power Differences (HARDWARE).ipynb] on the chipwhisperer lite with an XMEGA target but facing the same problem with the same error messages like the following:

cw.program_target(scope, prog, “…/…/…/hardware/victims/firmware/simpleserial-base-lab2/simpleserial-base-{}.hex”.format(PLATFORM))


OSError Traceback (most recent call last)
/tmp/ipykernel_81098/2297037091.py in
----> 1 cw.program_target(scope, prog, “…/…/…/hardware/victims/firmware/simpleserial-base-lab2/simpleserial-base-{}.hex”.format(PLATFORM))

~/chipwhisperer/software/chipwhisperer/init.py in program_target(scope, prog_type, fw_path, **kwargs)
111 prog._logging = None
112 prog.open()
–> 113 prog.find()
114 prog.erase()
115 prog.program(fw_path, memtype=“flash”, verify=True)

~/chipwhisperer/software/chipwhisperer/capture/api/programmers.py in func_wrapper(self, *args, **kwargs)
69 self.scope.io.nrst = ‘high_z’
70 try:
—> 71 val = func(self, *args, **kwargs)
72 finally:
73 target_logger.debug(‘Restoring pdic, pdid, and nrst pin configuration’)

~/chipwhisperer/software/chipwhisperer/capture/api/programmers.py in find(self, xmega)
224 def find(self, xmega=None):
225 xmega = self.xmegaprog()
–> 226 sig, chip = xmega.find()
227
228 # Print signature of unknown device

~/chipwhisperer/software/chipwhisperer/hardware/naeusb/programmer_xmega.py in find(self)
183 def find(self):
184 self.setParamTimeout(100)
–> 185 self.enablePDI(True)
186
187 # Read signature bytes

~/chipwhisperer/software/chipwhisperer/hardware/naeusb/programmer_xmega.py in enablePDI(self, status)
319 if status:
320 # self._xmegaDoWrite(self.XPROG_CMD_LEAVE_PROGMODE)
–> 321 self._xmegaDoWrite(self.XPROG_CMD_ENTER_PROGMODE)
322 self._pdienabled = True
323 else:

~/chipwhisperer/software/chipwhisperer/hardware/naeusb/programmer_xmega.py in _xmegaDoWrite(self, cmd, data, checkStatus)
518 status = self._xmegaDoRead(cmd=0x0020, dlen=3)
519 if status[1] != 0x00:
–> 520 raise IOError(“XMEGA Command %x failed: err=%x, timeout=%d” % (status[0], status[1], status[2]))
521
522 def _xmegaDoRead(self, cmd, dlen=1):

OSError: XMEGA Command 20 failed: err=1, timeout=1

After seeing this post, I followed Alex’s suggestions shorting the shunt resistor. But it didn’t work. I still got the same error messages.

If you’ve solved this problem, could you share your solution?

Best regard,

Michael

Hi Michael,

What’s your PC setup like (OS, are you running in a VM, etc.). Additionally, what ChipWhisperer version are you on and what firmware version are you on (cw.__version__ and scope.fw_version)?

I believe we just swapped hardware for Ben, but I believe we’ve seen some issues on devices with a newer FPGA bitstream. Can you try replacing chipwhisperer/software/chipwhisperer/hardware/firmware/cwlite.py with https://raw.githubusercontent.com/newaetech/chipwhisperer/2bbff8ca68bf1b1f8d0a2ae24f3da27980b48efc/software/chipwhisperer/hardware/firmware/cwlite.py?

Alex

Hi Alex,

Thanks for your prompt reply!

I ran the chipwhisperer lite with XMEGA target on macOS Big Sur 11.6 PC.
The cw.__version__ and scope.fw_version are like the following:

I’ve tried your suggestion to replace the cwlite.py file.
But it didn’t work and I got the same error messages which are similar to those in my last reply.

I’ve also tried on Parallels Desktop’s Windows 10 Virtual Machine running on the same macOS Big Sur 11.6 PC.
But I still got the same error messages.

Is there any other firmware file I should replace with the old version one like cwlite.py?

Best regard,

Michael

Hi Michael,

Forgot to mention it, but after replacing cwlite.py you should reset the Jupyter notebook (to make sure the new cwlite.py) gets loaded, as well as unplug + replug the ChipWhisperer (so that the FPGA gets reprogrammed). If you did both of these, feel free to disregard.

I’ll take a look at the XMega programming code on the Lite and see if there’s any parameters I can tweak.

Alex

Hi Alex,

My problem was solved when I tried to use another whole new hardware.
It seems that some parts of the original hardware setting had broken.
I’m still trying to find out the broken parts.
Thanks for your help!

Michael

Hi Michael,

Sorry to hear you had trouble with the hardware. If you contact support@newae.com, we should be able to swap hardware.

Out of curiosity, is both the new and old hardware an XMega target?

Alex