[SOLVED]Load spiffs_image.img after OTA

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: Load spiffs_image.img after OTA

Postby Ritesh » Wed Jul 10, 2019 4:52 pm

elie_daan wrote:
Wed Jul 10, 2019 9:25 am
Hello,

Thanks you Ritesh for your help. Finally I resolved the problem. It was always writing at the beginning of the partition. I had to implement a offset because my buffer was 1Kb.

Code: Select all

int offset=0;
    /*deal with all receive packet*/
    while (1) {
        int data_read = esp_http_client_read(client, ota_write_data, BUFFSIZE);
        if (data_read < 0) {
            ESP_LOGE(TAG, "Error: SSL data read error");
            http_cleanup(client);
            task_fatal_error();
        } else if (data_read > 0) {
            /* 3 : WRITE SPIFFS PARTITION */
            err= esp_partition_write(spiffs_partition,offset,(const void *)ota_write_data, data_read);
            
            if (err != ESP_OK) {
                http_cleanup(client);
                task_fatal_error();
            }
            offset=offset+1024;
Great work. Thanks again for your effort to resolve that issue.
Regards,
Ritesh Prajapati

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: [SOLVED]Load spiffs_image.img after OTA

Postby WiFive » Wed Jul 10, 2019 5:14 pm

Code: Select all

esp_partition_write(spiffs_partition,offset,(const void *)ota_write_data, data_read);
You write length data_read

So

Code: Select all

offset += data_read

pedros89
Posts: 4
Joined: Tue Aug 03, 2021 9:28 am

Re: [SOLVED]Load spiffs_image.img after OTA

Postby pedros89 » Tue Aug 03, 2021 9:37 am

Thank you for this post. I needed to update SPIFFS from OTA and I managed to do it thanks to you.

You may find the code for Arduino IDE below. I took most of code form this post to make it.

https://github.com/pedros89/ESP32-OTA-u ... th-Arduino

For me it works great. Bye!

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: [SOLVED]Load spiffs_image.img after OTA

Postby Ritesh » Sat Aug 28, 2021 10:36 am

pedros89 wrote:
Tue Aug 03, 2021 9:37 am
Thank you for this post. I needed to update SPIFFS from OTA and I managed to do it thanks to you.

You may find the code for Arduino IDE below. I took most of code form this post to make it.

https://github.com/pedros89/ESP32-OTA-u ... th-Arduino

For me it works great. Bye!
Great. Thanks for putting details with link which can be helpful for others as well
Regards,
Ritesh Prajapati

Who is online

Users browsing this forum: No registered users and 117 guests