🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Firev2.7 Test결과 PSRAM이 인식이안됩니다.

    Scheduled Pinned Locked Moved M5Stack Fire
    1 Posts 1 Posters 306 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • nongjung-dnsN Offline
      nongjung-dns
      last edited by

      Re: [Fire with UIFlow2](/topic/6685/fire```
      code_text

      
      
      # /flash/mem_fire_check.py 
      
      # check_psram_status.py - M5Stack Fire PSRAM Detection Script
      import gc
      import os
      import sys
      import machine
      
      
      def check_psram_status():
          print("M5Stack Fire PSRAM Detection Status")
          print("=" * 50)
      
          # 1. System information
          print("1. System Information:")
          print(f" - MicroPython version : {sys.implementation.version}")
          print(f" - Platform           : {sys.platform}")
          print(f" - Machine            : {os.uname().machine}")
      
          # 2. Official esp32 PSRAM API check
          print("\n2. Official PSRAM API Check:")
          try:
              import esp32
              if hasattr(esp32, 'PSRAM'):
                  size = esp32.PSRAM.size()
                  print(f"   esp32.PSRAM available: {size:,} bytes "
                        f"({size / 1024 / 1024:.1f} MB)")
              else:
                  print("   esp32.PSRAM attribute NOT found")
          except Exception as e:
              print(f"   Failed to access esp32.PSRAM → {e}")
      
          # 3. Current heap status
          print("\n3. Heap Memory Status:")
          gc.collect()
          total_heap = gc.mem_alloc() + gc.mem_free()
          print(f" - Total heap   : {total_heap:,} bytes ({total_heap / 1024 / 1024:.2f} MB)")
          print(f" - Allocated    : {gc.mem_alloc():,} bytes")
          print(f" - Free         : {gc.mem_free():,} bytes")
      
          # 4. PSRAM allocation stress test
          print("\n4. PSRAM Allocation Test (512KB chunks):")
          test_psram_allocation()
      
          print("=" * 50)
      
      
      def test_psram_allocation():
          gc.collect()
          start_free = gc.mem_free()
          buffers = []
          chunk_size = 512 * 1024  # 512KB
      
          try:
              for i in range(1, 17):  # Try up to ~8MB
                  buf = bytearray(chunk_size)
                  buffers.append(buf)
                  allocated = len(buffers) * chunk_size
                  current_free = gc.mem_free()
      
                  print(f"   {allocated / 1024 / 1024:.1f} MB allocated → "
                        f"{current_free / 1024 / 1024:.2f} MB free")
      
                  # If free memory drops too fast → we're NOT using PSRAM
                  if start_free - current_free > (start_free * 0.8):
                      print("   Sudden heap drop detected → Running WITHOUT PSRAM")
                      break
      
          except MemoryError:
              print(f"   MemoryError at {allocated / 1024 / 1024:.1f} MB → "
                    "PSRAM is NOT enabled in firmware")
          except Exception as e:
              print(f"   Unexpected error: {e}")
          finally:
              del buffers[:]
              gc.collect()
              print(f"   Cleanup complete → Free memory: "
                    f"{gc.mem_free() / 1024 / 1024:.2f} MB")
      
      
      def check_firmware_psram_support():
          print("\n5. Firmware PSRAM Support Summary:")
          print("   Testing different detection methods...")
      
          results = []
      
          # Method 1: esp32.PSRAM
          try:
              import esp32
              if hasattr(esp32, 'PSRAM') and esp32.PSRAM.size() > 0:
                  results.append("esp32.PSRAM API → Supported "
                                f"({esp32.PSRAM.size() / 1024 / 1024:.1f} MB)")
              else:
                  results.append("esp32.PSRAM API → Not available")
          except:
              results.append("esp32.PSRAM API → Failed to import")
      
          # Method 2: Large allocation test
          gc.collect()
          try:
              _ = bytearray(6 * 1024 * 1024)  # 6MB
              results.append("Large allocation (6MB+) → SUCCESS (PSRAM likely enabled)")
              del _
          except MemoryError:
              results.append("Large allocation (6MB+) → FAILED (NO PSRAM)")
      
          gc.collect()
      
          # Final verdict
          for r in results:
              print(f"   • {r}")
      
          print("\n   Verdict:")
          if any("SUCCESS" in r or "Supported" in r for r in results):
              print("   PSRAM is ENABLED and working!")
          else:
              print("   PSRAM is DISABLED → Flash a PSRAM-enabled firmware!")
      
      
      # Main execution
      if __name__ == "__main__":
          check_psram_status()
          check_firmware_psram_support()
      
      
      
      ------------- Result    =============
      
      
      MicroPython v1.25.0-dirty on 2025-10-24; M5STACK Fire with ESP32(SPIRAM)
      Type "help()" for more information.
      >>> 
      >>> 
      >>> import check_psram_status as pp
      >>> pp.check_psram_status
      <function check_psram_status at 0x3f8034c0>
      >>> pp.check_psram_status()
      M5Stack Fire PSRAM Detection Status
      ==================================================
      1. System Information:
       - MicroPython version : (1, 25, 0, '')
       - Platform           : esp32
       - Machine            : M5STACK Fire with ESP32(SPIRAM)
      
      2. Official PSRAM API Check:
         esp32.PSRAM attribute NOT found
      
      3. Heap Memory Status:
       - Total heap   : 4,184,768 bytes (3.99 MB)
       - Allocated    : 7,856 bytes
       - Free         : 4,176,864 bytes
      
      4. PSRAM Allocation Test (512KB chunks):
         0.5 MB allocated → 3.42 MB free
         1.0 MB allocated → 2.91 MB free
         1.5 MB allocated → 2.40 MB free
         2.0 MB allocated → 1.90 MB free
         2.5 MB allocated → 1.46 MB free
         3.0 MB allocated → 0.96 MB free
         3.5 MB allocated → 0.46 MB free
         Sudden heap drop detected → Running WITHOUT PSRAM
         Cleanup complete → Free memory: 3.44 MB
      ==================================================
      >>>
      1 Reply Last reply Reply Quote 0

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      • First post
        Last post