class documentation

Flash firmware to an ESP32 ROM bootloader.

Method __init__ Initialize the ESP32 flasher.
Method bootloader Enter the ESP32 ROM bootloader download mode.
Method flash_attach Attach the ESP32 SPI flash chip.
Method flash_config Configure the ESP32 flash geometry.
Method flash_read_size Read and return the connected ESP32 flash size.
Method flash_verify_file Verify a firmware file against the ESP32 flash contents.
Method flash_write_file Write a firmware file to the ESP32 flash chip.
Method reboot Reboot the ESP32 after flashing.
Method set_baudrate Set the ESP32 and UART communication baud rate.
Instance Variable baudrate Undocumented
Instance Variable chip Undocumented
Instance Variable gpio0_pin Undocumented
Instance Variable log Undocumented
Instance Variable md5sum Undocumented
Instance Variable reset_pin Undocumented
Instance Variable uart Undocumented
Method _checksum Calculate the ESP32 packet checksum.
Method _clear_uart Clear UART input and buffered SLIP data.
Method _command Send a command and return its response.
Method _detach_repl_uart Detach the flasher UART from the MicroPython REPL.
Method _log Log a packet when diagnostics are enabled.
Method _poll_reg Poll a flash register until a flag clears.
Method _read_reg Read a value from an ESP32 flash register.
Method _read_slip Read and decode one SLIP packet from the ESP32.
Method _restore_repl_uart Restore the MicroPython REPL UART.
Method _strerror Return a human-readable ESP32 error message.
Method _write_reg Write a value to an ESP32 flash register.
Method _write_slip Write a SLIP-encoded packet to the ESP32.
Instance Variable _flash_reg_base Undocumented
Instance Variable _pyb Undocumented
Instance Variable _repl_uart Undocumented
Instance Variable _slip_buffer Undocumented
Instance Variable _spi_dlen Undocumented
Instance Variable _spi_usr Undocumented
Instance Variable _spi_usr2 Undocumented
Instance Variable _spi_w0 Undocumented
def __init__(self, reset, gpio0, uart: UART, log_enabled=False, chip='esp32'):

Initialize the ESP32 flasher.

Parameters
reset:callableFunction used to control the ESP32 reset pin.
gpio0:callableFunction used to control the ESP32 GPIO0 pin.
uart:UARTPicoware UART interface connected to the ESP32.
log_enabled:boolWhether to print packet diagnostics. Defaults to False.
chip:strESP ROM target. Defaults to "esp32".
def bootloader(self, retry=6):

Enter the ESP32 ROM bootloader download mode.

Parameters
retry:intNumber of reset attempts. Defaults to 6.
Returns
boolTrue after synchronization succeeds.
def flash_attach(self):

Attach the ESP32 SPI flash chip.

def flash_config(self, flash_size=2 * 1024 * 1024):

Configure the ESP32 flash geometry.

Parameters
flash_size:intFlash size in bytes. Defaults to 2 * 1024 * 1024.
def flash_read_size(self):

Read and return the connected ESP32 flash size.

Returns
intFlash size in bytes.
def flash_verify_file(self, path, digest=None, offset=0):

Verify a firmware file against the ESP32 flash contents.

Parameters
path:strPath to the firmware image.
digest:bytes or NoneExpected hexadecimal MD5 digest. Defaults to None.
offset:intFlash offset to verify. Defaults to 0.
def flash_write_file(self, path, blksize=_FLASH_WRITE_SIZE, progress_interval=_FLASH_PROGRESS_INTERVAL):

Write a firmware file to the ESP32 flash chip.

Parameters
path:strPath to the firmware image.
blksize:intNumber of bytes in each transfer block. Must be 4-byte aligned and no larger than the ESP32 ROM limit of 0x400. Defaults to 0x400.
progress_interval:intNumber of blocks between progress messages. Defaults to 64.
def reboot(self):

Reboot the ESP32 after flashing.

def set_baudrate(self, baudrate, timeout=350):

Set the ESP32 and UART communication baud rate.

Parameters
baudrate:intNew baud rate.
timeout:intUnused compatibility argument. Defaults to 350.
baudrate =

Undocumented

chip =

Undocumented

gpio0_pin =

Undocumented

log =

Undocumented

md5sum =

Undocumented

reset_pin =

Undocumented

uart =

Undocumented

def _checksum(self, data):

Calculate the ESP32 packet checksum.

Parameters
data:bytesPacket data.
Returns
intCalculated checksum.
def _clear_uart(self):

Clear UART input and buffered SLIP data.

def _command(self, cmd, payload=b'', checksum=0, timeout_ms=3000):

Send a command and return its response.

Parameters
cmd:intESP32 ROM bootloader command.
payload:bytesCommand payload. Defaults to b"".
checksum:intPayload checksum. Defaults to 0.
timeout_msUndocumented
Returns
tupleResponse value and response data.
def _detach_repl_uart(self):

Detach the flasher UART from the MicroPython REPL.

def _log(self, data, out=True):

Log a packet when diagnostics are enabled.

Parameters
data:bytesPacket data to log.
out:boolWhether the packet is outgoing. Defaults to True.
def _poll_reg(self, addr, flag, retry=10, delay=0.05):

Poll a flash register until a flag clears.

Parameters
addr:intRegister offset from the flash register base.
flag:intBit flag to wait for.
retry:intMaximum number of reads. Defaults to 10.
delay:floatDelay between reads in seconds. Defaults to 0.050.
def _read_reg(self, addr):

Read a value from an ESP32 flash register.

Parameters
addr:intRegister offset from the flash register base.
Returns
intRegister value.
def _read_slip(self, timeout_ms=1000):

Read and decode one SLIP packet from the ESP32.

Parameters
timeout_ms:intMaximum time to wait for a complete packet.
Returns
bytearray or NoneDecoded packet, or None if no packet is available.
def _restore_repl_uart(self):

Restore the MicroPython REPL UART.

def _strerror(self, err):

Return a human-readable ESP32 error message.

Parameters
err:intESP32 error code.
Returns
strError description.
def _write_reg(self, addr, data, mask=4294967295, delay=0):

Write a value to an ESP32 flash register.

Parameters
addr:intRegister offset from the flash register base.
data:intValue to write.
mask:intRegister write mask. Defaults to 0xFFFFFFFF.
delay:intHardware delay value. Defaults to 0.
def _write_slip(self, pkt):

Write a SLIP-encoded packet to the ESP32.

Parameters
pkt:bytesPacket data to encode and write.
_flash_reg_base: int =

Undocumented

_pyb =

Undocumented

_repl_uart =

Undocumented

_slip_buffer =

Undocumented

_spi_dlen: int =

Undocumented

_spi_usr: int =

Undocumented

_spi_usr2: int =

Undocumented

_spi_w0: int =

Undocumented