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.
How best to handle firmware updates
Re: How best to handle firmware updates
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.
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.
Re: How best to handle firmware updates
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:
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.
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()
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.
Re: How best to handle firmware updates
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.ScottyBoy wrote: ↑Mon Sep 18, 2023 4:15 pmMy 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.
Who is online
Users browsing this forum: No registered users and 81 guests