0

I'm working on a esp32, trying to do a OTA update. I have the issues

" E (207512) esp_image: invalid segment length 0x400e47a4 0x400e47a4: _GLOBAL__sub_I__ZN11UpdateClass16_enablePartitionEPK15esp_partition_t at “

And

“E (61127) esp_image: invalid segment length 0x400e40d0 0x400e40d0: __static_initialization_and_destruction_0(int, int) at “

Sometimes it's the first one, sometimes it's the second one, it depends on the firmware that i'm trying to update.

It doesn't seem to be a power issue or a length issue.

Any ideas on what could cause this problem?

I'm using the AWS_S3_OTA_Update but i'm fetching the firmware by doing a post request on a thingworx service. I changed the code to get rid of the header before giving the firmware to the updater functions.

I tried multiple firmwares, tried to change the length of the firmware, tried looking in the menuconfig, tried looking for a power problem

        char data [1024]; //char array where we will put the bytes sent by the client 
 
    while (client.available()) {
      int fini=0;
      dataContent = client.readBytesUntil('?',data,1024); // read until a certain character " ` "
      
      for (int i = 0; i < 1024; i++)
        {
          if (i % 16 == 0 && i != 0)
            {
             Serial.println("");
            }
           // Serial.printf("%02x ", buff[i]); //lower case
          Serial.printf("%02X ", data[i]); // upper case

      //   //   if(data[i]== 'F' && data[i+1]=='0'){
      //   //      fini = 1;
      //   // break;
      
      //   //   }
         }
        // if(fini == 1){
        //   break;
        // }
      break; // break the while loop and feed the rest of the client to the update function

    }
             

  // Check what is the contentLength and if content type is `application/octet-stream`
  Serial.println("contentLength : " + String(contentLength) + ", isValidContentType : " + String(isValidContentType));

  // check contentLength and content type
  if (contentLength && isValidContentType) {
    // Check if there is enough to OTA Update
    bool canBegin = Update.begin(contentLength);

    // If yes, begin
    if (canBegin) {
      Serial.println("Begin OTA. This may take 2 - 5 mins to complete. Things might be quite for a while.. Patience!");
      // No activity would appear on the Serial monitor
      // So be patient. This may take 2 - 5mins to complete
      size_t written = Update.writeStream(client);

      if (written == contentLength) {
        Serial.println("Written : " + String(written) + " successfully");
      } else {
        Serial.println("Written only : " + String(written) + "/" + String(contentLength) + ". Retry?" );
        // retry??
        // execOTA();
      }

      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 {
      // not enough space to begin OTA
      // Understand the partitions and
      // space availability
      Serial.println("Not enough space to begin OTA");
      client.flush();
    }
  } else {
    Serial.println("There was no content in the response");
    client.flush();
  }
  
  }
  Serial.println("\r");
  client.stop();
  return return_value;
sab240
  • 1
  • 1
  • Hi sab240, welcome to SO. Please take the [Tour](https://stackoverflow.com/tour) and read [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask). Specifically, we can't do anything unless you post a minimal code sample producing this problem. – Tarmo Jan 12 '23 at 13:12
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jan 12 '23 at 13:18
  • "Any ideas on what could cause this problem?", obviously caused by your modification of the [orginal code](https://github.com/espressif/arduino-esp32/blob/master/libraries/Update/examples/AWS_S3_OTA_Update/AWS_S3_OTA_Update.ino) that you didn't disclosed, and we have no idea what exactly you modified. – hcheung Jan 14 '23 at 02:45

0 Answers0