07 - Memory Testing

# ESP32-S3 Memory Testing Guide: How to Test PSRAM, Flash & RAM Sizes ## Introduction Your **Lonely Binary ESP32-S3 N16R8** comes with impressive specifications: - **16MB Flash Memory** (for storing your programs and data) - **8MB PSRAM** (for extra working memory) - **512KB SRAM** (built-in working memory) But how do you verify these specifications? How do you test if all the memory is working correctly? This guide will show you how to test and verify your ESP32-S3's memory using Arduino IDE. ![](https://cdn.shopify.com/s/files/1/0331/9994/7908/files/Pasted_image_20250723224535_b376f1f0-7e21-46f7-aba9-4301c02b3837.png?v=1755945285) ## What You'll Learn - How to check PSRAM availability and size - How to verify Flash memory size - How to test RAM (SRAM) usage - How to run memory stress tests - How to interpret memory test results - Troubleshooting memory issues ## Prerequisites - Your Lonely Binary ESP32-S3 N16R8 board - Arduino IDE 2.x with ESP32 support (from previous setup guide) - USB cable - Basic understanding of Arduino programming ## Understanding ESP32-S3 Memory Types ### 1. **Flash Memory (16MB)** - **Purpose:** Stores your program code and data - **Persistence:** Keeps data even when power is off - **Speed:** Slower than RAM, but permanent storage - **Think of it like:** A hard drive for your ESP32-S3 ### 2. **PSRAM (8MB)** - **Purpose:** Extra working memory for large data - **Persistence:** Temporary (lost when power is off) - **Speed:** Faster than Flash, slower than SRAM - **Think of it like:** Extra RAM that you can use for big projects ### 3. **SRAM (512KB)** - **Purpose:** Fast working memory for variables - **Persistence:** Temporary (lost when power is off) - **Speed:** Fastest memory type - **Think of it like:** The main RAM of your ESP32-S3 ## Troubleshooting: Why Does My Board Show Only 4MB of Flash? ![](https://cdn.shopify.com/s/files/1/0331/9994/7908/files/Pasted_image_20251129071154.png?v=1764374119) The flash memory on your board acts like the hard drive in a computer. By default, the Arduino IDE partitions it to use only **4MB**, meaning it accesses just a small portion of the full **16MB** available. The remaining unused space is inaccessible to your code and essentially goes to waste. To fix this, you need to configure the Arduino IDE to utilize and format the partitions for the full 16MB. This can be done via the Tools menu before uploading your code. ![](https://cdn.shopify.com/s/files/1/0331/9994/7908/files/Pasted_image_20251129070854.png?v=1764374128) ## Code: Memory Information Test ### Create a New Sketch 1. Open Arduino IDE 2. Create a new sketch (File → New) 3. Replace the code with this memory information program: ```cpp /* Lonely Binary ESP32-S3 Memory Information Test For Lonely Binary ESP32-S3 N16R8 In Arduino Settings, USB CDC On Boot: "Enabled" Flash Mode: QIO 80MHZ Flash Size: 16MB(128Mb) Partition Scheme: 16MB Flash (3MB APP/9.9MB FATFS) PSRAM: OPI PSRAM Upload Mode: UART0 / Hardware CDC USB Mode: Hardware CDC and JTAG */ #include <esp_heap_caps.h> void setup() { Serial.begin(115200); delay(1000); // Wait for serial to initialize Serial.println("=== ESP32-S3 Memory Information ==="); Serial.println("Lonely Binary ESP32-S3 N16R8"); Serial.println(); // Test PSRAM testPSRAM(); // Test Flash Memory testFlashMemory(); // Test SRAM testSRAM(); Serial.println("=== Memory Test Complete ==="); } void loop() { // Nothing to do in loop delay(1000); } void testPSRAM() { Serial.println("--- PSRAM Test ---"); // Get PSRAM size size_t psramSize = ESP.getPsramSize(); if (psramSize > 0 ) { Serial.println("✅ PSRAM is available!"); Serial.printf("PSRAM Size: %d bytes (%.2f MB)\n", psramSize, psramSize / 1024.0 / 1024.0); // Check if PSRAM is initialized if (psramInit()) { Serial.println("✅ PSRAM is initialized and working!"); } else { Serial.println("❌ PSRAM initialization failed!"); } } else { Serial.println("❌ PSRAM not found!"); Serial.println("❌ PSRAM mode should be OPI PSRAM in Arduino Settings"); } Serial.println(); } void testFlashMemory() { Serial.println("--- Flash Memory Test ---"); // Get Flash memory size size_t flashSize = ESP.getFlashChipSize(); Serial.printf("Flash Size: %d bytes (%.2f MB)\n", flashSize, flashSize / 1024.0 / 1024.0); // Get Flash chip speed uint32_t flashSpeed = ESP.getFlashChipSpeed(); Serial.printf("Flash Speed: %d MHz\n", flashSpeed / 1000000); // Get Flash chip mode uint8_t flashMode = ESP.getFlashChipMode(); Serial.printf("Flash Mode: %d\n", flashMode); Serial.println("✅ Flash memory information retrieved!"); Serial.println(); } void testSRAM() { Serial.println("--- SRAM Test ---"); // Get free heap size size_t freeHeap = ESP.getFreeHeap(); Serial.printf("Free Heap: %d bytes (%.2f KB)\n", freeHeap, freeHeap / 1024.0); // Get minimum free heap size size_t minFreeHeap = ESP.getMinFreeHeap(); Serial.printf("Minimum Free Heap: %d bytes (%.2f KB)\n", minFreeHeap, minFreeHeap / 1024.0); // Get maximum allocatable heap size size_t maxAllocHeap = ESP.getMaxAllocHeap(); Serial.printf("Maximum Allocatable Heap: %d bytes (%.2f KB)\n", maxAllocHeap, maxAllocHeap / 1024.0); Serial.println("✅ SRAM information retrieved!"); Serial.println(); } ``` ### Upload and Test Let's uses the **Right Type-C** port which is marked "USB" to upload the code. If you uses the Left Type-C port, you need to disable the USB CDC on boot, otherwise there will be no serial output. 1. Make sure your board settings are correct: - **Board:** ESP32S3 Dev Module - **USB CDC On Boot**: "Enabled" - **PSRAM:** OPI PSRAM - **Flash Size:** 16MB (128Mb) - **Flash Mode:** QIO 80MHz - **Partition Scheme:** 16M Flash (3MB APP/9.9MB FATFS) - **Upload Mode**: UART0 / Hardware CDC - **USB Mode**: Hardware CDC and JTAG ![](https://cdn.shopify.com/s/files/1/0331/9994/7908/files/Pasted_image_20250723223826_8375083d-66d1-4834-9a00-95a167cbdcc4.png?v=1755945290) 1. Upload the code to your ESP32-S3 2. Open Serial Monitor (Tools → Serial Monitor) 3. Set baud rate to **115200** 4. Press the **RESET** button on your board ### Expected Results You should see output like this: ``` === ESP32-S3 Memory Information === Lonely Binary ESP32-S3 N16R8 --- PSRAM Test --- ✅ PSRAM is available! PSRAM Size: 8388608 bytes (8.00 MB) ✅ PSRAM is initialized and working! --- Flash Memory Test --- Flash Size: 16777216 bytes (16.00 MB) Flash Speed: 80 MHz Flash Mode: 0 ✅ Flash memory information retrieved! --- SRAM Test --- Free Heap: 123456 bytes (120.56 KB) Minimum Free Heap: 123456 bytes (120.56 KB) Maximum Allocatable Heap: 123456 bytes (120.56 KB) ✅ SRAM information retrieved! === Memory Test Complete === ``` ## Getting Hardware Details and Verifying the Genuineness of ESP32-S3 Chips You can also use the command line to obtain more detailed information about your ESP32 chips. To retrieve hardware details from an ESP32-S3 using esptool (a Python-based utility for communicating with Espressif chips), first install it, connect your device via a serial port, and then run specific commands. These commands can provide key information such as the chip ID, MAC address, flash size and manufacturer, and eFuse details (e.g., chip revision and package type). This can help verify if the chip is genuine by cross-referencing the reported values against official Espressif specifications. Note that esptool cannot directly detect PSRAM size; this is typically determined from the module's model number (e.g., "N16R8" indicates 8MB PSRAM) or through runtime code executed on the device. ### Installation Make sure you have python installed in your computer, then install esptool via pip: ``` bash % pip install esptool ``` #### Hardare Details Connect your ESP32-S3 board to your computer via USB . Identify the serial port (e.g., /dev/cu.wchusbserial10 on Linux/Mac or COM3 on Windows). Replace --port /dev/cu.wchusbserial10 in the examples below with your actual port. ``` bash % esptool --chip esp32s3 --port /dev/cu.wchusbserial10 chip-id ``` ![](https://cdn.shopify.com/s/files/1/0331/9994/7908/files/Pasted_image_20251129072251.png?v=1764374138) from above output, you can verify it is ESP32-S3 running at 240Mhz with Wi-Fi and bluetooth features and built in 8MB PSRAM. Unlike older Espressif chips like the ESP8266, which have a dedicated hardware register for a unique Chip ID, the ESP32 series does not. Instead, esptool falls back to using the device's factory-programmed MAC address as its unique identifier. This is not an error or indication of a hardware problem—it's simply how the tool handles identification for these chips. You can also get detailed Hardware Info by using espefuse tool for a comprehensive readout of eFuses, including factory-set details like MAC address (again), chip revision, package type, and calibration data. This is one of the most detailed ways to inspect hardware. ``` bash % espefuse --chip esp32s3 --port /dev/cu.wchusbserial10 summary ``` ### Flash Details ``` bash % esptool --chip esp32s3 --port /dev/cu.wchusbserial10 flash-id ``` ![](https://cdn.shopify.com/s/files/1/0331/9994/7908/files/Pasted_image_20251129072555.png?v=1764374147) - **Manufacturer: 46**: The JEDEC manufacturer ID in hexadecimal (0x46), which corresponds to OKI Semiconductor (now part of LAPIS Semiconductor under ROHM). This identifies the vendor of the flash chip. - **Device: 4018**: The device ID in hexadecimal (0x4018), which specifies the flash model's type and capacity. Here, "40" typically indicates the memory family/type (e.g., quad SPI compatible), and "18" encodes the density (2^(24) bits = 128Mbit or 16MB). - **Detected flash size: 16MB**: The total capacity of the SPI flash memory, detected via the device ID. This is where firmware, partitions, and user data are stored (non-volatile). - **Flash type set in eFuse: quad (4 data lines)**: The flash interface mode configured in the chip's eFuses (one-time programmable fuses). "Quad" means Quad SPI (QSPI) mode, using 4 data lines for faster read/write speeds (up to 4x faster than single-line SPI). - **Flash voltage set by eFuse: 3.3V**: The operating voltage for the flash chip, hardcoded in the eFuses. 3.3V is standard for most ESP32-S3 modules, ensuring compatibility and safe operation. ## Summary You've successfully learned how to test and verify your **Lonely Binary ESP32-S3 N16R8**'s memory specifications: ✅ **PSRAM Testing:** Verified 8MB PSRAM availability and performance ✅ **Flash Testing:** Confirmed 16MB Flash memory and file system ✅ **SRAM Testing:** Checked internal memory usage and performance ✅ **Stress Testing:** Validated memory reliability under load Your **Lonely Binary ESP32-S3** should show excellent memory performance with all 16MB Flash and 8MB PSRAM working correctly! ## Next Steps Now that you've verified your memory specifications, you can: - Build memory-intensive projects - Optimize your code for the available memory - Monitor memory usage in your applications - Use the full potential of your 16MB Flash and 8MB PSRAM --- ## Support If you encounter any issues, please go to [https://lonelybinary.com](https://lonelybinary.com) and click the Support button located in the bottom right corner. Our team is ready to assist you. [![Technical Support](https://cdn.shopify.com/s/files/1/0331/9994/7908/files/Pasted_image_20250527102623_4e41083f-a1d3-412d-a78f-9cb11ecf69e5.png?v=1754008493)](https://lonelybinary.com) or contact us at office@lonelybinary.com --- Happy coding with your fully-tested **Lonely Binary ESP32-S3**! 🚀