HTTPS OTA Firmware Upgrade for Arduino failed

luki_v11
Posts: 2
Joined: Tue Jan 26, 2021 9:13 pm

HTTPS OTA Firmware Upgrade for Arduino failed

Postby luki_v11 » Tue Jan 26, 2021 9:38 pm

Hello ESP32 Community

I am trying to run the HTTPS OTA Demo.
https://github.com/espressif/arduino-es ... Update.ino

I just added my WiFi Credentials, URL and Certificate (I am using the certificate in another sketch, so it should work). I don't know why the OTA update is failing.

Any help is very welcome.

Hardware:
Board: ESP32 Lolin D32
Core Installation version: arduino-esp32 1.0.5-rc6
IDE name: vscode with arduino-plugin
Partion Sheme: Minimal SPIFFS
Flash Frequency: 80Mhz
PSRAM enabled: not sure
Upload Speed: 115200
Computer OS: Mac OSX

Image

Code

Code: Select all

// This sketch provide the functionality of OTA Firmware Upgrade
#include "WiFi.h"
#include "HttpsOTAUpdate.h"
// This sketch shows how to implement HTTPS firmware update Over The Air.
// Please provide your WiFi credentials, https URL to the firmware image and the server certificate.

static const char *ssid = "**********";       // your network SSID (name of wifi network)
static const char *password = "**********"; // your network password

static const char *url = "https://vision11.ch/inklay/bin/inklay.bin"; //state url of your firmware image

const char *server_certificate =
    "-----BEGIN CERTIFICATE-----\n"
    "MIIEZTCCA02gAwIBAgIQQAF1BIMUpMghjISpDBbN3zANBgkqhkiG9w0BAQsFADA/\n"
    "MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT\n"
    "DkRTVCBSb290IENBIFgzMB4XDTIwMTAwNzE5MjE0MFoXDTIxMDkyOTE5MjE0MFow\n"
    "MjELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUxldCdzIEVuY3J5cHQxCzAJBgNVBAMT\n"
    "AlIzMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuwIVKMz2oJTTDxLs\n"
    "jVWSw/iC8ZmmekKIp10mqrUrucVMsa+Oa/l1yKPXD0eUFFU1V4yeqKI5GfWCPEKp\n"
    "Tm71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XXmNs+5ZnPBxzDJOLxhF2JIbeQAcH5H0tZrUlo5ZYyOqA7s9p\n"
    "O5b85o3AM/OJ+CktFBQtfvBhcJVd9wvlwPsk+uyOy2HI7mNxKKgsBTt375teA2Tw\n"
    "UdHkhVNcsAKX1H7GNNLOEADksd86wuoXvg==\n"
    "-----END CERTIFICATE-----\n"
    "";

static HttpsOTAStatus_t otastatus;

void HttpEvent(HttpEvent_t *event)
{
  switch (event->event_id)
  {
  case HTTP_EVENT_ERROR:
    Serial.println("Http Event Error");
    break;
  case HTTP_EVENT_ON_CONNECTED:
    Serial.println("Http Event On Connected");
    break;
  case HTTP_EVENT_HEADER_SENT:
    Serial.println("Http Event Header Sent");
    break;
  case HTTP_EVENT_ON_HEADER:
    Serial.printf("Http Event On Header, key=%s, value=%s\n", event->header_key, event->header_value);
    break;
  case HTTP_EVENT_ON_DATA:
    break;
  case HTTP_EVENT_ON_FINISH:
    Serial.println("Http Event On Finish");
    break;
  case HTTP_EVENT_DISCONNECTED:
    Serial.println("Http Event Disconnected");
    break;
  }
}

void setup()
{

  Serial.begin(115200);
  Serial.print("Attempting to connect to SSID: ");
  WiFi.begin(ssid, password);

  // attempt to connect to Wifi network:
  while (WiFi.status() != WL_CONNECTED)
  {
    Serial.print(".");
    delay(1000);
  }

  Serial.print("Connected to ");
  Serial.println(ssid);

  HttpsOTA.onHttpEvent(HttpEvent);
  Serial.println("Starting OTA");
  HttpsOTA.begin(url, server_certificate);

  Serial.println("Please Wait it takes some time ...");
}

