--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LPCtarget/__init__.py.orig Thu Jun 01 10:18:50 2017 +0200
@@ -0,0 +1,75 @@
+from subprocess import Popen,PIPE +from toolchain_makefile import toolchain_makefile +class LPC_target(toolchain_makefile): + def __init__(self, CTRInstance): + toolchain_makefile.__init__(self, CTRInstance) + def _GetBinMD5FileName(self): + return os.path.join(self.buildpath, "lastbuildPLCbin.md5") + def _get_md5_header(self): + """Returns signature header""" + buildpath = self.buildpath.encode(sys.getfilesystemencoding()) + ['arm-elf-size','-B',os.path.join(buildpath,"ArmPLC_rom.elf")], + stdout=PIPE).communicate()[0].splitlines()[1].split()[0]) + res = "&" + hashlib.md5(open(os.path.join(buildpath, "ArmPLC_rom.bin"), "rb").read(size)).hexdigest() + '\n' +\ + def GetBinaryCode(self): + """Returns ready to send signed + sized intel formated hex program""" + res = self._get_md5_header() +\ + open(os.path.join(self.buildpath, "ArmPLC_rom.hex"), "r").read() + def _get_cached_md5_header(self): + if self.binmd5key is not None: + return open(self._GetBinMD5FileName(), "r").read() + def ResetBinaryCodeMD5(self, mode): + if mode == "BOOTLOADER": + os.remove(self._GetBinMD5FileName()) + return toolchain_makefile.ResetBinaryCodeMD5(self) + def GetBinaryCodeMD5(self, mode): + if mode == "BOOTLOADER": + return self._get_cached_md5_header() + return toolchain_makefile.GetBinaryCodeMD5(self) + res = toolchain_makefile.build(self) + self.binmd5key = self._get_md5_header() + f = open(self._GetBinMD5FileName(), "w") + f.write(self.binmd5key) + self.CTRInstance.logger.write( + _("Binary is %s bytes long\n")% + os.path.join(self.buildpath, "ArmPLC_rom.bin"))))