Query on the ESP32's internal DRAM

mpulis
Posts: 57
Joined: Mon Aug 07, 2017 7:53 am

Query on the ESP32's internal DRAM

Postby mpulis » Tue Dec 15, 2020 9:44 am

Hi,

I've compiled a firmware and had it run on multiple devices without any sort of issue, but have found 1 which was stuck in a continuous reset loop.

On further investigation the cause was found. When a particular task was created using the xTaskCreatePinnedToCore() function, an error code of -1 would be returned. The firmware is designed to reset whenever a task cannot be created, assuming that something went wrong during program execution.

I've run heap_caps_get_largest_free_block(MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL) to find out how much contiguous internal DRAM I have available for stack allocation and have found it to be low. Reducing the stack depth of the task the RTOS is attempting to create solves the reset issue.

What's puzzling me is why this happened on a single device, but not on the rest. I've had 3 other devices undergoing extensive testing and none gave any hint of such an issue. Is there something I'm missing, such as perhaps variances in the order of a few kB in the available internal DRAM between one ESP32 and another?

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

Re: Query on the ESP32's internal DRAM

Postby ESP_Sprite » Wed Dec 16, 2020 1:58 am

Is this on initialization, or has the ESP32 already been running for a while after the WiFi stack has been initialized? If the second, the difference could be that some WiFi activity already has depleted the stack by a bit. (Another thing I can think of is that the chips may be a different ECO, although I'm not sure if that would show in an allocation size change.)

mpulis
Posts: 57
Joined: Mon Aug 07, 2017 7:53 am

Re: Query on the ESP32's internal DRAM

Postby mpulis » Wed Dec 16, 2020 9:15 am

This is during initialization, just after the WiFi stack has been initialized.

Please forgive what might be an obvious question, but what do you mean by different ECO?

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

Re: Query on the ESP32's internal DRAM

Postby ESP_Sprite » Wed Dec 16, 2020 10:38 am

The ESP32 has various revisions (you'll find ECO0, 1 and 3 in the wild) that fix various bugs. Workaround for some bugs may use some dynamic memory ('may' as I can't easily check here) that affect memory allocation. Shouldn't be much, but can be just enough to push you over the edge, as it were.

mpulis
Posts: 57
Joined: Mon Aug 07, 2017 7:53 am

Re: Query on the ESP32's internal DRAM

Postby mpulis » Wed Dec 16, 2020 3:48 pm

I see. Well, all the boards (custom made boards) being tested use the WROVER-IE, which should have the same ECO version.

But your earlier point regarding the WiFi stack has put a bug in my ear :P I'll try checking how the amount of un-allocated memory varies between different boards both with and without the WiFi stack initialized to see whether that's the source of the different behavior.

mpulis
Posts: 57
Joined: Mon Aug 07, 2017 7:53 am

Re: Query on the ESP32's internal DRAM

Postby mpulis » Fri Dec 18, 2020 1:21 pm

I've found the root of the issue! It has nothing to do with the ESP32's memory and everything to do with my firmware :oops: A TCP Client was being initialized twice in the device which kept rebooting, resulting in the lower amount of unallocated memory on it.

Thanks for your support!

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

Re: Query on the ESP32's internal DRAM

Postby ESP_Sprite » Mon Dec 21, 2020 3:37 am

No problem, thanks for reporting back on this!

Who is online

Users browsing this forum: No registered users and 250 guests