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

fix for firmware functions #243

Merged
merged 3 commits into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions sonic_platform_base/sonic_xcvr/api/public/cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,6 @@ def module_fw_download(self, startLPLsize, maxblocksize, lplonly_flag, autopagin
else:
count = BLOCK_SIZE
data = f.read(count)
progress = (imagesize - remaining) * 100.0 / imagesize
if lplonly_flag:
fw_download_status = self.cdb.block_write_lpl(address, data)
else:
Expand All @@ -1292,9 +1291,11 @@ def module_fw_download(self, startLPLsize, maxblocksize, lplonly_flag, autopagin
logger.info(txt)
return False, txt
elapsedtime = time.time()-starttime
logger.info('Address: {:#08x}; Count: {}; Progress: {:.2f}%; Time: {:.2f}s'.format(address, count, progress, elapsedtime))
address += count
remaining -= count
progress = (imagesize - remaining) * 100.0 / imagesize
logger.info('Address: {:#08x}; Count: {}; Remain: {:#08x}; Progress: {:.2f}%; Time: {:.2f}s'.format(address, count, remaining, progress, elapsedtime))

elapsedtime = time.time()-starttime
logger.info('Total module FW download time: %.2f s' %elapsedtime)

Expand Down
32 changes: 15 additions & 17 deletions sonic_platform_base/sonic_xcvr/api/public/cmisCDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
PAGE_LENGTH = 128
INIT_OFFSET = 128
CMDLEN = 2
MAX_WAIT = 100
MAX_WAIT = 600


class CmisCdbApi(XcvrApi):
Expand Down Expand Up @@ -121,12 +121,12 @@ def cdb1_chkstatus(self):
30h-3Fh=Custom
'''
status = self.xcvr_eeprom.read(consts.CDB1_STATUS)
is_busy = bool((status >> 7) & 0x1)
is_busy = bool((status >> 7) & 0x1)
cnt = 0
while is_busy and cnt < MAX_WAIT:
time.sleep(0.1)
status = self.xcvr_eeprom.read(consts.CDB1_STATUS)
is_busy = bool((status >> 7) & 0x1)
is_busy = bool((status >> 7) & 0x1)
cnt += 1
return status

Expand Down Expand Up @@ -165,7 +165,7 @@ def query_cdb_status(self):
if status > 127:
txt = 'Query CDB status: Busy'
else:
status_txt = self.failed_status_dict[status & 0x3f]
status_txt = self.failed_status_dict.get(status & 0x3f, "Unknown")
txt = 'Query CDB status: Fail- ' + status_txt
else:
txt = 'Query CDB status: Success'
Expand All @@ -189,7 +189,7 @@ def module_enter_password(self, psw = 0x00001011):
if status > 127:
txt = 'Enter password status: Busy'
else:
status_txt = self.failed_status_dict[status & 0x3f]
status_txt = self.failed_status_dict.get(status & 0x3f, "Unknown")
txt = 'Enter password status: Fail- ' + status_txt
else:
txt = 'Enter password status: Success'
Expand All @@ -209,7 +209,7 @@ def get_module_feature(self):
if status > 127:
txt = 'Get module feature status: Busy'
else:
status_txt = self.failed_status_dict[status & 0x3f]
status_txt = self.failed_status_dict.get(status & 0x3f, "Unknown")
txt = 'Get module feature status: Fail- ' + status_txt
else:
txt = 'Get module feature status: Success'
Expand All @@ -230,7 +230,7 @@ def get_fw_management_features(self):
if status > 127:
txt = 'Get firmware management feature status: Busy'
else:
status_txt = self.failed_status_dict[status & 0x3f]
status_txt = self.failed_status_dict.get(status & 0x3f, "Unknown")
txt = 'Get firmware management feature status: Fail- ' + status_txt
else:
txt = 'Get firmware management feature status: Success'
Expand All @@ -253,7 +253,7 @@ def get_fw_info(self):
if status > 127:
txt = 'Get firmware info status: Busy'
else:
status_txt = self.failed_status_dict[status & 0x3f]
status_txt = self.failed_status_dict.get(status & 0x3f, "Unknown")
txt = 'Get firmware info status: Fail- ' + status_txt
else:
txt = 'Get firmware info status: Success'
Expand Down Expand Up @@ -284,7 +284,7 @@ def start_fw_download(self, startLPLsize, header, imagesize):
if status > 127:
txt = 'Start firmware download status: Busy'
else:
status_txt = self.failed_status_dict[status & 0x3f]
status_txt = self.failed_status_dict.get(status & 0x3f, "Unknown")
txt = 'Start firmware download status: Fail- ' + status_txt
else:
txt = 'Start firmware download status: Success'
Expand All @@ -307,7 +307,7 @@ def abort_fw_download(self):
if status > 127:
txt = 'Abort firmware download status: Busy'
else:
status_txt = self.failed_status_dict[status & 0x3f]
status_txt = self.failed_status_dict.get(status & 0x3f, "Unknown")
txt = 'Abort firmware download status: Fail- ' + status_txt
else:
txt = 'Abort firmware download status: Success'
Expand All @@ -333,13 +333,12 @@ def block_write_lpl(self, addr, data):
cmd += paddedPayload
cmd[133-INIT_OFFSET] = self.cdb_chkcode(cmd)
self.write_cdb(cmd)
time.sleep(0.2)
status = self.cdb1_chkstatus()
if (status != 0x1):
if status > 127:
txt = 'LPL firmware download status: Busy'
else:
status_txt = self.failed_status_dict[status & 0x3f]
status_txt = self.failed_status_dict.get(status & 0x3f, "Unknown")
txt = 'LPL firmware download status: Fail- ' + status_txt
else:
txt = 'LPL firmware download status: Success'
Expand Down Expand Up @@ -386,13 +385,12 @@ def block_write_epl(self, addr, data, autopaging_flag, writelength):
cmd += addr_byte
cmd[133-INIT_OFFSET] = self.cdb_chkcode(cmd)
self.write_cdb(cmd)
time.sleep(0.2)
status = self.cdb1_chkstatus()
if (status != 0x1):
if status > 127:
txt = 'EPL firmware download status: Busy'
else:
status_txt = self.failed_status_dict[status & 0x3f]
status_txt = self.failed_status_dict.get(status & 0x3f, "Unknown")
txt = 'EPL firmware download status: Fail- ' + status_txt
else:
txt = 'EPL firmware download status: Success'
Expand All @@ -414,7 +412,7 @@ def validate_fw_image(self):
if status > 127:
txt = 'Firmware download complete status: Busy'
else:
status_txt = self.failed_status_dict[status & 0x3f]
status_txt = self.failed_status_dict.get(status & 0x3f, "Unknown")
txt = 'Firmware download complete status: Fail- ' + status_txt
else:
txt = 'Firmware download complete status: Success'
Expand Down Expand Up @@ -442,7 +440,7 @@ def run_fw_image(self, mode = 0x01):
if status > 127:
txt = 'Run firmware status: Busy'
else:
status_txt = self.failed_status_dict[status & 0x3f]
status_txt = self.failed_status_dict.get(status & 0x3f, "Unknown")
txt = 'Run firmware status: Fail- ' + status_txt
else:
txt = 'Run firmware status: Success'
Expand Down Expand Up @@ -472,7 +470,7 @@ def commit_fw_image(self):
if status > 127:
txt = 'Commit firmware status: Busy'
else:
status_txt = self.failed_status_dict[status & 0x3f]
status_txt = self.failed_status_dict.get(status & 0x3f, "Unknown")
txt = 'Commit firmware status: Fail- ' + status_txt
else:
txt = 'Commit firmware status: Success'
Expand Down