aboutsummaryrefslogtreecommitdiffstats
path: root/mpm
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2017-11-29 14:48:44 -0800
committerMartin Braun <martin.braun@ettus.com>2017-12-22 15:05:57 -0800
commit1e4e90d240dec91e56f0a0717f3e925c067105e4 (patch)
tree5238971209a19663f3aa8836c157725d23f07ddc /mpm
parentd5d7b84ac85f57b41038db63235a8271b8189ba8 (diff)
downloaduhd-1e4e90d240dec91e56f0a0717f3e925c067105e4.tar.gz
uhd-1e4e90d240dec91e56f0a0717f3e925c067105e4.tar.bz2
uhd-1e4e90d240dec91e56f0a0717f3e925c067105e4.zip
mpm: n310: Compile .dts files to .dtbo on update
Reviewed-By: Brent Stapleton <brent.stapleton@ettus.com>
Diffstat (limited to 'mpm')
-rw-r--r--mpm/python/usrp_mpm/periph_manager/n310.py38
1 files changed, 31 insertions, 7 deletions
diff --git a/mpm/python/usrp_mpm/periph_manager/n310.py b/mpm/python/usrp_mpm/periph_manager/n310.py
index 79c866aa4..122053b7f 100644
--- a/mpm/python/usrp_mpm/periph_manager/n310.py
+++ b/mpm/python/usrp_mpm/periph_manager/n310.py
@@ -22,6 +22,7 @@ from __future__ import print_function
import os
import copy
import shutil
+import subprocess
from six import iteritems, itervalues
from builtins import object
from .base import PeriphManagerBase
@@ -482,6 +483,7 @@ class n310(PeriphManagerBase):
'dts': {
'callback': "update_dts",
'path': '/lib/firmware/n3xx.dts',
+ 'output': '/lib/firmware/n3xx.dtbo',
'reset': False,
},
}
@@ -925,8 +927,8 @@ class n310(PeriphManagerBase):
:param filepath: path to new FPGA image
:param metadata: Dictionary of strings containing metadata
"""
- self.log.trace("Updating FPGA with image at {}"
- .format(filepath))
+ self.log.trace("Updating FPGA with image at {} (metadata: `{}')"
+ .format(filepath, str(metadata)))
_, file_extension = os.path.splitext(filepath)
# Cut off the period from the file extension
file_extension = file_extension[1:].lower()
@@ -944,7 +946,7 @@ class n310(PeriphManagerBase):
self.log.error("Invalid FPGA bitfile: {}"
.format(filepath))
raise RuntimeError("Invalid N310 FPGA bitfile")
- # TODO: Implement reload procedure
+ # RPC server will reload the periph manager after this.
return True
@no_rpc
@@ -955,9 +957,31 @@ class n310(PeriphManagerBase):
:param metadata: Dictionary of strings containing metadata
"""
dtsfile_path = self.updateable_components['dts']['path']
- self.log.trace("Updating DTS with image at {} to {}"
- .format(filepath, dtsfile_path)
- )
+ self.log.trace("Updating DTS with image at %s to %s (metadata: %s)",
+ filepath, dtsfile_path, str(metadata))
shutil.copy(filepath, dtsfile_path)
- # TODO: Compile the new dts file into a usable dtbo
+ dtbofile_path = self.updateable_components['dts']['output']
+ self.log.trace("Compiling to %s...", dtbofile_path)
+ dtc_command = [
+ 'dtc',
+ '--symbols',
+ '-O', 'dtb',
+ '-q', # Suppress warnings
+ '-o',
+ dtbofile_path,
+ dtsfile_path,
+ ]
+ self.log.trace("Executing command: `$ %s'", " ".join(dtc_command))
+ try:
+ out = subprocess.check_output(dtc_command)
+ if out.strip() != "":
+ self.log.debug("`dtc' command output: \n%s", out)
+ except OSError as ex:
+ self.log.error("Could not execute `dtc' command. Binary probably "\
+ "not installed. Please compile DTS by hand.")
+ # No fatal error here, in order not to break the current workflow
+ except subprocess.CalledProcessError as ex:
+ self.log.error("Error executing `dtc': %s", str(ex))
+ return False
return True
+