summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoakim Bech <joakim.bech@linaro.org>2016-09-02 17:22:35 +0200
committerJoakim Bech <joakim.bech@linaro.org>2016-09-02 20:37:09 +0200
commitd79bdc3055caa51e7b19643a709dda27285251a6 (patch)
tree5072b60ca19481f0424d5457963acbc1f355c7a1
parent4df2b47ace2f962ebd0e2fb7b3def646fa22ba85 (diff)
Ability to erase boot image trailer
Signed-off-by: Joakim Bech <joakim.bech@linaro.org>
-rwxr-xr-xzep2newt.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/zep2newt.py b/zep2newt.py
index b2b5354..7ed1ada 100755
--- a/zep2newt.py
+++ b/zep2newt.py
@@ -97,8 +97,8 @@ def create_jlink_script(image_file, offset, erase):
f.write("loadfile %s %s\n" % (image_file, hex(int(offset, 16))))
f.write("q\n")
f.close()
- print("To flash the Image for nrf52 using Jlink run:")
- print(" JLinkExe -CommanderScript flash_zephyr.jlink")
+ print("\nTo flash the Image for nrf52 run:")
+ print(" $ JLinkExe -CommanderScript flash_zephyr.jlink")
def create_jlink_bit_script(bit_file, bitoffset="0x7bff8"):
with open("flash_bit.jlink", "w+") as f:
@@ -110,9 +110,21 @@ def create_jlink_bit_script(bit_file, bitoffset="0x7bff8"):
f.write("loadfile %s %s\n" % (bit_file, hex(int(bitoffset, 16))))
f.write("q\n")
f.close()
- print("To flash Boot Image Trailer for nrf52 using Jlink run:")
- print(" JLinkExe -CommanderScript flash_bit.jlink")
+ print("\nTo flash Boot Image Trailer for nrf52 run:")
+ print(" $ JLinkExe -CommanderScript flash_bit.jlink")
+def create_jlink_clear_bit_script(bit_file, bitoffset="0x7bff8"):
+ with open("flash_clear_bit.jlink", "w+") as f:
+ f.write("device nrf52\n")
+ f.write("power on\n")
+ f.write("sleep 10\n")
+ f.write("si 1\n")
+ f.write("speed auto\n")
+ f.write("loadfile %s %s\n" % (bit_file, hex(int(bitoffset, 16))))
+ f.write("q\n")
+ f.close()
+ print("\nTo flash Boot Image Trailer for nrf52 run:")
+ print(" $ JLinkExe -CommanderScript flash_clear_bit.jlink")
def usage():
print(os.path.basename(sys.argv[0]) + " -b <zephyr.bin> -i <zephyr.img> -o <flash_base_offset> -f")
@@ -164,13 +176,12 @@ def main(argv):
digest = calculate_hash(image_file)
print("Hash of intermediate image: %s" % digest)
-
append_hash(image_file, digest)
create_jlink_script(image_file, offset, erase)
-
curdir = os.path.dirname(sys.argv[0])
create_jlink_bit_script(curdir + "/boot_image_trailer.bin")
+ create_jlink_clear_bit_script(curdir + "/empty_boot_image_trailer.bin")
if try_flash:
os.system("JLinkExe -CommanderScript flash_zephyr.jlink")