p.wait() time.sleep(1) print "Programming done" if not noReset: print "Now resetting EEPROM to defaults" # reset EEPROM to defaults configFile = util.scriptPath() + '/settings/config.cfg' config = util.readCfgWithDefaults(configFile) config_copy = config if 'socket:' in config['port']: print "Socket configured as serial port, using auto detect to find USB serial" config_copy['port'] = 'auto' programmer = SerialProgrammer.create(config_copy, device_type) # open serial port print "Opening serial port to reset factory defaults" if not programmer.open_serial_with_retry(config_copy, 57600, 1): print "Could not open serial port after programming" else: programmer.fetch_version("Success! ") time.sleep(5) programmer.reset_settings(testMode) # update serial ports here so device will not be seen as new serialPorts = list(autoSerial.find_compatible_serial_ports()) else: print "found DFU device, but no binary specified for flashing" if not multi: break else:
print "Programming done" if not noReset: print "Now resetting EEPROM to defaults" # reset EEPROM to defaults configFile = util.scriptPath() + '/settings/config.cfg' config = util.readCfgWithDefaults(configFile) config_copy = config if 'socket:' in config['port']: print "Socket configured as serial port, using auto detect to find USB serial" config_copy['port'] = 'auto' raw_input("Press Enter to continue...") programmer = SerialProgrammer.create(config_copy, device_type) # open serial port print "Opening serial port to reset factory defaults" if not programmer.open_serial_with_retry(config_copy, 57600, 1): print "Could not open serial port after programming" else: programmer.fetch_version("Success! ") time.sleep(5) programmer.reset_settings(testMode) # update serial ports here so device will not be seen as new serialPorts = list(autoSerial.find_compatible_serial_ports()) else: print "found DFU device, but no binary specified for flashing" if not multi: break else:
print "Continuing updating system firmware for the Photon, part 2: {0}".format(system2) p = subprocess.Popen(dfuPath + " -d 2b04:d006 -a 0 -s 0x8060000 -D {0}".format(system2), shell=True) p.wait() print "Now writing BrewPi firmware {0} to Photon".format(binFile) p = subprocess.Popen(dfuPath + " -d 0x2B04:0xD006 -a 0 -s 0x80A0000:leave -D {0}".format(binFile), shell=True) p.wait() print "Programming done" if not noReset: print "Now resetting EEPROM to defaults" # reset EEPROM to defaults configFile = util.scriptPath() + '/settings/config.cfg' config = util.readCfgWithDefaults(configFile) programmer = SerialProgrammer.create(config, type) # open serial port print "Opening serial port" if not programmer.open_serial_with_retry(config, 57600, 1): print "Could not open serial port after programming" else: programmer.fetch_version("Success! ") time.sleep(5) programmer.reset_settings(testMode) serialPorts = list(autoSerial.find_compatible_serial_ports()) # update serial ports here so device will not be seen as new else: print "found DFU device, but no binary specified for flashing" if not multi: break
binFile) p = subprocess.Popen( dfuPath + " -d 0x2B04:0xD006 -a 0 -s 0x80A0000:leave -D {0}".format( binFile), shell=True) p.wait() print "Programming done" if not noReset: print "Now resetting EEPROM to defaults" # reset EEPROM to defaults configFile = util.scriptPath() + '/settings/config.cfg' config = util.readCfgWithDefaults(configFile) programmer = SerialProgrammer.create(config, type) # open serial port print "Opening serial port" if not programmer.open_serial_with_retry(config, 57600, 1): print "Could not open serial port after programming" else: programmer.fetch_version("Success! ") time.sleep(5) programmer.reset_settings(testMode) serialPorts = list( autoSerial.find_compatible_serial_ports() ) # update serial ports here so device will not be seen as new else: print "found DFU device, but no binary specified for flashing"
shell=True) p.wait() print "Now writing BrewPi firmware {0}".format(binFile) p = subprocess.Popen( dfuPath + " -d 0x2B04:0xD006 -a 0 -s 0x80A0000:leave -D {0}".format( binFile), shell=True) p.wait() print "Programming done, now resetting EEPROM to defaults" # reset EEPROM to defaults configFile = util.scriptPath() + '/settings/config.cfg' config = util.readCfgWithDefaults(configFile) programmer = SerialProgrammer.create(config, "core") # open serial port print "Opening serial port" retries = 10 while retries > 0: if programmer.open_serial(config, 57600, 0.2): break retries -= 1 time.sleep(1) if retries > 0: programmer.fetch_version("Success! ") programmer.reset_settings(testMode) serialPorts = autoSerial.detect_all_ports( ) # update serial ports here so device will not be seen as new else:
p.wait() output, errors = p.communicate() if errors: print errors if "Found" in output: # found a DFU device, flash the binary file to it if binFile: print "found DFU device, now flashing %s \n\n" % binFile p = subprocess.Popen(dfuPath + " dfu-util -d 1d50:607f -a 0 -s 0x08005000:leave -D %s" % binFile, shell=True) p.wait() # reset EEPROM to defaults configFile = util.scriptPath() + '/settings/config.cfg' config = util.readCfgWithDefaults(configFile) programmer = SerialProgrammer.create(config, "spark-core") # open serial port retries = 30 while retries > 0: time.sleep(1) if programmer.open_serial(config, 57600, 0.2): break retries -= 1 if retries > 0: programmer.fetch_version("Success! ") programmer.reset_settings() print "Programming done!" else: print "Could not open serial port after programming" else:
if system1: print "First updating system firmware for the Photon" p = subprocess.Popen(dfuPath + " -d 2b04:d006 -a 0 -s 0x8020000 -D {0}".format(system1), shell=True) p.wait() p = subprocess.Popen(dfuPath + " -d 2b04:d006 -a 0 -s 0x8060000 -D {0}".format(system2), shell=True) p.wait() print "Now writing BrewPi firmware {0}".format(binFile) p = subprocess.Popen(dfuPath + " -d 0x2B04:0xD006 -a 0 -s 0x80A0000:leave -D {0}".format(binFile), shell=True) p.wait() print "Programming done, now resetting EEPROM to defaults" # reset EEPROM to defaults configFile = util.scriptPath() + '/settings/config.cfg' config = util.readCfgWithDefaults(configFile) programmer = SerialProgrammer.create(config, "core") # open serial port print "Opening serial port" retries = 10 while retries > 0: if programmer.open_serial(config, 57600, 0.2): break retries -= 1 time.sleep(1) if retries > 0: programmer.fetch_version("Success! ") programmer.reset_settings(testMode) serialPorts = autoSerial.detect_all_ports() # update serial ports here so device will not be seen as new else: print "Could not open serial port after programming"