JAndrassy / ArduinoOTA

Arduino library to upload sketch over network to Arduino board with WiFi or Ethernet libraries
GNU Lesser General Public License v2.1
435 stars 89 forks source link

Avoid erasing all pages at once (takes looong time on some platforms) #190

Closed vshymanskyy closed 1 year ago

vshymanskyy commented 1 year ago

Areaseing all pages at once can take ~30 seconds on Micro:bit 2, and the board it unresponsive during this time, which leads to timeouts, etc.

vshymanskyy commented 1 year ago

@JAndrassy what do you think?

JAndrassy commented 1 year ago

Hello Volodymyr

did you test it on SAMD21, SAMD51 too?

I would call erase at the beginning of write and remove the erase call from open. why the const nextAddress variable? why the recalculation of pageAlignedLength in close? and what is * 4 there?

vshymanskyy commented 1 year ago

Honestly, I did this change quite some time ago, so I don't remember ;) But, I'll be running this modified version of ArduinoOTA on a bunch of platforms soon (including SAMD) so I'll try to answer all the questions!

vshymanskyy commented 1 year ago
  1. I'm erasing at the beginning of write now
  2. nextAddress was removed
  3. Now, on recalculation of pageAlignedLength...

This is needed in case the actually written binary is smaller than the size provided in open(). Why? In some cases (i.e. a compressed firmware binary, HTTP file upload) the size of the firmware binary is not known upfront. The firmware update can be achieved in such cases by calling:

InternalStorage.open(InternalStorage.maxSize());

I've added some comments, and the * 4 was changed to * sizeof(uint32_t) to make it easier to understand.

I've tested this version on multiple platforms:

JAndrassy commented 1 year ago

I like it. Is it ready to merge or you want to change something on it yet?

vshymanskyy commented 1 year ago

it's ready

On Thu, 23 Mar 2023, 16:03 Juraj Andrássy, @.***> wrote:

I like it. Is it ready to merge or you want to change something on it yet?

— Reply to this email directly, view it on GitHub https://github.com/JAndrassy/ArduinoOTA/pull/190#issuecomment-1481255756, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALP3FCMVIVN3JPD5NEMTMTW5RJ2XANCNFSM6AAAAAAVYIEJWI . You are receiving this because you authored the thread.Message ID: @.***>

JAndrassy commented 1 year ago

Volodymyr, let me know when you need a release of ArduinoOTA

vshymanskyy commented 1 year ago

No urgency! i can use it as is. Thanks ;)

On Wed, 26 Apr 2023, 09:47 Juraj Andrássy, @.***> wrote:

Volodymyr, let me know when you need a release of ArduinoOTA

— Reply to this email directly, view it on GitHub https://github.com/JAndrassy/ArduinoOTA/pull/190#issuecomment-1522874547, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALP3FFYKJLWMVPHUNLWKB3XDDAHNANCNFSM6AAAAAAVYIEJWI . You are receiving this because you authored the thread.Message ID: @.***>