Flash size error OTA

Home Forums esp32 Flash size error OTA

Viewing 2 reply threads
  • Author
    Posts
    • #24730
      Rulio
      Participant

        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

        Can someone help me?

        
        
        void execOTA() {
        	Serial.println("Connecting to: " + String(host));
        	if (ota_h_client.connect(host.c_str(), port)) {
        		Serial.println("Fetching Bin: " + String(bin2));
        
        		ota_h_client.print(
        				String("GET ") + bin2 + " HTTP/1.1\r\n" + "Host: " + host
        						+ "\r\n" + "Cache-Control: no-cache\r\n"
        						+ "Connection: close\r\n\r\n");
        
        		unsigned long timeout = millis();
        		while (ota_h_client.available() == 0) {
        			if (millis() – timeout > 5000) {
        				Serial.println("Client Timeout !");
        				ota_h_client.stop();
        				return;
        			}
        		}
        		while (ota_h_client.available()) {
        			String line = ota_h_client.readStringUntil(‘\n’);
        			line.trim();
        			if (!line.length()) {
        				break;
        			}
        
        			if (line.startsWith("HTTP/1.1")) {
        				if (line.indexOf("200") < 0) {
        					Serial.println(
        							"Got a non 200 status code from server. Exiting OTA Update.");
        					break;
        				}
        			}
        
        			if (line.startsWith("Content-Length: ")) {
        				contentLength = atol(
        						(getHeaderValue(line, "Content-Length: ")).c_str());
        				Serial.println(
        						"Got " + String(contentLength) + " bytes from server");
        			}
        
        			if (line.startsWith("Content-Type: ")) {
        				String contentType = getHeaderValue(line, "Content-Type: ");
        				Serial.println("Got " + contentType + " payload.");
        				if (contentType == "application/octet-stream") {
        					isValidContentType = true;
        				}
        			}
        		}
        	} else {
        		Serial.println(
        				"Connection to " + String(host)
        						+ " failed. Please check your setup");
        	}
        
        	Serial.println(
        			"contentLength : " + String(contentLength)
        					+ ", isValidContentType : " + String(isValidContentType));
        
        	if (contentLength &&isValidContentType) {
        		bool canBegin = Update.begin(contentLength);
        
        		if (canBegin) {
        			Serial.println(
        					"Begin OTA. This may take 2 – 5 mins to complete. Things might be quite for a while.. Patience!");
        			size_t written = Update.writeStream(ota_h_client);
        
        			if (written == contentLength) {
        				Serial.println(
        						"Written : " + String(written) + " successfully");
        			} else {
        				Serial.println(
        						"Written only : " + String(written) + "/"
        								+ String(contentLength) + ". Retry?");
        			}
        
        			if (Update.end()) {
        				Serial.println("OTA done!");
        				if (Update.isFinished()) {
        					Serial.println("Update successfully completed. Rebooting.");
        					ESP.restart();
        				} else {
        					Serial.println(
        							"Update not finished? Something went wrong!");
        				}
        			} else {
        				Serial.println(
        						"Error Occurred. Error #: "
        								+ String(Update.getError()));
        			}
        		} else {
        			Serial.println("Not enough space to begin OTA");
        			ota_h_client.flush();
        		}
        	} else {
        		Serial.println("There was no content in the response");
        		ota_h_client.flush();
        	}
        }
        
        
      • #24735
        Renzo Mischianti
        Keymaster

          Hi Rulio,
          Does It possible that the configuration of the first upload (the partitions) is different from the generated firmware?
          Bye Renzo

        • #24749
          Rulio
          Participant

            I found out that mklittlefs was generating a corrupted file, but it’s still not working now the error is another one.

            Connecting to: XXX.s3.amazonaws.com
            Fetching Bin: /XXX.littlefs.bin
            Got application/octet-stream payload.
            Got 983040 bytes from server
            contentLength : 983040, isValidContentType : 1
            Begin OTA. This may take 2 – 5 mins to complete. Things might be quite for a while.. Patience!
            Written only : 0/983040. Retry?
            Error Occurred. Error #: 8

        Viewing 2 reply threads
        • You must be logged in to reply to this topic.
        Exit mobile version