litex_ok.py bitstream configuration example

This commit is contained in:
AEW2015 2023-03-06 22:02:51 -07:00
parent c8dcc39957
commit 4276a181ba
6 changed files with 1689 additions and 1 deletions

2
.gitignore vendored
View File

@ -7,7 +7,7 @@ __pycache__/
*~
# C extensions
*.so
# *.so Removed for okHost SO files
# Distribution / packaging
.Python

View File

@ -0,0 +1,11 @@
# udev rules file for all Opal Kelly VID matches.
# This file allows udev to change the mode to 666 (all read/write)
# for any Opal Kelly VID.
#
# For FedoraCore 5 and similar:
SUBSYSTEM=="usb_device", SYSFS{idVendor}=="151f", MODE="0666"
# For FedoraCore 7 and similar:
SUBSYSTEM=="usb", ATTRS{idVendor}=="151f", MODE="0666"

BIN
litex/tools/_ok.so Executable file

Binary file not shown.

BIN
litex/tools/libokFrontPanel.so Executable file

Binary file not shown.

50
litex/tools/litex_ok.py Executable file
View File

@ -0,0 +1,50 @@
#!/usr/bin/env python3
#
# This file is part of LiteX.
#
# Copyright (c) 2023 Andrew Elbert Wilson <Andrew.E.Wilson@ieee.org>
# SPDX-License-Identifier: BSD-2-Clause
import time
import argparse
#Dependencies for ok library
# * sudo apt install libsdl2-2.0-0
# * sudo apt install liblua5.3-0
# * udev rules for ok USB 60-opalkelly.rules
import ok
# Run ----------------------------------------------------------------------------------------------
def _get_args():
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("bitstream", help="Bitstream for XEM8320")
return parser.parse_args()
def main():
args = _get_args()
print(args.bitstream)
xem = ok.FrontPanelDevices().Open()
if not xem:
print ("A device could not be opened. Is one connected?")
exit()
devInfo = ok.okTDeviceInfo()
if (xem.NoError != xem.GetDeviceInfo(devInfo)):
print ("Unable to retrieve device information.")
exit()
print(" Product: " + devInfo.productName)
print("Firmware version: %d.%d" % (devInfo.deviceMajorVersion, devInfo.deviceMinorVersion))
print(" Serial Number: %s" % devInfo.serialNumber)
print(" Device ID: %s" % devInfo.deviceID)
tic = time.perf_counter()
if (xem.NoError != xem.ConfigureFPGA(args.bitstream)):
print ("FPGA configuration failed.")
else:
toc = time.perf_counter()
print (f"FPGA configuration succeded in {toc - tic:0.4f} seconds")
xem.Close()
if __name__ == "__main__":
main()

1627
litex/tools/ok.py Normal file

File diff suppressed because it is too large Load Diff