commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r9063 - usrp2/branches/features/host-ng/firmware


From: eb
Subject: [Commit-gnuradio] r9063 - usrp2/branches/features/host-ng/firmware
Date: Wed, 30 Jul 2008 16:49:18 -0600 (MDT)

Author: eb
Date: 2008-07-30 16:49:17 -0600 (Wed, 30 Jul 2008)
New Revision: 9063

Modified:
   usrp2/branches/features/host-ng/firmware/u2_flash_tool
Log:
added -r read-back option to u2_flash_tool

Modified: usrp2/branches/features/host-ng/firmware/u2_flash_tool
===================================================================
--- usrp2/branches/features/host-ng/firmware/u2_flash_tool      2008-07-30 
22:48:13 UTC (rev 9062)
+++ usrp2/branches/features/host-ng/firmware/u2_flash_tool      2008-07-30 
22:49:17 UTC (rev 9063)
@@ -52,6 +52,13 @@
                 break
     return False
 
+def read_flash(offset, filename, devname):
+    dev = open(devname, "rb")
+    dev.seek(offset, 0)                 # seek to absolute byte offset
+    dev_data = dev.read(MAX_FILE_SIZE)
+    dev.close()
+    open(filename, "wb").write(dev_data)
+
     
 def main():
     parser = OptionParser(usage="%prog: [options] filename")
@@ -59,6 +66,8 @@
                       help="write FILE to TARGET slot")
     parser.add_option("-v", "--verify",  action="store_const", const="verify", 
dest="mode",
                       help="verify FILE against TARGET slot")
+    parser.add_option("-r", "--read",  action="store_const", const="read", 
dest="mode",
+                      help="read TARGET slot, write to FILE")
     parser.add_option("-t", "--target", type="choice", choices=("fpga", 
"s/w"), default="s/w",
                       help="select TARGET slot from: fpga, s/w 
[default=%default]")
     parser.add_option("", "--dev", default=None,
@@ -73,7 +82,7 @@
     filename = args[0]
 
     if options.mode is None:
-        sys.stderr.write("specify mode with -w or -v\n")
+        sys.stderr.write("specify mode with -w, -v or -r\n")
         parser.print_help()
         raise SystemExit
 
@@ -87,8 +96,12 @@
     if options.mode == "write":
         r = (write_flash(offset, filename, options.dev)
              and verify_flash(offset, filename, options.dev))
+    elif options.mode == "verify":
+        r = verify_flash(offset, filename, options.dev)
+    elif options.mode == "read":
+        r = read_flash(offset, filename, options.dev)
     else:
-        r = verify_flash(offset, filename, options.dev)
+        raise NotImplemented
 
     if not r:
         raise SystemExit, 1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]