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 ## 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 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 === ``` ## 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**! 🚀