SAM4S Issues with capture

Hello all,
I was running the 1 - Connecting to Hardware.ipynb notebook, (CHUSKY and SAM4S) with the 313 board

In the notebook at the Capturing Traces step I get :

(ChipWhisperer Scope WARNING|File _OpenADCInterface.py:732) Timeout in OpenADC capture(), no trigger seen! Trigger forced, data is invalid. Status: 13
(ChipWhisperer Scope WARNING|File _OpenADCInterface.py:732) Timeout in OpenADC capture(), no trigger seen! Trigger forced, data is invalid. Status: 12

print(cw._version_) –> 6.0.0

scope.gain.gain changed from 0 to 22
scope.gain.db changed from 15.0 to 25.091743119266056
scope.adc.samples changed from 131124 to 5000
scope.clock.clkgen_freq changed from 0 to 7363636.363636363
scope.clock.adc_freq changed from 0 to 29454545.454545453
scope.clock.adc_rate changed from 0.0 to 29454545.454545453
scope.io.tio1 changed from serial_tx to serial_rx
scope.io.tio2 changed from serial_rx to serial_tx
scope.io.hs2 changed from None to clkgen
scope.glitch.phase_shift_steps changed from 0 to 4592
scope.trace.capture.trigger_source changed from trace trigger, rule #0 to firmware trigger

I then created an isolated python script to reproduce the error:
import chipwhisperer as cw

import time

scope = cw.scope()

scope.default_setup()

target = cw.target(scope, cw.targets.SimpleSerial)

print(“-----------------”)

print(cw._version_)

print(“-----------------”)

# manual reset target

scope.io.nrst = ‘low’

time.sleep(0.05)

scope.io.nrst = ‘high_z’

time.sleep(0.05)

data = bytearray([0]*16)

target.flush()

scope.arm()

target.simpleserial_write(‘p’, data)

print(“-----------------”)

ret = scope.capture()

if ret:

print(“Warning: trigger not seen!”)

else:

print(“Trigger captured successfully!”)

print(“-----------------”)

# Read UART response

resp = target.simpleserial_read(‘r’, 16, timeout=500)

print(“UART Response:”, resp)

print(“-----------------”)

target.dis()

scope.dis()

which has the same behavior as the notebook with the
(ChipWhisperer Scope WARNING|File _OpenADCInterface.py:732) Timeout in OpenADC capture(), no trigger seen! Trigger forced, data is invalid. Status: 13
(ChipWhisperer Scope WARNING|File _OpenADCInterface.py:732) Timeout in OpenADC capture(), no trigger seen! Trigger forced, data is invalid. Status: 12
errors.

The simpleserial-base was compiled with:make PLATFORM=CWHUSKY CRYPTO_TARGET=NONE SS_VER=SS_VER_1_1

Verifying the GPIO4 with an oscilloscope, i only see a sinusoidal like signal at
probe point JP2–>CW-GPIO4.

Hypothesis is that the target the SAM4S is not setting the trigger_high() …

Any ideas what i am doing wrong ?

Thanks

when i do this:
trigger_high();
volatile int k = 0;
for (int i = 0; i < (1 << 22); i++)
{
k++;
}
trigger_low();

GPIO4 jumps between 140mV and 1 V

Measured with oscilloscope across all GPIO4 PINs
but i still get the
(ChipWhisperer Scope WARNING|File _OpenADCInterface.py:732) Timeout in OpenADC capture(), no trigger seen! Trigger forced, data is invalid. Status: 13
(ChipWhisperer Scope WARNING|File _OpenADCInterface.py:732) Timeout in OpenADC capture(), no trigger seen! Trigger forced, data is invalid. Status: 12

message

Python that exercises the CW:
… prelude + setup code …

scope.arm()

target.simpleserial_write(‘p’, data)

print(“-----------------”)

Capture trace

ret = scope.capture(True)

if ret:

print(“Warning: trigger not seen!”)

else:

print(“Trigger captured successfully!”)

print(“-----------------”)

Read UART response

resp = target.simpleserial_read(‘r’, 16, timeout=10000)

print(“UART Response:”, resp)

print(“-----------------”)

target.dis()

scope.dis()

setting adc timeout to 10s with scope.adc._set_timeout(10)
does not help either :frowning:

  1. Can you share a screenshot of the GPIO4 line toggling?
  2. Try with the SMA cables disconnected - is it any different?

Hi JP,
thanks for the reply.

