Skip to content

Commit ec7335d

Browse files
authored
fix for firmware functions (#243)
* fix for firmware functions 1. report updated address, count and remaining bytes info in module_fw_download() 2. remove additional 200 ms wait time in block_write_lpl() and block_write_epl() 3. increase max wait time to 1 min in cdb1_chkstatus() if status is not 1. If status is password error (70) it will break the wait loop. 4. add protection to failed_status_dict * change cdb1_chkstatus(): only wait if status is busy * change cdb1_chkstatus(): only wait if status is busy
1 parent cf2ebe9 commit ec7335d

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

sonic_platform_base/sonic_xcvr/api/public/cmis.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,6 @@ def module_fw_download(self, startLPLsize, maxblocksize, lplonly_flag, autopagin
12801280
else:
12811281
count = BLOCK_SIZE
12821282
data = f.read(count)
1283-
progress = (imagesize - remaining) * 100.0 / imagesize
12841283
if lplonly_flag:
12851284
fw_download_status = self.cdb.block_write_lpl(address, data)
12861285
else:
@@ -1292,9 +1291,11 @@ def module_fw_download(self, startLPLsize, maxblocksize, lplonly_flag, autopagin
12921291
logger.info(txt)
12931292
return False, txt
12941293
elapsedtime = time.time()-starttime
1295-
logger.info('Address: {:#08x}; Count: {}; Progress: {:.2f}%; Time: {:.2f}s'.format(address, count, progress, elapsedtime))
12961294
address += count
12971295
remaining -= count
1296+
progress = (imagesize - remaining) * 100.0 / imagesize
1297+
logger.info('Address: {:#08x}; Count: {}; Remain: {:#08x}; Progress: {:.2f}%; Time: {:.2f}s'.format(address, count, remaining, progress, elapsedtime))
1298+
12981299
elapsedtime = time.time()-starttime
12991300
logger.info('Total module FW download time: %.2f s' %elapsedtime)
13001301

sonic_platform_base/sonic_xcvr/api/public/cmisCDB.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
PAGE_LENGTH = 128
1919
INIT_OFFSET = 128
2020
CMDLEN = 2
21-
MAX_WAIT = 100
21+
MAX_WAIT = 600
2222

2323

2424
class CmisCdbApi(XcvrApi):
@@ -121,12 +121,12 @@ def cdb1_chkstatus(self):
121121
30h-3Fh=Custom
122122
'''
123123
status = self.xcvr_eeprom.read(consts.CDB1_STATUS)
124-
is_busy = bool((status >> 7) & 0x1)
124+
is_busy = bool((status >> 7) & 0x1)
125125
cnt = 0
126126
while is_busy and cnt < MAX_WAIT:
127127
time.sleep(0.1)
128128
status = self.xcvr_eeprom.read(consts.CDB1_STATUS)
129-
is_busy = bool((status >> 7) & 0x1)
129+
is_busy = bool((status >> 7) & 0x1)
130130
cnt += 1
131131
return status
132132

@@ -165,7 +165,7 @@ def query_cdb_status(self):
165165
if status > 127:
166166
txt = 'Query CDB status: Busy'
167167
else:
168-
status_txt = self.failed_status_dict[status & 0x3f]
168+
status_txt = self.failed_status_dict.get(status & 0x3f, "Unknown")
169169
txt = 'Query CDB status: Fail- ' + status_txt
170170
else:
171171
txt = 'Query CDB status: Success'
@@ -189,7 +189,7 @@ def module_enter_password(self, psw = 0x00001011):
189189
if status > 127:
190190
txt = 'Enter password status: Busy'
191191
else:
192-
status_txt = self.failed_status_dict[status & 0x3f]
192+
status_txt = self.failed_status_dict.get(status & 0x3f, "Unknown")
193193
txt = 'Enter password status: Fail- ' + status_txt
194194
else:
195195
txt = 'Enter password status: Success'
@@ -209,7 +209,7 @@ def get_module_feature(self):
209209
if status > 127:
210210
txt = 'Get module feature status: Busy'
211211
else:
212-
status_txt = self.failed_status_dict[status & 0x3f]
212+
status_txt = self.failed_status_dict.get(status & 0x3f, "Unknown")
213213
txt = 'Get module feature status: Fail- ' + status_txt
214214
else:
215215
txt = 'Get module feature status: Success'
@@ -230,7 +230,7 @@ def get_fw_management_features(self):
230230
if status > 127:
231231
txt = 'Get firmware management feature status: Busy'
232232
else:
233-
status_txt = self.failed_status_dict[status & 0x3f]
233+
status_txt = self.failed_status_dict.get(status & 0x3f, "Unknown")
234234
txt = 'Get firmware management feature status: Fail- ' + status_txt
235235
else:
236236
txt = 'Get firmware management feature status: Success'
@@ -253,7 +253,7 @@ def get_fw_info(self):
253253
if status > 127:
254254
txt = 'Get firmware info status: Busy'
255255
else:
256-
status_txt = self.failed_status_dict[status & 0x3f]
256+
status_txt = self.failed_status_dict.get(status & 0x3f, "Unknown")
257257
txt = 'Get firmware info status: Fail- ' + status_txt
258258
else:
259259
txt = 'Get firmware info status: Success'
@@ -284,7 +284,7 @@ def start_fw_download(self, startLPLsize, header, imagesize):
284284
if status > 127:
285285
txt = 'Start firmware download status: Busy'
286286
else:
287-
status_txt = self.failed_status_dict[status & 0x3f]
287+
status_txt = self.failed_status_dict.get(status & 0x3f, "Unknown")
288288
txt = 'Start firmware download status: Fail- ' + status_txt
289289
else:
290290
txt = 'Start firmware download status: Success'
@@ -307,7 +307,7 @@ def abort_fw_download(self):
307307
if status > 127:
308308
txt = 'Abort firmware download status: Busy'
309309
else:
310-
status_txt = self.failed_status_dict[status & 0x3f]
310+
status_txt = self.failed_status_dict.get(status & 0x3f, "Unknown")
311311
txt = 'Abort firmware download status: Fail- ' + status_txt
312312
else:
313313
txt = 'Abort firmware download status: Success'
@@ -333,13 +333,12 @@ def block_write_lpl(self, addr, data):
333333
cmd += paddedPayload
334334
cmd[133-INIT_OFFSET] = self.cdb_chkcode(cmd)
335335
self.write_cdb(cmd)
336-
time.sleep(0.2)
337336
status = self.cdb1_chkstatus()
338337
if (status != 0x1):
339338
if status > 127:
340339
txt = 'LPL firmware download status: Busy'
341340
else:
342-
status_txt = self.failed_status_dict[status & 0x3f]
341+
status_txt = self.failed_status_dict.get(status & 0x3f, "Unknown")
343342
txt = 'LPL firmware download status: Fail- ' + status_txt
344343
else:
345344
txt = 'LPL firmware download status: Success'
@@ -386,13 +385,12 @@ def block_write_epl(self, addr, data, autopaging_flag, writelength):
386385
cmd += addr_byte
387386
cmd[133-INIT_OFFSET] = self.cdb_chkcode(cmd)
388387
self.write_cdb(cmd)
389-
time.sleep(0.2)
390388
status = self.cdb1_chkstatus()
391389
if (status != 0x1):
392390
if status > 127:
393391
txt = 'EPL firmware download status: Busy'
394392
else:
395-
status_txt = self.failed_status_dict[status & 0x3f]
393+
status_txt = self.failed_status_dict.get(status & 0x3f, "Unknown")
396394
txt = 'EPL firmware download status: Fail- ' + status_txt
397395
else:
398396
txt = 'EPL firmware download status: Success'
@@ -414,7 +412,7 @@ def validate_fw_image(self):
414412
if status > 127:
415413
txt = 'Firmware download complete status: Busy'
416414
else:
417-
status_txt = self.failed_status_dict[status & 0x3f]
415+
status_txt = self.failed_status_dict.get(status & 0x3f, "Unknown")
418416
txt = 'Firmware download complete status: Fail- ' + status_txt
419417
else:
420418
txt = 'Firmware download complete status: Success'
@@ -442,7 +440,7 @@ def run_fw_image(self, mode = 0x01):
442440
if status > 127:
443441
txt = 'Run firmware status: Busy'
444442
else:
445-
status_txt = self.failed_status_dict[status & 0x3f]
443+
status_txt = self.failed_status_dict.get(status & 0x3f, "Unknown")
446444
txt = 'Run firmware status: Fail- ' + status_txt
447445
else:
448446
txt = 'Run firmware status: Success'
@@ -472,7 +470,7 @@ def commit_fw_image(self):
472470
if status > 127:
473471
txt = 'Commit firmware status: Busy'
474472
else:
475-
status_txt = self.failed_status_dict[status & 0x3f]
473+
status_txt = self.failed_status_dict.get(status & 0x3f, "Unknown")
476474
txt = 'Commit firmware status: Fail- ' + status_txt
477475
else:
478476
txt = 'Commit firmware status: Success'

0 commit comments

Comments
 (0)