aboutsummaryrefslogtreecommitdiffstats
path: root/mpm
diff options
context:
space:
mode:
authorSteven Koo <steven.koo@ni.com>2020-09-03 17:18:56 -0500
committermichael-west <michael.west@ettus.com>2020-09-04 11:38:27 -0700
commitbe53058a47c6b2925103d44595f06fd6fb85e4be (patch)
tree40dad308921816b110b837b147b3bd3a7fa04159 /mpm
parentab9f4eab72df289d8d160082287112195e4604b7 (diff)
downloaduhd-be53058a47c6b2925103d44595f06fd6fb85e4be.tar.gz
uhd-be53058a47c6b2925103d44595f06fd6fb85e4be.tar.bz2
uhd-be53058a47c6b2925103d44595f06fd6fb85e4be.zip
mpm: e31x: Accept FF terminated strings in eeprom
Older revisions of the e31x used FF terminated strings in the EEPROM. The eeprom implementation didn't take this into account and would fail on ascii conversion. This change resolves mpm bring up on the older revisions by replacing FF with null. This didn't affect newer revisions because they used null terminated strings. Signed-off-by: Steven Koo <steven.koo@ni.com>
Diffstat (limited to 'mpm')
-rw-r--r--mpm/python/usrp_mpm/e31x_legacy_eeprom.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/mpm/python/usrp_mpm/e31x_legacy_eeprom.py b/mpm/python/usrp_mpm/e31x_legacy_eeprom.py
index 70e6632ae..029619b5c 100644
--- a/mpm/python/usrp_mpm/e31x_legacy_eeprom.py
+++ b/mpm/python/usrp_mpm/e31x_legacy_eeprom.py
@@ -24,7 +24,7 @@ class MboardEEPROM(object):
- 6 bytes MAC address
- 2 bytes hw_pid
- 2 bytes hw_rev
- - 8 bytes serial number (zero-terminated string of 7 characters)
+ - 8 bytes serial number (xFF or NULL terminated)
- 12 bytes padding
- 8 bytes user_name
@@ -33,7 +33,7 @@ class MboardEEPROM(object):
or ask the system.
"""
# Refer e300_eeprom_manager.hpp.
- eeprom_header_format = "<H H 6s H H 7s 12s 8s"
+ eeprom_header_format = "<H H 6s H H 8s 12s 8s"
eeprom_header_keys = (
'data_version_major',
'data_version_minor',
@@ -55,11 +55,11 @@ class DboardEEPROM(object):
- 2 bytes data_version_minor
- 2 bytes hw_pid
- 2 bytes hw_rev
- - 8 bytes serial number (zero-terminated string of 7 characters)
+ - 8 bytes serial number (xFF or NULL terminated)
- 12 bytes padding
"""
# Refer e300_eeprom_manager.hpp.
- eeprom_header_format = "<H H H H 7s 12s"
+ eeprom_header_format = "<H H H H 8s 12s"
eeprom_header_keys = (
'data_version_major',
'data_version_minor',
@@ -100,6 +100,10 @@ def read_eeprom(
parsed_data_list = list(parsed_data)
parsed_data_list[3] = struct.unpack("<H", struct.pack(">H", parsed_data_list[3]))[0]
parsed_data_list[4] = struct.unpack("<H", struct.pack(">H", parsed_data_list[4]))[0]
+ # Some revisions use xFF terminated strings for serial and user_name.
+ # Replace xFF with NULL to pass ascii conversion.
+ parsed_data_list[5] = parsed_data_list[5].replace(b'\xff',b'\x00')
+ parsed_data_list[7] = parsed_data_list[7].replace(b'\xff',b'\x00')
parsed_data = tuple(parsed_data_list)
else: # E310 DB.
@@ -108,6 +112,9 @@ def read_eeprom(
parsed_data_list = list(parsed_data)
parsed_data_list[2] = struct.unpack("<H", struct.pack(">H", parsed_data_list[2]))[0]
parsed_data_list[3] = struct.unpack("<H", struct.pack(">H", parsed_data_list[3]))[0]
+ # Some revisions use xFF terminated strings for serial.
+ # Replace xFF with NULL to pass ascii conversion.
+ parsed_data_list[4] = parsed_data_list[4].replace(b'\xff',b'\x00')
parsed_data = tuple(parsed_data_list)
ret_val = (dict(list(zip(eeprom_keys, parsed_data))), data)