def func_burn_fac_app_with_new_equLabel(self, imageFile, newEquLabel): res = {} #Update image burn objBat = ModFmptIhuCon.ClassBatchOpr() callRes = objBat.FuncBat_burn_fac_app1_app2_load(imageFile) if (callRes['res'] < 0): res['string'] = 'Exec err - func_burn_fac_app_with_new_equLabel failure' + callRes[ 'string'] res['res'] = callRes['res'] return res #Update equipment label try: res['res'] = 0 objCon = ModFmptIhuCon.ClassConnProc() callRes = objCon.FuncWriteRegister( ModFmptCom.GL_FMPT_BOOT_CFG_ENG_ADDR['equLable'][0], ModFmptCom.GL_FMPT_BOOT_CFG_ENG_ADDR['equLable'][1], newEquLabel, ModFmptCom.GL_FMPT_bootcfg_equlabel) if (callRes['res'] < 0): res['string'] = 'Exec err - func_burn_fac_app_with_new_equLabel failure' res['res'] = callRes['res'] else: res['res'] = 1 res['string'] = 'Exec Res - func_burn_fac_app_with_new_equLabel' + callRes[ 'string'] except Exception as err: print("Exec Err: func_burn_fac_app_with_new_equLabel!" + str(err)) return ("Exec Err: func_burn_fac_app_with_new_equLabel!" + str(err)) finally: return res
def func_byteopr_write(self, parAddr, parFormat, parValue): res = {} if ((parFormat != 1) and (parFormat != 2) and (parFormat != 4)): res['string'] = 'Exec err - func_byteopr_read failure in parameter setting.' res['res'] = -1 return res if ((parAddr[0:2] != '0x') and (parAddr[0:2] != '0X')): res['string'] = 'Exec err - func_byteopr_read failure in parameter setting.' res['res'] = -2 return res if ((parValue[0:2] != '0x') and (parValue[0:2] != '0X')): res['string'] = 'Exec err - func_byteopr_read failure in parameter setting.' res['res'] = -3 return res parAddr = int(parAddr, base=16) #parValue = int(parValue, base = 16); try: objConn = ModFmptIhuCon.ClassConnProc() callRes = objConn.FuncWriteRegister( parAddr, parFormat, parValue, ModFmptCom.GL_FMPT_bootcfg_byte_opr) if (callRes['res'] < 0): res['string'] = 'Exec err - func_byteopr_write failure in low layer.' res['res'] = callRes['res'] else: res['res'] = 1 res['value'] = callRes['value'] res['string'] = 'Exec Res - func_byteopr_write' except Exception as err: print("Exec Err: func_byteopr_write!" + str(err)) return ("Exec Err: func_byteopr_write!" + str(err)) finally: return res
def func_app2_file_update(self, app2File): try: objBat = ModFmptIhuCon.ClassBatchOpr() res = {} callRes = objBat.FuncBat_app2_load(app2File) if (callRes['res'] < 0): res['string'] = 'Exec err - func_app2_file_update failure' + callRes[ 'string'] res['res'] = callRes['res'] else: res['res'] = 1 res['string'] = 'Exec Res - func_app2_file_update' + callRes[ 'string'] except Exception as err: print("Exec Err: func_app2_file_update!" + str(err)) return ("Exec Err: func_app2_file_update!" + str(err)) finally: return res
def func_burn_bc_fac_app(self, imageFile): try: objBat = ModFmptIhuCon.ClassBatchOpr() res = {} callRes = objBat.FuncBat_burn_bootcfg_fac_app1_app2_load(imageFile) if (callRes['res'] < 0): res['string'] = 'Exec err - func_burn_bc_fac_app failure' + callRes[ 'string'] res['res'] = callRes['res'] else: res['res'] = 1 res['string'] = 'Exec Res - func_burn_bc_fac_app' + callRes[ 'string'] except Exception as err: print("Exec Err: func_burn_bc_fac_app!" + str(err)) return ("Exec Err: func_burn_bc_fac_app!" + str(err)) finally: return res
def func_file_image_load_into_flash(self, imageName): try: objBat = ModFmptIhuCon.ClassBatchOpr() res = {} callRes = objBat.FuncBat_load_image_to_flash(imageName) if (callRes['res'] < 0): res['string'] = 'Exec err - func_file_image_load_into_flash failure' + callRes[ 'string'] res['res'] = callRes['res'] else: res['res'] = 1 res['string'] = 'Exec Res - func_file_image_load_into_flash' + callRes[ 'string'] except Exception as err: print("Exec Err: func_file_image_load_into_flash!" + str(err)) return ("Exec Err: func_file_image_load_into_flash!" + str(err)) finally: return res
def func_app2_swVer_set(self, par): try: objConn = ModFmptIhuCon.ClassConnProc() res = {} callRes = objConn.FuncWriteRegister( ModFmptCom.GL_FMPT_BOOT_CFG_ENG_ADDR['bootLoad2VerId'][0], ModFmptCom.GL_FMPT_BOOT_CFG_ENG_ADDR['bootLoad2VerId'][1], par, ModFmptCom.GL_FMPT_bootcfg_bootLoad2VerId) if (callRes['res'] < 0): res['string'] = 'Exec err - func_app2_swVer_set failure in low layer.' res['res'] = callRes['res'] else: res['res'] = 1 res['value'] = callRes['value'] res['string'] = 'Exec Res - func_app2_swVer_set' except Exception as err: print("Exec Err: func_app2_swVer_set!" + str(err)) return ("Exec Err: func_app2_swVer_set!" + str(err)) finally: return res
def func_hwType_write(self, dataValue): try: objConn = ModFmptIhuCon.ClassConnProc() res = {} callRes = objConn.FuncWriteRegister( ModFmptCom.GL_FMPT_BOOT_CFG_ENG_ADDR['hwType'][0], ModFmptCom.GL_FMPT_BOOT_CFG_ENG_ADDR['hwType'][1], dataValue, ModFmptCom.GL_FMPT_bootcfg_hw_type) if (callRes['res'] < 0): res['string'] = 'Exec err - func_hwType_write failure in low layer.' res['res'] = callRes['res'] else: res['res'] = 1 res['value'] = callRes['value'] res['string'] = 'Exec Res - func_hwType_write' except Exception as err: print("Exec Err: func_hwType_write!" + str(err)) return ("Exec Err: func_hwType_write!" + str(err)) finally: return res
def func_cfgFile_WriteAllToHw(self): try: objConn = ModFmptIhuCon.ClassConnProc() res = {} callRes = objConn.FuncWriteRegister( ModFmptCom.GL_FMPT_BOOT_CFG_ENG_ADDR['equLable'][0], ModFmptCom.GL_FMPT_BOOT_CFG_ENG_TOTAL_LEN, ModFmptCom.zStrBootCfgEng, ModFmptCom.GL_FMPT_bootcfg_all) if (callRes['res'] < 0): res['string'] = 'Exec err - func_cfgFile_WriteAllToHw failure in low layer.' res['res'] = callRes['res'] else: res['res'] = 1 res['value'] = callRes['value'] res['string'] = 'Exec Res - func_cfgFile_WriteAllToHw' except Exception as err: print("Exec Err: func_cfgFile_WriteAllToHw!" + str(err)) return ("Exec Err: func_cfgFile_WriteAllToHw!" + str(err)) finally: return res
def func_cfgFile_ReadAllFromHw(self): try: objConn = ModFmptIhuCon.ClassConnProc() res = {} callRes = objConn.FuncReadRegister( ModFmptCom.GL_FMPT_BOOT_CFG_ENG_ADDR['equLable'][0], ModFmptCom.GL_FMPT_BOOT_CFG_ENG_TOTAL_LEN, 1) if (callRes['res'] < 0): res['string'] = 'Exec err - func_cfgFile_ReadAllFromHw failure in low layer.' res['res'] = callRes['res'] else: res['res'] = 1 res['value'] = objConn.FuncLoadIhuReadIntoBootCfg( callRes['value']) res['string'] = 'Exec Res - func_cfgFile_ReadAllFromHw' except Exception as err: print("Exec Err: func_cfgFile_ReadAllFromHw!" + str(err)) return ("Exec Err: func_cfgFile_ReadAllFromHw!" + str(err)) finally: return res
def func_cypherKey_read(self): try: objConn = ModFmptIhuCon.ClassConnProc() res = {} callRes = objConn.FuncReadRegister( ModFmptCom.GL_FMPT_BOOT_CFG_ENG_ADDR['cipherKey'][0], ModFmptCom.GL_FMPT_BOOT_CFG_ENG_ADDR['cipherKey'][1], ModFmptCom.GL_FMPT_bootcfg_cipher_key) if (callRes['res'] < 0): res['string'] = 'Exec err - func_cypherKey_read failure in low layer.' res['res'] = callRes['res'] else: res['res'] = 1 res['value'] = callRes['value'] res['string'] = 'Exec Res - func_cypherKey_read' except Exception as err: print("Exec Err: func_cypherKey_read!" + str(err)) return ("Exec Err: func_cypherKey_read!" + str(err)) finally: return res
def func_fac_chk_chk(self): objConn = ModFmptIhuCon.ClassConnProc() res = {} res['res'] = 1 oldChecksum = 0 newChecksum = 0 swLen = 0 #Firstly read old checksum callRes = objConn.FuncReadRegister( ModFmptCom.GL_FMPT_BOOT_CFG_ENG_ADDR['facLoadCheckSum'][0], ModFmptCom.GL_FMPT_BOOT_CFG_ENG_ADDR['facLoadCheckSum'][1], ModFmptCom.GL_FMPT_bootcfg_facLoadCheckSum) if (callRes['res'] < 0): res['string'] = 'Exec err - func_fac_chk_chk failure in low layer.' res['res'] = callRes['res'] return res else: oldChecksum = callRes['value'] #Secondly read SW len callRes = objConn.FuncReadRegister( ModFmptCom.GL_FMPT_BOOT_CFG_ENG_ADDR['facLoadLen'][0], ModFmptCom.GL_FMPT_BOOT_CFG_ENG_ADDR['facLoadLen'][1], ModFmptCom.GL_FMPT_bootcfg_facLoadLen) if (callRes['res'] < 0): res['string'] = 'Exec err - func_fac_chk_chk failure in low layer.' res['res'] = callRes['res'] return res else: swLen = callRes['value'] #Thirdly read sw-body and caculate current checksum newCheckSum = 0 segLen = ModFmptCom.GL_FMPT_MAX_LEN_FLASH_RAW_COMMAND_DATA segTotal = math.ceil(swLen / segLen) for segIndex in range(0, segTotal): outputData = {} if (segIndex == (segTotal - 1)): dataLen = swLen - segIndex * segLen else: dataLen = segLen segBase = segIndex * segLen callRes = objConn.FuncReadRegister( ModFmptCom.GL_FMPT_FLASH_ADDRESS_FACTORY_LOAD + segBase, dataLen, ModFmptCom.GL_FMPT_bootcfg_appImage) if (callRes['res'] < 0): res['string'] = 'Exec err - func_fac_chk_chk failure in low layer.' res['res'] = callRes['res'] return res else: outputData = callRes['value'] for i in range(0, dataLen): newChecksum = (newChecksum + int(outputData[i], base=16)) & 0xFFFF #Forthly write back try: if (newCheckSum != oldChecksum): callRes = objConn.FuncWriteRegister( ModFmptCom.GL_FMPT_BOOT_CFG_ENG_ADDR['facLoadCheckSum'][0], ModFmptCom.GL_FMPT_BOOT_CFG_ENG_ADDR['facLoadCheckSum'][1], newCheckSum, ModFmptCom.GL_FMPT_bootcfg_facLoadCheckSum) if (callRes['res'] < 0): res['string'] = 'Exec err - func_fac_chk_chk failure in low layer.' res['res'] = callRes['res'] else: res['res'] = 1 res['value'] = callRes['value'] res['string'] = 'Exec Res - func_fac_chk_chk, new checksum rewrite!' else: res['res'] = 1 res['value'] = newCheckSum res['string'] = 'Exec Res - func_fac_chk_chk, same checksum!' except Exception as err: print("Exec Err: func_fac_chk_chk!" + str(err)) return ("Exec Err: func_fac_chk_chk!" + str(err)) finally: return res