What is the relation between checking if trigger went low and speeding up the loop?

for glitch_setting in gc.glitch_values():
    # optional: you can speed up the loop by checking if the trigger never went low
    #           (the target never called trigger_low();) via scope.adc.state
    scope.glitch.offset = glitch_setting[1]
    scope.glitch.width = glitch_setting[0]

    target.simpleserial_write("g", bytearray([]))
    ret = scope.capture()
    val = target.simpleserial_read_witherrors('r', 4, glitch_timeout=10)#For loop check

How does this speed up the loop? and why is it considered as a reset even though it was not a reset for the glitch we are looping on at the moment

It speeds up the loop because it takes longer to timeout on the capture and the serial read than it does to check if the trigger pin is high. If you want to be accurate, you should indeed record the offset/width for the previous glitch settings.


Thank you. Another question please, can the repeat substitute the ext_offset for small values, for example if my ext offset=2 and my repeat is 10, this means there will be a glitch for each cycle from cycle 2 till cycle 12?

That can be somewhat true when clock glitching. Essentially there’s a tradeoff where using a larger repeat allows you to hit more instructions, but you’ll be more likely to cause the target to crash/reset.

With voltage glitching, the Vcc rail won’t have enough time to fully recover, so repeat > 1 glitches will behave differently from repeat=1 glitches.


Okay, and also for the clock glitching, the continuous trigger mode would do the same function as changing the ext offset while glitching?
I have a loop of 100 iterations and I want to glitch every iteration. I tried 3 methods, but each produced a different rresults

The 3 methods are:
1- constant ext offset and many repeats
2- changing the offset for the range of the trigger count
3- using continuous trigger without repeats and with constant ext offset.

Which one is considered to be the optimal for my case please?

the body of the loop contains 1 instruction only

Continuous mode fires off the glitch every clock cycle. It’ll almost certainly just crash your target repeatedly. Same thing with just varying the repeat value.

I recommend varying just ext_offset. If you want, you can increase the repeat value to something like 5 or 10 and increase your ext_offset step size. If you think you’re getting too many crashes/resets, you can back the repeat value off.


Thank you so much Alex :slight_smile: