start = hexfile.minaddr() length = (hexfile.maxaddr() - start) + 1 data = list() for index in range(length): data.append(hexfile[start + index]) print "Writing %d bytes (%04X:%04X) from file '%s'." % ( length, start, start + length - 1, filename) print "Target is a '%s' on port '%s'." % (device, port) # Write the data try: mb.connect(device, port) except Exception, ex: print "Error: Could not connect to device, error message is:" print " " + str(ex) exit(1) beginProgress("Writing") try: mb.write(start, length, data, updateProgress) except Exception, ex: endProgress() print "Error: Writing to flash failed, error message is:" print " " + str(ex) exit(1) endProgress() # Now verify beginProgress("Verifying") try: mb.verify(start, length, data, updateProgress) except Exception, ex: endProgress() print "Error: Verification failed, error message is:"
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") try: data = mb.read(info[3], size, updateProgress) except Exception, ex: endProgress() print "Error: Reading failed, error message is:" print " " + str(ex) exit(1) endProgress() mb.disconnect() # Create the HEX file hexfile = IntelHex() address = info[3] for val in data: hexfile[address] = val address = address + 1
# Set up for the write start = hexfile.minaddr() length = (hexfile.maxaddr() - start) + 1 data = list() for index in range(length): data.append(hexfile[start + index]) print "Writing %d bytes (%04X:%04X) from file '%s'." % (length, start, start + length - 1, filename) print "Target is a '%s' on port '%s'." % (device, port) # Write the data try: mb.connect(device, port) except Exception, ex: print "Error: Could not connect to device, error message is:" print " " + str(ex) exit(1) beginProgress("Writing") try: mb.write(start, length, data, updateProgress) except Exception, ex: endProgress() print "Error: Writing to flash failed, error message is:" print " " + str(ex) exit(1) endProgress() # Now verify beginProgress("Verifying") try: mb.verify(start, length, data, updateProgress) except Exception, ex: endProgress() print "Error: Verification failed, error message is:"
# 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") try: data = mb.read(info[3], size, updateProgress) except Exception, ex: endProgress() print "Error: Reading failed, error message is:" print " " + str(ex) exit(1) endProgress() mb.disconnect() # Create the HEX file hexfile = IntelHex() address = info[3] for val in data: hexfile[address] = val address = address + 1