OTA of micropython code on ESP32?
Posted: Thu Oct 10, 2019 4:04 pm
I am exploring "the best" way to do OTA of my micropython code that runs on an ESP32. Do you have any recommendations?
Thank you.
Thank you.
Please see the new forum at
https://forum.micropython.org/
Code: Select all
from esp32 import Partition
import gc
class Ota:
SEC_SIZE = 4096
def copyPartition(self):
currentPartition = Partition(Partition.RUNNING)
nextPartition = currentPartition.get_next_update()
buf = bytearray(self.SEC_SIZE)
for i in range(0, currentPartition.info()[3] // self.SEC_SIZE):
currentPartition.readblocks(i, buf)
nextPartition.writeblocks(i, buf)
print('Block No. ' + str(i) + ' copied')
gc.collect()
print('Partition copied')
nextPartition.set_boot()
Code: Select all
from esp32 import Partition
currentPartition = Partition(Partition.RUNNING)
nextPartition = currentPartition.get_next_update()
nextPartition.set_boot()
Code: Select all
Partition.mark_app_valid_cancel_rollback()
Code: Select all
Partition.set_boot(nextPartition)