targets/LPC/__init__.py
author Lolitech
Wed, 02 Jun 2010 16:40:06 +0200
changeset 540 bacc1314fee6
parent 538 ad05f27222cd
child 571 427bf9130d12
permissions -rwxr-xr-x
Overloaded GetBinaryCode in LPC connector returns ready to send over serial binary
540
bacc1314fee6 Overloaded GetBinaryCode in LPC connector returns ready to send over serial binary
Lolitech
parents: 538
diff changeset
     1
import os
bacc1314fee6 Overloaded GetBinaryCode in LPC connector returns ready to send over serial binary
Lolitech
parents: 538
diff changeset
     2
from subprocess import Popen,PIPE
425
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
     3
from .. import toolchain_makefile
540
bacc1314fee6 Overloaded GetBinaryCode in LPC connector returns ready to send over serial binary
Lolitech
parents: 538
diff changeset
     4
import hashlib
425
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
     5
489
e3adb9f63171 Name error in LPC target fixed
laurent
parents: 478
diff changeset
     6
class LPC_target(toolchain_makefile):
425
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
     7
    extension = ".ld"
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
     8
    DebugEnabled = False
538
ad05f27222cd Moved LPC specific code from toolchain_makefile into LPC target, added FROM_BEREMIZ variable to tell LPC's makefile it is invoked from here.
edouard
parents: 508
diff changeset
     9
ad05f27222cd Moved LPC specific code from toolchain_makefile into LPC target, added FROM_BEREMIZ variable to tell LPC's makefile it is invoked from here.
edouard
parents: 508
diff changeset
    10
    def GetBinaryCode(self):
540
bacc1314fee6 Overloaded GetBinaryCode in LPC connector returns ready to send over serial binary
Lolitech
parents: 538
diff changeset
    11
        """Returns ready to send signed + sized intel formated hex program"""
538
ad05f27222cd Moved LPC specific code from toolchain_makefile into LPC target, added FROM_BEREMIZ variable to tell LPC's makefile it is invoked from here.
edouard
parents: 508
diff changeset
    12
        try:
540
bacc1314fee6 Overloaded GetBinaryCode in LPC connector returns ready to send over serial binary
Lolitech
parents: 538
diff changeset
    13
            size = int(Popen(
bacc1314fee6 Overloaded GetBinaryCode in LPC connector returns ready to send over serial binary
Lolitech
parents: 538
diff changeset
    14
                 ['arm-elf-size','-B',os.path.join(self.buildpath,"ArmPLC_rom.elf")],
bacc1314fee6 Overloaded GetBinaryCode in LPC connector returns ready to send over serial binary
Lolitech
parents: 538
diff changeset
    15
                 stdout=PIPE).communicate()[0].splitlines()[1].split()[0])
bacc1314fee6 Overloaded GetBinaryCode in LPC connector returns ready to send over serial binary
Lolitech
parents: 538
diff changeset
    16
            res = "&" + hashlib.md5(open(os.path.join(self.buildpath, "ArmPLC_rom.bin"), "rb").read(size)).hexdigest() + '\n' +\
bacc1314fee6 Overloaded GetBinaryCode in LPC connector returns ready to send over serial binary
Lolitech
parents: 538
diff changeset
    17
                   "$" + str(size) + '\n' +\
bacc1314fee6 Overloaded GetBinaryCode in LPC connector returns ready to send over serial binary
Lolitech
parents: 538
diff changeset
    18
                   open(os.path.join(self.buildpath, "ArmPLC_rom.hex"), "r").read()
bacc1314fee6 Overloaded GetBinaryCode in LPC connector returns ready to send over serial binary
Lolitech
parents: 538
diff changeset
    19
            return res
538
ad05f27222cd Moved LPC specific code from toolchain_makefile into LPC target, added FROM_BEREMIZ variable to tell LPC's makefile it is invoked from here.
edouard
parents: 508
diff changeset
    20
        except Exception, e:
ad05f27222cd Moved LPC specific code from toolchain_makefile into LPC target, added FROM_BEREMIZ variable to tell LPC's makefile it is invoked from here.
edouard
parents: 508
diff changeset
    21
            return None
540
bacc1314fee6 Overloaded GetBinaryCode in LPC connector returns ready to send over serial binary
Lolitech
parents: 538
diff changeset
    22