diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-04-19 22:58:12 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:03:46 -0800 |
commit | 60af7b1a1f6b105e63e5fe2945146ef401dd70b0 (patch) | |
tree | f6d86b8d4c5c40432980d9f853acbbd831f028f3 /mpm/python/n3xx_bist | |
parent | f9a6de45be2b5a296e93d4eb06e6a934b154108e (diff) | |
download | uhd-60af7b1a1f6b105e63e5fe2945146ef401dd70b0.tar.gz uhd-60af7b1a1f6b105e63e5fe2945146ef401dd70b0.tar.bz2 uhd-60af7b1a1f6b105e63e5fe2945146ef401dd70b0.zip |
n3xx: Added bist tool skeleton
Diffstat (limited to 'mpm/python/n3xx_bist')
-rwxr-xr-x | mpm/python/n3xx_bist | 183 |
1 files changed, 183 insertions, 0 deletions
diff --git a/mpm/python/n3xx_bist b/mpm/python/n3xx_bist new file mode 100755 index 000000000..566722a01 --- /dev/null +++ b/mpm/python/n3xx_bist @@ -0,0 +1,183 @@ +#!/usr/bin/env python +# +# Copyright 2017 Ettus Research (National Instruments) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +""" +N310 Built-In Self Test (BIST) +""" + +from __future__ import print_function +import sys +import argparse + +class N310BIST(object): + """ + BIST Tool for the USRP N3xx series + """ + # This defines special tests that are really collections of other tests. + collections = { + 'standard': ["ddr3", "gpsdo", "rtc", "temp", "clock_int", "tpm"], + 'extended': "*", + } + + @staticmethod + def make_arg_parser(): + """ + Return arg parser + """ + parser = argparse.ArgumentParser( + description="N3xx BIST Tool", + ) + parser.add_argument( + 'tests', + help="List the tests that should be run", + nargs='+', # There has to be at least one + ) + return parser + + def __init__(self): + self.args = N310BIST.make_arg_parser().parse_args() + self.tests_to_run = set() + for test in self.args.tests: + if test in self.collections: + for test in self.expand_collection(test): + self.tests_to_run.add(test) + else: + self.tests_to_run.add(test) + + def expand_collection(self, coll): + """ + Return names of tests in a collection + """ + tests = self.collections[coll] + if tests == "*": + tests = {x.replace('bist_', '') + for x in dir(self) + if x.find('bist_') == 0 + } + else: + tests = set(tests) + return tests + + def run(self): + """ + Execute tests. + + Returns True on Success. + """ + def execute_test(testname): + """ + Actually run a test. + """ + testmethod_name = "bist_{0}".format(testname) + sys.stderr.write("Executing test method: {0}\n\n".format(testmethod_name)) + return getattr(self, testmethod_name)() + tests_successful = True + for test in self.tests_to_run: + tests_successful = tests_successful and execute_test(test) + return tests_successful + +############################################################################# +# BISTS +# All bist_* methods must return True/False success values! +############################################################################# + def bist_rtc(self): + """ + BIST for RTC (real time clock) + """ + assert 'rtc' in self.tests_to_run + sys.stderr.write("Test not implemented.\n") + return True + + def bist_ddr3(self): + """ + BIST for PL DDR3 DRAM + """ + assert 'ddr3' in self.tests_to_run + sys.stderr.write("Test not implemented.\n") + return True + + def bist_gpsdo(self): + """ + BIST for GPSDO + """ + assert 'gpsdo' in self.tests_to_run + sys.stderr.write("Test not implemented.\n") + return True + + def bist_tpm(self): + """ + BIST for TPM (Trusted Platform Module) + """ + assert 'gpsdo' in self.tests_to_run + sys.stderr.write("Test not implemented.\n") + return True + + def bist_clock_int(self): + """ + BIST for clock lock from internal source + """ + assert 'clock_int' in self.tests_to_run + sys.stderr.write("Test not implemented.\n") + return True + + def bist_clock_ext(self): + """ + BIST for clock lock from external source + """ + assert 'clock_ext' in self.tests_to_run + sys.stderr.write("Test not implemented.\n") + return True + + def bist_usbhost(self): + """ + BIST for USB host functionality + """ + assert 'usbhost' in self.tests_to_run + sys.stderr.write("Test not implemented.\n") + return True + + def bist_sfp(self): + """ + BIST for SFP+ ports + """ + assert 'sfp' in self.tests_to_run + sys.stderr.write("Test not implemented.\n") + return True + + def bist_gpio(self): + """ + BIST for SFP+ ports + """ + assert 'gpio' in self.tests_to_run + sys.stderr.write("Test not implemented.\n") + return True + + def bist_temp(self): + """ + BIST for temperature sensors + """ + assert 'temp' in self.tests_to_run + sys.stderr.write("Test not implemented.\n") + return True + +def main(): + " Go, go, go! " + return N310BIST().run() + +if __name__ == '__main__': + exit(not main()) + |