Enabling PSRAM breaks my OTA over HTTPS

MichaelS
Posts: 29
Joined: Mon Jul 08, 2024 12:08 am

Enabling PSRAM breaks my OTA over HTTPS

Postby MichaelS » Sat Nov 16, 2024 7:09 am

I have a problem using PSRAM. Actually just enabling PSRAM in Menu config, but not actually using it. I have configured
- ESP PSRAM Support for external SPI-connected RAM
- Selected Octal Mode PSRAM
- set SPI RAM accerss method to Make RAM allocatable using heap_caps_malloc(..., MALLOC_CAP_SPIRAM)

I do plan to use CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY and __NOINIT_ATTR to store variables in PSRAM which will be non volatile across a CPS reset, but I have not got this far yet due to the problem below.

My project uses OTA https integrated into my applicaton from the example project advanced_https_ota. My project also uses Wifi Mesh with 4 Nodes under test and using MQTT5.

Up until recently I haven't enabled PSRAM and everything has been running fine.

When I enable PSRAM, my MQTT and WiFi mesh comms and MQTT operate fine, even under heavy tests.

But enabling PSRAM seems to affect my MESH_ROOT doing HTTPS OTA. OTA runs slower and eventually errors. If I don't run my MQTT Host client on my PC, the OTA runs slower and reports some error but does complete. If I run my Host client, it only publishes one message to each node and gets publish response every 3 seconds, so pretty low traffic. But this is enough to break make the OTA fail.

If I go back and disable PSRAM in Menu Config, everything behaves perfectly again.

I have read at https://docs.espressif.com/projects/esp ... l-ram.html under the header "Restrictions ... When flash cache is disabled (for example, if the flash is being written to), the external RAM also becomes inaccessible...External RAM uses the same cache region as the external flash...However, when accessing large chunks of data (> 32 KB), the cache can be insufficient, and speeds will fall back...
This sounds possibly relevant, but I don't understand it enough to know how to fix my problem. Obviously OTA involves writing large chunks of data to Flash.

Once my MESH_ROOT has received the new application over HTTPS OTA, it uses WiFi Mesh commands

Code: Select all

esp_mesh_send(destMac, &data, MESH_DATA_P2P, NULL, 0)
in a protocol I developed to send the new application to all my MESH_NODEs which also write to flash. This never has a problem even with PSRAM being enabled and with MQTT comms running at the same time. But the difference is this only sends and writes in block sizes on 1024 bytes due to the maximum Mesh packet size MESH_MPS being 1472 bytes.

So I tried configuring Menu Config "HTTP request size" from 16,384 down to 1024 bytes and confirmed it was writing 1024 bytes to flash in the OTA by adding this line of code to

Code: Select all

esp_https_ota.c in function static esp_err_t _ota_write(esp_https_ota_t *https_ota_handle, const void *buffer, size_t buf_len)
    ESP_LOGI(TAG, "_ota_write: %d", buf_len);
and confirmed this.

But the problem still occurs.

See log file attached where I start the OTA HTTPS with only the MESH_ROOT and then power up MESH_NODEs part way through. Everything is running fine until the MESH_NODES join. The logs show HTTPS errors but this is not my code and I can't work inside this.

Again if I go back and disable PSRAM, everything runs rock solid again.
SO it kind of looks like the problem with HTTPS when PSRAM is enabled

Again, disabling PS-RAM again brings everything good. I have double check tested this many times.
Test logs 16Nov.zip
(2.2 KiB) Downloaded 122 times

Who is online

Users browsing this forum: Google [Bot] and 106 guests