ESP32-OTA: Partition.writeblocks with buffer size not multiple of blocksize gives OSError
Hey,
Just realized, that writing data into partition with a data buffer with size != 0 mod BLOCK_SIZE leads to an OSError: -260.
It is due to the erase call esp_partition_erase_range(self->part, offset, bufinfo.len) in
esp32_partition_writeblocks.
I am not sure if this is intended behavior. If not, I would recommend either to return a proper error message or to erase ceil(buffer_size/BLOCK_SIZE) blocks.
esp32: Add esp32.Partition class to interface to OTA functions.
Following on from the comment https://github.com/micropython/micropython/pull/3576#issuecomment-486954865 here is a proposal for a wrapper class for the ESP32 OTA/partition functions.
The API is based around a single Partition class. The constructor is used to create new Partition objects, and methods manipulate such objects.
from esp32 import Partition
# Constructors
Partition(Partition.FIRST, type=Partition.TYPE_APP)
Partition(Partition.FIRST, type=Partition.TYPE_DATA)
Partition(Partition.FIRST, type=Partition.TYPE_DATA, subtype=2, label='nvs')
Partition(Partition.BOOT) # get boot partition
Partition(Partition.RUNNING) # get currently running partition
# Methods
part.info() # returns a 6-tuple of (type, subtype, addr, size, label, encr)
part.readblocks(block_num, buf)
part.writeblocks(block_num, buf)
part.eraseblocks(block_num, size)
part.set_boot() # sets current as bootable, for next reset
part.get_next_update() # returns new Partition
I didn't yet test the OTA functionality
Edit: updated signatures for partition methods.