from subprocess import Popen,PIPE
from targets.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"""
['arm-elf-size','-B',os.path.join(self.buildpath,"ArmPLC_rom.elf")],
stdout=PIPE).communicate()[0].splitlines()[1].split()[0])
res = "&" + hashlib.md5(open(os.path.join(self.buildpath, "ArmPLC_rom.bin"), "rb").read(size)).hexdigest() + '\n' +\
"""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):
os.remove(self._GetBinMD5FileName())
return toolchain_makefile.ResetBinaryCodeMD5(self)
def GetBinaryCodeMD5(self, mode):
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")
self.CTRInstance.logger.write(
_("Binary is %s bytes long\n")%
os.path.join(self.buildpath, "ArmPLC_rom.bin"))))