Created
December 26, 2017 13:38
-
-
Save ktemkin/938fe663c5a205269630742032f02535 to your computer and use it in GitHub Desktop.
reproduces @scanlime's tablet work using GlitchKit instead of the FaceWhisperer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
import sys | |
import binascii | |
from greatfet import GreatFET | |
from greatfet.protocol import vendor_requests as vr | |
gf = GreatFET() | |
# Use the ChipWhisperer to clock the GreatFET. Synchronize all the things. | |
print("Switching to external clock...") | |
gf.switch_to_external_clock() | |
# Provide a phase-locked clock to the target from the GreatFET, | |
# which will be enabled at the same time as VBUS. | |
print("Spinning up a clock for the target...") | |
gf.glitchkit.provide_target_clock(gf.glitchkit.usb.VBUS_ENABLED); | |
# Listen for a single event on J1_P7 to indicate that the device has booted. | |
# This essentially instructs future commands to wait for device boot before they | |
# perform their core function. | |
print("Configuring system...") | |
gf.glitchkit.simple.watch_for_event(1, [('EDGE_RISING', 'J1_P7')]) | |
gf.glitchkit.use_events_for_synchronization(gf.glitchkit.simple.COUNT_REACHED) | |
# Trigger when a setup packet is issued. | |
gf.glitchkit.trigger_on_events(gf.glitchkit.usb.HOST_SETUP_TRANSFER_QUEUED) | |
# Finally, try the event we're interested in. | |
print("Waiting for board startup & trigger...") | |
descriptor = gf.glitchkit.usb.capture_control_in( | |
request= gf.glitchkit.usb.GET_DESCRIPTOR, | |
value = gf.glitchkit.usb.GET_DEVICE_DESCRIPTOR, | |
length = 18 | |
) | |
print("Read descriptor: {}".format(binascii.hexlify(bytearray(descriptor)))) | |
# Reset the GreatFET when we're done, for good measure. | |
gf.reset() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment