[Resolved] ESP_HTTPS_OTA gives memory allocation failed error

shaqlain garana
Posts: 6
Joined: Wed Feb 02, 2022 5:43 pm

[Resolved] ESP_HTTPS_OTA gives memory allocation failed error

Postby shaqlain garana » Wed Feb 02, 2022 5:57 pm

Here are the logs that i am getting in the terminal
i am sending url in json to esp32 (which is my http webserver) and starting ota task on that link but its giving error of memory allocation failed

logs during startup of ESP32
I (570) cpu_start: Application information:
I (575) cpu_start: Project name: template-app
I (580) cpu_start: App version: 7bcdc7e-dirty
I (586) cpu_start: Compile time: Feb 2 2022 22:32:05
I (592) cpu_start: ELF file SHA256: ec97cfa832198e8c...
I (598) cpu_start: ESP-IDF: v4.4-dev-3703-gddc44956bf-dirty
I (605) heap_init: Initializing. RAM available for dynamic allocation:
I (612) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (618) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM
I (624) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
I (630) heap_init: At 3FFCC018 len 00013FE8 (79 KiB): DRAM
I (637) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (643) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (649) heap_init: At 4009AAC0 len 00005540 (21 KiB): IRAM
I (657) spi_flash: detected chip: generic
I (660) spi_flash: flash io: dio
I (676) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.

log during ota start
I (40647) OTA: Starting OTA example<ESC>[0m<CR><LF>
I (40697) before OTA: [APP] Free memory: 121004 bytes<ESC>[0m<CR><LF>
E (40767) HTTP_CLIENT: Allocation failed<ESC>[0m<CR><LF>
E (40817) esp_https_ota: Failed to initialise HTTP connection<ESC>[0m<CR><LF>
I (40897) after OTA: [APP] Free memory: 124116 bytes<ESC>[0m<CR><LF>

E (40967) OTA: Firmware upgrade failed<ESC>[0m<CR><LF>

Please help me i am not getting much help on the internet in this issue While i figured out that this is heap size issue is there any way to clear all unnecessary heap before ota_start

Although i am also printing the availabe heap size before ota_start which is more than 110Kb still don't know what causing the issue.
looking forward for some breath taking solution

Thanks in advance !!!
cheers :D :D

ESP_Sprite
Posts: 9772
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP_HTTPS_OTA gives memory allocation failed error

Postby ESP_Sprite » Thu Feb 03, 2022 5:38 am

It means either your memory is super-fragmented or you indeed try to allocate a too large chunk of memory. Which leads to the question: how much RAM are you actually trying to allocate there?

shaqlain garana
Posts: 6
Joined: Wed Feb 02, 2022 5:43 pm

Re: ESP_HTTPS_OTA gives memory allocation failed error

Postby shaqlain garana » Thu Feb 03, 2022 9:18 am

hello thankyou for your response
although i have resolved the issue the issue was occurring during client config so i just did this

esp_http_client_config_t config = {0};

config.url = "www.xyz.com/";
config.cert_pem = (char *)server_cert_pem_start;
config.event_handler = _http_event_handler;
config.timeout_ms = 2000;
config.keep_alive_enable = true;

and now its working
cheers !!!


Squirrelbd
Posts: 6
Joined: Tue Mar 22, 2022 4:39 am

Re: [Resolved] ESP_HTTPS_OTA gives memory allocation failed error

Postby Squirrelbd » Thu May 12, 2022 6:56 pm

Can you please share your OTA over the internet project? Maybe the procedure and code. Thanks

253379568@qq.com
Posts: 1
Joined: Mon Feb 26, 2024 7:07 am

Re: [Resolved] ESP_HTTPS_OTA gives memory allocation failed error

Postby 253379568@qq.com » Tue Feb 27, 2024 1:38 am

hello ,Can you help me solve this problem? thanks!
Attachments
aly.h
(2.39 KiB) Downloaded 132 times
aly.c
(9.85 KiB) Downloaded 153 times
屏幕截图 2024-02-27 093503.png
屏幕截图 2024-02-27 093503.png (60.77 KiB) Viewed 2066 times

Who is online

Users browsing this forum: Bing [Bot], elettronica67 and 90 guests