5.2.4 pycom
active.
shall hold the image data to be written, in arbitrary sizes. A block size of
buffer
4096 is recommended.
Example:
# Firmware update by reading the image from the SD card
#
from pycom import ota_start, ota_write, ota_finish
from os import mount
from machine import SD
BLOCKSIZE = const(4096)
APPIMG = "/sd/appimg.bin"
sd = SD()
mount(sd, '/sd')
with open(APPIMG, "rb") as f:
buffer = bytearray(BLOCKSIZE)
mv = memoryview(buffer)
size=0
ota_start()
while True:
chunk = f.readinto(buffer)
if chunk > 0:
ota_write(mv[:chunk])
size += chunk
print("\r%7d " % size, end="")
else:
break
ota_finish()
Instead of reading the data to be written from a file, it can obviously also be received from a
server using any suitable protocol, without the need to store it in the devices file system.
344
Need help?
Do you have a question about the WiPy 3.0 and is the answer not in the manual?
Questions and answers