All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot]  arm: socfpga: script for installing u-boot / u-boot-SPL
Date: Tue, 25 Nov 2014 12:14:38 +0100	[thread overview]
Message-ID: <20141125111438.GA22167@amd> (raw)
In-Reply-To: <201411131402.59132.marex@denx.de>

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@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

  reply	other threads:[~2014-11-25 11:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-11 20:45 [U-Boot] arm: socfpga: set skew settings for ethernet phy dinguyen at opensource.altera.com
2014-11-13 12:09 ` Pavel Machek
2014-11-13 12:20   ` Wolfgang Denk
2014-11-13 12:25     ` Pavel Machek
2014-11-13 12:32       ` Albert ARIBAUD
2014-11-13 12:48         ` Pavel Machek
2014-11-13 13:02           ` Marek Vasut
2014-11-25 11:14             ` Pavel Machek [this message]
2014-11-25 15:28               ` [U-Boot] arm: socfpga: script for installing u-boot / u-boot-SPL Marek Vasut

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141125111438.GA22167@amd \
    --to=pavel@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.