From fadf6e2ebaa12cfd89942a57efbe60e8e56bff77 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 12 Dec 2017 10:40:46 -0800 Subject: mpm: mg: Fix lookup of user EEPROM map For unknown revs, this now scales back to the last known rev. Reviewed-By: Trung Tran --- mpm/python/usrp_mpm/dboard_manager/magnesium.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/mpm/python/usrp_mpm/dboard_manager/magnesium.py b/mpm/python/usrp_mpm/dboard_manager/magnesium.py index c17e5db27..8645ec9f6 100644 --- a/mpm/python/usrp_mpm/dboard_manager/magnesium.py +++ b/mpm/python/usrp_mpm/dboard_manager/magnesium.py @@ -285,6 +285,9 @@ class Magnesium(DboardManagerBase): base_i2c_adapter = '/sys/class/i2c-adapter' # Map I2C channel to slot index i2c_chan_map = {0: 'i2c-9', 1: 'i2c-10'} + # This map describes how the user data is stored in EEPROM. If a dboard rev + # changes the way the EEPROM is used, we add a new entry. If a dboard rev + # is not found in the map, then we go backward until we find a suitable rev user_eeprom = { 2: { # RevC 'label': "e0004000.i2c", @@ -349,7 +352,7 @@ class Magnesium(DboardManagerBase): self.log.trace("Loaded C++ drivers.") self._init_myk_api(self.mykonos) self.eeprom_fs, self.eeprom_path = self._init_user_eeprom( - self.user_eeprom[self.rev] + self._get_user_eeprom_info(self.rev) ) self.log.trace("Loading SPI devices...") self._spi_ifaces = { @@ -404,6 +407,20 @@ class Magnesium(DboardManagerBase): self.log.trace("adding {}".format(method)) setattr(self, method, export_method(myk, method)) + def _get_user_eeprom_info(self, rev): + """ + Return an EEPROM access map (from self.user_eeprom) based on the rev. + """ + rev_for_lookup = rev + while rev_for_lookup not in self.user_eeprom: + if rev_for_lookup < 0: + raise RuntimeError("Could not find a user EEPROM map for " + "revision %d!", rev) + rev_for_lookup -= 1 + assert rev_for_lookup in self.user_eeprom, \ + "Invalid EEPROM lookup rev!" + return self.user_eeprom[rev_for_lookup] + def _init_user_eeprom(self, eeprom_info): """ Reads out user-data EEPROM, and intializes a BufferFS object from that. -- cgit v1.2.3