Skip to content

Commit

Permalink
apollo_fpga: add VID/PID options to ApolloDebugger
Browse files Browse the repository at this point in the history
  • Loading branch information
mossmann committed Jul 23, 2024
1 parent dc29b15 commit ed22a00
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions apollo_fpga/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,24 @@ class ApolloDebugger:

backend = None


def __init__(self, force_offline=False, device=None):
""" Sets up a connection to the debugger. """
def __init__(self, force_offline=False, device=None, ids=None, stub_ids=None):
"""Set up a connection to the debugger."""
if ids is None:
ids = self.APOLLO_USB_IDS
if stub_ids is None:
stub_ids = self.LUNA_USB_IDS

# Try to create a connection to our Apollo debug firmware.
if device is None:
device = self._find_device(self.APOLLO_USB_IDS, custom_match=self._device_has_apollo_id)
device = self._find_device(ids, custom_match=self._device_has_apollo_id)

# If Apollo VID/PID is not found, try to find a gateware VID/PID with a valid Apollo stub
# interface. If found, request the gateware to liberate the USB port. In devices with a
# shared port, this effectively hands off the USB port to Apollo.
if device is None:

# First, find the candidate device...
fpga_device = self._find_device(self.LUNA_USB_IDS, custom_match=self._device_has_stub_iface)
fpga_device = self._find_device(stub_ids, custom_match=self._device_has_stub_iface)
if fpga_device is None:
raise DebuggerNotFound("No Apollo debugger or stub interface found.")
elif not force_offline:
Expand All @@ -118,7 +121,7 @@ def __init__(self, force_offline=False, device=None):
raise DebuggerNotFound(f"Handoff request failed: {e.strerror}")

# Wait for Apollo to enumerate and try again
device = self._find_device(self.APOLLO_USB_IDS, custom_match=self._device_has_apollo_id, timeout=5000)
device = self._find_device(ids, custom_match=self._device_has_apollo_id, timeout=5000)
if device is None:
raise DebuggerNotFound("Handoff was requested, but Apollo debugger not found.")

Expand Down

0 comments on commit ed22a00

Please sign in to comment.