summaryrefslogtreecommitdiff
path: root/uboot2bin/u2b.py
diff options
context:
space:
mode:
Diffstat (limited to 'uboot2bin/u2b.py')
-rw-r--r--uboot2bin/u2b.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/uboot2bin/u2b.py b/uboot2bin/u2b.py
new file mode 100644
index 0000000..4505c98
--- /dev/null
+++ b/uboot2bin/u2b.py
@@ -0,0 +1,43 @@
+#!/usr/bin/python
+import argparse
+import sys
+import os
+
+s="9f000000: 10 00 00 ff 00 00 00 00 10 00 00 fd 00 00 00 00 ................"
+
+def uboot2str(s):
+ ret = ""
+ s = s.replace("\n","")
+ s = s.replace(" ","")
+ ret = s.split(":")[1][:32]
+ return ret
+
+def str2byte(s):
+ ret = []
+ l = len(s)
+ for i in range(0,l,2):
+ num = s[i]+s[i+1]
+ ret.append(int(num,16))
+ return ret
+
+def byte2bfile(f,bytes):
+ ba = bytearray(bytes)
+ f.write(ba)
+
+ap = argparse.ArgumentParser()
+ap.add_argument("--ifile",dest='ifname',action='store',required=True,help="Run test")
+ap.add_argument("--ofile",dest='ofname',action='store',required=True,help="Run test")
+
+if __name__=="__main__":
+ apn = ap.parse_args()
+ args = vars(apn)
+ in_f = open(args["ifname"],"r")
+ if in_f == None:
+ print("Cant open %s"%ifname)
+ out_f = open(args["ofname"],"wb")
+
+ for line in in_f:
+ byte2bfile(out_f,str2byte(uboot2str(line)))
+
+ in_f.close()
+ out_f.close() \ No newline at end of file