Why is there no support for external SPIRAM for the Espressif ESP-WROVER-KIT default?

Why is there no support for external SPIRAM for the Espressif ESP-WROVER-KIT default?

    [platformio]
    src_dir = main
    lib_dir = components
    [env:esp-wrover-kit]
    platform = espressif32
    board = esp-wrover-kit
    framework = espidf
    monitor_speed = 115200
    board_build.partitions = partitions.csv
    build_flags =
        -DBOARD_HAS_PSRAM
        -mfix-esp32-psram-cache-issue

this configuration does not work!

    [platformio]
    src_dir = main
    lib_dir = components
    [env:esp-wrover-kit]
    platform = espressif32
    board = esp-wrover-kit
    framework = espidf
    monitor_speed = 115200
    board_build.partitions = partitions.csv
    build_flags =
    	-D CONFIG_SPIRAM_SUPPORT=1

in this configuration, when compiling, so many errors appear that the question arises: why proudly announce support for ESP-WROVER-KIT, if there is not even a hint of support?
After two or three dozen attempts, correcting bugs by «trial and error», I still managed to compile the project and flash the device. External RAM has been decided.
I spent a huge amount of time and nerve cells on this.
A new PlatformIO update will be released and all my torment with compiling the project will resume.
It is very sad that support for the esp-idf framework in PlatformIO is far from perfekt.
P.S. Here is the working configuration. I hope this comes in handy.

    build_flags =

	-D CONFIG_SPIRAM_SUPPORT=1

	-D CONFIG_SUPPORT_STATIC_ALLOCATION=1

	-D CONFIG_SPIRAM_BOOT_INIT=1

	-D CONFIG_SPIRAM_USE_MALLOC=1
	-D CONFIG_SPIRAM_TYPE_AUTO=1
	-D CONFIG_SPIRAM_SIZE=-1
	-D CONFIG_SPIRAM_SPEED_40M=1
	-D CONFIG_SPIRAM_MEMTEST=1
	-D CONFIG_SPIRAM_CACHE_WORKAROUND=1
	-D CONFIG_SPIRAM_BANKSWITCH_ENABLE=1
	-D CONFIG_SPIRAM_BANKSWITCH_RESERVE=4

	-D CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=8192
	-D CONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST=1
	-D CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=16384

	-D CONFIG_D2WD_PSRAM_CLK_IO=9
	-D CONFIG_D2WD_PSRAM_CS_IO=10
	-D CONFIG_PICO_PSRAM_CS_IO=10
	-D CONFIG_D0WD_PSRAM_CLK_IO=17
	-D CONFIG_D0WD_PSRAM_CS_IO=16
	-D CONFIG_SPIRAM_SPIWP_SD3_PIN=7

I’ve already noted this in Extend PSRAM documentation · Issue #175 · platformio/platform-espressif32 · GitHub, along with a working example of activating PSRAM, 8 months ago. It’s a bit lazy that the documentation just points to ESP-IDF and gives an incomplete example for PSRAM activation.

However, after all, you have to do / set the exact same macros for PIO as you would do in ESP-IDF, so they are equivalent in support.

This is not a solution, but a crutch for a lame horse.

If you want to it be activated by default, a modification to the extra_flags of the board definition with the addition of all PSRAM related flags is a solution.

Either an issue at Issues · platformio/platform-espressif32 · GitHub or a direct pull-request would get the needed attention.

1 Like

When declaring device support with external SPIRAM, the developer is obviously obligated to include all the necessary flags and assign the default values ​​to the necessary esp-idf variables. Users, especially beginners, should not be affected. Everything should work out of the box without a shamanic tambourine.
This is my humble opinion.

It, like a lot of features, is configured by a flag, because the chip developer (espressif) doesn’t know if your particular program will use the PSRAM or not, and often enabling unused functionality uses extra memory and resources, and can lead to unexpected results. If you think it should be enabled by default, do a Pull Request on esp-wrover-kit.json with the necessary change, and see if the developers agree with you. However, since the release notes state

Disabled PSRAM for ESP Wrover Kit by default (resolves an issue with debugging).

I don’t think you’ll have much luck unless the underlying issue has been fixed, which it doesn’t seem to have been yet… In the meantime, setting the CONFIG_SPIRAM_CACHE_WORKAROUND is needed because of a bug in the actual silicon, and according this PR isn’t handled properly by PlatformIOs build scripts. If that truely fixes the issue, perhaps PSRAM can be enabled by default, assuming it still doesn’t run afoul of debugging.

I expressed my point of view. A developer can do anything with his product.
At a minimum, there should be detailed documentation describing the mechanism for configuring support external SPIRAM for ESP32 + with detailed examples.

Don’t try to use SPI RAM until this issue is fixed. You might manage to enable it, but without a patch that fixes that, you will run into issues with memory corruption and bits randomly flipping. This is due to an underlying silicon bug.

There’s no combination of flags you can provide to fix this or enable the workaround right now. It needs to be fixed in the build system.

2 Likes

Thank you for paying attention to my message.
Please explain to me what I must do right now to solve this problem, without waiting for Your Pull request to be merged into master branch?
What needs to be included in platformio.ini, (sdkconfig.h and sdkconfig or main.c of the project)?
I sincerely thank you!

what does this mean? I was using spiram just fine until this latest library build.
Please explain and provide some thoughts for a solution.

Thanks!

Rohan is referring to the information provided by espressif themselves about bugs in the silicon : Support for External RAM - ESP32 - — ESP-IDF Programming Guide latest documentation

You state “until this latest library build” - do you mean something changed for you in the 1.11.1 espressif32 platform update from November 2nd? Or are you trying out the development builds, which are at 2.0.0 at present.

Rohan has already proposed changes to the build scripts to implement Espressif’s workaround, which are awaiting review, and look to need a few more tweaks to get everything working properly.

1 Like

ha…awesome. I was just preparing myself for what might happen with the update. I updated to 3.3 and will be testing SPIRAM and PSRAM usage over the next couple of days.

2 Likes