I have a int32 array with up to 4MB. How can i allocate Memory for this Array?
I tried with heap_caps_malloc but it dont work.
How to allocate a big array on ESP32-S3 (8MB Flash,8MB PSRAM)
-
- Posts: 9708
- Joined: Thu Nov 26, 2015 4:08 am
Re: How to allocate a big array on ESP32-S3 (8MB Flash,8MB PSRAM)
Given you enabled psram in menuconfig, heap_caps_malloc() with the proper arguments or a plain malloc() should work.
Re: How to allocate a big array on ESP32-S3 (8MB Flash,8MB PSRAM)
Have i to enable "Support for external, SPI-connected RAM"? Its on my ESP32-S3 board
-
- Posts: 9708
- Joined: Thu Nov 26, 2015 4:08 am
Re: How to allocate a big array on ESP32-S3 (8MB Flash,8MB PSRAM)
Yes. 'External' here means 'not on the CPU die'.
Re: How to allocate a big array on ESP32-S3 (8MB Flash,8MB PSRAM)
uint32_t *data = heap_caps_malloc(50000*(sizeof(uint32_t)),MALLOC_CAP_SPIRAM);
With this i get a "Store probihited" error. Is there a example to allocate the PSRAM?
With this i get a "Store probihited" error. Is there a example to allocate the PSRAM?
-
- Posts: 9708
- Joined: Thu Nov 26, 2015 4:08 am
Re: How to allocate a big array on ESP32-S3 (8MB Flash,8MB PSRAM)
That's normally not something that can give you a store prohibited error... can you post your complete project? There's not really a psram example as it normally is not something people have issues with.
Re: How to allocate a big array on ESP32-S3 (8MB Flash,8MB PSRAM)
I think the declaration is ok and i get no error. But if i write data on it it crashed.
With ESP_LOGI (TAG, "heap_caps_get_free_size: %d\n", heap_caps_get_free_size(MALLOC_CAP_SPIRAM);
i get a size of 0. I dont know whats wrong.
With ESP_LOGI (TAG, "heap_caps_get_free_size: %d\n", heap_caps_get_free_size(MALLOC_CAP_SPIRAM);
i get a size of 0. I dont know whats wrong.
Re: How to allocate a big array on ESP32-S3 (8MB Flash,8MB PSRAM)
Code: Select all
uint32_t *data = heap_caps_malloc(50000*(sizeof(uint32_t)),MALLOC_CAP_SPIRAM);
heap_caps_print_heap_info(MALLOC_CAP_SPIRAM);
Code: Select all
Heap summary for capabilities 0x00000400:
Totals:
free 0 allocated 0 min_free 0 largest_free_block 0
Re: How to allocate a big array on ESP32-S3 (8MB Flash,8MB PSRAM)
It works...there was wrong settings in menuconfig
Who is online
Users browsing this forum: Bing [Bot] and 88 guests