From 178b35569b1a25180a80a23b945b10b04c9f10f5 Mon Sep 17 00:00:00 2001 From: Sugandha Gupta Date: Fri, 25 Jan 2019 11:34:47 -0800 Subject: e310/e320: Move E310 to MPM architecture and refactor - Turns the E310 into an MPM device (like N3xx, E320) - Factor out common code between E320 and E310, maximize sharing between the two devices - Remove all pre-MPM E310 code that is no longer needed - Modify MPM to remove all existing overlays before applying new ones (this is necessary to enable idle image mode for E310) Co-authored-by: Virendra Kakade Signed-off-by: Virendra Kakade --- mpm/python/usrp_mpm/e31x_legacy_eeprom.py | 103 ++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 mpm/python/usrp_mpm/e31x_legacy_eeprom.py (limited to 'mpm/python/usrp_mpm/e31x_legacy_eeprom.py') diff --git a/mpm/python/usrp_mpm/e31x_legacy_eeprom.py b/mpm/python/usrp_mpm/e31x_legacy_eeprom.py new file mode 100644 index 000000000..4c0fb19a5 --- /dev/null +++ b/mpm/python/usrp_mpm/e31x_legacy_eeprom.py @@ -0,0 +1,103 @@ +# +# Copyright 2017 Ettus Research, a National Instruments Company +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +""" +EEPROM management code +""" + +import struct +import zlib +from builtins import zip +from builtins import object + + +class MboardEEPROM(object): + """ + Given a nvmem path, read out EEPROM values from the motherboard's EEPROM. + The format of data in the EEPROM must follow the following standard: + + E310 Legacy EEPROM Format + + - 2 bytes data_version_major + - 2 bytes data_version_minor + - 6 bytes MAC address + - 2 bytes hw_pid + - 2 bytes hw_rev + - 8 bytes serial number (zero-terminated string of 7 characters) + - 12 bytes padding + - 8 bytes user_name + + MAC addresses are ignored here; they are read elsewhere. If we really need + to know the MAC address of an interface, we can fish it out the raw data, + or ask the system. + """ + + # Refer e300_eeprom_manager.hpp. + eeprom_header_format = "H", parsed_data_list[3]))[0] + parsed_data_list[4] = struct.unpack("H", parsed_data_list[4]))[0] + parsed_data = tuple(parsed_data_list) + + else: # E310 DB. + # Rectify the PID and REV parsing. Reverse the bytes. + # PID and REV are the 3rd and 4th elements in the tuple. + parsed_data_list = list(parsed_data) + parsed_data_list[2] = struct.unpack("H", parsed_data_list[2]))[0] + parsed_data_list[3] = struct.unpack("H", parsed_data_list[3]))[0] + parsed_data = tuple(parsed_data_list) + + ret_val = (dict(list(zip(eeprom_keys, parsed_data))),data) + return ret_val \ No newline at end of file -- cgit v1.2.3