Hi all -
As my application has outgrown the internal RAM resources of the ESP32, I'm attempting to use the external RAM supplied in the WROVER. My efforts, though, result in a system that fails early in the startup. Depending on the options I set, the failure ranges from a stack overflow in one task (wifi), to a failed system call (nvs_flash_init_partition) in another.
Based on the docs, I'd assumed that with the WROVER, everything was provided from a hardware standpoint, and I just needed to do the configuration. Correct or not?
Also, it's worth pointing out that when I undo my changes (in menuconfig), the sdkconfig file is not restored to its pre-change contents, *and* my app still fails. The contents difference could be because I've also changed my idf version, though that doesn't explain the crashing.
Module WROVER, revision 1. Now using v4.0-rc.
Thanks for any help.
(solved) failing to use external RAM
(solved) failing to use external RAM
Last edited by mzimmers on Tue Feb 04, 2020 2:37 pm, edited 1 time in total.
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: failing to use external RAM
Not sure about the rest, but:
That is correct, given you provide it with power and all the standard things that a Wroom would also need.Based on the docs, I'd assumed that with the WROVER, everything was provided from a hardware standpoint, and I just needed to do the configuration. Correct or not?
Re: failing to use external RAM
Hi Sprite -
My device and application are otherwise functional, and have been for months, so unless there are any special needs that the SPI RAM has, I should be good.
Does the use of the SPI RAM itself consume internal RAM?
My device and application are otherwise functional, and have been for months, so unless there are any special needs that the SPI RAM has, I should be good.
Does the use of the SPI RAM itself consume internal RAM?
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: failing to use external RAM
I don't recall if that's the case, sorry. Should be easy to check.
-
- Posts: 26
- Joined: Thu May 23, 2019 3:05 pm
Re: failing to use external RAM
I use extensively external RAM and there it should work pretty easily. You need to tweak the malloc parameters if you want malloc() to use it, potentially move some BSS to external RAM as well but all that is fairly transparent once set. Check as well the bus SPI size and speed (I use QIO and 80MHz on WROVER).
The result still use internal RAM, depending on the threshold you have set for malloc() to go external and the other libraries config (you can have WiFi, LWIP and a few others use SPIRAM).
One thing to check is if you are using some GPIO's that are normally used for ChipSelect of the SPIRAM. I can't remember them on top of my head, but they are indicated in the datasheet.
Other thing, you can't use SPIRAM to create tasks, unless you have enable it in menuconfig and even there, you can only have the stack in SPIRAM, not the BCT. ANd your code shall not use ROM code (for example calls to WiFi routines do not work). But I would be surprised this is the problem at this point.
The result still use internal RAM, depending on the threshold you have set for malloc() to go external and the other libraries config (you can have WiFi, LWIP and a few others use SPIRAM).
One thing to check is if you are using some GPIO's that are normally used for ChipSelect of the SPIRAM. I can't remember them on top of my head, but they are indicated in the datasheet.
Other thing, you can't use SPIRAM to create tasks, unless you have enable it in menuconfig and even there, you can only have the stack in SPIRAM, not the BCT. ANd your code shall not use ROM code (for example calls to WiFi routines do not work). But I would be surprised this is the problem at this point.
Re: failing to use external RAM
Thanks for the information, philippe_44. I'm not sure what I changed, but I tried configuring it again, and it seems to work now. I do have a few remaining questions:
1. you speak of a threshold beyond which malloc() calls begin to use external RAM. Where is this threshold defined?
2. from your statement, do I correctly infer that malloc() attempts to use internal RAM until unavailable (or until this threshold is reached)?
3. Most of my code is C++ and I've been using "new" instead of malloc(). Any idea which RAM this uses?
4. Have you noticed a significant performance difference between internal and external RAM?
Thank you.
1. you speak of a threshold beyond which malloc() calls begin to use external RAM. Where is this threshold defined?
2. from your statement, do I correctly infer that malloc() attempts to use internal RAM until unavailable (or until this threshold is reached)?
3. Most of my code is C++ and I've been using "new" instead of malloc(). Any idea which RAM this uses?
4. Have you noticed a significant performance difference between internal and external RAM?
Thank you.
-
- Posts: 26
- Joined: Thu May 23, 2019 3:05 pm
Re: failing to use external RAM
Hi
1- In menuconfig, components, ESP32 specific, SPI RAM config, there you have an item (after you've enabled malloc() in SPIRAM) that sets the max that will *always* be allocated in IRAM first
2- No, malloc uses internal RAM if requested size is above the minimum set in 1-. Now if you only allocate tiny blocks using malloc (or at least below threshold), yes, SPIRAM will be used until exhaustion, the SPIRAM will be used.
3- I'm not sure, but I'd assume it uses malloc()
4- Difficult for me to say. Of course, IRAM will be faster, but the cache is doing an *amazing* job. When I started my fairly large project, I had very little hope that it would work. I had a few tweaks to do, but the vast majority of my data is SPIRAM and I'm able to get WiFi streaming in flac @96kHz/24, decoding, resampling, gain, very high speed I2S (or BT retransmission), an I2C display connected, a HTTP server, a Telnet server and all that together with zero issue. This is simply mindblowing for a Quad-SPI RAM.
1- In menuconfig, components, ESP32 specific, SPI RAM config, there you have an item (after you've enabled malloc() in SPIRAM) that sets the max that will *always* be allocated in IRAM first
2- No, malloc uses internal RAM if requested size is above the minimum set in 1-. Now if you only allocate tiny blocks using malloc (or at least below threshold), yes, SPIRAM will be used until exhaustion, the SPIRAM will be used.
3- I'm not sure, but I'd assume it uses malloc()
4- Difficult for me to say. Of course, IRAM will be faster, but the cache is doing an *amazing* job. When I started my fairly large project, I had very little hope that it would work. I had a few tweaks to do, but the vast majority of my data is SPIRAM and I'm able to get WiFi streaming in flac @96kHz/24, decoding, resampling, gain, very high speed I2S (or BT retransmission), an I2C display connected, a HTTP server, a Telnet server and all that together with zero issue. This is simply mindblowing for a Quad-SPI RAM.
mzimmers wrote: ↑Mon Feb 03, 2020 3:17 pmThanks for the information, philippe_44. I'm not sure what I changed, but I tried configuring it again, and it seems to work now. I do have a few remaining questions:
1. you speak of a threshold beyond which malloc() calls begin to use external RAM. Where is this threshold defined?
2. from your statement, do I correctly infer that malloc() attempts to use internal RAM until unavailable (or until this threshold is reached)?
3. Most of my code is C++ and I've been using "new" instead of malloc(). Any idea which RAM this uses?
4. Have you noticed a significant performance difference between internal and external RAM?
Thank you.
Re: (solved) failing to use external RAM
Thanks again for all the help, philippe. I've marked this as solved.
Who is online
Users browsing this forum: No registered users and 104 guests