Skip to content

Commit

Permalink
Merge pull request #76 from mndza/add-force-offline
Browse files Browse the repository at this point in the history
apollo_fpga.commands: avoid automatic FPGA takeover for info commands
  • Loading branch information
mossmann authored Jun 21, 2024
2 parents 1d3b03d + 5713248 commit a994b4d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 4 additions & 1 deletion apollo_fpga/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class ApolloDebugger:
}


def __init__(self):
def __init__(self, force_offline=False):
""" Sets up a connection to the debugger. """

# Try to create a connection to our Apollo debug firmware.
Expand All @@ -95,6 +95,9 @@ def __init__(self):
if fpga_device is None:
raise DebuggerNotFound("No Apollo or valid LUNA device found. "
"The LUNA_USB_IDS environment variable can be used to add custom VID:PID pairs.")
elif not force_offline:
raise DebuggerNotFound("Apollo stub interface found. "
"Switch the device to Apollo mode or add the `--force-offline` option.")

# ... and now request a USB handoff to Apollo
try:
Expand Down
8 changes: 5 additions & 3 deletions apollo_fpga/commands/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,11 @@ def jtag_debug_spi_register(device, args):

COMMANDS = [
# Info queries
Command("info", handler=print_device_info,
Command("info", handler=print_device_info, args=[(("--force-offline",), dict(action='store_true'))],
help="Print device info.", ),
Command("jtag-scan", handler=print_chain_info,
help="Prints information about devices on the onboard JTAG chain."),
Command("flash-info", handler=print_flash_info,
Command("flash-info", handler=print_flash_info, args=[(("--force-offline",), dict(action='store_true'))],
help="Prints information about the FPGA's attached configuration flash."),

# Flash commands
Expand Down Expand Up @@ -408,7 +408,9 @@ def main():
parser.print_help()
return

device = ApolloDebugger()
# Force the FPGA offline by default in most commands to force Apollo mode if needed.
force_offline = args.force_offline if "force_offline" in args else True
device = ApolloDebugger(force_offline=force_offline)

# Set up python's logging to act as a simple print, for now.
logging.basicConfig(level=logging.INFO, format="%(message)-s")
Expand Down

0 comments on commit a994b4d

Please sign in to comment.