void loop()
{
  otastatus = HttpsOTA.status();
  if (otastatus == HTTPS_OTA_SUCCESS)
  {
    Serial.println("Firmware written successfully. To reboot device, call API ESP.restart() or PUSH restart button on device");
  }
  else if (otastatus == HTTPS_OTA_FAIL)
  {
    Serial.println("Firmware Upgrade Fail");
  }
  delay(1000);
}
Debug:

Code: Select all

Starting OTA
Please Wait it takes some time ...
E (2365) esp-tls: mbedtls_ssl_handshake returned -0x2700
E (2368) esp-tls: Failed to open new connection
E (2368) TRANS_SSL: Failed to open a new connection
E (2368) HTTP_CLIENT: Connection failed, sock < 0
E (2373) esp_https_ota: Failed to open HTTP connection: ESP_ERR_HTTP_CONNECT
E (2379) esp_https_ota: Failed to establish HTTP connection
Http Event Disconnected
Http Event Disconnected
Firmware Upgrade Fail
I also tried:

Code: Select all

HttpsOTA.begin(url, cert_vision11, false);
Then i get:

Code: Select all

Attempting to connect to SSID: .Connected to Lukas WiFi
Starting OTA
Please Wait it takes some time ...
Http Event On Connected
Http Event Header Sent
Http Event On Header, key=Connection, value=Keep-Alive
Http Event On Header, key=Content-Type, value=application/octet-stream
Http Event On Header, key=Last-Modified, value=Mon, 25 Jan 2021 20:52:29 GMT
Http Event On Header, key=Etag, value="1812b0-600f2f8d-cb4e1db8c82e7411;;;"
Http Event On Header, key=Accept-Ranges, value=bytes
Http Event On Header, key=Content-Length, value=1577648
Http Event On Header, key=Date, value=Tue, 26 Jan 2021 20:48:35 GMT
Http Event On Header, key=Alt-Svc, value=quic=":443"; ma=2592000; v="43,46", h3-Q043=":443"; ma=2592000, h3-Q046=":443"; ma=2592000, h3-Q050=":443"; ma=2592000, h3-25=":443"; ma=2592000, h3-27=":443"; ma=2592000
E (7413) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (7450) task_wdt:  - IDLE0 (CPU 0)
E (7582) task_wdt: Tasks currently running:
E (7582) task_wdt: CPU 0: ipc0
E (7582) task_wdt: CPU 1: IDLE1
E (7582) task_wdt: Aborting.
abort() was called at PC 0x401085f0 on core 0

ELF file SHA256: 0000000000000000

Backtrace: 0x40088214:0x3ffbe2c0 0x40088491:0x3ffbe2e0 0x401085f0:0x3ffbe300 0x40082e65:0x3ffbe320 0x40085485:0x3ffb9d60 0x40082541:0x3ffb9d80 0x40085203:0x3ffb9da0 0x4008942a:0x3ffb9dc0

Rebooting...

Michalpu
Posts: 22
Joined: Sun Jan 24, 2021 1:37 pm

Re: HTTPS OTA Firmware Upgrade for Arduino failed

Postby Michalpu » Wed Jan 27, 2021 8:27 pm

Debuging this type of errors was done with mbedtls debug
Content creator at https://911electronic.com

luki_v11
Posts: 2
Joined: Tue Jan 26, 2021 9:13 pm

Re: HTTPS OTA Firmware Upgrade for Arduino failed

Postby luki_v11 » Thu Jan 28, 2021 9:14 pm

Thank you for your answer.

Can you be a bit more precise? In case the cert is not valid for this connection, how would you retrieve a valid cert from this server: https://www.vision11.ch

I am using this service: https://projects.petrucci.ch/esp32/?page=ssl

Thanks in advance for help.

Lukas

Who is online

Users browsing this forum: No registered users and 122 guests