Arduino icon indicating copy to clipboard operation
Arduino copied to clipboard

UpdaterClass error [10] Magic byte is wrong most of the time

Open BrotherV opened this issue 3 years ago • 2 comments

Update firmware returns error [10] Magic byte is wrong, not 0xE9 while the first byte of bin file is 0xE9

  • [ ] This issue complies with the issue POLICY doc.
  • [x] I have read the documentation at readthedocs and the issue is not addressed there.
  • [x] I have tested that the issue is present in the current master branch (aka latest git).
  • [x] I have searched the issue tracker for a similar issue.
  • [ ] If there is a stack dump, I have decoded it.
  • [x] I have filled out all fields below.

Platform

  • Hardware: [ESP-12]
  • Core Version: [3.0.2]
  • Development Env: [Platformio]
  • Operating System: [Windows]

Settings in IDE

  • Module: [Nodemcu]
  • Flash Mode: [qio|dio|other]
  • Flash Size: [4MB/1MB]
  • lwip Variant: [v1.4|v2 Lower Memory|Higher Bandwidth]
  • Reset Method: [nodemcu]
  • Flash Frequency: [40Mhz]
  • CPU Frequency: [80Mhz]
  • Upload Using: [SERIAL]
  • Upload Speed: [115200] (serial upload only)

Problem Description

I am trying to download the ESP firmware bin file from AWS, however, since I could not pass the HTTPclient object to the ESPhttpUpdateobject, I tried to create a method to download firmware and upload on the ESP chip.

Sketch


#include <Arduino.h>
#include <ESP8266HTTPClient.h>
#include "AWSClient4.h"
#include "Utils.h"

