[U-Boot] arm: socfpga: script for installing u-boot / u-boot-SPL
Pavel Machek
pavel at denx.de
Tue Nov 25 12:14:38 CET 2014
It is very easy to overwrite partition on your harddrive when all you
want is installing new u-boot(-SPL). Plus... figuring out needed steps
for installation is not trivial, either. This automates installation,
and provides safety net by checking signature on existing partition.
[I managed to overwrite partition once, and in second incident second
mistake -- -EPERM -- saved my data]
Signed-off-by: Pavel Machek <pavel at denx.de>
diff --git a/tools/socfpga_install b/tools/socfpga_install
new file mode 100755
index 0000000..b62d3e77
--- /dev/null
+++ b/tools/socfpga_install
@@ -0,0 +1,39 @@
+#!/usr/bin/python3
+
+import subprocess
+import sys
+import os
+
+print("install device ", sys.argv[1])
+device = open(sys.argv[1], "r+b")
+
+sig = device.read(0x44)
+if sig[0x40] != 0x41 or sig[0x41] != 0x53 or \
+ sig[0x42] != 0x30 or sig[0x43] != 0x31:
+ print("Do not see AS01 signature, do you have right partition?")
+ sys.exit(1)
+
+print("u-boot-spl.bin at ", sys.argv[2])
+spl = sys.argv[2]
+
+res = subprocess.check_call(["tools/mkimage", "-T", "socfpgaimage", "-d", spl, "img.tmp"])
+if res != 0:
+ print("mkimage failed.")
+ sys.exit(1)
+device.seek(0)
+
+spl_bin = open("img.tmp", "rb").read()
+if len(spl_bin) != 65536:
+ print("Preloader image has wrong length.")
+ sys.exit(1)
+
+device.write(spl_bin)
+device.write(spl_bin)
+device.write(spl_bin)
+device.write(spl_bin)
+
+print("u-boot.img at ", sys.argv[3])
+uboot_bin = open(sys.argv[3], "rb").read()
+print("Have u-boot, %d bytes" % len(uboot_bin))
+device.write(uboot_bin)
+print("All done.")
\ No newline at end of file
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
More information about the U-Boot
mailing list