HTTPS OTA fail

User avatar
urbanze
Posts: 301
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

HTTPS OTA fail

Postby urbanze » Mon Sep 25, 2023 2:53 pm

Hello guys! I started to use IDF v5.1.1 to develop new products but I stucked when trying to use HTTPS OTA. Someone can give me an idea about this problem?


Init Code:

Code: Select all

void ota_init()
{
    esp_http_client_config_t config;
    config.host = "blabla.com";
    config.port = 443;
    config.path = "/blabla.bin";
    config.cert_pem = (char *)server_cert_pem_start;
    config.user_agent = "Blabla";
    config.timeout_ms = 30000;
    config.event_handler = event_handler;
    config.transport_type = HTTP_TRANSPORT_OVER_SSL;
    config.keep_alive_enable = true;
    config.keep_alive_interval = 5;

    esp_https_ota_config_t ota_config;
    ota_config.http_config = &config;

    esp_err_t ret = esp_https_ota(&ota_config);
    ESP_LOGI(__func__, "OTA RET: %d", ret);
}

Error (Back trace):

Code: Select all

Guru Meditation Error: Core  0 panic'ed (LoadStoreError). Exception was unhandled.

Core  0 register dump:
PC      : 0x40086a14  PS      : 0x00060f30  A0      : 0x8011e10e  A1      : 0x3ffb6a20  
0x40086a14: memcpy at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/memcpy.S:229

A2      : 0x3ffc68ec  A3      : 0x40127b48  A4      : 0x00000006  A5      : 0x3ffc68f0  
0x40127b48: vprintf at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/stdio/vprintf.c:30

A6      : 0x39006136  A7      : 0x00000000  A8      : 0x00000000  A9      : 0x3ffb69f0  
A10     : 0x3ffc68ec  A11     : 0x00000007  A12     : 0x000000ff  A13     : 0x0000ff00  
A14     : 0x00ff0000  A15     : 0xff000000  SAR     : 0x00000017  EXCCAUSE: 0x00000003  
EXCVADDR: 0x40127b48  LBEG    : 0x400869c4  LEND    : 0x400869e0  LCOUNT  : 0xffffffff  
0x40127b48: vprintf at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/stdio/vprintf.c:30

0x400869c4: memcpy at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/memcpy.S:175

0x400869e0: memcpy at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/memcpy.S:197



Backtrace: 0x40086a11:0x3ffb6a20 0x4011e10b:0x3ffb6a30 0x401014bb:0x3ffb6a60 0x40101af3:0x3ffb6aa0 0x400d969d:0x3ffb6ad0 0x400d8d03:0x3ffb6b90 0x4013139f:0x3ffb6bb0 0x4008c35d:0x3ffb6be0
0x40086a11: memcpy at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/memcpy.S:226

0x4011e10b: esp_http_client_init at /home/ze/esp/v5.0/esp-idf/components/esp_http_client/esp_http_client.c:678 (discriminator 2)

0x401014bb: esp_https_ota_begin at /home/ze/esp/v5.0/esp-idf/components/esp_https_ota/src/esp_https_ota.c:295

0x40101af3: esp_https_ota at /home/ze/esp/v5.0/esp-idf/components/esp_https_ota/src/esp_https_ota.c:733

0x400d969d: ota_init() at /home/ze/esp/v5.0/hello_world/components/network/ota.cpp:64

0x400d8d03: app_main at /home/ze/esp/v5.0/hello_world/main/main.cpp:101

0x4013139f: main_task at /home/ze/esp/v5.0/esp-idf/components/freertos/app_startup.c:208 (discriminator 13)

0x4008c35d: vPortTaskWrapper at /home/ze/esp/v5.0/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:162





ELF file SHA256: f82604f762cf46ba

Rebooting...

When I set config struct to zero, another error appears:

Code: Select all

void ota_init()
{
    esp_http_client_config_t config;
    memset(&config, 0, sizeof(config));
    config.host = "noprod.followenergy.com";
    config.port = 443;
    config.path = "/gtwfirmware/iotmqtt/firmware.bin";
    config.cert_pem = (char *)server_cert_pem_start;
    config.user_agent = "ZEEngie CE0037-IoT MQTT Gateway";
    config.timeout_ms = 180000;
    config.event_handler = event_handler;
    config.transport_type = HTTP_TRANSPORT_OVER_SSL;
    config.keep_alive_enable = true;
    config.keep_alive_interval = 180;

    esp_https_ota_config_t ota_config;
    ota_config.http_config = &config;

    esp_err_t ret = esp_https_ota(&ota_config);
    ESP_LOGI(__func__, "OTA RET: %d", ret);
}
Back trace:

Code: Select all

Guru Meditation Error: Core  0 panic'ed (InstrFetchProhibited). Exception was unhandled.

Core  0 register dump:
PC      : 0x801313aa  PS      : 0x00060f30  A0      : 0x80101afe  A1      : 0x3ffb6a60  
A2      : 0x3ffb6b5c  A3      : 0x3ffb6aa0  A4      : 0x3ffc65a4  A5      : 0x801313aa  
A6      : 0x40127b4c  A7      : 0xb33fffff  A8      : 0x801014f0  A9      : 0x3ffb6a30  
0x40127b4c: vprintf at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/stdio/vprintf.c:30

A10     : 0x3ffc65d4  A11     : 0x00000001  A12     : 0x3ffc66b8  A13     : 0x4012fae0  
0x4012fae0: http_on_chunk_header at /home/ze/esp/v5.0/esp-idf/components/esp_http_client/esp_http_client.c:329

A14     : 0x00000002  A15     : 0x00000000  SAR     : 0x00000018  EXCCAUSE: 0x00000014  
EXCVADDR: 0x801313a8  LBEG    : 0x40087131  LEND    : 0x40087141  LCOUNT  : 0xfffffff9  
0x40087131: strlen at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/strlen.S:84

0x40087141: strlen at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/strlen.S:96



Backtrace: 0x401313a7:0x3ffb6a60 0x40101afb:0x3ffb6aa0 0x400d96a5:0x3ffb6ad0 0x400d8d03:0x3ffb6b90 0x401313a7:0x3ffb6bb0 0x4008c35d:0x3ffb6be0
0x401313a7: main_task at /home/ze/esp/v5.0/esp-idf/components/freertos/app_startup.c:208 (discriminator 13)

0x40101afb: esp_https_ota at /home/ze/esp/v5.0/esp-idf/components/esp_https_ota/src/esp_https_ota.c:733

0x400d96a5: ota_init() at /home/ze/esp/v5.0/hello_world/components/network/ota.cpp:65

0x400d8d03: app_main at /home/ze/esp/v5.0/hello_world/main/main.cpp:101

0x401313a7: main_task at /home/ze/esp/v5.0/esp-idf/components/freertos/app_startup.c:208 (discriminator 13)

0x4008c35d: vPortTaskWrapper at /home/ze/esp/v5.0/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:162





ELF file SHA256: 89d5729e59cc39a8

Rebooting...

MicroController
Posts: 1734
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: HTTPS OTA fail

Postby MicroController » Mon Sep 25, 2023 5:51 pm

When I set config struct to zero, another error appears:
Make sure you also fully initialize or zero out ota_config.

User avatar
urbanze
Posts: 301
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Re: HTTPS OTA fail

Postby urbanze » Mon Sep 25, 2023 6:46 pm

MicroController wrote:
Mon Sep 25, 2023 5:51 pm
When I set config struct to zero, another error appears:
Make sure you also fully initialize or zero out ota_config.
I used memset() to fill with zeros, then internal http function (callback) crashs.

MicroController
Posts: 1734
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: HTTPS OTA fail

Postby MicroController » Tue Sep 26, 2023 7:04 pm

urbanze wrote:
Mon Sep 25, 2023 6:46 pm
Make sure you also fully initialize or zero out ota_config.
I used memset() to fill with zeros
Not in the code you posted.
Also check that the PEM actually is a 0-terminated string.

User avatar
urbanze
Posts: 301
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Re: HTTPS OTA fail

Postby urbanze » Tue Sep 26, 2023 10:05 pm

MicroController wrote:
Tue Sep 26, 2023 7:04 pm
urbanze wrote:
Mon Sep 25, 2023 6:46 pm
Make sure you also fully initialize or zero out ota_config.
I used memset() to fill with zeros
Not in the code you posted.
Also check that the PEM actually is a 0-terminated string.
Please pay attention on the second code, I used memset().

I already check if string is correct from embbed_txtfile (cmake) and everything is fine. I try to copy the embbed_txtfile to another char* just to test but the same error continues to ocurr.

Someone can help me to find what is the problem?

boarchuz
Posts: 606
Joined: Tue Aug 21, 2018 5:28 am

Re: HTTPS OTA fail

Postby boarchuz » Tue Sep 26, 2023 11:09 pm

urbanze wrote:
Tue Sep 26, 2023 10:05 pm
Please pay attention on the second code, I used memset().
You did for esp_http_client_config_t but not for the esp_https_ota_config_t.

Who is online

Users browsing this forum: Baidu [Spider] and 152 guests