Hi,
Using here the ESP32S3 with ESP-IDF in master branch.
The development kits on the bench are
ESP32-S3-DevKitC-1-N8
ESP32-S3-DevKitC-1-N8R2
ESP32-S3-DevKitC-1-N8R8
where respectively the modules they got are
ESP32-S3-WROOM-1-N8
ESP32-S3-WROOM-1-N8R2
ESP32-S3-WROOM-1-N8R8
I need to have memory allocated in programs with calloc().
How can I use the 8M Quad Flash memory and the 2M or 8M PSRAM memory of the modules to be accessible via calloc() ?
The "himem" example in ESP-IDF is not applicable to ESP32S3, just the ESP32.
Is there any example to examine?
Or any documentation on this?
Regards,
ESP32-S3-WROOM-1 N8/N8R2/N8R8 memory
-
- Posts: 9764
- Joined: Thu Nov 26, 2015 4:08 am
Re: ESP32-S3-WROOM-1 N8/N8R2/N8R8 memory
There's no need for himem on the ESP32-S3. Himem is a workaround on the original ESP32 to work around the fact that it only has addressing space for 4MiB of PSRAM. That addressing space got expanded to 32MiB (shared with flash) for data on the ESP32-S3; it means you can simply enable PSRAM and allocate the entire 8MiB using malloc()/calloc or heap_caps_alloc().
-
- Posts: 20
- Joined: Sat May 14, 2022 1:36 pm
Re: ESP32-S3-WROOM-1 N8/N8R2/N8R8 memory
Hi @ESP_Sprite, thanks for answering.
Got a few blanks though regarding the details of the ESP32S3 part numbers and of RAM usage in the modules.
What ESP32S3 part numbers are actually inside the modules
ESP32-S3-WROOM-1-N8
ESP32-S3-WROOM-1-N8R2
ESP32-S3-WROOM-1-N8R8
as I did not found this specific information in the relevant modules datasheet
https://www.espressif.com/sites/default ... eet_en.pdf
As I understand it, I do not need to enable the 8MiB flash RAM (the N8 part, 8MiB Quad SPI) as it is already by default enabled, only the additional 2MiB/8MiB PSRAM from sdkconfig, is that correct?
Also, from what I understand, inside the ESP32S3 chip is a 512KB RAM, is this the specified IRAM in sdkconfig?
Regards,
Got a few blanks though regarding the details of the ESP32S3 part numbers and of RAM usage in the modules.
What ESP32S3 part numbers are actually inside the modules
ESP32-S3-WROOM-1-N8
ESP32-S3-WROOM-1-N8R2
ESP32-S3-WROOM-1-N8R8
as I did not found this specific information in the relevant modules datasheet
https://www.espressif.com/sites/default ... eet_en.pdf
As I understand it, I do not need to enable the 8MiB flash RAM (the N8 part, 8MiB Quad SPI) as it is already by default enabled, only the additional 2MiB/8MiB PSRAM from sdkconfig, is that correct?
Also, from what I understand, inside the ESP32S3 chip is a 512KB RAM, is this the specified IRAM in sdkconfig?
Regards,
-
- Posts: 9764
- Joined: Thu Nov 26, 2015 4:08 am
Re: ESP32-S3-WROOM-1 N8/N8R2/N8R8 memory
Table 1 and 2 in the datasheet indicate the amount of PSRAM and flash inside the modules; the exact type of chip used isn't really relevant as PSRAM/flash inside the chip package works 100% exactly the same as PSRAM/flash outside the chip package but inside the module.
The flash (note that flash is not RAM) is indeed enabled by default, as that is the thing your program runs off. You indeed can/need to enable PSRAM in menuconfig before it works. The ESP32S3 has 512K of internal memory as well, this is partially used as IRAM and partially used as DRAM.
The flash (note that flash is not RAM) is indeed enabled by default, as that is the thing your program runs off. You indeed can/need to enable PSRAM in menuconfig before it works. The ESP32S3 has 512K of internal memory as well, this is partially used as IRAM and partially used as DRAM.
-
- Posts: 20
- Joined: Sat May 14, 2022 1:36 pm
Re: ESP32-S3-WROOM-1 N8/N8R2/N8R8 memory
Hi @ESP_Sprite,
Thanks for making this clear.
It needed for me to do some reading regarding the memory scheme of ESP32 CPU and now I think I got a grasp more or less of the SRAM0/1/2, D/IRAM, flash and PseudoStaticRAM.
Did successfully the required calloc() that I was trying to do earlier (and failed due to size).
That happened by enabling PSRAM support in sdkconfig and thus seen added the PSRAM available space (esp_get_free_heap_size).
One question, it seems I cannot do calloc() by using only the 8M flash space, just the D/IRAM & PSRAM, is that the normal behaviour or am I missing something?
Also, can I direct which area (D/IRAM or PSRAM) calloc() will allocate memory from ?
Regards,
Thanks for making this clear.
It needed for me to do some reading regarding the memory scheme of ESP32 CPU and now I think I got a grasp more or less of the SRAM0/1/2, D/IRAM, flash and PseudoStaticRAM.
Did successfully the required calloc() that I was trying to do earlier (and failed due to size).
That happened by enabling PSRAM support in sdkconfig and thus seen added the PSRAM available space (esp_get_free_heap_size).
One question, it seems I cannot do calloc() by using only the 8M flash space, just the D/IRAM & PSRAM, is that the normal behaviour or am I missing something?
Also, can I direct which area (D/IRAM or PSRAM) calloc() will allocate memory from ?
Regards,
-
- Posts: 9764
- Joined: Thu Nov 26, 2015 4:08 am
Re: ESP32-S3-WROOM-1 N8/N8R2/N8R8 memory
Suggest you refer to the docs for this. You can specifically ask for a certain type of memory by using heap_caps_alloc. Calloc and friends will generally never return IRAM (as it's not byte-addressable and those functions are expected to return byte-addressable RAM), and they will use a heuristic to return PSRAM or DRAM: if the memory amount allocated is over a certain (configurable in menuconfig) size, it'll try psram first, otherwise it'll try dram first. If that fails, it'll try the other; if that fails, it'll return NULL.aristarchos wrote: ↑Mon Oct 03, 2022 5:35 pmHi @ESP_Sprite,
Thanks for making this clear.
It needed for me to do some reading regarding the memory scheme of ESP32 CPU and now I think I got a grasp more or less of the SRAM0/1/2, D/IRAM, flash and PseudoStaticRAM.
Did successfully the required calloc() that I was trying to do earlier (and failed due to size).
That happened by enabling PSRAM support in sdkconfig and thus seen added the PSRAM available space (esp_get_free_heap_size).
One question, it seems I cannot do calloc() by using only the 8M flash space, just the D/IRAM & PSRAM, is that the normal behaviour or am I missing something?
Also, can I direct which area (D/IRAM or PSRAM) calloc() will allocate memory from ?
Regards,
Who is online
Users browsing this forum: Baidu [Spider] and 133 guests