CW Lite Received fewer points than expected

Hi,

I’m using a ChipWhisperer Lite to capture power traces from the CW308T-STM32F3 target.
The target is running a Masked AES implementation.

However, I’ve noticed that whenever I set an offset value by changing scope.adc.offset, one of the following errors appears:

  • (ChipWhisperer Scope ERROR|File OpenADC.py:787) Received fewer points than expected
  • (ChipWhisperer Scope WARNING|File _OpenADCInterface.py:955) Trigger not found in ADC data. No data reported!

My scope settings are as follows:

 fw_version = 
      major = 0
      minor = 65
      debug = 0
gain = 
    mode = high
    gain = 30
    db   = 24.8359375
adc = 
    state          = False
    basic_mode     = rising_edge
    timeout        = 12
    offset         = 17000
    presamples     = 0
    samples        = 5000
    decimate       = 1
    trig_count     = 309844672
    fifo_fill_mode = normal
clock = 
    adc_src       = clkgen_x1
    adc_phase     = 0
    adc_freq      = 23140571
    adc_rate      = 23140571.0
    adc_locked    = True
    freq_ctr      = 0
    freq_ctr_src  = extclk
    clkgen_src    = system
    extclk_freq   = 10000000
    clkgen_mul    = 2
    clkgen_div    = 26
    clkgen_freq   = 7384615.384615385
    clkgen_locked = True
trigger = 
    triggers = tio4
    module   = basic
io = 
    tio1         = serial_rx
    tio2         = serial_tx
    tio3         = high_z
    tio4         = high_z
    pdid         = high_z
    pdic         = high_z
    nrst         = high_z
    glitch_hp    = False
    glitch_lp    = False
    extclk_src   = hs1
    hs2          = clkgen
    target_pwr   = True
    tio_states   = (1, 1, 0, 0)
    cdc_settings = bytearray(b'\x00\x00\x00\x00')
glitch = 
    clk_src     = target
    width       = 10.15625
    width_fine  = 0
    offset      = 10.15625
    offset_fine = 0
    trigger_src = manual
    arm_timing  = after_scope
    ext_offset  = 0
    repeat      = 1
    output      = clock_xor

My capturing code is as follows:

trace_array = []
plaintext_array = []

for i in trange(N, desc='Capturing traces'):
    _, text = ktp.next()
    scope.arm()

    target.simpleserial_write('p', text)

    ret = scope.capture()
    if ret:
        print("Target timed out!")
        continue

    response = target.simpleserial_read('r', 16)

    print("plaintext: {},  ciphertext:{}".format(binascii.hexlify(text), binascii.hexlify(response)))
    trace_array.append(scope.get_last_trace())
    plaintext_array.append(text)
    splot.update(scope.get_last_trace())

The program output showing the errors/warnings during capture is as below:

I’m not sure why this is happening. The encryption/decryption seems to be working fine. However, this issue makes it impossible to capture long traces.

Thanks in advance for replying!

Hi,

There might be something wrong in your setup code as you’re trying to clock the ADC and target at the same speed (~7.37MHz), but your ADC is running at a strange clock frequency. Can you post this code as well?

Also, can you verify that your trigger is working properly?

Alex

My setup code looks as follows:

PLATFORM="CW308_STM32F3"  # F071: CW308_STM32F0 , F303: CW308_STM32F3
SCOPETYPE = "OPENADC"
scope = cw.scope(cw.scopes.OpenADC)
target = cw.target(scope, cw.targets.SimpleSerial)

scope.default_setup()
while scope.clock.clkgen_locked == False:
    print(".", end='')


def reset_target(scope):  #source: https://rtfm.newae.com/tutorials/CWLITEARM/SOLN_Fault%202_3%20-%20Voltage%20Glitching%20to%20Memory%20Dump/
    scope.io.nrst = 'low'
    time.sleep(0.05)
    scope.io.nrst = 'high_z'
    time.sleep(0.05)


def reboot_flush():  
    reset_target(scope)
    #Flush garbage too
    target.flush()



cw.program_target(scope, cw.programmers.STM32FProgrammer, "program. Hex")


scope.clock.adc_src = "clkgen_x1"  
reboot_flush()

scope.adc.samples = 5000
scope.adc.offset = 17000
scope.adc.timeout = 12

And for verifying the trigger, do I have to use something like an oscilloscope?