changes merged
authorlaurent
Wed, 02 Jun 2010 16:53:38 +0200
changeset 542 1b0f72deeb99
parent 541 4d9ca788205e (current diff)
parent 540 bacc1314fee6 (diff)
child 543 3dec6ff88620
changes merged
--- a/targets/LPC/__init__.py	Wed Jun 02 16:52:58 2010 +0200
+++ b/targets/LPC/__init__.py	Wed Jun 02 16:53:38 2010 +0200
@@ -1,11 +1,22 @@
+import os
+from subprocess import Popen,PIPE
 from .. import toolchain_makefile
+import hashlib
 
 class LPC_target(toolchain_makefile):
     extension = ".ld"
     DebugEnabled = False
 
     def GetBinaryCode(self):
+        """Returns ready to send signed + sized intel formated hex program"""
         try:
-            return open(os.path.join(self.buildpath, "ArmPLC_rom.bin"), "rb").read()
+            size = int(Popen(
+                 ['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' +\
+                   "$" + str(size) + '\n' +\
+                   open(os.path.join(self.buildpath, "ArmPLC_rom.hex"), "r").read()
+            return res
         except Exception, e:
             return None
+