I am using chipwhisperer nano and I have hard time understanding few things about the samples capturing.
In the simple-serial example the code looks like this:
When I capture a trace the length of the wave equals to scope.adc.samples property regardless of the execution time of some_function.
I would expect the length of the wave to be running_time*sampling_rate.
How can I achieve this behavior in CWNANO?
I want to capture only the samples between trigger_high and trigger_low
The number of samples captured is uniquely by
scope.adc.samples; the capture is started by the capture trigger (via
trigger_high()) and finishes after
scope.adc.samples, regardless of when
trigger_low() is reached.
With other ChipWhisperers (Lite and up), you can look at
scope.adc.trig_count to learn how many cycles the trigger was high for, but that capability doesn’t exist in the Nano. You’ll have to use an oscilloscope or logic analyzer to measure it.
Is there a way to get the sampling rate of the scope with python?
Is there a way to calculate the running time or number of cycles of a function from within the c code?
Is it possible to achieve both? this way I can know how many samples in the wave are related to the function
Unfortunately no; this is just one of the many things that the Nano’s bigger siblings can do, but the Nano can’t.
In theory you could get to the running time by analyzing the assembly, but that would be very tedious and error-prone! Any cheap logic analyzer or oscilloscope would do, for example 1BitSquared - BitMagic Basic Logic Analyzer
Failing that, you can also try to indirectly infer the execution time from the power trace itself; in most of our examples,
trigger_low() is followed by sending out UART traffic, which tends to have a very distinct power trace, once you know what to look for. And you can learn “what to look for” pretty easily by say doing a first capture with your existing FW, then doing a second capture where the FW was modified to run what’s in between
trigger_low() twice; comparing the two power traces should allow you to figure it out.
Thank you for the detailed answer.
I came up with a logic analyzer to calculate the duration of the trigger.
Is there a way to get the current sampling rate of the CWnano with python?
if you’re using the CW-generated clock (i.e.
scope.adc.clk_src = 'int'):
scope.adc.clk_freq. If you’re using a stock Nano with our target attached, then this is what you have.
Otherwise, it’s the frequency of the external clock that you’re feeding to the Nano.