-
Notifications
You must be signed in to change notification settings - Fork 178
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
[CMIS] Return the CDB status value for the caller to check the status… #485
Changes from 3 commits
a3dde34
7b098c7
4d919c8
ea7ee0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1240,7 +1240,7 @@ def get_module_fw_mgmt_feature(self, verbose = False): | |
""" | ||
txt = '' | ||
if self.cdb is None: | ||
return {'status': False, 'info': "CDB Not supported", 'result': None} | ||
return {'status': False, 'info': "CDB Not supported", 'feature': None} | ||
|
||
# get fw upgrade features (CMD 0041h) | ||
starttime = time.time() | ||
|
@@ -1252,8 +1252,11 @@ def get_module_fw_mgmt_feature(self, verbose = False): | |
writelength = (writelength_raw + 1) * 8 | ||
txt += 'Auto page support: %s\n' %autopaging_flag | ||
txt += 'Max write length: %d\n' %writelength | ||
rpllen, rpl_chkcode, rpl = self.cdb.get_fw_management_features() | ||
if self.cdb.cdb_chkcode(rpl) == rpl_chkcode: | ||
result = self.cdb.get_fw_management_features() | ||
status = result['status'] | ||
_, rpl_chkcode, rpl = result['rpl'] | ||
|
||
if status == 1 and self.cdb.cdb_chkcode(rpl) == rpl_chkcode: | ||
startLPLsize = rpl[2] | ||
txt += 'Start payload size %d\n' % startLPLsize | ||
maxblocksize = (rpl[4] + 1) * 8 | ||
|
@@ -1276,8 +1279,10 @@ def get_module_fw_mgmt_feature(self, verbose = False): | |
txt += 'Read to LPL/EPL {:#x}\n'.format(rpl[6]) | ||
|
||
else: | ||
txt += 'Reply payload check code error\n' | ||
return {'status': False, 'info': txt, 'result': None} | ||
txt += 'Status or reply payload check code error\n' | ||
logger.info(txt) | ||
logger.info('Fail to get fw mgmt feature, cdb status: {:#x}, cdb_chkcode: {:#x}, rpl_chkcode: {:#x}\n'.format(status, self.cdb.cdb_chkcode(rpl), rpl_chkcode)) | ||
return {'status': False, 'info': txt, 'feature': None} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mihirpat1 As suggested by rqx110, I should ensure that get_module_fw_mgmt_feature() returns a dictionary with the key 'feature' instead of 'result'; otherwise, other callers may not function properly. To ensure consistency in the output dictionary keys, I have also corrected the key to 'feature' for error cases. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @xinyulin Can we log an error with the value of status here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This error will be logged with the following format in the latest commit else:
txt += 'Status or reply payload check code error\n'
logger.info(txt)
logger.info('Fail to get fw mgnt feature, cdb status: 0x{}\n'.format(status))
return {'status': False, 'info': txt, 'feature': None} The new commit has been tested with firmware download, run, and commit flows without any errors. Could you please review it to see if anything is missing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my opinion, there is no need to log here. The method caller will make the judgment and log the result. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rqx110 I think capturing the |
||
elapsedtime = time.time()-starttime | ||
logger.info('Get module FW upgrade features time: %.2f s\n' %elapsedtime) | ||
logger.info(txt) | ||
|
@@ -1297,20 +1302,25 @@ def get_module_fw_info(self): | |
return {'status': False, 'info': "CDB Not supported", 'result': None} | ||
|
||
# get fw info (CMD 0100h) | ||
rpllen, rpl_chkcode, rpl = self.cdb.get_fw_info() | ||
result = self.cdb.get_fw_info() | ||
status = result['status'] | ||
rpllen, rpl_chkcode, rpl = result['rpl'] | ||
|
||
# Interface NACK or timeout | ||
if (rpllen is None) or (rpl_chkcode is None): | ||
return {'status': False, 'info': "Interface fail", 'result': 0} # Return result 0 for distinguishing CDB is maybe in busy or failure. | ||
|
||
# password issue | ||
if self.cdb.cdb_chkcode(rpl) != rpl_chkcode: | ||
if status == 0x46: | ||
string = 'Get module FW info: Need to enter password\n' | ||
logger.info(string) | ||
# Reset password for module using CMIS 4.0 | ||
self.cdb.module_enter_password(0) | ||
rpllen, rpl_chkcode, rpl = self.cdb.get_fw_info() | ||
result = self.cdb.get_fw_info() | ||
status = result['status'] | ||
rpllen, rpl_chkcode, rpl = result['rpl'] | ||
|
||
if self.cdb.cdb_chkcode(rpl) == rpl_chkcode: | ||
if status == 1 and self.cdb.cdb_chkcode(rpl) == rpl_chkcode: | ||
# Regiter 9Fh:136 | ||
fwStatus = rpl[0] | ||
ImageARunning = (fwStatus & 0x01) # bit 0 - image A is running | ||
|
@@ -1603,7 +1613,7 @@ def module_fw_upgrade(self, imagepath): | |
return result['status'], result['info'] | ||
result = self.get_module_fw_mgmt_feature() | ||
try: | ||
startLPLsize, maxblocksize, lplonly_flag, autopaging_flag, writelength = result['result'] | ||
startLPLsize, maxblocksize, lplonly_flag, autopaging_flag, writelength = result['feature'] | ||
except (ValueError, TypeError): | ||
return result['status'], result['info'] | ||
download_status, txt = self.module_fw_download(startLPLsize, maxblocksize, lplonly_flag, autopaging_flag, writelength, imagepath) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,13 +155,13 @@ def query_cdb_status(self): | |
''' | ||
This QUERY Status command may be used to retrieve the password acceptance | ||
status and to perform a test of the CDB interface. | ||
It returns the reply message of this CDB command 0000h. | ||
It returns the status and reply message of this CDB command 0000h. | ||
''' | ||
cmd = bytearray(b'\x00\x00\x00\x00\x02\x00\x00\x00\x00\x10') | ||
cmd[133-INIT_OFFSET] = self.cdb_chkcode(cmd) | ||
self.write_cdb(cmd) | ||
status = self.cdb1_chkstatus() | ||
if (status != 0x1): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @xinyulin Can you please revert this unrelated change to avoid increasing line history (agreed that the version without parenthesis is more pythonic though). Please do the same for similar changes in the diff. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, I have reverted it. |
||
if status != 0x1: | ||
if status > 127: | ||
txt = 'Query CDB status: Busy' | ||
else: | ||
|
@@ -170,7 +170,8 @@ def query_cdb_status(self): | |
else: | ||
txt = 'Query CDB status: Success' | ||
logger.info(txt) | ||
return self.read_cdb() | ||
rpl = self.read_cdb() | ||
return {'status': status, 'rpl': rpl} | ||
|
||
# Enter password | ||
def module_enter_password(self, psw = 0x00001011): | ||
|
@@ -199,7 +200,7 @@ def module_enter_password(self, psw = 0x00001011): | |
def get_module_feature(self): | ||
''' | ||
This command is used to query which CDB commands are supported. | ||
It returns the reply message of this CDB command 0040h. | ||
It returns the status and reply message of this CDB command 0040h. | ||
''' | ||
cmd = bytearray(b'\x00\x40\x00\x00\x00\x00\x00\x00') | ||
cmd[133-INIT_OFFSET] = self.cdb_chkcode(cmd) | ||
|
@@ -214,13 +215,15 @@ def get_module_feature(self): | |
else: | ||
txt = 'Get module feature status: Success' | ||
logger.info(txt) | ||
return self.read_cdb() | ||
|
||
rpl = self.read_cdb() | ||
return {'status': status, 'rpl': rpl} | ||
|
||
# Firmware Update Features Supported | ||
def get_fw_management_features(self): | ||
''' | ||
This command is used to query supported firmware update features | ||
It returns the reply message of this CDB command 0041h. | ||
It returns the status and reply message of this CDB command 0041h. | ||
''' | ||
cmd = bytearray(b'\x00\x41\x00\x00\x00\x00\x00\x00') | ||
cmd[133-INIT_OFFSET] = self.cdb_chkcode(cmd) | ||
|
@@ -235,14 +238,16 @@ def get_fw_management_features(self): | |
else: | ||
txt = 'Get firmware management feature status: Success' | ||
logger.info(txt) | ||
return self.read_cdb() | ||
|
||
rpl = self.read_cdb() | ||
return {'status': status, 'rpl': rpl} | ||
|
||
# Get FW info | ||
def get_fw_info(self): | ||
''' | ||
This command returns the firmware versions and firmware default running | ||
images that reside in the module | ||
It returns the reply message of this CDB command 0100h. | ||
It returns the status and reply message of this CDB command 0100h. | ||
''' | ||
cmd = bytearray(b'\x01\x00\x00\x00\x00\x00\x00\x00') | ||
cmd[133-INIT_OFFSET] = self.cdb_chkcode(cmd) | ||
|
@@ -257,7 +262,9 @@ def get_fw_info(self): | |
else: | ||
txt = 'Get firmware info status: Success' | ||
logger.info(txt) | ||
return self.read_cdb() | ||
|
||
rpl = self.read_cdb() | ||
return {'status': status, 'rpl': rpl} | ||
|
||
# Start FW download | ||
def start_fw_download(self, startLPLsize, header, imagesize): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mihirpat1 Thanks for the suggestion, I have modified it accordingly.