Is it ok to call esp_ota_write() with buffer size of 1 byte?

MikeCode
Posts: 4
Joined: Wed Apr 20, 2022 10:25 am

Is it ok to call esp_ota_write() with buffer size of 1 byte?

Postby MikeCode » Wed Jul 06, 2022 8:51 am

Hi,

we are calling the
esp_ota_write(esp_ota_handle_t handle, const void *data, size_t size)
function with a buffer size of 1 byte, because we are receiving the firmware byte per byte.

Is it ok to do so, or will this lead to a faster wear of the flash, because only one byte is writte at one time?

Thanks,
Mike

chegewara
Posts: 2207
Joined: Wed Jun 14, 2017 9:00 pm

Re: Is it ok to call esp_ota_write() with buffer size of 1 byte?

Postby chegewara » Thu Jul 07, 2022 1:47 am

Hi,
It will wear level flash faster for sure, because low level API is working with 4kB flash sectors (read/write).
It is much better to have temporary buffer which will be flashed after filling with 4kB of data or even with 1kB of data.

ESP_Sprite
Posts: 8921
Joined: Thu Nov 26, 2015 4:08 am

Re: Is it ok to call esp_ota_write() with buffer size of 1 byte?

Postby ESP_Sprite » Thu Jul 07, 2022 3:44 am

chegewara wrote:
Thu Jul 07, 2022 1:47 am
Hi,
It will wear level flash faster for sure, because low level API is working with 4kB flash sectors (read/write).
It is much better to have temporary buffer which will be flashed after filling with 4kB of data or even with 1kB of data.
I disagree on the extra wear: generally flash *erases* is the thing that makes flash wear out, not flash *writes*. +1 on the temp buffer, but it may be that the OTA routines already have a buffer like that internally.

EDIT: Looked it up, ota has a buffer of 16 bytes. I don't think there's anything technically wrong with calling esp_ota_write every byte, but it is likely to be a lot faster if you feed it a big buffer instead.

Who is online

Users browsing this forum: Baidu [Spider] and 115 guests