diff options
Diffstat (limited to 'mpm/python/usrp_mpm/periph_manager/base.py')
| -rw-r--r-- | mpm/python/usrp_mpm/periph_manager/base.py | 45 | 
1 files changed, 30 insertions, 15 deletions
| diff --git a/mpm/python/usrp_mpm/periph_manager/base.py b/mpm/python/usrp_mpm/periph_manager/base.py index 2dc69e908..8c3937702 100644 --- a/mpm/python/usrp_mpm/periph_manager/base.py +++ b/mpm/python/usrp_mpm/periph_manager/base.py @@ -85,7 +85,7 @@ class PeriphManagerBase(object):      # 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 +    mboard_last_rev_compat = None      # A list of available sensors on the motherboard. This dictionary is a map      # of the form sensor_name -> method name      mboard_sensor_callback_map = {} @@ -281,22 +281,37 @@ class PeriphManagerBase(object):                      )                  )                  raise RuntimeError("Invalid PID found in EEPROM.") -        if 'rev' in eeprom_head: -            try: -                rev_numeric = int(eeprom_head.get('rev')) -            except (ValueError, TypeError): +        # The rev_compat is either directly stored in the EEPROM, or we fall +        # back first to the dt_compat, then the rev itself (because every rev is +        # compatible with itself). +        # The dt_compat solution is a technically a hack, but it works because +        # all hardware we have released until we made this change happened to +        # have a dt_compat that also works as a rev_compat. +        rev_compat = \ +            eeprom_head.get('rev_compat', +                            eeprom_head.get('dt_compat', +                                            eeprom_head.get('rev'))) +        try: +            rev_compat = int(rev_compat) +        except (ValueError, TypeError): +            raise RuntimeError( +                "Invalid revision compat info read from EEPROM!" +            ) +        # We check if this software is actually compatible with the hardware. +        # In order for the software to be able to understand the hardware, the +        # rev_compat value (stored on the EEPROM) must be smaller or equal to +        # the value stored in the software itself. +        if self.mboard_last_rev_compat is None: +            self.log.warning("Skipping HW/SW compatibility check!") +        else: +            if rev_compat > self.mboard_last_rev_compat:                  raise RuntimeError( -                    "Invalid revision info read from EEPROM!" +                    "Software is maximally compatible with revision `{}', but " +                    "the hardware has revision `{}' and is minimally compatible " +                    "with hardware revision `{}'. Please upgrade your version of" +                    "MPM in order to use this device." +                    .format(self.mboard_last_rev_compat, mboard_info['rev'], rev_compat)                  ) -            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.")          return mboard_info      def _get_dboard_eeprom_info(self): | 
