loboris / MicroPython_ESP32_psRAM_LoBo

MicroPython for ESP32 with psRAM support
Other
831 stars 344 forks source link

OTA Update fails on 3rd Update #245

Closed colin-infersens closed 5 years ago

colin-infersens commented 5 years ago

Hi,

I'm developing an application on an ESP32 device ( TTGO T-Cell WiFi & Bluetooth Module ), with the NOR Flash upgraded to 16Mb.

It has been configured for OTA updates using the three-partition model.

I'm downloading the MicroPython.bin file with some other filesystem files in a tar file, which is unpacked in the image directory, before deleting the tar file, then executing the OTA Update process on the local file.

After successfully completing the OTA Update, the MicroPython.bin file is deleted.

The tar file is about 2.25 Mb.

The MicroPython.bin file is about 2Mb.

When doing a directory listing, there's about 9Mb of NOR Flash storage available before kicking off the OTA Update process.

This all works perfectly, until I attempt a third OTA Update. The download works as expected, but after creating the tar file container, the application fails with an error code of "28" when trying to write the download contents to the tar file.

Could this be something to do with the way SPIFFS file systems write/delete data, or does anyone else have any other ideas, please?

Many thanks in advance.

bdespatis commented 5 years ago

Same for me after 5. That's exactly the space left on my internal file system. If I erase, (with esptool) it's back to normal.

colin-infersens commented 5 years ago

UPDATE After further testing, I found that rather than downloading the entire urequests GET stream to memory and then writing it to a local file, if you direct the stream to the file straight away at the outset, it works fine, with no failures. It is a bit slower, though.

It might be worth giving this a try @bdespatis - good luck!

import urequests
import shutil

with open('localFileName', 'wb') as f:
    r = urequests.get('remoteFileURL', stream=True)
    shutil.copyfileobj(r.raw, f)
    r.close()