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

    TAB5: Unable to mount SD card as USB mass storage

    PRODUCTS
    2
    2
    232
    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.
    • V
      vitalEOL
      last edited by

      Hi,

      I'm trying to get the SD2USBMSC example (https://github.com/espressif/arduino-esp32/tree/master/libraries/SD_MMC/examples/SD2USBMSC) running on my M5TAB5

      I have been able to get the same example running on an ESP32-S3 board & now I want to test the High Speed USB of the ESP32-P4 in the Tab5.

      I have the sketch running on my Tab5 and the SD card appears to be detected & mounted correctly; at run-time I get USB UNPLUGGED reported (ARDUINO_USB_STOPPED_EVENT).

      I have powered the Tab5 externally via the posts on the battery slot but I do not see events reported for the other USB events:

      • ARDUINO_USB_STARTED_EVENT
      • ARDUINO_USB_SUSPEND_EVENT
      • ARDUINO_USB_RESUME_EVENT

      Below is the log from the device

      EESP-ROM:esp32p4-eco2-20240710
      Build:Jul 10 2024
      rst:0x1 (POWERON),boot:0x20f (SPI_FAST_FLASH_BOOT)
      SPI mode:DIO, clock div:1
      load:0x4ff33ce0,len:0x118c
      load:0x4ff2abd0,len:0xcd0
      load:0x4ff2cbd0,len:0x3304
      entry 0x4ff2abd0
      ESP-ROM:esp32p4-eco2-20240710
      Build:Jul 10 2024
      rst:0x7 (HP_SYS_HP_WDT_RESET),boot:0x20f (SPI_FAST_FLASH_BOOT)
      SPI mode:DIO, clock div:1
      load:0x4ff33ce0,len:0x118c
      load:0x4ff2abd0,len:0xcd0
      load:0x4ff2cbd0,len:0x3304
      entry 0x4ff2abd0
      [     1][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x400138a8
      [    12][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x40013866
      [    23][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x40013824
      [    35][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x400137e2
      [    46][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x400138a8
      [    57][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x40013866
      [    68][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x40013824
      [    80][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x400137e2
      [    91][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x400138a8
      [   102][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x40013866
      [   114][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x40013824
      [   125][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x400137e2
      [   136][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x400138a8
      [   147][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x40013866
      [   159][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x40013824
      [   170][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x400137e2
      [   181][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x400138a8
      [   193][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x40013866
      [   204][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x40013824
      [   215][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x400137e2
      [   226][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x400138a8
      [   238][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x40013866
      [   249][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x40013824
      [   260][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x400137e2
      [   272][D][esp32-hal-tinyusb.c:806] tinyusb_enable_interface2(): Interface MSC enabled
      [   286][I][esp32-hal-psram.c:102] psramAddToHeap(): PSRAM added to the heap.
      [   297][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 38 successfully set to type UART_RX (2) with bus 0x4ff11048
      [   308][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 37 successfully set to type UART_TX (3) with bus 0x4ff11048
      =========== Before Setup Start ===========
      Chip Info:
      ------------------------------------------
        Model             : ESP32-P4
        Package           : 0
        Revision          : 1.00
        Cores             : 2
        CPU Frequency     : 360 MHz
        XTAL Frequency    : 40 MHz
        Features Bitfield : 0000000000
        Embedded Flash    : No
        Embedded PSRAM    : No
        2.4GHz WiFi       : No
        Classic BT        : No
        BT Low Energy     : No
        IEEE 802.15.4     : No
      ------------------------------------------
      INTERNAL Memory Info:
      ------------------------------------------
        Total Size        :   572780 B ( 559.4 KB)
        Free Bytes        :   544996 B ( 532.2 KB)
        Allocated Bytes   :    21964 B (  21.4 KB)
        Minimum Free Bytes:   540020 B ( 527.4 KB)
        Largest Free Block:   385012 B ( 376.0 KB)
      ------------------------------------------
      SPIRAM Memory Info:
      ------------------------------------------
        Total Size        : 33554432 B (32768.0 KB)
        Free Bytes        : 33551856 B (32765.5 KB)
        Allocated Bytes   :        0 B (   0.0 KB)
        Minimum Free Bytes: 33551856 B (32765.5 KB)
        Largest Free Block: 33030132 B (32256.0 KB)
        Bus Mode          : QSPI
      ------------------------------------------
      Flash Info:
      ------------------------------------------
        Chip Size         : 16777216 B (16 MB)
        Block Size        :    65536 B (  64.0 KB)
        Sector Size       :     4096 B (   4.0 KB)
        Page Size         :      256 B (   0.2 KB)
        Bus Speed         : 80 MHz
        Bus Mode          : QIO
      ------------------------------------------
      Partitions Info:
      ------------------------------------------
                      nvs : addr: 0x00009000, size:    20.0 KB, type: DATA, subtype: NVS
                  otadata : addr: 0x0000E000, size:     8.0 KB, type: DATA, subtype: OTA
                     app0 : addr: 0x00010000, size:  6400.0 KB, type:  APP, subtype: OTA_0
                     app1 : addr: 0x00650000, size:  6400.0 KB, type:  APP, subtype: OTA_1
                   spiffs : addr: 0x00C90000, size:  3456.0 KB, type: DATA, subtype: SPIFFS
                 coredump : addr: 0x00FF0000, size:    64.0 KB, type: DATA, subtype: COREDUMP
      ------------------------------------------
      Software Info:
      ------------------------------------------
        Compile Date/Time : Sep 10 2025 11:23:03
        Compile Host OS   : windows
        ESP-IDF Version   : v5.4.2-25-g858a988d6e
        Arduino Version   : 3.2.1
      ------------------------------------------
      Board Info:
      ------------------------------------------
        Arduino Board     : M5STACK_TAB5
        Arduino Variant   : m5stack_tab5
        Arduino FQBN      : m5stack:esp32:m5stack_tab5:UploadSpeed=921600,USBMode=default,CDCOnBoot=default,MSCOnBoot=default,DFUOnBoot=default,UploadMode=default,CPUFreq=360,FlashFreq=80,FlashMode=qio,FlashSize=16M,PartitionScheme=default,DebugLevel=verbose,PSRAM=enabled,EraseFlash=none,JTAGAdapter=builtin
      ============ Before Setup End ============
      [   673][V][esp32-hal-uart.c:676] uartBegin(): UART0 baud(115200) Mode(800001c) rxPin(38) txPin(37)
      [   682][V][esp32-hal-uart.c:774] uartBegin(): UART0 not installed. Starting installation
      [   690][V][esp32-hal-uart.c:784] uartBegin(): UART0 RX FIFO full threshold set to 120 (value requested: 120 || FIFO Max = 128)
      [   701][V][esp32-hal-uart.c:810] uartBegin(): Setting UART0 to use XTAL clock
      [   709][V][esp32-hal-uart.c:874] uartBegin(): UART0 initialization done.
      [   715][V][esp32-hal-uart.c:925] uartSetRxFIFOFull(): UART0 RX FIFO Full value set to 120 from a requested value of 120
      Starting Serial
      Mounting SDcard
      [   726][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type SDMMC_CLK (38) successfully set to 0x4000b840
      [   740][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type SDMMC_CMD (39) successfully set to 0x4000b840
      [   752][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type SDMMC_D0 (40) successfully set to 0x4000b840
      [   763][D][SD_MMC.cpp:188] begin(): pin_cmd: 44, pin_clk: 43, pin_d0: 39, pin_d1: 40, pin_d2: 41, pin_d3: 42
      [   773][I][SD_MMC.cpp:252] begin(): On-chip power channel specified, use external power for SDMMC
      [   846][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 44 successfully set to type SDMMC_CMD (39) with bus 0x4ff142f8
      [   857][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 43 successfully set to type SDMMC_CLK (38) with bus 0x4ff142f8
      [   868][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 39 successfully set to type SDMMC_D0 (40) with bus 0x4ff142f8
      Initializing MSC
      Initializing USB
      [   879][D][esp32-hal-tinyusb.c:684] tinyusb_load_enabled_interfaces(): Load Done: if_num: 1, descr_len: 32, if_mask: 0x1
      Card Size: 7447MB
                       Sector: 512    Count: 15251456
                                                     =========== After Setup Start ============
      USB UNPLUGGED
      INTERNAL Memory Info:
      ------------------------------------------
        Total Size        :   572780 B ( 559.4 KB)
        Free Bytes        :   538448 B ( 525.8 KB)
        Allocated Bytes   :    28064 B (  27.4 KB)
        Minimum Free Bytes:   538428 B ( 525.8 KB)
        Largest Free Block:   385012 B ( 376.0 KB)
      ------------------------------------------
      SPIRAM Memory Info:
      ------------------------------------------
        Total Size        : 33554432 B (32768.0 KB)
        Free Bytes        : 33520032 B (32734.4 KB)
        Allocated Bytes   :    31584 B (  30.8 KB)
        Minimum Free Bytes: 33520032 B (32734.4 KB)
        Largest Free Block: 33030132 B (32256.0 KB)
      ------------------------------------------
      GPIO Info:
      ------------------------------------------
        GPIO : BUS_TYPE[bus/unit][chan]
        --------------------------------------
          37 : UART_TX[0]
          38 : UART_RX[0]
          39 : SDMMC_D0
          43 : SDMMC_CLK
          44 : SDMMC_CMD
      ============ After Setup End =============
      

      Has anyone had any luck (or problems) with getting this working on the Tab5 device?

      Appreciate any help/direction...

      1 Reply Last reply Reply Quote 0
      • henryCharmH
        henryCharm
        last edited by

        Hi,

        From what you described and the logs, it looks like the SD card is being detected and mounted correctly, but the USB MSC interface reports USB UNPLUGGED (ARDUINO_USB_STOPPED_EVENT). This usually means the USB host (e.g., your PC) is not recognizing the device as connected or the USB device stack on the ESP32-P4 isn’t properly signaling a connection.

        check:

        • Make sure the USB data lines (D+ and D-) and power (VBUS) are hooked up right. If you’re just powering through the battery spots without the USB power line, the computer might think the device is unplugged.

        • Check that the USB Mass Storage mode is turned on in your code and board settings.

        • Use the latest ESP32-P4 USB support in Arduino or ESP-IDF. Sometimes the USB stuff on this chip can be a bit tricky.

        • If you don’t see USB started or resume messages, the USB connection might not be working properly or the computer isn’t recognizing the device.

        • Run a basic USB example (like USB serial or simple storage) to see if USB itself works, without the SD card part.

        • Make sure the pins for SD card and USB don’t clash with each other or other parts.

        this is all I can think off

        From a Data Science Intern to now happy as a IoT Solutions Architect.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post