How to use the esptool.write_flash function in esptool

To help you get started, we’ve selected a few esptool examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws / amazon-freertos / vendors / espressif / esp-idf / tools / tiny-test-fw / IDF / IDFDUT.py View on Github external
flash_args = FlashArgs({
                'flash_size': self.app.flash_settings["flash_size"],
                'flash_mode': self.app.flash_settings["flash_mode"],
                'flash_freq': self.app.flash_settings["flash_freq"],
                'addr_filename': flash_files,
                'no_stub': False,
                'compress': True,
                'verify': False,
                'encrypt': False,
                'erase_all': False,
            })

            esp.change_baud(baud_rate)
            esptool.detect_flash_size(esp, flash_args)
            esptool.write_flash(esp, flash_args)
        finally:
            for (_, f) in flash_files:
                f.close()
github Blinkinlabs / EightByEight / test / espflasher.py View on Github external
class argsStub():
			def __init__(self, address, filename):
				self.flash_mode = 'qio'
				self.flash_size = '4m'
				self.flash_freq='40m'
				self.baud=115200
				self.no_progress=False
				self.operation='write_flash'
				self.verify=False
				self.addr_filename = []
				argfile = open(filename, 'rb')
				self.addr_filename.append((address,argfile))

		args = argsStub(address, filename)
		return esptool.write_flash(device, args)
github BetaRavener / uPyLoader / flash.py View on Github external
# Erase flash
        esptool.erase_flash(esp, args)

    if not firmware_file:
        return

    # Reconnect
    esp.connect()

    # Prepare arguments for writing flash
    address = 0
    args.flash_size = "detect"
    args.addr_filename = [(address, open(firmware_file, "rb"))]

    # Write flash
    esptool.write_flash(esp, args)
    print "Done writing new firmware."
github espressif / esp-idf / tools / ci / python_packages / ttfw_idf / IDFDUT.py View on Github external
flash_args = FlashArgs({
                'flash_size': self.app.flash_settings["flash_size"],
                'flash_mode': self.app.flash_settings["flash_mode"],
                'flash_freq': self.app.flash_settings["flash_freq"],
                'addr_filename': flash_files,
                'no_stub': False,
                'compress': True,
                'verify': False,
                'encrypt': self.app.flash_settings.get("encrypt", False),
                'erase_all': False,
            })

            esp.change_baud(baud_rate)
            esptool.detect_flash_size(esp, flash_args)
            esptool.write_flash(esp, flash_args)
        finally:
            for (_, f) in flash_files:
                f.close()
github pycom / pycom-micropython-sigfox / esp32 / tools / fw_updater / updater.py View on Github external
args.compress = compress
        args.verify = False
        args.no_stub = False
        if args.flash_size == 'detect':
            esptool.detect_flash_size(self.esp, args)
            self.__flash_size = args.flash_size
        self.set_baudrate(False)

        fmap = cStringIO.StringIO(contents)
        args.addr_filename = [[offset, fmap]]
        if std_out is not None:
            sys.stdout = std_out
        first_exception = None
        for x in range(0, 3):
            try:
                esptool.write_flash(self.esp, args, ui_label=ui_label, file_name=file_name, resultUpdateList=self.__resultUpdateList if updateList else None, partition=self.partition_name(offset), progress_fs=self.__progress_fs)
                fmap.close()
                return
            except AttributeError as ae:
                print_exc(ae)
                raise RuntimeError('Content at offset 0x%x does not fit available flash size of %s' % (offset, args.flash_size))
            except Exception as e:
                print_debug("Exception in write: {}".format(e), self.__debug)
                if x == 0:
                    first_exception = e
        fmap.close()
        if first_exception is not None:
            raise first_exception
github pycom / pycom-micropython-sigfox / esp32 / tools / fw_updater / updater.py View on Github external
args.flash_freq = FLASH_FREQ
        args.compress = True
        args.verify = True

        if args.flash_size == 'detect':
            esptool.detect_flash_size(self.esp, args)
            self.__flash_size = args.flash_size
            
        dest_and_file = list(dest_and_file_pairs)

        for i, el in enumerate(dest_and_file):
            dest_and_file[i][1] = open(el[1], "rb")

        args.addr_filename = dest_and_file

        esptool.write_flash(self.esp, args, ui_label=ui_label, file_name=file_name, resultUpdateList=self.__resultUpdateList, progress_fs=progress_fs)