def __init__(self, arguments, cdc, sahara, LOGGER, printer): self.LOGGER = LOGGER self.cdc = cdc self.sahara = sahara self.arguments = arguments self.printer = printer self.cfg = qualcomm_firehose.cfg() self.cfg.MemoryName = arguments["--memory"] self.cfg.ZLPAwareHost = 1 self.cfg.SkipStorageInit = arguments["--skipstorageinit"] self.cfg.SkipWrite = arguments["--skipwrite"] self.cfg.MaxPayloadSizeToTargetInBytes = int(arguments["--maxpayload"], 16) self.cfg.SECTOR_SIZE_IN_BYTES = int(arguments["--sectorsize"], 16) self.cfg.bit64 = sahara.bit64 devicemodel = "" skipresponse = False if "--skipresponse" in arguments: if arguments["--skipresponse"]: skipresponse = True if "--devicemodel" in arguments: if arguments["--devicemodel"] is not None: devicemodel = arguments["--devicemodel"] self.firehose = qualcomm_firehose(cdc, xmlparser(), self.cfg, LOGGER, devicemodel, sahara.serial, skipresponse, self.getluns(arguments), arguments) self.supported_functions = self.firehose.connect(0) funcs = "Supported functions:\n-----------------\n" for function in self.supported_functions: funcs += function + "," funcs = funcs[:-1] LOGGER.info(funcs) self.target_name = self.firehose.cfg.TargetName if "hwid" in dir(sahara): if sahara.hwid is not None: hwid = sahara.hwid >> 32 if hwid in msmids: self.target_name = msmids[hwid] elif hwid in sochw: self.target_name = sochw[hwid].split(",")[0]
def __init__(self, arguments, cdc, sahara, loglevel, printer): self.cdc = cdc self.sahara = sahara self.arguments = arguments self.printer = printer self.info = self.__logger.info self.error = self.__logger.error self.warning = self.__logger.warning self.__logger.setLevel(loglevel) if loglevel == logging.DEBUG: logfilename = "log.txt" fh = logging.FileHandler(logfilename) self.__logger.addHandler(fh) self.cfg = firehose.cfg() if not arguments["--memory"] is None: self.cfg.MemoryName = arguments["--memory"].lower() else: self.cfg.MemoryName = "" self.cfg.ZLPAwareHost = 1 self.cfg.SkipStorageInit = arguments["--skipstorageinit"] self.cfg.SkipWrite = arguments["--skipwrite"] self.cfg.MaxPayloadSizeToTargetInBytes = getint( arguments["--maxpayload"]) self.cfg.SECTOR_SIZE_IN_BYTES = getint(arguments["--sectorsize"]) self.cfg.bit64 = sahara.bit64 devicemodel = "" skipresponse = False if "--skipresponse" in arguments: if arguments["--skipresponse"]: skipresponse = True if "--devicemodel" in arguments: if arguments["--devicemodel"] is not None: devicemodel = arguments["--devicemodel"] self.firehose = firehose(cdc, xmlparser(), self.cfg, self.__logger.level, devicemodel, sahara.serial, skipresponse, self.getluns(arguments), arguments) self.connected = False self.firehose.connect() if "hwid" in dir(sahara): if sahara.hwid is not None: hwid = (sahara.hwid >> 32) & 0xFFFFFF socid = ((sahara.hwid >> 32) >> 16) if hwid in msmids: self.target_name = msmids[hwid] self.info(f"Target detected: {self.target_name}") if self.cfg.MemoryName == "": if self.target_name in memory_type.preferred_memory: type = memory_type.preferred_memory[ self.target_name] if type == memory_type.nand: self.cfg.MemoryName = "nand" if type == memory_type.spinor: self.cfg.MemoryName = "spinor" elif type == memory_type.emmc: self.cfg.MemoryName = "eMMC" elif type == memory_type.ufs: self.cfg.MemoryName = "UFS" self.info("Based on the chipset, we assume " + self.cfg.MemoryName + " as default memory type...") elif socid in sochw: self.target_name = sochw[socid].split(",")[0] # We assume ufs is fine (hopefully), set it as default if self.cfg.MemoryName == "": self.info( "No --memory option set, we assume \"eMMC\" as default ..., if it fails, try using \"--memory\" " + "with \"UFS\",\"NAND\" or \"spinor\" instead !") self.cfg.MemoryName = "eMMC" if self.firehose.configure(0): funcs = "Supported functions:\n-----------------\n" for function in self.firehose.supported_functions: funcs += function + "," funcs = funcs[:-1] self.info(funcs) self.target_name = self.firehose.cfg.TargetName self.connected = True
logging.info("[SAHARA] upload firehose image...") m = sahara.upload_loader() if not m: logging.error("[ERROR] update firehose image failed!") sys.exit(1) logging.info("[FIREHOSE] waiting connecting...") cfg = qualcomm_firehose.cfg() cfg.MemoryName = args.memory cfg.ZLPAwareHost = 1 cfg.SkipStorageInit = False cfg.SkipWrite = False cfg.MaxPayloadSizeToTargetInBytes = 1048576 cfg.SECTOR_SIZE_IN_BYTES = 512 cfg.bit64 = True fh = qualcomm_firehose(cdc, xmlparser(), cfg, log_level, None, sahara.serial) supported_functions = fh.connect(0) logging.info("[FIREHOSE] connected ok. supported functions: %s" % supported_functions) logging.info("[FIREHOSE] raw programming...") for xml in args.rawprogram: logging.info("[FIREHOSE] programming %s" % xml) fl = open(xml, "r") for evt, elem in ET.iterparse(fl, events=["end"]): if elem.tag == "program": if elem.get("filename", ""): filename = os.path.join(args.imagedir, elem.get("filename")) if not os.path.isfile(filename):
logging.info("[SAHARA] upload firehose image...") m = sahara.upload_loader() if not m: logging.error("[ERROR] update firehose image failed!") sys.exit(1) logging.info("[FIREHOSE] waiting connecting...") cfg = qualcomm_firehose.cfg() cfg.MemoryName = args.memory cfg.ZLPAwareHost = 1 cfg.SkipStorageInit = False cfg.SkipWrite = False cfg.MaxPayloadSizeToTargetInBytes = 1048576 cfg.SECTOR_SIZE_IN_BYTES = 512 cfg.bit64 = True fh = qualcomm_firehose(cdc, xmlparser(), cfg, log_level, args.devicemodel, sahara.serial, args.skipresponse, getluns(args.memory)) supported_functions = fh.connect(0) logging.info("[FIREHOSE] connected ok. supported functions: %s" % supported_functions) logging.info("[FIREHOSE] raw programming...") for xml in args.rawprogram: logging.info("[FIREHOSE] programming %s" % xml) fl = open(xml, "r") for evt, elem in ET.iterparse(fl, events=["end"]): if elem.tag == "program": if elem.get("filename", ""): filename = os.path.join(args.imagedir, elem.get("filename"))
logging.info("[SAHARA] upload firehose image...") m = sahara.upload_loader() if not m: logging.error("[ERROR] update firehose image failed!") sys.exit(1) logging.info("[FIREHOSE] waiting connecting...") cfg = qualcomm_firehose.cfg() cfg.MemoryName = args.memory cfg.ZLPAwareHost = 1 cfg.SkipStorageInit = False cfg.SkipWrite = False cfg.MaxPayloadSizeToTargetInBytes = 1048576 cfg.SECTOR_SIZE_IN_BYTES = 512 cfg.bit64 = True fh = qualcomm_firehose(cdc, xmlparser(), cfg, log_level, None, sahara.serial,args.skipresponse) supported_functions = fh.connect(0) logging.info("[FIREHOSE] connected ok. supported functions: %s" % supported_functions) logging.info("[FIREHOSE] raw programming...") for xml in args.rawprogram: logging.info("[FIREHOSE] programming %s" % xml) fl = open(xml, "r") for evt, elem in ET.iterparse(fl, events=["end"]): if elem.tag == "program": if elem.get("filename", ""): filename = os.path.join( args.imagedir, elem.get("filename")) if not os.path.isfile(filename):