espressif / arduino-esp32

Arduino core for the ESP32
GNU Lesser General Public License v2.1
12.73k stars 7.22k forks source link

OTA updates from server error 8 #3909

Closed Mr-HaleYa closed 2 years ago

Mr-HaleYa commented 4 years ago

I'm doing an OTA update from an HTTP server using the example. https://github.com/espressif/arduino-esp32/blob/master/libraries/Update/examples/AWS_S3_OTA_Update/AWS_S3_OTA_Update.ino

I have it working now but I had to modify the Update.cpp file because I was getting an error: 8 even tho my magic bytes are starting correctly.

I deleted https://github.com/espressif/arduino-esp32/blob/master/libraries/Update/src/Updater.cpp#L218-L221

Now it works perfectly. I'm assuming this is a bug... I found an old issues post on here #325 that describes this problem but it has been closed a long time and it doesn't seem that the issue was fully fixed...

Is there any way to fix this other than modifying the library files?

stale[bot] commented 3 years ago

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

Mr-HaleYa commented 3 years ago

So it looks like no one cares that there's a bug that makes it so that some Arduino devices can't use the Arduino ota update but whatever I guess lol it's a pretty easy fix for the user if they just want to delete the magic byte check (doesn't fix the problem but a quick way around it)

stale[bot] commented 3 years ago

[STALE_CLR] This issue has been removed from the stale queue. Please ensure activity to keep it openin the future.

viktak commented 3 years ago

Same issue here. I removed the lines @Mr-HaleYa suggested and the update process starts and finishes fine.

stale[bot] commented 3 years ago

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

Mr-HaleYa commented 3 years ago

Same issue here. I removed the lines @Mr-HaleYa suggested and the update process starts and finishes fine.

