Skip to content

Commit

Permalink
Refatcor 'deliver_notebooks' and 'download_overlays' in pynq.utils (#…
Browse files Browse the repository at this point in the history
…1011)

* Refatcor 'deliver_notebooks' and 'download_overlays' in pynq.utils

* Add comment in pynq_utils documentation regarding structure of .link JSON for global resource
  • Loading branch information
Giuseppe Natale authored and schelleg committed Feb 19, 2020
1 parent 03f0028 commit 67feca2
Show file tree
Hide file tree
Showing 4 changed files with 374 additions and 243 deletions.
15 changes: 13 additions & 2 deletions docs/source/overlay_design_methodology/pynq_utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,20 @@ the URL where the overlay can be downloaded, and the MD5 checksum of the file
}
}
In case the resource to be downloaded is *global* the *url* and *md5sum*
entries should be at the top-level of the JSON dictionary. In this case, no
device-based resolution will be performed.

.. code-block :: javascript
{
"url": "https://link.to/resource.extension",
"md5sum": "1df38cf582c4c5d0c8e3ca38be8f1eb3"
}
PYNQ provides a ``download_overlays`` setuptools command which will process any
link files in your repository and download the overlays for your board and
place them alongside the link files. To run the the download command
link files in your repository and download overlays and resources for your
board and place them alongside the link files. To run the the download command
automatically at build time the utils module provides a ``build_py`` command
class that can be used in place of the normal ``build_py`` phase. For more
details on how to include this command in your setup.py see the
Expand Down
13 changes: 7 additions & 6 deletions pynq/_cli/get_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,15 @@ def main():
raise FileExistsError("Target notebooks directory already "
"exists. Specify another path or use "
"the 'force' option to proceed")
overlays_lookup = not args.ignore_overlays
overlays_res_lookup = not args.ignore_overlays
try:
## Ignoring notebooks from main `pynq.notebooks` namespace as of now
# src_path = notebooks_ext_man.extension_path(NOTEBOOKS_GROUP)
# logger.info("Delivering notebooks from '{}'...".format(
# NOTEBOOKS_GROUP))
# deliver_notebooks(device, src_path, delivery_path,
# NOTEBOOKS_GROUP, overlays_lookup=overlays_lookup)
# NOTEBOOKS_GROUP,
# overlays_res_lookup=overlays_res_lookup)
##
for ext in notebooks_ext_man.list:
if args.notebooks and "all" not in args.notebooks and \
Expand Down Expand Up @@ -228,13 +229,13 @@ def main():
# pre- or post-processing calling
# `pynq.utils:deliver_notebooks` inside, or an entirely custom
# delivery procedure
ext_mod.deliver_notebooks(device, src_path, delivery_path,
ext.name, folder=folder,
overlays_lookup=overlays_lookup)
ext_mod.deliver_notebooks(
device, src_path, delivery_path, ext.name, folder=folder,
overlays_res_lookup=overlays_res_lookup)
else:
deliver_notebooks(device, src_path, delivery_path,
ext.name, folder=folder,
overlays_lookup=overlays_lookup)
overlays_res_lookup=overlays_res_lookup)
except (Exception, KeyboardInterrupt) as e:
raise e
finally:
Expand Down
11 changes: 4 additions & 7 deletions pynq/bitstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,8 @@
__email__ = "pynq_support@xilinx.com"

import os
from datetime import datetime
import struct
import numpy as np
from .devicetree import get_dtbo_path
from .utils import _find_local_overlay
from .utils import _find_local_overlay_res

PYNQ_PATH = os.path.dirname(os.path.realpath(__file__))

Expand All @@ -45,14 +42,14 @@ def _resolve_bitstream(bitfile_path, device):
if os.path.isfile(bitfile_path):
return bitfile_path
if os.path.isdir(bitfile_path + ".d") and hasattr(device, 'name'):
device_name = device.name
split_bitfile = os.path.split(bitfile_path)
local_bitfile = _find_local_overlay(device.name, split_bitfile[1],
split_bitfile[0])
local_bitfile = _find_local_overlay_res(device.name, split_bitfile[1],
split_bitfile[0])
if local_bitfile is not None:
return local_bitfile
return None


class Bitstream:
"""This class instantiates the meta class for PL bitstream (full/partial).
Expand Down
Loading

0 comments on commit 67feca2

Please # to comment.