UART Trigger Not Working on ChipWhisperer Husky

Hello,

I’m having trouble getting the UART trigger to work properly on my ChipWhisperer Husky. I’ve set everything up according to the documentation, but the trigger isn’t firing when the expected pattern is received.

My Setup

I’m using the following hardware and configuration:

  • Device: ChipWhisperer Husky
  • Scope: OPENADC
  • Platform: CWHUSKY

My Code

import chipwhisperer as cw
scope = cw.scope(name='Husky')
scope.default_setup()
scope.io.tio1 = 'serial_tx'
scope.io.tio2 = 'serial_rx'
scope.io.glitch_trig_mcx = 'trigger'
target = cw.target(scope)
target.baud = 5000
target.flush()
scope.trigger.module = 'UART'
scope.UARTTrigger.enabled = True
scope.UARTTrigger.baud = 5000
scope.gain.db = 12
scope.trigger.triggers = 'tio2'
scope.UARTTrigger.set_pattern_match(0, '\xf8')
scope.UARTTrigger.trigger_source = 0
scope.UARTTrigger.rules_enabled = [0]
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"
print(scope.adc.bits_per_sample)
print(scope.errors)
print(scope)
try:
    c = 0
    while True:
        scope.arm()
        data = target.read()
        if data:
            print(f"Recieved data: {data}, HEX: {as_hex(data)}")
            if '\xf8' in data:
                print("\\xf8 Found!")
        if scope.UARTTrigger.matched_pattern_counts[0] > c:
            c = scope.UARTTrigger.matched_pattern_counts[0]
            print(f"Trigger counts: {scope.UARTTrigger.matched_pattern_counts}")
            print(f"Trigger data: {scope.UARTTrigger.matched_pattern_data(as_string=True)}")
        time.sleep(0.001)
except KeyboardInterrupt:
    print(f"matched_pattern_counts: {scope.UARTTrigger.matched_pattern_counts}")

Current Behavior

I can see the UART data is coming through correctly - I can see the 0xF8 byte in the received data and my code prints “\xf8 Found!” when it’s detected:

Received data: ª», HEX: \xaa\xbb
Received data: Ìø, HEX: \xcc\xf8
\xf8 Found!
Received data: Ý, HEX: \xdd
Received data: î, HEX: \xee
Received data: ª», HEX: \xaa\xbb
Received data: Ì, HEX: \xcc
Received data: øÝ, HEX: \xf8\xdd
\xf8 Found!

However, the actual hardware trigger never fires - the matched_pattern_counts does not increment, suggesting the UART trigger module isn’t detecting the pattern.

System Configuration

Here’s the output from print(scope):

cwhusky Device
sn             = 50203220383753593230313239313035
fpga_buildtime = 12/11/2024, 12:33
fw_version = 
    major = 1
    minor = 5
    debug = 0
gain = 
    mode = low
    gain = 59
    db   = 12.064220183486238
...
trigger = 
    sequencer_enabled = False
    module            = UART
    triggers          = tio2
io = 
    tio1            = serial_tx
    tio2            = serial_rx
...
trace = 
    capture = 
        trigger_source         = trace trigger, rule #0
        use_husky_arm          = True
        raw                    = True
        rules_enabled          = [0]
        rules                  = [{'rule': 0, 'patt': bytearray(b'\x00\x00\x00\x00\x00\x00\x00\xf8'), 'mask': bytearray(b'\x00\x00\x00\x00\x00\x00\x00\xff')}]

What I’ve Tried

I’ve verified:

  1. The UART communications are working (I can see the data)
  2. The pattern I’m looking for (0xF8) is being received
  3. The UART trigger module is enabled

Questions

  1. I notice the ADC and glitch LEDs on my ChipWhisperer Husky are glowing red. Is this normal during this operation, or does it indicate a problem?

  2. Is there anything special needed for the UART trigger to recognize the pattern beyond what I’ve configured?

scope.UARTTrigger.set_pattern_match() doesn’t process the backslash in the string argument that you are giving it. Try instead:

scope.UARTTrigger.set_pattern_match(0, [0xf8])

Unfortunately, it still doesn’t work. The UART data is still coming through (I can see the 0xF8 bytes in the received data), but the matched_pattern_counts never increments and no trigger occurs.

Are the parity, stop bits, etc… correctly set?
Compare the UART settings from print(target) and print(scope.UARTTrigger).