Optimize CW305 Power Traces

Hello,

For several months now, I’ve been using the CW305 board with the ChiWhisperer-Lite to evaluate some power leakages on hardware designs. After a new reading of the documentation, I see new points that I am not sure I understand to optimize traces (Target API — ChipWhisperer 5.7.0 documentation):

  • It is mentioned that I have “to disable the USB clock during encryption to reduce noise”. Some commands are used:
target.clkusbautooff = True
target.clksleeptime = 1 # 1ms typically good for sleep

but I can’t find any documentation in the API on these commands. How are we supposed to use them exactly ? Is the USB clock necessary after programming the FPGA ? If yes, when ? If no, is there any way to stop it indefinitely (without using sleep) ?

  • It is also mentioned “Don’t forget to clock the ChipWhisperer ADC off the FPGA instead of the internal clock” with the following command:
scope.clock.adc_src = "extclk_x4"
scope.clock.reset_adc() # make sure the DCM is locked

Currently, I am using the PLL1 (25 MHz) for the FPGA and the “clkgen_x4” (which I assume to be 100MHz) for the ADC. What are the differences ?

Thanks in advance for your answers.

1 Like

From what i can see in the file cw305.py it’s a property of the CW305 class and it’s only used in the go function. Reported below.
I’m guessing that once you write your plaintext and key to the fpga, before of starting the power trace capture, is sufficient to call this go function and this should handle autonomously the disable and re-enable of the usb-clock. The clksleeptime should be set accordingly to your need.
I can’t test it right now, but I’ll test it later and keep you updated.

def go(self):
    """Disable USB clock (if requested), perform encryption, re-enable clock"""
    if (self.REG_USER_LED is None):
        target_logger.error("target.REG_USER_LED unset. Have you given target a verilog defines file?")
        return
    if self.clkusbautooff:
        self.usb_clk_setenabled(False)
    self.fpga_write(self.REG_USER_LED, [0x01])
    time.sleep(0.001)
    self.usb_trigger_toggle()
    # it's also possible to 'go' via register write but that won't take if
    # the USB clock was turned off:
    #self.fpga_write(self.REG_CRYPT_GO, [1])
    if self.clkusbautooff:
        time.sleep(self.clksleeptime/1000.0)
        self.usb_clk_setenabled(True)

I can confirm that replacing

    cw305.fpga_write(cw305.CW305.REG_USER_LED, [0x01])
    cw305.usb_trigger_toggle()

with

    cw305.go()

The capture setup still works