can you explain the variable printing by gc.display_stats()
in Voltage Glitch Script the total_successes was updating In success count.
but in Clock Glitch there is no total_successes, even there is no reset, success increasing in python script so how it is updating.
import chipwhisperer.common.results.glitch as glitch
from tqdm.notebook import trange
import struct
scope.glitch.ext_offset = 2
gc.set_range("width", -18, -10)
gc.set_range("offset", 40, 48)
gc.set_global_step([8, 4, 2])
scope.glitch.repeat = 10
scope.adc.timeout = 0.1
reboot_flush()
broken = False
for glitch_setting in gc.glitch_values():
scope.glitch.offset = glitch_setting[1]
scope.glitch.width = glitch_setting[0]
# ###################
# Add your code here
# ###################
#raise NotImplementedError("Add your code here, and delete this.")
# ###################
# START SOLUTION
# ###################
if scope.adc.state:
# can detect crash here (fast) before timing out (slow)
#print("Trigger still high!")
gc.add("reset", (scope.glitch.width, scope.glitch.offset))
plt.plot(lwid, loff, 'xr', alpha=1)
fig.canvas.draw()
#Device is slow to boot?
reboot_flush()
scope.arm()
#Do glitch loop
target.simpleserial_write('g', bytearray([]))
ret = scope.capture()
val = target.simpleserial_read_witherrors('r', 4, glitch_timeout=10)#For loop check
loff = scope.glitch.offset
lwid = scope.glitch.width
if ret:
print('Timeout - no trigger')
gc.add("reset", (scope.glitch.width, scope.glitch.offset))
plt.plot(scope.glitch.width, scope.glitch.offset, 'xr', alpha=1)
fig.canvas.draw()
#Device is slow to boot?
reboot_flush()
else:
if val['valid'] is False:
gc.add("reset", (scope.glitch.width, scope.glitch.offset))
plt.plot(scope.glitch.width, scope.glitch.offset, 'xr', alpha=1)
fig.canvas.draw()
else:
#print(val['payload'])
if val['payload'] is None:
print(val['payload'])
continue #what
#gcnt = struct.unpack("<b", val['payload'])[0] #for code-flow check
gcnt = struct.unpack("<I", val['payload'])[0]
#print(gcnt)
# for table display purposes
#if gnt != 0: #for code-flow check
if gcnt != 2500: #for loop check
broken = True
gc.add("success", (scope.glitch.width, scope.glitch.offset))
plt.plot(scope.glitch.width, scope.glitch.offset, '+g')
fig.canvas.draw()
#print(val['payload'])
print('\n' + "Glitch OUTPUT : " + str(gcnt))
#print("🐙", end="")
print("offset = {}, width = {}".format(scope.glitch.offset, scope.glitch.width))
else:
gc.add("normal", (scope.glitch.width, scope.glitch.offset))
# ###################
# END SOLUTION
# ###################
print(successes)
print('\n' + "Done glitching :)" +'\n')
Glitch OUTPUT : 2450
offset = 44.140625, width = -10.15625
Glitch OUTPUT : 2450
offset = 46.09375, width = -12.109375
NameError Traceback (most recent call last)
in
87 # END SOLUTION
88 # ###################
—> 89 print(successes)
90 print(’\n’ + “Done glitching :)” +’\n’)
NameError: name ‘successes’ is not defined