From: Anton Blanchard Date: Sat, 11 Jan 2020 10:31:48 +0000 (+1100) Subject: Move bin2hex.py to scripts/ X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9362f2dd100486ee6c1d4518f7adbcf18ec9832f;p=microwatt.git Move bin2hex.py to scripts/ Signed-off-by: Anton Blanchard --- diff --git a/hello_world/Makefile b/hello_world/Makefile index 12daea2..89f3e00 100644 --- a/hello_world/Makefile +++ b/hello_world/Makefile @@ -22,7 +22,7 @@ hello_world.bin: hello_world.elf $(OBJCOPY) -O binary hello_world.elf hello_world.bin hello_world.hex: hello_world.bin - ./bin2hex.py hello_world.bin > hello_world.hex + ../scripts/bin2hex.py hello_world.bin > hello_world.hex clean: @rm -f *.o hello_world.elf hello_world.bin hello_world.hex diff --git a/hello_world/bin2hex.py b/hello_world/bin2hex.py deleted file mode 100755 index af278bc..0000000 --- a/hello_world/bin2hex.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/python3 - -import sys -import subprocess -import struct - -with open(sys.argv[1], "rb") as f: - while True: - word = f.read(8) - if len(word) == 8: - print("%016x" % struct.unpack('Q', word)); - elif len(word) == 4: - print("00000000%08x" % struct.unpack('I', word)); - elif len(word) == 0: - exit(0); - else: - raise Exception("Bad length") diff --git a/scripts/bin2hex.py b/scripts/bin2hex.py new file mode 100755 index 0000000..af278bc --- /dev/null +++ b/scripts/bin2hex.py @@ -0,0 +1,17 @@ +#!/usr/bin/python3 + +import sys +import subprocess +import struct + +with open(sys.argv[1], "rb") as f: + while True: + word = f.read(8) + if len(word) == 8: + print("%016x" % struct.unpack('Q', word)); + elif len(word) == 4: + print("00000000%08x" % struct.unpack('I', word)); + elif len(word) == 0: + exit(0); + else: + raise Exception("Bad length")