Skip to content

Commit

Permalink
cli: ensure flash-fast fails gracefully when LUNA is not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
mndza committed Mar 13, 2024
1 parent 34143f9 commit 91a4302
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions apollo_fpga/commands/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
from luna.gateware.platform import get_appropriate_platform
from apollo_fpga.gateware.flash_bridge import FlashBridge, FlashBridgeConnection
except ImportError:
pass
flash_fast_enable = False
else:
flash_fast_enable = True


#
Expand Down Expand Up @@ -202,6 +204,12 @@ def program_flash_fast(device, args, *, platform):
programmer.flash(bitstream)


def program_flash_fast_unavailable(device, args):
logging.error("`flash-fast` requires the `luna` package in the Python environment.\n"
"Install `luna` or use `flash` instead.")
sys.exit(-1)


def read_back_flash(device, args):
ensure_unconfigured(device)

Expand Down Expand Up @@ -391,7 +399,10 @@ def main():

# Add a special case where the platform information is needed
if args.command == "flash-fast":
args.func = partial(program_flash_fast, platform=get_appropriate_platform())
if flash_fast_enable:
args.func = partial(program_flash_fast, platform=get_appropriate_platform())
else:
args.func = program_flash_fast_unavailable

device = ApolloDebugger()

Expand Down

0 comments on commit 91a4302

Please sign in to comment.