author | Lolitech |
Fri, 04 Jun 2010 14:59:11 +0200 | |
changeset 556 | 1ad4e7f1e89e |
parent 540 | bacc1314fee6 |
child 571 | 427bf9130d12 |
permissions | -rwxr-xr-x |
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 | 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 | 5 |
|
489 | 6 |
class LPC_target(toolchain_makefile): |
425 | 7 |
extension = ".ld" |
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 |