diff --git a/mtkclient/Library/DA/xml/xml_lib.py b/mtkclient/Library/DA/xml/xml_lib.py index a3575383..89521f13 100755 --- a/mtkclient/Library/DA/xml/xml_lib.py +++ b/mtkclient/Library/DA/xml/xml_lib.py @@ -967,7 +967,10 @@ def writeflash(self, addr, length, filename, offset=0, parttype=None, wdata=None self.ack_value(length) cmd, result = self.get_command_result() if type(result) is DwnFile: - data = fh.read(length) + if fh: + data = fh.read(length) + else: + data = wdata if not self.upload(result, data, raw=True): self.error("Error on writing flash at 0x%08X" % addr) return False