newaetech / chipwhisperer

ChipWhisperer - the complete open-source toolchain for side-channel power analysis and glitching attacks
http://chipwhisperer.com
Other
1.09k stars 280 forks source link

Internal error trying to set reset pin to high/low #455

Closed Elec332 closed 1 year ago

Elec332 commented 1 year ago

Internal chipwhisperer error trying to setet a chip, error during setting the value of the reset pin.

`NameError Traceback (most recent call last) Cell In[32], line 12 ---> 12 reboot_flush()

Cell In[24], line 2, in reboot_flush() 1 def reboot_flush(): ----> 2 reset_target(scope) 3 target.flush()

File ~\AppData\Local\Temp\ipykernel_23540\18016138.py:14, in reset_target(scope) 12 raise IOError("Default iCE40 neorv32 build does not have external reset - reprogram device to reset") 13 elif PLATFORM == "CW308_SAM4S": ---> 14 scope.io.nrst = 'low' 15 time.sleep(0.25) 16 scope.io.nrst = 'high_z'

File c:\users\user\chipwhisperer5_64\cw\home\portable\chipwhisperer\software\chipwhisperer\common\utils\util.py:397, in DisableNewAttr.setattr(self, name, value) 396 def setattr(self, name, value): --> 397 if hasattr(self, '_new_attributes_disabled') and self._new_attributes_disabled and not hasattr(self, name): # would this create a new attribute? 398 #raise AttributeError("Attempt to set unknown attribute in %s"%self.class, name) 399 other_logger.error("Setting unknown attribute {} in {}".format(name, self.class)) 400 if hasattr(self, '_new_attributes_disabled_strict') and self._new_attributes_disabled_strict and not hasattr(self, name):

File c:\users\user\chipwhisperer5_64\cw\home\portable\chipwhisperer\software\chipwhisperer\capture\scopes\cwhardware\ChipWhispererExtra.py:536, in GPIOSettings.nrst(self) 531 @property 532 def nrst(self): 533 """The state of the NRST pin. 534 535 See pdic for more information.""" --> 536 return self._getGpio(100)

File c:\users\user\chipwhisperer5_64\cw\home\portable\chipwhisperer\software\chipwhisperer\capture\scopes\cwhardware\ChipWhispererExtra.py:544, in GPIOSettings._getGpio(self, pinnum) 542 def _getGpio(self, pinnum): 543 """GPIO state getter for GPIO settings on 1-4 and for special pins""" --> 544 state = self.cwe.getGPIOState(pinnum) 545 if state is None: 546 return "high_z"

File c:\users\user\chipwhisperer5_64\cw\home\portable\chipwhisperer\software\chipwhisperer\capture\scopes\cwhardware\ChipWhispererExtra.py:1381, in CWExtraSettings.getGPIOState(self, IONumber) 1380 def getGPIOState(self, IONumber): -> 1381 data = self.oa.sendMessage(CODE_READ, ADDR_IOROUTE, Validate=False, maxResp=8) 1383 #Catch special modes 1384 if IONumber >= 100:

File c:\users\user\chipwhisperer5_64\cw\home\portable\chipwhisperer\software\chipwhisperer\capture\scopes_OpenADCInterface.py:294, in OpenADCInterface.sendMessage(self, mode, address, payload, Validate, maxResp, readMask) 289 """Top level swiss-army knife method for sending a message. Kept for back-compat 290 291 TODO: Transition API calls to use simplified API and remove this function... 292 """ 293 if mode != CODE_WRITE: --> 294 return self.msg_read(address, maxResp) 295 self.msg_write(address, payload) 296 if Validate:

File c:\users\user\chipwhisperer5_64\cw\home\portable\chipwhisperer\software\chipwhisperer\capture\scopes_OpenADCInterface.py:223, in OpenADCInterface.msg_read(self, address, max_resp) 221 if self._serial_not_stream: 222 if self._fast_fifo_read_active and address != ADDR_ADCDATA: --> 223 scope_logger.warning("Internal error: in fast read mode but not reading FIFO! (address=%0d, datalen=%0d)." % (address, datalen)) 224 scope_logger.warning("This happens when attempting to access (read or write) some Husky FPGA setting after the") 225 scope_logger.warning("ADC sample FIFO read has been set up; in stream mode, this is done when scope.arm() is called.")

NameError: name 'datalen' is not defined`

(Once again code-blocks seem to hate me, sorry)

jpcrypt commented 1 year ago

The root of this is in the warning at the very end. In order to speed up reading captures as much as possible on Husky, we switch Husky and the SAM3U into a "fast read mode", which prevents doing pretty much anything other than reading the capture -- like toggling a reset pin. For a streaming capture, fast read mode is entered upon arming; for non-streaming, when scope.capture() is called.

You must have had a capture prior to this which didn't go or complete as it should have. You might be able to recover from the incomplete capture and reset communications to normal with scope.sc.setFastSMC(0). (in the case of streaming, you'll likely need to hard reboot Husky)

You can also disable fast read mode entirely by setting scope.sc._fast_fifo_read_enable = False.