my toggle code is as follows:
while (1)
{
trigger_high();
for (int i = 0; i < (1 << 21); i++)
{
k++;
}
k = 0;
trigger_low();
for (int i = 0; i < (1 << 21); i++)
{
k++;
}
}

2nd Q:) w/o SMA no difference in behavior

with the default trigger_high() trigger_low() in simpleserial-base

Not sure what’s exactly causing your issue, but I recommend looking at the following:

  1. 0.05 seconds is way too short for a reset pulse. Try something like 0.25 or 0.5 seconds.
  2. Your loops aren’t using volatile variables, so they’re probably being entirely removed
  3. Because there’s nothing between the trigger_high/low calls, your device is probably trying to very rapidly toggle its IO pin, which might be causing issues.

Alex

Hi Alex,
thanks for the reply.
1.) adjusted to even 1s → does not make a difference
2.) i did it with volotile ( earlier post showed this) , but i tried again with sth like this:
volatile int k = 0;
while (1)
{
trigger_high();
for (int i = 0; i < (1 << 21); i++)
{
k++;
}
k=0;
trigger_low();
for (int i = 0; i < (1 << 21); i++)
{
k++;
}
}
→ which is abt 2.2s
→ no difference
3.) see above code
attached scope:

Can you post the output of print(scope)? It looks like your TIO4 pin is toggling, but the voltage is too low.

Sure here it is :

cwhusky Device
sn = HEXNUMBER
fpga_buildtime = XX/YY/2024, XX:XX
fw_version =
major = 1
minor = 5
debug = 0
gain =
mode = high
gain = 22
db = 25.091743119266056
adc =
state = False
basic_mode = rising_edge
timeout = 2
offset = 0
presamples = 0
samples = 5000
decimate = 1
trig_count = 0
stream_mode = False
test_mode = False
bits_per_sample = 12
segments = 1
segment_cycles = 0
segment_cycle_counter_en = False
clip_errors_disabled = False
lo_gain_errors_disabled = False
errors = False
clock =
clkgen_src = system
clkgen_freq = 7363636.363636363
adc_mul = 4
adc_freq = 29454545.454545453
adc_rate = 29454545.454545453
freq_ctr = 0
freq_ctr_src = extclk
clkgen_locked = True
adc_phase = 0.0
extclk_monitor_enabled = False
extclk_error = False
extclk_tolerance = 1144409.1796875
trigger =
sequencer_enabled = False
module = basic
triggers = tio4
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 = [0, 0, 0, 0]
aux_io_mcx = high_z
glitch_trig_mcx = trigger
glitch =
enabled = False
num_glitches = 1
clk_src = target
mmcm_locked = False
width = 0
offset = 0
trigger_src = manual
arm_timing = after_scope
ext_offset = 0
repeat = 1
output = clock_xor
phase_shift_steps = 4592
SAD =
threshold = 0
interval_threshold = 1
trigger_sample = 256
sad_reference_length = 256
emode = False
multiple_triggers = False
num_triggers_seen = 0
always_armed = False
ADS4128 =
mode = normal
low_speed = True
hi_perf = 2
LA =
present = True
enabled = False
clkgen_enabled = False
locked = False
clk_source = pll
trigger_source = glitch
oversampling_factor = 1
sampling_clock_frequency = 0.0
downsample = 1
capture_group = glitch
capture_depth = 0
trace =
present = True
enabled = False
errors = False
trace_synced = False
trace_mode = parallel
trace_width = 4
clock =
fe_clock_alive = True
fe_clock_src = usb_clock
clkgen_enabled = False
fe_freq = 96000000.0
swo_clock_locked = False
swo_clock_freq = 0.0
capture =
trigger_source = firmware trigger
use_husky_arm = False
raw = True
rules_enabled =
rules =
mode = while_trig
count = 0
max_triggers = 1
triggers_generated = 0
record_syncs = False
matched_pattern_data = 0000000000000000
matched_pattern_counts = [0, 0, 0, 0, 0, 0, 0, 0]
XADC =
status = good
temp = 40.6 [C]
max_temp = 42.1 [C]
temp_trigger = 80.0 [C]
temp_reset = 59.9 [C]
ot_temp_trigger = 84.9 [C]
ot_temp_reset = 59.9 [C]
vccint = 1.000 [V]
vccaux = 1.792 [V]
vccbram = 0.995 [V]
userio =
mode = normal
direction = 0
drive_data = 0
status = 511
Individual pins =
pin D0 = Target-driven, value = 1
pin D1 = Target-driven, value = 1
pin D2 = Target-driven, value = 1
pin D3 = Target-driven, value = 1
pin D4 = Target-driven, value = 1
pin D5 = Target-driven, value = 1
pin D6 = Target-driven, value = 1
pin D7 = Target-driven, value = 1
pin CK = Target-driven, value = 1
LEDs =
setting = 0 (default, as labelled)
errors =
sam_errors = False
sam_led_setting = Default
XADC errors = False
ADC errors = False
extclk error = False
trace errors = False

