ChipWhisperer Husky UART Trigger issues?

Hi to everyone,

I have bought a Husky to start exploring hardware glitching on various processors.
My first project is glitching a serial communication. All the serial requests and responses are handled by the husky. So I have set my husky for triggering on the uart TX line, because this is where I want the glitch offset to start and more specific I want the glitch to happen after a specific request.
So this is how I have it setup

scope.default_setup()
scope.io.tio1 = ‘serial_tx’
scope.io.tio2 = ‘serial_rx’
scope.io.tio3 = ‘gpio_low’
scope.io.glitch_trig_mcx = ‘trigger’
scope.clock.clkgen_src = ‘system’
scope.clock.clkgen_freq = 100e6
scope.clock.adc_mul = 0

target = cw.target(scope)
target.baud = 9600
target.flush()

scope.trigger.triggers = ‘tio1’
scope.trigger.module = ‘UART’
scope.gain.db = 40

scope.glitch.enabled = True
scope.glitch.clk_src = “pll”

scope.io.glitch_hp = False
scope.io.glitch_lp = True
scope.io.glitch_trig_mcx = ‘trigger’

scope.glitch.output = “enable_only”
scope.glitch.trigger_src = “ext_single”

scope.UARTTrigger.enabled = True
scope.UARTTrigger.baud = 9600
scope.UARTTrigger.set_pattern_match(0, b"\x01\x00\x01\x00\xff\x03")
scope.UARTTrigger.trigger_source = 0

I believe that this is correct according to the tutorials in the notebook.
So while I was looking at the husky LEDs i noticed that the glitch never light and since my oscilloscope is not working (bad PSU) i tried to figure out what could cause it.
I tried to print the matched pattern counts and everything is 0. Like nothing matches the pattern.
But the serial communication happens and everything is fine.

print(“pattern counts:”, scope.UARTTrigger.matched_pattern_counts)

So after some noodling around I thought to try and change the trigger module to

scope.trigger.module = ‘basic’

Now the trigger happens but I have no idea if it happens at the correct timing. Well I assume that it happens because the glitch LED lights up momentarily. Also the Armed LED is light up.

So I am wondering if I do something wrong in my setup or this is somekind of a bug or restriction. I have thought various workarounds to solve this issue and some of them are, toggle a pin high when a specific request is sent and monitor that pin back and trigger the glitch or maybe redirect the TX pin to another IO pin which functions as serial and that triggers the glitch? I am not sure and I would like to know your thoughts on this.

Regards

P.S.: I am not sure when I will have my oscilloscope repaired. Waiting for an answer from siglent.

Have you set scope.UARTTrigger.rules_enabled = [0]?

What’s the output of print(scope.UARTTrigger)?

Have you set the number of data bits, stop bits, parity correctly?

This is the output:

UARTTrigger: enabled = True
baud = 9600.180880403017
data_bits = 8
stop_bits = 1
parity = none
accept_parity_errors = False
sampling_clock = 200003597.25952148
trigger_source = rule #0
rules_enabled = [0]
rules = [{‘rule’: 0, ‘patt’: bytearray(b’\x00\x00\x01\x00\x01\x00\xff\x03’), ‘mask’: bytearray(b’\x00\x00\xff\xff\xff\xff\xff\xff’)}]
matched_pattern_counts = [0, 0, 0, 0, 0, 0, 0, 0]

The data_bits, parity and stop_bits are left stock because the default settings are the correct ones.

Then it’s simply not seeing that pattern - or possibly, it’s happening before the scope is armed.

First, make sure that you are arming the scope before the target is made to send this UART activity.

Then, I recommend using an external logic analyzer to see what’s actually being sent.

Finally I managed to trigger properly with the UART.

scope = cw.scope(name='Husky')
print(cw)

scope.default_setup()
scope.io.tio1 = 'serial_tx'
scope.io.tio2 = 'serial_rx'
scope.io.nrst = 'high_z'    #reset pin

target = cw.target(scope)
target.baud = 9600
target.flush()

scope.trigger.triggers = 'tio1'
scope.trigger.module = 'UART'
scope.glitch.enabled = True
scope.glitch.clk_src = "pll"

scope.io.glitch_hp = True
scope.io.glitch_lp = False
scope.io.glitch_trig_mcx = 'trigger'

scope.glitch.output = "enable_only"
scope.glitch.trigger_src = "ext_single" 

scope.UARTTrigger.enabled = True
scope.UARTTrigger.baud = 9600

scope.UARTTrigger.set_pattern_match(0, 'your pattern here')
scope.UARTTrigger.rules_enabled = [0]
scope.UARTTrigger.trigger_source = 0

The above seems to work as it is expected. It triggers on the pattern and now I can start exploring the variables that will make it glitch. Looks like a big journey.

Thank you.