Skip to content

Commit

Permalink
Merge pull request #75 from mndza/deprecate-flash-fast
Browse files Browse the repository at this point in the history
apollo_fpga.commands: deprecate `flash-fast`, recommend `flash --fast`
  • Loading branch information
mossmann committed Jun 21, 2024
2 parents 8eac6c6 + 947d8f5 commit 1d3b03d
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions apollo_fpga/commands/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ def erase_flash(device, args):


def program_flash(device, args):
if args.fast:
return program_flash_fast(device, args)

ensure_unconfigured(device)

with device.jtag as jtag:
Expand All @@ -173,7 +176,7 @@ def program_flash_fast(device, args):
from luna.gateware.platform import get_appropriate_platform
from apollo_fpga.gateware.flash_bridge import FlashBridge, FlashBridgeConnection
except ImportError:
logging.error("`flash-fast` requires the `luna` package in the Python environment.\n"
logging.error("`flash --fast` requires the `luna` package in the Python environment.\n"
"Install `luna` or use `flash` instead.")
sys.exit(-1)

Expand Down Expand Up @@ -209,6 +212,11 @@ def program_flash_fast(device, args):
programmer.flash(bitstream)


def program_flash_fast_deprecated(device, args):
logging.warning("[WARNING] `flash-fast` is now deprecated. Please use `flash --fast` instead.")
return program_flash_fast(device, args)


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

Expand Down Expand Up @@ -343,10 +351,10 @@ def jtag_debug_spi_register(device, args):
# Flash commands
Command("flash-erase", handler=erase_flash,
help="Erases the contents of the FPGA's flash memory."),
Command("flash-program", alias=["flash"], args=["file", "--offset"], handler=program_flash,
help="Programs the target bitstream onto the FPGA's configuration flash."),
Command("flash-fast", args=["file", "--offset"], handler=program_flash_fast,
help="Programs a bitstream onto the FPGA's configuration flash using a SPI bridge"),
Command("flash-program", alias=["flash"], args=["file", "--offset", (("--fast",), dict(action='store_true'))],
handler=program_flash, help="Programs the target bitstream onto the FPGA's configuration flash."),
Command("flash-fast", args=["file", "--offset"], handler=program_flash_fast_deprecated,
help="Programs a bitstream onto the FPGA's configuration flash using a SPI bridge."),
Command("flash-read", args=["file", "--offset", "--length"], handler=read_back_flash,
help="Reads the contents of the attached FPGA's configuration flash."),

Expand Down Expand Up @@ -390,7 +398,10 @@ def main():
cmd_parser = sub_parsers.add_parser(command.name, aliases=command.alias, help=command.help)
cmd_parser.set_defaults(func=command.handler)
for arg in command.args:
cmd_parser.add_argument(arg)
if isinstance(arg, tuple):
cmd_parser.add_argument(*arg[0], **arg[1])
else:
cmd_parser.add_argument(arg)

args = parser.parse_args()
if not args.command:
Expand Down

0 comments on commit 1d3b03d

Please sign in to comment.