summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoakim Bech <joakim.bech@linaro.org>2016-08-31 00:12:41 +0200
committerJoakim Bech <joakim.bech@linaro.org>2016-08-31 00:12:41 +0200
commitcc9dacdbd381ba75b3c33b53fae1f2b43c788a8d (patch)
tree891379dbaaa8091b8df5b5b7254c758d93355619
parent2b3184ce247b549e3300386d69191b5c492200ec (diff)
Create flash script for Jlink/nrf52dk
Signed-off-by: Joakim Bech <joakim.bech@linaro.org>
-rwxr-xr-xpatch_mynewt_img.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/patch_mynewt_img.py b/patch_mynewt_img.py
index 634399d..d2f4761 100755
--- a/patch_mynewt_img.py
+++ b/patch_mynewt_img.py
@@ -79,6 +79,14 @@ def append_hash(image_file, digest):
f.write(digest.decode('hex'))
f.close()
+def create_jlink_script(image_file, commander_script="CommanderScript"):
+ with open("flash_zephyr.jlink", "w+") as f:
+ f.write("device nrf52\n")
+ f.write("si 1\n")
+ f.write("speed auto\n")
+ f.write("loadfile %s 0x8000\n" % image_file)
+ f.close()
+
def usage():
print(sys.argv[0] + " -b <zephyr.bin> -i <zephyr.img> -o <offset>")
@@ -86,7 +94,7 @@ def usage():
def main(argv):
binary_file = "zephyr.bin"
- image_file = "zephyr.img"
+ image_file = "zephyr.img.bin"
offset = 0x80
try:
opts, args = getopt.getopt(argv, 'b:i:o:h', ['bin=', 'img=', 'offset=', "help"])
@@ -116,11 +124,15 @@ def main(argv):
hdr = create_header(binary_file)
write_partial_img(binary_file, image_file, hdr)
+
digest = calculate_hash(image_file)
print("Hash of intermediate image: %s" % digest)
append_hash(image_file, digest)
+ create_jlink_script(image_file)
+
+
if __name__ == "__main__":
if sys.argv[1]:
try: