How best to handle firmware updates

Chevelle
Posts: 19
Joined: Sun Nov 29, 2020 12:50 pm

How best to handle firmware updates

Postby Chevelle » Sun Nov 29, 2020 1:12 pm

I am designing a series of products that will use ESP32 development kits in the prototypes. These will eventually be replaced with separate components in the final product.

I fully expect to have to update the firmware from time to time after the product is release. What would be the best way to do this.

One way that I thought of was to use the USB port on the development kit and to provide a USB port to the ESP32 in the final product. I can provide an "Update Module" that would consist of a microSD card reader and the USB connection to the product. There will be an app that connects to the product via Bluetooth. It will be possible to initiate the firmware update via the app.

My question is, is one the app tells the ESP32 to initiate the update, how do I get the new firmware from the SD card into the product? I am assuming that it isn't possible to do all of that through the Bluetooth connection but I may be wrong.

Thanks for any suggestions.

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: How best to handle firmware updates

Postby ESP_igrr » Sun Nov 29, 2020 7:27 pm

If you are using ESP-IDF, you can implement firmware updates (OTA updates) from any medium. There are 3 main functions: esp_ota_begin, esp_ota_write, esp_ota_end (see https://docs.espressif.com/projects/esp ... a_handle_t).
First, call esp_ota_begin specifying the size of new firmware, then repeatedly call esp_ota_write for each chunk of the firmware you read/receive, and finally call esp_ota_end.

You can read new firmware from a file on SD card, or from Bluetooth (which might be a bit more complex but wouldn't require additional pins), or from the Internet over WiFi and HTTPS. Read it in chunks and pass them to esp_ota_write.

ScottyBoy
Posts: 3
Joined: Fri Jun 11, 2021 3:22 pm

Re: How best to handle firmware updates

Postby ScottyBoy » Mon Sep 18, 2023 4:15 pm

How do do this from a local file?

We have been using the OTA via a web page (using http). Currently we are using the Update.h code.

with calls interspersed with Update method calls:

Code: Select all

Update.begin(_contentLength);
      // So be patient. This may take 2 - 5mins to complete
size_t written = Update.writeStream(_client);

 Update.end()
Update.isFinished()
My question is how we might do this with a local file instead?

In particular, if we don't have WIFI working, it seems a web page served by the ESP using the AP mode, could provide the OTA binary from the users computer and an OTA update could be performed. I don't know how the write stream would be performed except with a binary writing of some sort.

Any chance anyone has code that might perform this?
thanks.

vinci1989
Posts: 28
Joined: Mon Oct 08, 2018 6:07 pm

Re: How best to handle firmware updates

Postby vinci1989 » Tue Sep 19, 2023 9:42 am

ScottyBoy wrote:
Mon Sep 18, 2023 4:15 pm
My question is how we might do this with a local file instead?

In particular, if we don't have WIFI working, it seems a web page served by the ESP using the AP mode, could provide the OTA binary from the users computer and an OTA update could be performed. I don't know how the write stream would be performed except with a binary writing of some sort.

Any chance anyone has code that might perform this?
thanks.
The web page you're serving could provide an "open file" dialog and then send a locally opened binary back to the ESP32. I think a good starting point might be to look at the file_serving example. This example provides file upload via HTTP requests. Instead of saving the file to SPIFFS (like the example does) you could write it to an OTA partition.

Who is online

Users browsing this forum: No registered users and 406 guests