Skip to content

Commit

Permalink
Merge pull request #85 from mndza/cli-more-info
Browse files Browse the repository at this point in the history
cli: show both serial number and flash UID in `info` and `flash-info`
  • Loading branch information
mossmann authored Jun 25, 2024
2 parents 219624c + 6329108 commit 0468037
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions apollo_fpga/commands/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ def print_device_info(device, args):
logging.info(f"\tSerial number: {device.serial_number}")
logging.info(f"\tFirmware version: {device.get_firmware_version()}")
logging.info(f"\tUSB API version: {device.get_usb_api_version_string()}")

with device.jtag as jtag:
programmer = device.create_jtag_programmer(jtag)
flash_uid = programmer.read_flash_uid()
logging.info(f"\tFlash UID: {flash_uid:016x}")

def print_chain_info(device, args):
""" Command that prints information about devices connected to the scan chain to the console. """
Expand Down Expand Up @@ -240,17 +243,19 @@ def read_back_flash(device, args):
def print_flash_info(device, args):
""" Command that prints information about the currently connected FPGA's configuration flash. """
ensure_unconfigured(device)
serial_number = device.serial_number

with device.jtag as jtag:
programmer = device.create_jtag_programmer(jtag)
manufacturer, device = programmer.read_flash_id()
unique_id = programmer.read_flash_uid()

if manufacturer == 0xFF:
logging.info("No flash detected.")
return

logging.info("")
logging.info(f"Detected an FPGA-connected SPI configuration flash!")
logging.info(f"Device serial number: {serial_number}")
logging.info("Detected an FPGA-connected SPI configuration flash!")

try:
logging.info(f"\tManufacturer: {JEDEC_MANUFACTURERS[manufacturer]} ({manufacturer:02x})")
Expand All @@ -262,6 +267,8 @@ def print_flash_info(device, args):
except KeyError:
logging.info(f"\tUnknown device ({device:06x}).")

logging.info(f"\tUnique ID: {unique_id:016x}")

logging.info("")


Expand Down

0 comments on commit 0468037

Please sign in to comment.