void executeOTAFirmware()
{
DateTimeProvider *dateTimeProvider = new DateTimeProvider;
  char *dateTime = dateTimeProvider->getDateTime();
  Serial.printf("Date and Time: %s\r\n", dateTime);
  
  AWSClient4 *awsClient4 = new AWSClient4;
  awsClient4->setQuery("");
  awsClient4->setMethod("GET");
  awsClient4->setSignedHeaders("host;x-amz-content-sha256;x-amz-date");
  awsClient4->setAWSRegion(awsRegion);
  awsClient4->setAWSEndpoint(awsEndpoint);
  awsClient4->setAWSDomain(awsDomain);
  awsClient4->setAWSService("s3");
  awsClient4->setAWSKeyID(awsAccessKey);
  awsClient4->setAWSSecretKey(awsSecretKey);
  awsClient4->setDateTime(dateTime);
  awsClient4->setAWSPath(awsPath_WiFi);
  awsClient4->createSignature("");

  HTTPClient *httpClient = new HTTPClient;
  WiFiClientSecure *client = new WiFiClientSecure;
  if (client)
  {
    client->setInsecure();
    Log("\n\t[HTTPS] begin...");
    httpClient->begin(*client, url_WiFi);
    // httpClient.begin(client, awsDomain, 80, awsPath, true);
    httpClient->addHeader("x-amz-content-sha256", awsClient4->getPayloadHash());
    httpClient->addHeader("x-amz-date", awsClient4->getDateTime());
    httpClient->addHeader("Authorization", awsClient4->getAuthorization());
    httpClient->addHeader("Connection", "keep-alive");
    httpClient->collectHeaders(headerKeys, numberOfHeaders);

    Log("\n\t[HTTP] GET...");
    // start connection and send HTTP header
    int httpCode = httpClient->GET();
    if (httpCode == HTTP_CODE_OK)
    {
      Log("\n\tConnected successfully");
      //  get length of document (is -1 when Server sends no Content-Length header)
      size_t contentLength = httpClient->header("Content-Length").toInt();
      bool isValidContentType = (httpClient->header("Content-Type") == "application/octet-stream") ? true : false;

      Serial.printf("\n\tContent length: %ld, Is valid content: %s\n", contentLength, (isValidContentType ? "Yes" : "No"));
      // check contentLength and content type
      if (contentLength && isValidContentType)
      {
        // Check if there is enough to OTA Update
        UpdaterClass *update = new UpdaterClass;
        bool canBegin = update->begin(contentLength);

        // If yes, begin
        if (canBegin)
        {
          Serial.print("\n\tBegin 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
          delay(50);
          size_t written = update->writeStream(*client);

          if (written == contentLength)
          {
            Serial.print("\n\tWritten : " + String(written) + " successfully");
          }
          else
          {
            Serial.print("\n\tWritten only : " + String(written) + "/" + String(contentLength) + ". Retry?");
          }

          if (update->end())
          {
            Serial.print("\n\tOTA done!");
            if (update->isFinished())
            {
              Serial.print("\n\tUpdate successfully completed. Rebooting.");
              ESP.restart();
            }
            else
            {
              Serial.print("\n\tUpdate not finished? Something went wrong!");
            }
          }
          else
          {
            Serial.print("\n\tError Occurred. Error #: " + String(update->getError()));
          }
          delete update;
        }
        else
        {
          Serial.print("\n\tNot enough space to begin OTA");
        }
      }
      else
      {
        Serial.print("\n\tThere was no content in the response");
      }
    }
    else
    {
      Serial.printf("\n\t[HTTP] GET... failed, error: %s\n", httpClient->errorToString(httpCode).c_str());
    }

    delete awsClient4;

    client->flush();
    client->stop();
    delete client;

    httpClient->end();
    delete httpClient;
  }
}

Debug Messages

    -----
    GET /wifi/WIFI.bin HTTP/1.1
    Host: xxxxxxxxx.xxxxxxxxxx.xxxxxxx.amazonaws.com
    User-Agent: ESP8266HTTPClient
    Accept-Encoding: identity;q=1,chunked;q=0.1,*;q=0
    Connection: keep-alive
    x-amz-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
    x-amz-date: 20220716T123911Z
    Authorization: AWS4-HMAC-SHA256 Credential=XXXXXXXXXXXXXXXXXX/20220716/xxxxxxxxx/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=d7bdcd376c19f7082f3b8dafa3e829d39692200fb9e828a6b4c07d9047af4921
    Content-Length: 0

    -----
    [HTTP-Client][handleHeaderResponse] RX: 'HTTP/1.1 200 OK
    '
    [HTTP-Client][handleHeaderResponse] RX: 'x-amz-id-2: Q9kWQticrr21YkDOXz4W4+egRRGDZwqHFLqgkFaJ3T3QgRUfjR996THGUgbwdchgRZNpsSW+kME=
    '
    [HTTP-Client][handleHeaderResponse] RX: 'x-amz-request-id: R36KWQYM6V6ENSP1
    '
    [HTTP-Client][handleHeaderResponse] RX: 'Date: Sat, 16 Jul 2022 12:39:15 GMT
    '
    [HTTP-Client][handleHeaderResponse] RX: 'Last-Modified: Fri, 15 Jul 2022 21:57:26 GMT
    '
    [HTTP-Client][handleHeaderResponse] RX: 'ETag: "e116552586477fbd1530aebceb332ee8"
    '
    [HTTP-Client][handleHeaderResponse] RX: 'x-amz-server-side-encryption: AES256
    '
    [HTTP-Client][handleHeaderResponse] RX: 'x-amz-version-id: biNSdrPNNyPdPOKOCBWC0muum.evqW1u
    '
    [HTTP-Client][handleHeaderResponse] RX: 'Accept-Ranges: bytes
    '
    [HTTP-Client][handleHeaderResponse] RX: 'Content-Type: application/octet-stream
    '
    [HTTP-Client][handleHeaderResponse] RX: 'Server: AmazonS3
    '
    [HTTP-Client][handleHeaderResponse] RX: 'Content-Length: 535920
    '
    [HTTP-Client][handleHeaderResponse] RX: '
    '
    [HTTP-Client][handleHeaderResponse] code: 200
    [HTTP-Client][handleHeaderResponse] size: 535920

    Free size: 10120, After GET

	Connected successfully
	Content length: 535920, Is valid content: Yes
    sleep disable
    [begin] roundedSize:       0x00083000 (536576)
    [begin] updateEndAddress:  0x00300000 (3145728)
    [begin] currentSketchSize: 0x00072000 (466944)
    [begin] _startAddress:     0x0027D000 (2609152)
    [begin] _currentAddress:   0x0027D000 (2609152)
    [begin] _size:             0x00082D70 (535920)

	Begin OTA. This may take 2 - 5 mins to complete. Things might be quite for a while.. Patience!
    
    ERROR[10]: Magic byte is wrong, not 0xE9
	Error Occurred. Error #: 10

Check file data with a downloader sketch

Sketch

int httpCode = httpClient->GET();
    Serial.printf("\r\nFree size: %d, After GET\r\n", ESP.getFreeHeap());
    if (httpCode == HTTP_CODE_OK)
    {
      Log("\n\tConnected successfully");
      //  get length of document (is -1 when Server sends no Content-Length header)
      size_t contentLength = httpClient->header("Content-Length").toInt();
      bool isValidContentType = (httpClient->header("Content-Type") == "application/octet-stream") ? true : false;

      Serial.printf("\n\tContent length: %ld, Is valid content: %s\n", contentLength, (isValidContentType ? "Yes" : "No"));
      // check contentLength and content type
      if (contentLength && isValidContentType)
      {

        static uint8_t buff[128] = {0};
        while (httpClient->connected() && (contentLength > 0 || contentLength == -1))
        {
          // get available data size
          size_t size = client->available();

          if (size)
          {
            // read up to 128 byte
            int c = client->readBytes(buff, ((size > sizeof(buff)) ? sizeof(buff) : size));
            // write it to Serial
            for (int i = 0; i < 128; i++)
            {
              if (i % 16 == 0 && i != 0)
              {
                Serial.println("");
              }
              // Serial.printf("%02x ", buff[i]); //lower case
              Serial.printf("%02X ", buff[i]); // uper case
            }

            Serial.println("");

            if (contentLength > 0)
            {
              contentLength -= c;
            }
          }
          delay(1);
        }

        Log("\n\t[HTTPS] connection closed or file end.\n");
      }
      else
      {
        Serial.print("\n\tThere was no content in the response");
      }
    }
    else
    {
      Serial.printf("\n\t[HTTP] GET... failed, error: %s\n", httpClient->errorToString(httpCode).c_str());
    }

Debug Messages

    -----
    [HTTP-Client][handleHeaderResponse] RX: 'HTTP/1.1 200 OK
    '
    [HTTP-Client][handleHeaderResponse] RX: 'x-amz-id-2: DO19YGEgC58NHgyN+S04yWRBAAvi0afCqZyxDEs2wgp49t5JUE3jCjRttnERcZrgu8RuHVwDci4=
    '
    [HTTP-Client][handleHeaderResponse] RX: 'x-amz-request-id: C9YDKYPYKHQ1P7WB
    '
    [HTTP-Client][handleHeaderResponse] RX: 'Date: Sat, 16 Jul 2022 12:39:58 GMT
    '
    [HTTP-Client][handleHeaderResponse] RX: 'Last-Modified: Fri, 15 Jul 2022 21:57:26 GMT
    '
    [HTTP-Client][handleHeaderResponse] RX: 'ETag: "e116552586477fbd1530aebceb332ee8"
    '
    [HTTP-Client][handleHeaderResponse] RX: 'x-amz-server-side-encryption: AES256
    '
    [HTTP-Client][handleHeaderResponse] RX: 'x-amz-version-id: biNSdrPNNyPdPOKOCBWC0muum.evqW1u
    '
    [HTTP-Client][handleHeaderResponse] RX: 'Accept-Ranges: bytes
    '
    [HTTP-Client][handleHeaderResponse] RX: 'Content-Type: application/octet-stream
    '
    [HTTP-Client][handleHeaderResponse] RX: 'Server: AmazonS3
    '
    [HTTP-Client][handleHeaderResponse] RX: 'Content-Length: 535920
    '
    [HTTP-Client][handleHeaderResponse] RX: '
    '
    [HTTP-Client][handleHeaderResponse] code: 200
    [HTTP-Client][handleHeaderResponse] size: 535920

    Free size: 8304, After GET

        Connected successfully
        Content length: 535920, Is valid content: Yes
    E9 02 02 30 94 F4 10 40 00 F0 10 40 84 0D 00 00 
    00 80 FE 3F 00 90 FE 3F 1C 4B 00 40 B8 20 FF 3F 
    CC 24 00 40 FF BF 00 00 FF FF FF 1F F0 FF FF 3F 
    FF 0F 00 00 94 F0 10 40 04 90 FE 3F 04 10 FF 3F 
    90 E1 00 40 A8 DE 00 40 E8 2B 00 40 00 4A 00 40 
    4C 4A 00 40 BF 20 FF 3F C9 20 FF 3F C3 20 FF 3F 
    C7 20 FF 3F 00 07 00 60 F0 30 00 40 A0 2F 00 40 
    B7 1D C1 04 00 12 00 60 00 EE FF 9F 80 12 00 60 
    00 10 00 EB 7C 12 00 60 88 DC 00 40 CD 20 FF 3F 
    04 20 FF 3F 7C 20 FF 3F 40 20 FF 3F 9A 20 FF 3F 
    FF FF 00 00 12 C1 F0 31 DA FF C9 21 D9 11 09 31 
    D1 D9 FF CD 02 39 02 21 D7 FF 0C 14 29 1C 28 0D 
    40 44 11 01 D5 FF C0 00 00 28 0D 08 31 22 D2 10 
    29 0D 28 0C D8 11 1B 32 39 0C 22 02 00 C8 21 12 
    C1 10 0D F0 52 A1 01 12 C1 E0 C0 55 11 0C 44 3D 
    01 5A 22 C9 61 09 71 01 C8 FF C0 00 00 CD 02 CC 
    D2 38 01 21 C6 FF 01 C6 FF C0 00 00 86 00 00 00 
    0C 1C 08 71 2D 0C C8 61 12 C1 20 0D F0 00 00 00 
    12 C1 E0 0C 84 D9 51 4A 31 DD 02 22 D2 10 09 71 
    C2 61 06 E2 61 04 01 B8 FF C0 00 00 56 22 07 C2 
    A2 01 D0 CC B0 ED 02 DD 02 C6 14 00 0C 84 3D 01 
    2D 0C D9 01 D9 11 01 B0 FF C0 00 00 FC 42 38 01 
    22 AB FF C0 22 01 51 AF FF 2A 23 48 11 8B CC 27 
    B5 0F 7C F2 20 22 01 51 AC FF 2A 23 27 35 02 C6 

Based on the debug message, the first byte of the file is 0xE9. I have tested "UpdaterClass" 10 times and it could only update ESP firmware just two times.

The question is, what is wrong with that? I checked it several times.

BrotherV avatar Jul 16 '22 16:07 BrotherV

I added a method in "ESP8266HTTPUpdate" to pass down only "HTTPClient" object instead of "WifiClient" and "URL". In this way, I can add some specific headers to the "HTTPClient". I do not know why the above sketch does not work all the time, however, the modified "ESP8266HTTPUpdate" class can update the sketch with no problem.

ESP8266httpUpdate.h file

HTTPUpdateResult ESP8266HTTPUpdate::update(HTTPClient &http, const String &currentVersion)
{
    return handleUpdate(http, currentVersion, false);
}

ESP8266httpUpdate.cpp file, added in public section.**

t_httpUpdate_return update(HTTPClient &http, const String &currentVersion = "");

CPP file

WiFiClientSecure *client = new WiFiClientSecure;
  if (client)
  {
    client->setInsecure();
    Log("\n\t[HTTPS] begin...");

    HTTPClient *httpClient = new HTTPClient;
    httpClient->begin(*client, url_WiFi);
    httpClient->addHeader(F("x-amz-content-sha256"), awsClient4->getPayloadHash());
    httpClient->addHeader(F("x-amz-date"), awsClient4->getDateTime());
    httpClient->addHeader(F("Authorization"), awsClient4->getAuthorization());

    ESP8266HTTPUpdate *otaUpdater = new ESP8266HTTPUpdate;
    otaUpdater->setLedPin(LED_BUILTIN, LOW);

    // Add optional callback notifiers
    otaUpdater->onStart(update_started);
    otaUpdater->onEnd(update_finished);
    otaUpdater->onProgress(update_progress);
    otaUpdater->onError(update_error);

    otaUpdater->rebootOnUpdate(false); // remove automatic update

    Serial.println(F("Update start now!"));

    t_httpUpdate_return ret = otaUpdater->update(*httpClient);
    // Or:
    // t_httpUpdate_return ret = ESPhttpUpdate.update(client, "bvtech.parsaspace.com", 443, "/firmware.bin");

    switch (ret)
    {
    case HTTP_UPDATE_FAILED:
      Serial.printf("HTTP_UPDATE_FAILD Error (%d): %s\n", ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str());
      break;

    case HTTP_UPDATE_NO_UPDATES:
      Serial.println("HTTP_UPDATE_NO_UPDATES");
      break;

    case HTTP_UPDATE_OK:
      Serial.println("HTTP_UPDATE_OK");
      delay(1000); // Wait a second and restart
      ESP.restart();
      break;
    }

    delete otaUpdater;

    client->flush();
    client->stop();

    httpClient->end();
  }

Debug file

-----
[HTTP-Client][handleHeaderResponse] RX: 'HTTP/1.1 200 OK
'
[HTTP-Client][handleHeaderResponse] RX: 'x-amz-id-2: Zi90NDauWIhRyLo/6/l/fPrhsK3rv7W0jai2u5ykNE5sditG47fuSDUASTQLx1+W+QOyr5SSvE4=
'
[HTTP-Client][handleHeaderResponse] RX: 'x-amz-request-id: VDPY8B1C83H7S4MW
'
[HTTP-Client][handleHeaderResponse] RX: 'Date: Sat, 16 Jul 2022 14:53:55 GMT
'
[HTTP-Client][handleHeaderResponse] RX: 'Last-Modified: Fri, 15 Jul 2022 21:57:26 GMT
'
[HTTP-Client][handleHeaderResponse] RX: 'ETag: "e116552586477fbd1530aebceb332ee8"
'
[HTTP-Client][handleHeaderResponse] RX: 'x-amz-server-side-encryption: AES256
'
[HTTP-Client][handleHeaderResponse] RX: 'x-amz-version-id: biNSdrPNNyPdPOKOCBWC0muum.evqW1u
'
[HTTP-Client][handleHeaderResponse] RX: 'Accept-Ranges: bytes
'
[HTTP-Client][handleHeaderResponse] RX: 'Content-Type: application/octet-stream
'
[HTTP-Client][handleHeaderResponse] RX: 'Server: AmazonS3
'
[HTTP-Client][handleHeaderResponse] RX: 'Content-Length: 535920
'
[HTTP-Client][handleHeaderResponse] RX: 'Connection: close
'
[HTTP-Client][handleHeaderResponse] RX: '
'
[HTTP-Client][handleHeaderResponse] code: 200
[HTTP-Client][handleHeaderResponse] size: 535920

CALLBACK:  HTTP update process started
sleep disable
[begin] roundedSize:       0x00083000 (536576)
[begin] updateEndAddress:  0x00300000 (3145728)
[begin] currentSketchSize: 0x00074000 (475136)
[begin] _startAddress:     0x0027D000 (2609152)
[begin] _currentAddress:   0x0027D000 (2609152)
[begin] _size:             0x00082D70 (535920)
CALLBACK:  HTTP update process at 0 of 535920 bytes...
CALLBACK:  HTTP update process at 0 of 535920 bytes...
Header: 0xE9 2 2 30
CALLBACK:  HTTP update process at 4096 of 535920 bytes...
CALLBACK:  HTTP update process at 8192 of 535920 bytes...
CALLBACK:  HTTP update process at 12288 of 535920 bytes...
CALLBACK:  HTTP update process at 16384 of 535920 bytes...
CALLBACK:  HTTP update process at 20480 of 535920 bytes...
CALLBACK:  HTTP update process at 24576 of 535920 bytes...
CALLBACK:  HTTP update process at 28672 of 535920 bytes...
CALLBACK:  HTTP update process at 32768 of 535920 bytes...
CALLBACK:  HTTP update process at 36864 of 535920 bytes...
CALLBACK:  HTTP update process at 40960 of 535920 bytes...
CALLBACK:  HTTP update process at 45056 of 535920 bytes...
CALLBACK:  HTTP update process at 49152 of 535920 bytes...
CALLBACK:  HTTP update process at 53248 of 535920 bytes...
CALLBACK:  HTTP update process at 57344 of 535920 bytes...
CALLBACK:  HTTP update process at 61440 of 535920 bytes...
CALLBACK:  HTTP update process at 65536 of 535920 bytes...
CALLBACK:  HTTP update process at 69632 of 535920 bytes...
CALLBACK:  HTTP update process at 73728 of 535920 bytes...
CALLBACK:  HTTP update process at 77824 of 535920 bytes...
CALLBACK:  HTTP update process at 81920 of 535920 bytes...
CALLBACK:  HTTP update process at 86016 of 535920 bytes...
CALLBACK:  HTTP update process at 90112 of 535920 bytes...
CALLBACK:  HTTP update process at 94208 of 535920 bytes...
CALLBACK:  HTTP update process at 98304 of 535920 bytes...
CALLBACK:  HTTP update process at 102400 of 535920 bytes...
CALLBACK:  HTTP update process at 106496 of 535920 bytes...
CALLBACK:  HTTP update process at 110592 of 535920 bytes...
CALLBACK:  HTTP update process at 114688 of 535920 bytes...
CALLBACK:  HTTP update process at 118784 of 535920 bytes...
CALLBACK:  HTTP update process at 122880 of 535920 bytes...
CALLBACK:  HTTP update process at 126976 of 535920 bytes...
CALLBACK:  HTTP update process at 131072 of 535920 bytes...
CALLBACK:  HTTP update process at 135168 of 535920 bytes...
CALLBACK:  HTTP update process at 139264 of 535920 bytes...
CALLBACK:  HTTP update process at 143360 of 535920 bytes...
CALLBACK:  HTTP update process at 147456 of 535920 bytes...
CALLBACK:  HTTP update process at 151552 of 535920 bytes...
CALLBACK:  HTTP update process at 155648 of 535920 bytes...
CALLBACK:  HTTP update process at 159744 of 535920 bytes...
CALLBACK:  HTTP update process at 163840 of 535920 bytes...
CALLBACK:  HTTP update process at 167936 of 535920 bytes...
CALLBACK:  HTTP update process at 172032 of 535920 bytes...
CALLBACK:  HTTP update process at 176128 of 535920 bytes...
CALLBACK:  HTTP update process at 180224 of 535920 bytes...
CALLBACK:  HTTP update process at 184320 of 535920 bytes...
CALLBACK:  HTTP update process at 188416 of 535920 bytes...
CALLBACK:  HTTP update process at 192512 of 535920 bytes...
CALLBACK:  HTTP update process at 196608 of 535920 bytes...
CALLBACK:  HTTP update process at 200704 of 535920 bytes...
CALLBACK:  HTTP update process at 204800 of 535920 bytes...
CALLBACK:  HTTP update process at 208896 of 535920 bytes...
CALLBACK:  HTTP update process at 212992 of 535920 bytes...
CALLBACK:  HTTP update process at 217088 of 535920 bytes...
CALLBACK:  HTTP update process at 221184 of 535920 bytes...
CALLBACK:  HTTP update process at 225280 of 535920 bytes...
CALLBACK:  HTTP update process at 229376 of 535920 bytes...
CALLBACK:  HTTP update process at 233472 of 535920 bytes...
CALLBACK:  HTTP update process at 237568 of 535920 bytes...
CALLBACK:  HTTP update process at 241664 of 535920 bytes...
CALLBACK:  HTTP update process at 245760 of 535920 bytes...
CALLBACK:  HTTP update process at 249856 of 535920 bytes...
CALLBACK:  HTTP update process at 253952 of 535920 bytes...
CALLBACK:  HTTP update process at 258048 of 535920 bytes...
CALLBACK:  HTTP update process at 262144 of 535920 bytes...
CALLBACK:  HTTP update process at 266240 of 535920 bytes...
CALLBACK:  HTTP update process at 270336 of 535920 bytes...
CALLBACK:  HTTP update process at 274432 of 535920 bytes...
CALLBACK:  HTTP update process at 278528 of 535920 bytes...
CALLBACK:  HTTP update process at 282624 of 535920 bytes...
CALLBACK:  HTTP update process at 286720 of 535920 bytes...
CALLBACK:  HTTP update process at 290816 of 535920 bytes...
CALLBACK:  HTTP update process at 294912 of 535920 bytes...
CALLBACK:  HTTP update process at 299008 of 535920 bytes...
CALLBACK:  HTTP update process at 303104 of 535920 bytes...
CALLBACK:  HTTP update process at 307200 of 535920 bytes...
CALLBACK:  HTTP update process at 311296 of 535920 bytes...
CALLBACK:  HTTP update process at 315392 of 535920 bytes...
CALLBACK:  HTTP update process at 319488 of 535920 bytes...
CALLBACK:  HTTP update process at 323584 of 535920 bytes...
CALLBACK:  HTTP update process at 327680 of 535920 bytes...
CALLBACK:  HTTP update process at 331776 of 535920 bytes...
CALLBACK:  HTTP update process at 335872 of 535920 bytes...
CALLBACK:  HTTP update process at 339968 of 535920 bytes...
CALLBACK:  HTTP update process at 344064 of 535920 bytes...
CALLBACK:  HTTP update process at 348160 of 535920 bytes...
CALLBACK:  HTTP update process at 352256 of 535920 bytes...
CALLBACK:  HTTP update process at 356352 of 535920 bytes...
CALLBACK:  HTTP update process at 360448 of 535920 bytes...
CALLBACK:  HTTP update process at 364544 of 535920 bytes...
CALLBACK:  HTTP update process at 368640 of 535920 bytes...
CALLBACK:  HTTP update process at 372736 of 535920 bytes...
CALLBACK:  HTTP update process at 376832 of 535920 bytes...
CALLBACK:  HTTP update process at 380928 of 535920 bytes...
CALLBACK:  HTTP update process at 385024 of 535920 bytes...
CALLBACK:  HTTP update process at 389120 of 535920 bytes...
CALLBACK:  HTTP update process at 393216 of 535920 bytes...
CALLBACK:  HTTP update process at 397312 of 535920 bytes...
CALLBACK:  HTTP update process at 401408 of 535920 bytes...
CALLBACK:  HTTP update process at 405504 of 535920 bytes...
CALLBACK:  HTTP update process at 409600 of 535920 bytes...
CALLBACK:  HTTP update process at 413696 of 535920 bytes...
CALLBACK:  HTTP update process at 417792 of 535920 bytes...
CALLBACK:  HTTP update process at 421888 of 535920 bytes...
CALLBACK:  HTTP update process at 425984 of 535920 bytes...
CALLBACK:  HTTP update process at 430080 of 535920 bytes...
CALLBACK:  HTTP update process at 434176 of 535920 bytes...
CALLBACK:  HTTP update process at 438272 of 535920 bytes...
CALLBACK:  HTTP update process at 442368 of 535920 bytes...
CALLBACK:  HTTP update process at 446464 of 535920 bytes...
CALLBACK:  HTTP update process at 450560 of 535920 bytes...
CALLBACK:  HTTP update process at 454656 of 535920 bytes...
CALLBACK:  HTTP update process at 458752 of 535920 bytes...
CALLBACK:  HTTP update process at 462848 of 535920 bytes...
CALLBACK:  HTTP update process at 466944 of 535920 bytes...
CALLBACK:  HTTP update process at 471040 of 535920 bytes...
CALLBACK:  HTTP update process at 475136 of 535920 bytes...
CALLBACK:  HTTP update process at 479232 of 535920 bytes...
CALLBACK:  HTTP update process at 483328 of 535920 bytes...
CALLBACK:  HTTP update process at 487424 of 535920 bytes...
CALLBACK:  HTTP update process at 491520 of 535920 bytes...
CALLBACK:  HTTP update process at 495616 of 535920 bytes...
CALLBACK:  HTTP update process at 499712 of 535920 bytes...
CALLBACK:  HTTP update process at 503808 of 535920 bytes...
CALLBACK:  HTTP update process at 507904 of 535920 bytes...
CALLBACK:  HTTP update process at 512000 of 535920 bytes...
CALLBACK:  HTTP update process at 516096 of 535920 bytes...
CALLBACK:  HTTP update process at 520192 of 535920 bytes...
CALLBACK:  HTTP update process at 524288 of 535920 bytes...
CALLBACK:  HTTP update process at 528384 of 535920 bytes...
CALLBACK:  HTTP update process at 532480 of 535920 bytes...
CALLBACK:  HTTP update process at 535920 of 535920 bytes...
CALLBACK:  HTTP update process at 535920 of 535920 bytes...
CALLBACK:  HTTP update process at 535920 of 535920 bytes...
Staged: address:0x0027D000, size:0x00082D70
[HTTP-Client][end] tcp is closed
CALLBACK:  HTTP update process finished
[HTTP-Client][end] tcp is closed
HTTP_UPDATE_OK

BrotherV avatar Jul 16 '22 16:07 BrotherV

This seems to be wrong here

        if (canBegin)
        {
          size_t written = update->writeStream(*client);

you should work on httpClient object, not on client secured stream. Try it like this

    WiFiClient *stream = httpClient.getStreamPtr();
    if (!stream){
      // do some error processing
          return;
    }

   size_t written = update->writeStream(*stream);

vortigont avatar Aug 08 '22 06:08 vortigont