glad it worked for you. just wished someone would actually reply, even if to say this can be fixed (more like they won't since code can always be fixed) then have a useless stale bot close issues they don't want to reply to

stale[bot] commented 3 years ago

[STALE_CLR] This issue has been removed from the stale queue. Please ensure activity to keep it openin the future.

stale[bot] commented 3 years ago

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

viktak commented 3 years ago

Keeping this issue alive....

stale[bot] commented 3 years ago

[STALE_CLR] This issue has been removed from the stale queue. Please ensure activity to keep it openin the future.

stale[bot] commented 3 years ago

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

viktak commented 3 years ago

Still not resolved...

stale[bot] commented 3 years ago

[STALE_CLR] This issue has been removed from the stale queue. Please ensure activity to keep it openin the future.

star297 commented 3 years ago

You could try something like what I use, just set the FIRMWARE_URL and call updateFIRMWARE() in your program. Returns true if successful, restart and its done. Works on HTTP and HTTPS url's. I use it to download ota updates that I put on my from Firebase Storage, works every time.

#include <Firebase_ESP_Client.h>
#include <Update.h>
#include "HTTPClient.h"

HTTPClient http;

char      FIRMWARE_URL[256] = "firmware update URL";

int updateFIRMWARE()
{ 
  http.begin(FIRMWARE_URL);
  int httpCode = http.GET();
  if (httpCode <= 0) {
    //Error HTTP failed
    return 0;
  }
  int contentLen = http.getSize();
  bool canBegin = Update.begin(contentLen);
  if (!canBegin) {
    // Error, not  enough space for the new binary.
    return 0;
  }
  WiFiClient* client = http.getStreamPtr();
  size_t written = Update.writeStream(*client);
  if (written != contentLen) {
    // Error, wrote partial binary.
    return 0;
  }
  if (!Update.end()) {
    // Error from Update.end()
    return 0;
  }
  if (Update.isFinished()) {
   // Update successfully completed. Reboot to apply update.
   return 1;
  } else {
    // Error from Update.isFinished()
    return 0;
  }
}
ziadalkalza commented 3 years ago

@star297 Do you have a place where I can learn how to perform ota updates from the firebase storage? I tried looking at the library you included, but I'm not that experienced so I need some help with it.

star297 commented 3 years ago

Create a Firebase account here: https://firebase.google.com/products/realtime-database

You can look at our updater for some instructions: This is a more advanced set up if you have many devices in many remote locations. But there are no firmware files on the links at the moment. https://esp-updater.netlify.app/docs/firebase

ziadalkalza commented 3 years ago

@star297 Thank you for the quick reply. Yeah I need it for a product that I'm making, so it's potentially (fingers crossed) going to be hundreds of devices worldwide. Therefore, I need the device to support future updates, so not only will I be able to update the mobile app, but also the esp32 device.

sansillusion commented 3 years ago

If you are developing a app mabe put a update feature in the app that could "post" the update from the app.

1 - check for update on server using app. 2 - download update in app. 3 - post update from app.

ziadalkalza commented 3 years ago

Why would I go through all that when I can just do an OTA update from the esp32 straight away. I'll basically tell the esp32 to update by sending a message via BLE (which is what the app uses) when a button is pressed on the mobile app. So that the esp32 can do its job and just fetch the bin file.

sansillusion commented 3 years ago

You do you, I was just suggesting that since you would not need to store a certificate in the esp32 for secure server connection.

Le lun. 17 mai 2021 7 h 39 p.m., ziadalkalza @.***> a écrit :

Why would I go through all that when I can just do an OTA update from the esp32 straight away. I'll basically tell the esp32 to update by sending a message via BLE (which is what the app uses) when a button is pressed on the mobile app. So that the esp32 can do its job and just fetch the bin file.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/espressif/arduino-esp32/issues/3909#issuecomment-842713640, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHBFDCQ26LC5GESWYT7U7A3TOGSLLANCNFSM4MIPUDSA .

star297 commented 3 years ago

We found using Firebase Storage the best solution for multiple remote ESP32 device ota updates in our case. The firmware can be compiled from any global location placed on Firebase Storage and uploaded to a device to any global location providing there's wifi connection. Devices will check to see if there's firmware available when active, download and update automatically.

We have used ESP8266 with 4Mbyte Flash, but we needed more analog functions. Plenty of space for SSL even with a very large program.

ziadalkalza commented 3 years ago

@star297 Yes this was my initial approach, but I can't seem to find a way to:

  1. access the bin files from the Firebase storage securely.
  2. download the bin file into the OTA partition, so I can then restart the ESP32. How do you reckon I can go about doing that? I know there is a firebase arduino library but I'm still fairly new to this.
ziadalkalza commented 3 years ago

Ok I think for a secure anonymous connection to the Firebase storage, all we need is to include the host link and the secrets authentication token in the device firmware. Conversely, if you want to use proper user sign in, you'll need to include the email and password.

Is my understanding correct? Or is there something I'm missing regarding this aspect of the code?

stale[bot] commented 2 years ago

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

stale[bot] commented 2 years ago

[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions.

Introvertuous commented 11 months ago

is anyone even maintaining this?

reinerbraun99 commented 1 week ago

I'm doing an OTA update from an HTTP server using the example. https://github.com/espressif/arduino-esp32/blob/master/libraries/Update/examples/AWS_S3_OTA_Update/AWS_S3_OTA_Update.ino

I have it working now but I had to modify the Update.cpp file because I was getting an error: 8 even tho my magic bytes are starting correctly.

I deleted https://github.com/espressif/arduino-esp32/blob/master/libraries/Update/src/Updater.cpp#L218-L221

Now it works perfectly. I'm assuming this is a bug... I found an old issues post on here #325 that describes this problem but it has been closed a long time and it doesn't seem that the issue was fully fixed...

Is there any way to fix this other than modifying the library files?

Hello, I have the same issue, and I'm trying to delete the lines you attached here, but it seems the source code of Updater.cpp has changed. Could you please give me the exact lines I must delete in Updater.cpp?

Best regards, Rainier Adrian