TAB5: Unable to mount SD card as USB mass storage
-
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...
-
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
-
-
Thanks for the feedback.
I have tried several examples from both the Arduino & IDF (both updated to the latest) and none of them seem to expose the Tab5 as a usb device:
- USB Keyboard & Mouse examples
- USB Custom HID device
- USBMSC example
- USB Serial example
I can get similar projects working on my ESP32-S3 device without issue..
I'm wondering if anyone has a working example of the Tab5 enumerating as a USB device?
-
I'm having the same issue with my Tab5, when I try USBMSC or SD2USBMSC examples in Arduino IDE they upload fine but I don't get a usb device on my computer. I did notice in the serial monitor that it says USB-Serial/JTAG, even though I changed the settings under tools, following this fellows video:
https://www.youtube.com/watch?v=hJSBTFsOnoA
He's using a ESP32-S3 and it seems to work fine. One thing I did discover in the ESP32-P4 docs is that it needs the strapping pins set in order to get the chip in Joint download mode:
https://docs.espressif.com/projects/esp-hardware-design-guidelines/en/latest/esp32p4/schematic-checklist-esp32p4.html#schematic-checklist-strapping-pins
It also can share the same lines for USB:
https://docs.espressif.com/projects/esp-hardware-design-guidelines/en/latest/esp32p4/schematic-checklist-esp32p4.html#usb
I think the usb-c might be connected to both sets of lines and the pins are not set correctly to select joint download mode. I couldn't really determine this in the schematics provided by M5 as they are confusing but I think they need to provide separate examples and libraries for the ESP32-P4 as it is quite different from the ESP32-S3 -
Using this example is fine.
https://github.com/espressif/esp-idf/tree/master/examples/peripherals/usb/device/tusb_msc
sdkconfig.defaults
# This file was generated using idf.py save-defconfig. It can be edited manually. # Espressif IoT Development Framework (ESP-IDF) 5.5.1 Project Minimal Configuration # CONFIG_IDF_TARGET="esp32p4" CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y CONFIG_PARTITION_TABLE_CUSTOM=y CONFIG_EXAMPLE_STORAGE_MEDIA_SDMMC=y CONFIG_EXAMPLE_SD_PWR_CTRL_LDO_INTERNAL_IO=n CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y CONFIG_FATFS_LFN_HEAP=y CONFIG_WL_SECTOR_SIZE_512=y CONFIG_WL_SECTOR_MODE_PERF=y CONFIG_TINYUSB_MSC_ENABLED=y
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