Phipps Electronics

Order within the next 


50,000+ ORDERS



Debugging ESP32 Cam PSRAM Issues with VSCode


Read the article below if you want to program your ESP32 Cam using Espressif’s ESP32 Camera Driver and debug your ESP32 CAM’s PSRAM. 


If you search the net, you may see dozens of pages pointing to an ESP32 CAM PSRAM read error or failure. It may read as:

E (332) psram: PSRAM ID read error: 0xffffffff

Or have various forms. Several websites have included different fixes; some work, some don’t. It may involve going through several options in Arduino IDE and/or printing out various PSRAM parameters.

Why it's Hard to Debug ESP32 CAM's PSRAM failure

One of the reasons why it’s hard to debug this kind of failure is that most users are using the Arduino IDE to verify or fix the problem. The Arduino IDE is just a wrapper for the original ESP-IDF core. In reality, Arduino “simplifies” the use of the ESP-IDF core so that the user can get his or her code running quickly. This method can make programming for the ESP32 plain and simple for the user. Additionally, you may not be able to recompile some core components of the ESP-IDF library in Arduino IDE.

That said, you may miss out on several optimizations or detailed debug messages found only when using the ESP-IDF core directly. Such optimizations as using the Himem API to access greater than the 4MB area of your PSRAM. This optimization cannot be done on the Arduino IDE. Additionally, the debug messages may be more detailed when using ESP-IDF. Most importantly, if needed, you can recompile parts of the core library.

Regarding PSRAM vendors, Espressif has already expressed that they will only support certain vendors. Espressif themselves have their own. They have the “ESP PSRAM64H”, for example, an 8 MB PSRAM.

Program and Debug Your ESP32 CAM using VSCODE

To have a more detailed and flexible debugging session, why not learn how to program your ESP32 CAM in VSCode? Moreover, learn how to install Espressif’s esp32-camera driver as a component in your ESP32 project. After that, learn to configure your project to utilize your PSRAM more effectively to verify your issue.

Create a New Project in VsCOde ESP-IDF

It all starts with creating a new project in VScode with the ESP-IDF framework and then adding an ESP-IDF component. Below is a simple video walkthrough.

Download the ESP CAMera Driver

There exists an ESP32 Camera Driver from Espressif that you can easily add to your ESP32 based projects. Simply add a component folder to your project’s folder and then place this driver inside this; it’s as easy as that. See below:

Copy an Example CamerA Code to your Project's Main file

The ESP32 Camera Driver has an example code that uses your ESP32 Camera’s frame buffer to capture an image and simply show the image’s file size. With this, you’ll already have accessed your PSRAM. This is good for testing/verification purposes. Choose the AI Thinker Cam configuration for this code.

Configure YOur Project to Use Your PSRAM

In ESP-IDF, you must configure your project to match your preferred peripheral settings. This includes your ESP32 CAM and PSRAM. Set your SPI Flash and PSRAM clock access to 80MHz. Next, choose a PSRAM size. It’s at this point where you can choose to initialize and test your PSRAM before starting your application. You will find out if your PSRAM has problems immediately here. You can optionally set your program in panic mode and restart if it does not detect a good PSRAM.


Build and Flash the code to your ESP32 Camera. Below, you’ll see a good and a bad/uninstalled PSRAM demo run. If it’s a good PSRAM and the project continues, you should see the file size of the picture you’ve taken.



Good PSRAM Output Monitor

Bad PSRAM Output Monitor


It can be that the vendor ID is being rejected by the framework. Espressif seems to have locked the use of PSRAM to only a list they prefer. With this, they check the vendor ID when they initialize the PSRAM. If the vendor ID is not what they prefer, they can reject that PSRAM.

A possible solution to this problem is to patch the code related to the esp_psram_impl_quad.c file. This file can be found in your \esp-idf\components\esp_psram\esp32\ directory. Modify code so that the vendor ID (and other read ID checks) can be bypassed. 

					//read psram id, should issue `psram_disable_qio_mode` before calling this
static void psram_read_id(psram_spi_num_t spi_num, uint64_t* dev_id)
    uint32_t dummy_bits = 0 + extra_dummy;
    uint32_t psram_id[2] = {0};
    psram_cmd_t ps_cmd;

    uint32_t addr = 0;
    ps_cmd.addrBitLen = 3 * 8;
    ps_cmd.cmd = PSRAM_DEVICE_ID;
    ps_cmd.cmdBitLen = 8;
    if (s_clk_mode == PSRAM_CLK_MODE_DCLK) {
        switch (s_psram_mode) {
            case PSRAM_CACHE_F80M_S80M:
            case PSRAM_CACHE_F80M_S40M:
            case PSRAM_CACHE_F40M_S40M:
                ps_cmd.cmdBitLen = 2;   //this two bits is used to delay 2 clock cycle
                ps_cmd.cmd = 0;
                addr = (PSRAM_DEVICE_ID << 24) | 0;
                ps_cmd.addrBitLen = 4 * 8;
    ps_cmd.addr = &addr;
    ps_cmd.txDataBitLen = 0;
    ps_cmd.txData = NULL;
    ps_cmd.rxDataBitLen = 8 * 8;
    ps_cmd.rxData = psram_id;
    ps_cmd.dummyBitLen = dummy_bits;

    psram_cmd_config(spi_num, &ps_cmd);
    psram_cmd_recv_start(spi_num, ps_cmd.rxData, ps_cmd.rxDataBitLen / 8, PSRAM_CMD_SPI);
    *dev_id = (uint64_t)(((uint64_t)psram_id[1] << 32) | psram_id[0]);

Finally, recompile the code.


The Arduino IDE is a convenient way of programming your ESP32 Camera. However, you may miss out on several optimizations and verification procedures. With this, it’s a good idea to learn how to program your ESP32 Camera through VSCode using the ESP Camera driver from Espressif. If you learn this, you’ll have an easier time debugging your ESP32 Camera PSRAM issues.


Subscribe to be the first to know when we publish a new article!
List Subscriptions(Required)


Scroll to Top