summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoakim Bech <joakim.bech@linaro.org>2016-09-02 15:39:46 +0200
committerJoakim Bech <joakim.bech@linaro.org>2016-09-02 20:29:21 +0200
commit461a6f20d8f222a73ab4a24f1b51c93b6713404c (patch)
treeeb00c51d22216264d57047a5f62acf7950ea0d46
parent443aeaefe00383facd114867367def00f8a2d955 (diff)
Implement flash base offset parameter
Signed-off-by: Joakim Bech <joakim.bech@linaro.org>
-rwxr-xr-xzep2newt.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/zep2newt.py b/zep2newt.py
index aa843a7..40010ce 100755
--- a/zep2newt.py
+++ b/zep2newt.py
@@ -79,7 +79,13 @@ def append_hash(image_file, digest):
f.write(digest.decode('hex'))
f.close()
-def create_jlink_script(image_file, erase=False):
+def create_jlink_script(image_file, offset, erase):
+ """
+ Creates a jlink script to flash the created binary.
+
+ @erase: whether the script first shall erase or not when flashing.
+ @offset: where in flash to store the image.
+ """
with open("flash_zephyr.jlink", "w+") as f:
f.write("device nrf52\n")
f.write("power on\n")
@@ -88,7 +94,7 @@ def create_jlink_script(image_file, erase=False):
f.write("speed auto\n")
if erase:
f.write("erase\n")
- f.write("loadfile %s 0x8000\n" % image_file)
+ f.write("loadfile %s %s\n" % (image_file, hex(int(offset, 16))))
f.write("q\n")
f.close()
@@ -104,7 +110,7 @@ def usage():
def main(argv):
binary_file = "zephyr.bin"
image_file = "zephyr.img.bin"
- offset = 0x80
+ offset = "0x8000"
try_flash = False
erase = False
@@ -146,7 +152,7 @@ def main(argv):
append_hash(image_file, digest)
- create_jlink_script(image_file, erase)
+ create_jlink_script(image_file, offset, erase)
if try_flash:
os.system("JLinkExe -CommanderScript flash_zephyr.jlink")