def __backupFlash(self): """ Private slot to backup the currently flashed firmware. """ from .EspBackupRestoreFirmwareDialog import ( EspBackupRestoreFirmwareDialog) dlg = EspBackupRestoreFirmwareDialog(backupMode=True) if dlg.exec_() == QDialog.Accepted: chip, flashSize, flashMode, firmware = dlg.getData() flashArgs = [ "-u", "-m", "esptool", "--chip", chip, "--port", self.microPython.getCurrentPort(), "read_flash", "0x0", flashSize, firmware, ] dlg = E5ProcessDialog(self.tr("'esptool read_flash' Output"), self.tr("Backup Firmware"), showProgress=True) res = dlg.startProcess(sys.executable, flashArgs) if res: dlg.exec_()
def __flashAddons(self): """ Private slot to flash some additional firmware images. """ from .EspFirmwareSelectionDialog import EspFirmwareSelectionDialog dlg = EspFirmwareSelectionDialog(addon=True) if dlg.exec_() == QDialog.Accepted: chip, firmware, flashAddress = dlg.getData() flashArgs = [ "-u", "-m", "esptool", "--chip", chip, "--port", self.microPython.getCurrentPort(), "write_flash", flashAddress.lower(), firmware, ] dlg = E5ProcessDialog(self.tr("'esptool write_flash' Output"), self.tr("Flash Additional Firmware"), showProgress=True) res = dlg.startProcess(sys.executable, flashArgs) if res: dlg.exec_()
def __flashMicroPython(self): """ Private slot to flash a MicroPython firmware to the device. @exception ValueError raised to indicate an unsupported chip type """ from .EspFirmwareSelectionDialog import EspFirmwareSelectionDialog dlg = EspFirmwareSelectionDialog() if dlg.exec_() == QDialog.Accepted: chip, firmware, _ = dlg.getData() if chip == "esp8266": flashAddress = "0x0000" elif chip == "esp32": flashAddress = "0x1000" else: raise ValueError( self.tr("Unsupported chip type '{0}'.").format(chip)) flashArgs = [ "-u", "-m", "esptool", "--chip", chip, "--port", self.microPython.getCurrentPort(), "write_flash", flashAddress, firmware, ] dlg = E5ProcessDialog(self.tr("'esptool write_flash' Output"), self.tr("Flash MicroPython Firmware"), showProgress=True) res = dlg.startProcess(sys.executable, flashArgs) if res: dlg.exec_()
def __flashMicroPython(self): """ Private slot to flash a MicroPython firmware. """ if self.__dfuUtilAvailable(): ok2continue = self.__showDfuEnableInstructions() if ok2continue: program = Preferences.getMicroPython("DfuUtilPath") if not program: program = "dfu-util" downloadsPath = QStandardPaths.standardLocations( QStandardPaths.DownloadLocation)[0] firmware = E5FileDialog.getOpenFileName( self.microPython, self.tr("Flash MicroPython Firmware"), downloadsPath, self.tr( "MicroPython Firmware Files (*.dfu);;All Files (*)")) if firmware and os.path.exists(firmware): args = [ "--alt", "0", "--download", firmware, ] dlg = E5ProcessDialog( self.tr("'dfu-util' Output"), self.tr("Flash MicroPython Firmware")) res = dlg.startProcess(program, args) if res: dlg.exec_() self.__showDfuDisableInstructions()
def __showMACAddress(self): """ Private slot to show the MAC address of the ESP chip. """ args = [ "-u", "-m", "esptool", "--port", self.microPython.getCurrentPort(), "read_mac" ] dlg = E5ProcessDialog(self.tr("'esptool read_mac' Output"), self.tr("Show MAC Address")) res = dlg.startProcess(sys.executable, args) if res: dlg.exec_()
def __showFlashID(self): """ Private slot to show the ID of the ESP flash chip. """ args = [ "-u", "-m", "esptool", "--port", self.microPython.getCurrentPort(), "flash_id" ] dlg = E5ProcessDialog(self.tr("'esptool flash_id' Output"), self.tr("Show Flash ID")) res = dlg.startProcess(sys.executable, args) if res: dlg.exec_()
def __listDfuCapableDevices(self): """ Private slot to list all DFU-capable devices. """ if self.__dfuUtilAvailable(): ok2continue = self.__showDfuEnableInstructions(flash=False) if ok2continue: program = Preferences.getMicroPython("DfuUtilPath") if not program: program = "dfu-util" args = [ "--list", ] dlg = E5ProcessDialog(self.tr("'dfu-util' Output"), self.tr("List DFU capable Devices")) res = dlg.startProcess(program, args) if res: dlg.exec_()
def __eraseFlash(self): """ Private slot to erase the device flash memory. """ ok = E5MessageBox.yesNo( self.microPython, self.tr("Erase Flash"), self.tr("""Shall the flash of the selected device really be""" """ erased?""")) if ok: flashArgs = [ "-u", "-m", "esptool", "--port", self.microPython.getCurrentPort(), "erase_flash", ] dlg = E5ProcessDialog(self.tr("'esptool erase_flash' Output"), self.tr("Erase Flash"), showProgress=True) res = dlg.startProcess(sys.executable, flashArgs) if res: dlg.exec_()
def __restoreFlash(self): """ Private slot to restore a previously saved firmware. """ from .EspBackupRestoreFirmwareDialog import ( EspBackupRestoreFirmwareDialog) dlg = EspBackupRestoreFirmwareDialog(backupMode=False) if dlg.exec_() == QDialog.Accepted: chip, flashSize, flashMode, firmware = dlg.getData() flashArgs = [ "-u", "-m", "esptool", "--chip", chip, "--port", self.microPython.getCurrentPort(), "write_flash", "--flash_mode", flashMode, ] if bool(flashSize): flashArgs.extend([ "--flash_size", flashSize, ]) flashArgs.extend([ "0x0", firmware, ]) dlg = E5ProcessDialog(self.tr("'esptool write_flash' Output"), self.tr("Restore Firmware"), showProgress=True) res = dlg.startProcess(sys.executable, flashArgs) if res: dlg.exec_()