Flash size error OTA

Rulioht
Posts: 2
Joined: Fri Dec 16, 2022 2:32 pm

Flash size error OTA

Postby Rulioht » Mon Mar 13, 2023 6:23 pm

Hello, I have problem to update flash OTA

Connecting to: XXX.s3.amazonaws.com
Fetching Bin: /XXX.littlefs.bin
Got application/octet-stream payload.
Got 1507328 bytes from server
contentLength : 1507328, isValidContentType : 1
Not enough space to begin OTA

I'm starting on this subject, probably something went unnoticed.
I imagine it should have this file size.
Can someone help me?
  1. void execOTA() {
  2.   Serial.println("Connecting to: " + String(host));
  3.   if (ota_h_client.connect(host.c_str(), port)) {
  4.     Serial.println("Fetching Bin: " + String(bin2));
  5.  
  6.     ota_h_client.print(String("GET ") + bin2 + " HTTP/1.1\r\n" +
  7.                  "Host: " + host + "\r\n" +
  8.                  "Cache-Control: no-cache\r\n" +
  9.                  "Connection: close\r\n\r\n");
  10.  
  11.     unsigned long timeout = millis();
  12.     while (ota_h_client.available() == 0) {
  13.       if (millis() - timeout > 5000) {
  14.         Serial.println("Client Timeout !");
  15.         ota_h_client.stop();
  16.         return;
  17.       }
  18.     }
  19.     while (ota_h_client.available()) {
  20.       String line = ota_h_client.readStringUntil('\n');
  21.       line.trim();
  22.       if (!line.length()) {
  23.         break;
  24.       }
  25.  
  26.       if (line.startsWith("HTTP/1.1")) {
  27.         if (line.indexOf("200") < 0) {
  28.           Serial.println("Got a non 200 status code from server. Exiting OTA Update.");
  29.           break;
  30.         }
  31.       }
  32.  
  33.       if (line.startsWith("Content-Length: ")) {
  34.         contentLength = atol((getHeaderValue(line, "Content-Length: ")).c_str());
  35.         Serial.println("Got " + String(contentLength) + " bytes from server");
  36.       }
  37.  
  38.       if (line.startsWith("Content-Type: ")) {
  39.         String contentType = getHeaderValue(line, "Content-Type: ");
  40.         Serial.println("Got " + contentType + " payload.");
  41.         if (contentType == "application/octet-stream") {
  42.           isValidContentType = true;
  43.         }
  44.       }
  45.     }
  46.   } else {
  47.     Serial.println("Connection to " + String(host) + " failed. Please check your setup");
  48.   }
  49.  
  50.   Serial.println("contentLength : " + String(contentLength) + ", isValidContentType : " + String(isValidContentType));
  51.  
  52.   if (contentLength && isValidContentType) {
  53.     bool canBegin = Update.begin(contentLength);
  54.  
  55.     if (canBegin) {
  56.       Serial.println("Begin OTA. This may take 2 - 5 mins to complete. Things might be quite for a while.. Patience!");
  57.       size_t written = Update.writeStream(ota_h_client);
  58.  
  59.       if (written == contentLength) {
  60.         Serial.println("Written : " + String(written) + " successfully");
  61.       } else {
  62.         Serial.println("Written only : " + String(written) + "/" + String(contentLength) + ". Retry?" );
  63.       }
  64.  
  65.       if (Update.end()) {
  66.         Serial.println("OTA done!");
  67.         if (Update.isFinished()) {
  68.           Serial.println("Update successfully completed. Rebooting.");
  69.           ESP.restart();
  70.         } else {
  71.           Serial.println("Update not finished? Something went wrong!");
  72.         }
  73.       } else {
  74.         Serial.println("Error Occurred. Error #: " + String(Update.getError()));
  75.       }
  76.     } else {
  77.       Serial.println("Not enough space to begin OTA");
  78.       ota_h_client.flush();
  79.     }
  80.   } else {
  81.     Serial.println("There was no content in the response");
  82.     ota_h_client.flush();
  83.   }
  84. }
Chip : esp32
Using partition scheme from Arduino IDE.
Start: 0x290000
Size : 0x170000
mklittlefs : C:\Users\Rulio\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\tools\mklittlefs.exe

esptool : C:\Users\Rulio\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\3.0.0\esptool.exe

[LittleFS] data : C:\Users\Rulio\Documents\Rulio compartilhada\XXX\data
[LittleFS] offset : 0
[LittleFS] start : 2686976
[LittleFS] size : 1472
[LittleFS] page : 256
[LittleFS] block : 4096
->/787.chunk.js
->/787.chunk.js.map
->/afira_logo2..png
->/asset-manifest.json
->/index.html
->/main.css
->/main.css.map
->/main.js
->/main.js.LICENSE.txt
->/main.js.map
->/manifest.json
->/robots.txt
[LittleFS] upload : C:\Users\Rulio\AppData\Local\Temp\arduino_build_454786/XXX.littlefs.bin
[LittleFS] address: 2686976
[LittleFS] port : COM14
[LittleFS] speed : 921600
[LittleFS] mode : dio
[LittleFS] freq : 80m

->esptool.py v3.0-dev
->Serial port COM14
Attachments
erro (1).jpg
erro (1).jpg (47.54 KiB) Viewed 792 times
imagem_2023-03-13_151348275.png
imagem_2023-03-13_151348275.png (29.09 KiB) Viewed 792 times

Who is online

Users browsing this forum: No registered users and 70 guests