Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mellanox] update eeprom.py plugin #4364

Merged
merged 1 commit into from
Apr 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions device/mellanox/x86_64-mlnx_msn2700-r0/plugins/eeprom.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from cStringIO import StringIO
from sonic_eeprom import eeprom_base
from sonic_eeprom import eeprom_tlvinfo
from sonic_device_util import get_machine_info
import subprocess
except ImportError, e:
raise ImportError (str(e) + "- required module not found")
Expand All @@ -34,6 +35,14 @@ def log_error(msg):
syslog.syslog(syslog.LOG_ERR, msg)
syslog.closelog()


machine_info = get_machine_info()
onie_platform = machine_info['onie_platform']
if 'simx' in onie_platform:
platform_path = os.path.join('/usr/share/sonic/device', onie_platform)
subprocess.check_call(['/usr/bin/xxd', '-r', '-p', 'syseeprom.hex', 'syseeprom.bin'], cwd=platform_path)
CACHE_FILE = os.path.join(platform_path, 'syseeprom.bin')

class board(eeprom_tlvinfo.TlvInfoDecoder):

_TLV_INFO_MAX_LEN = 256
Expand All @@ -45,12 +54,12 @@ def __init__(self, name, path, cpld_root, ro):
time.sleep(1)
else:
break

if not (os.path.exists(EEPROM_SYMLINK) or os.path.isfile(CACHE_FILE)):
log_error("Nowhere to read syseeprom from! No symlink or cache file found")
raise RuntimeError("No syseeprom symlink or cache file found")

self.eeprom_path = EEPROM_SYMLINK
self.eeprom_path = EEPROM_SYMLINK if 'simx' not in onie_platform else CACHE_FILE
super(board, self).__init__(self.eeprom_path, 0, '', True)

def decode_eeprom(self, e):
Expand All @@ -60,3 +69,4 @@ def decode_eeprom(self, e):
decode_output = sys.stdout.getvalue()
sys.stdout = original_stdout
print(decode_output.replace('\0', ''))