aboutsummaryrefslogtreecommitdiffstats
path: root/mpm
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2017-08-28 16:48:40 -0700
committerMartin Braun <martin.braun@ettus.com>2017-12-22 15:04:01 -0800
commit688637522a60eda64d17ed293fd36ff73085e3d1 (patch)
tree6e4fb140ea6d928c8d82cbfc368864de8f5553ba /mpm
parentb43ab2705bdd3a26d5bff012cfd54fbf6775ffb9 (diff)
downloaduhd-688637522a60eda64d17ed293fd36ff73085e3d1.tar.gz
uhd-688637522a60eda64d17ed293fd36ff73085e3d1.tar.bz2
uhd-688637522a60eda64d17ed293fd36ff73085e3d1.zip
mpm: Added max rev check overridable
When reading revision numbers from EEPROM, we now have an easy way of checking of our version MPM is sufficient to run on the current device. N310 implicitly makes use of this starting with this commit.
Diffstat (limited to 'mpm')
-rw-r--r--mpm/python/usrp_mpm/periph_manager/base.py34
-rw-r--r--mpm/python/usrp_mpm/periph_manager/n310.py1
2 files changed, 30 insertions, 5 deletions
diff --git a/mpm/python/usrp_mpm/periph_manager/base.py b/mpm/python/usrp_mpm/periph_manager/base.py
index 3ab822a30..0aa1adf59 100644
--- a/mpm/python/usrp_mpm/periph_manager/base.py
+++ b/mpm/python/usrp_mpm/periph_manager/base.py
@@ -89,6 +89,10 @@ class PeriphManagerBase(object):
# means that keys from this dict could be overwritten during the
# initialization process.
mboard_info = {"type": "unknown"}
+ # For checking revision numbers, this is the highest revision that this
+ # particular version of MPM supports. Leave at None to skip a max rev
+ # check.
+ mboard_max_rev = None
# This is a sanity check value to see if the correct number of
# daughterboards are detected. If somewhere along the line more than
# max_num_dboards dboards are found, an error or warning is raised,
@@ -177,12 +181,32 @@ class PeriphManagerBase(object):
)
except TypeError:
self.mboard_info[key] = str(self._eeprom_head.get(key, ''))
- if 'pid' in self._eeprom_head and self._eeprom_head['pid'] not in self.pids:
- self.log.error("Found invalid PID in EEPROM: 0x{:04X}. Valid PIDs are: {}".format(
- self._eeprom_head['pid'],
- ", ".join(["0x{:04X}".format(x) for x in self.pids]),
- ))
+ if 'pid' in self._eeprom_head \
+ and self._eeprom_head['pid'] not in self.pids:
+ self.log.error(
+ "Found invalid PID in EEPROM: 0x{:04X}. " \
+ "Valid PIDs are: {}".format(
+ self._eeprom_head['pid'],
+ ", ".join(["0x{:04X}".format(x) for x in self.pids]),
+ )
+ )
raise RuntimeError("Invalid PID found in EEPROM.")
+ if 'rev' in self._eeprom_head:
+ try:
+ rev_numeric = int(self._eeprom_head.get('rev'))
+ except (ValueError, TypeError):
+ raise RuntimeError(
+ "Invalid revision info read from EEPROM!"
+ )
+ if self.mboard_max_rev is not None \
+ and rev_numeric > self.mboard_max_rev:
+ raise RuntimeError(
+ "Device has revision `{}', but max supported " \
+ "revision is `{}'".format(
+ rev_numeric, self.mboard_max_rev
+ ))
+ else:
+ raise RuntimeError("No revision found in EEPROM.")
else:
self.log.trace("No EEPROM address to read from.")
self._eeprom_head = {}
diff --git a/mpm/python/usrp_mpm/periph_manager/n310.py b/mpm/python/usrp_mpm/periph_manager/n310.py
index a9c8076ca..f855f2f3f 100644
--- a/mpm/python/usrp_mpm/periph_manager/n310.py
+++ b/mpm/python/usrp_mpm/periph_manager/n310.py
@@ -177,6 +177,7 @@ class n310(PeriphManagerBase):
mboard_eeprom_addr = "e0005000.i2c"
mboard_eeprom_max_len = 256
mboard_info = {"type": "n3xx"}
+ mboard_max_rev = 3 # 3 == RevD
dboard_eeprom_addr = "e0004000.i2c"
dboard_eeprom_max_len = 64
# We're on a Zynq target, so the following two come from the Zynq standard