Beispiel #1
0
 if device is None:
     print "Error: You must specify a device.\n"
     showUsage()
 if filename is None:
     print "Error: You must specify a filename.\n"
     showUsage()
 # Add default extension to filename if the unadorned version does not exist
 if not exists(filename):
     name, ext = splitext(filename)
     if ext == "":
         filename = name + ".hex"
 if not exists(filename):
     print "Error: You must specify a filename.\n"
     showUsage()
 # Set up the device interface
 mb = Microboot()
 info = mb.getDeviceInfo(device)
 if info is None:
     print "Unsupported device type '%s'." % device
     exit(1)
 # Set up logging if requested
 if g_logFile is not None:
     mb.logger = logFunction
 # Load the HEX file
 hexfile = IntelHex()
 hexfile.fromfile(filename, format='hex')
 if device == "attiny85":
     # Adjust the code to move the RESET vector
     hexfile = adjustStartup(info, hexfile)
 # Set up for the write
 start = hexfile.minaddr()
Beispiel #2
0
 # Rationalise parameters
 if device is None:
     print "Error: You must specify a device.\n"
     showUsage()
 if not command in ("read", "write"):
     print "Error: Command must be one of 'read' or 'write'.\n"
     showUsage()
 if (command == "write") and (filename is None) and (not random):
     print "Error: You must specify an input file or --random with the 'write' command\n"
     showUsage()
 # Show information
 print "Device    : %s" % device
 print "Block size: %d" % blocksize
 print "Operation : %s" % command
 # Set up the interface
 mb = Microboot()
 info = mb.getDeviceInfo(device)
 if info is None:
     print "Error: Unsupported device type '%s'." % device
     exit(1)
 mb.DATA_SIZE = blocksize
 # Do the task
 if command == "read":
     if start is None:
         start = info[3]
     if length is None:
         length = info[4] - start + 1
     # Show data range being read
     print "Start Addr: %04X" % start
     print "Byte count: %04X (%d)" % (length, length)
     # Make sure the range is valid for the device
Beispiel #3
0
 if device is None:
   print "Error: You must specify a device.\n"
   showUsage()
 if filename is None:
   print "Error: You must specify a filename.\n"
   showUsage()
 # Add default extension to filename if the unadorned version does not exist
 if not exists(filename):
   name, ext = splitext(filename)
   if ext == "":
     filename = name + ".hex"
 if not exists(filename):
   print "Error: You must specify a filename.\n"
   showUsage()
 # Set up the device interface
 mb = Microboot()
 info = mb.getDeviceInfo(device)
 if info is None:
   print "Unsupported device type '%s'." % device
   exit(1)
 # Set up logging if requested
 if g_logFile is not None:
   mb.logger = logFunction
 # Load the HEX file
 hexfile = IntelHex()
 hexfile.fromfile(filename, format='hex')
 if device == "attiny85":
   # Adjust the code to move the RESET vector
   hexfile = adjustStartup(info, hexfile)
 # Set up for the write
 start = hexfile.minaddr()
Beispiel #4
0
     if index <> len(sys.argv):
       print "Error: Filename must be the last parameter.\n"
       showUsage()
   index = index + 1
 # Rationalise parameters
 if device is None:
   print "Error: You must specify a device.\n"
   showUsage()
 if filename is None:
   filename = device + ".hex"
 # Add default extension to filename
 name, ext = splitext(filename)
 if ext == "":
   filename = name + ".hex"
 # Set up the device interface
 mb = Microboot()
 info = mb.getDeviceInfo(device)
 if info is None:
   print "Unsupported device type '%s'." % device
 # Show what we are doing
 size = info[4] - info[3] + 1
 print "Reading %d bytes (0x%04X:0x%04X) from '%s' on '%s'." % (size, info[3], info[4], device, port)
 # Set up logging if requested
 if g_logFile is not None:
   mb.logger = logFunction
 # Connect to the device
 mb.connect(device, port)
 # Read everything
 data = mb.read(info[3], size)
 mb.disconnect()
 # Create the HEX file
Beispiel #5
0
         if index <> len(sys.argv):
             print "Error: Filename must be the last parameter.\n"
             showUsage()
     index = index + 1
 # Rationalise parameters
 if device is None:
     print "Error: You must specify a device.\n"
     showUsage()
 if filename is None:
     filename = device + ".hex"
 # Add default extension to filename
 name, ext = splitext(filename)
 if ext == "":
     filename = name + ".hex"
 # Set up the device interface
 mb = Microboot()
 info = mb.getDeviceInfo(device)
 if info is None:
     print "Unsupported device type '%s'." % device
 # Show what we are doing
 size = info[4] - info[3] + 1
 print "Reading %d bytes (0x%04X:0x%04X) from '%s' on '%s'." % (
     size, info[3], info[4], device, port)
 # Set up logging if requested
 if g_logFile is not None:
     mb.logger = logFunction
 # Connect to the device
 mb.connect(device, port)
 # Read everything
 data = None
 beginProgress("Reading")
 # Rationalise parameters
 if device is None:
   print "Error: You must specify a device.\n"
   showUsage()
 if not command in ("read", "write"):
   print "Error: Command must be one of 'read' or 'write'.\n"
   showUsage()
 if (command == "write") and (filename is None) and (not random):
   print "Error: You must specify an input file or --random with the 'write' command\n"
   showUsage()
 # Show information
 print "Device    : %s" % device
 print "Block size: %d" % blocksize
 print "Operation : %s" % command
 # Set up the interface
 mb = Microboot()
 info = mb.getDeviceInfo(device)
 if info is None:
   print "Error: Unsupported device type '%s'." % device
   exit(1)
 mb.DATA_SIZE = blocksize
 # Do the task
 if command == "read":
   if start is None:
     start = info[3]
   if length is None:
     length = info[4] - start + 1
   # Show data range being read
   print "Start Addr: %04X" % start
   print "Byte count: %04X (%d)" % (length, length)
   # Make sure the range is valid for the device