Just to make sure your not shorting the IO pin, can you remove your oscilloscope probe from that header pin and put it on the orange GPIO4 instead?

done, same behavior
Low voltage - but toggle
Attached photo: between pin 3 and 4 of the J1 connection I only get 1.2V flat
not the full 3.3V that should be there (?)


Note to self: Nope 3.3 should not be ther as these PINs are the B -Row of “PCIE-064-02-X-D-RA”

1.2V is the proper voltage for the core voltage. The IO voltage should be at 3.3V. I’m wondering if there’s a partial short somewhere on the GPIO4 path. Can you try the following measurements:

  1. Disconnect the Husky from the CW313. Set scope.io.tio4 = 1. Measure the voltage on pin 16 of the 20-pin connector
  2. Disconnect the SAM4S from the CW313. Connect the Husky to the CW313. Set scope.io.tio4 = 1. Measure the voltage on the orange GPIO4 test point
  3. Set scope.io.tio4 = None and set scope.io.nrst = 0. Connect the SAM4S back to the CW313. Set scope.io.tio4 = 1. Measure the GPIO4 test point again. Set scope.io.tio4 = None.

Also just to confirm, do you still have the setup code from our normal firmware in that file?

Q1)
Disconnect the Husky from the CW313. Set scope.io.tio4 = 1. Measure the voltage on pin 16 of the 20-pin connector
scope.io.tio4 ->1 : → 0 (PIN16)

Out of curiosity i measured other PINs too:
scope.io.tio3 ->1 : → 0
scope.io.tio2 ->1 : → jumps to 5V then goes to 3.3V
scope.io.tio1 ->1 : → jumps to 5V then goes to 3.3V

Q2) scope.io.tio4 ->1 : -->0
Q3) stays the same voltage as Q1, Q2, not even jumping…

Q4) yes, it is the trigger_high(), trigger_low() w/o anything in between

some more digging:
appears pins 14 and 16 are shorted to GND (at least continuity and Ohm measurement show this apprrx 5MOhm vs 0 Ohm)

You definitely need the setup code (trigger_setup()) for the IO pins to function properly, so as I start I recommend adding both that and platform_setup() to your code and running it. It could be possible there’s something wrong with the FPGA on your Husky, though it’s very weird for the IO to fail like that. Is this your first time using the Husky?

Seeing the results from the tests u suggested earlier, I would conclude that the Husky is not driving the tio4 pin, or am i missing sth here ?

Yep this specific device is first time use, but I have used other Huskies w/o any issues whatsoever


SAM4S FW:

#include “hal.h”
#include <stdint.h>
#include <stdlib.h>
#include <time.h>

#include “simpleserial.h”

uint8_t get_pt(uint8_t *pt, uint8_t len)
{
volatile int k = 0;
while (1)
{
trigger_high();
for (int i = 0; i < (1 << 12); i++)
{
k++;
}
k=0;
trigger_low();
for (int i = 0; i < (1 << 12); i++)
{
k++;
}
}
simpleserial_put(‘r’, 16, pt);
return 0x00;
}

int main(void)
{
platform_init();
init_uart();
trigger_setup();
simpleserial_init();
simpleserial_addcmd(‘p’, 16, get_pt);
while (1)
simpleserial_get();
}

I’m guessing at this point that there’s some sort of short on the GPIO3/4 pins of your Husky, as it seems like not even the Husky can drive the line high. If you swap your Husky out for a different one, do things work properly?

I do not have any of the other Huskies handy, I can see if I find a CWLite …
In the meantime, I will set it to trigger on tio1, or tio2 - of course adjust SAM4S FW accordingly and see how that goes. PIO_PA7_IDX is tio4, can i assume PIO_PA4_IDX would map to tio1 or better phrased were can i find the mapping from the SMA4S pins to the Husky ?

Will keep u posted