USB Ram Disk showing 0 bytes of physical size.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-06-22 11:23 AM - last edited on 2025-06-25 3:11 AM by mƎALLEm
i have created a USBx ramdisk which enumerates with windows and a usb disk is shown. when i look at the properties it is 0bytes in size and wont let me format it.if ULONG USBD_STORAGE_GetMediaLastLba(VOID) and USBD_STORAGE_GetMediaBlocklength are set to0 the USB will enumerates. if they are any other size then the USB wont enumerate.
i have attched the design. Any pointers would be great. i will eventually be adding an external SD card inthe design. but just want to get the ramdisk working first.
- Labels:
-
STM32U5 series
-
USB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-07-13 12:23 PM
I have hooked the board up to an external SD card and can successfully read and write to the SD card manually before any USB setup. So I'm confident that, electrically, the SD card is correctly connected. The USBD_STORAGE_GetMediaLastLba and USBD_STORAGE_GetMediaBlocklength functions correctly return the expected numbers (124735488 and 512).
In the USBD_STORAGE_Read and USBD_STORAGE_Write functions, I have tried a few different methods:
Adding a RAM buffer with a file system.
Using HAL_SD_ReadBlock to read directly from the SD card.
When I step through the code, there aren't any errors, and I can break on the read function. However, Windows doesn't show a size for the USB drive once it has enumerated.
When I look at dmesg, I see a lot of Read(10) requests from the host.
31717.788044] usb 1-2.1: new full-speed USB device number 30 using uhci_hcd
[31718.089170] usb 1-2.1: New USB device found, idVendor=0483, idProduct=5720, bcdDevice= 2.00
[31718.089182] usb 1-2.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[31718.089190] usb 1-2.1: Product: STM32 USB Device
[31718.089198] usb 1-2.1: Manufacturer: STMicroelectronics
[31718.089205] usb 1-2.1: SerialNumber: 000000000001
[31718.091189] usb-storage 1-2.1:1.0: USB Mass Storage device detected
[31718.091952] scsi host33: usb-storage 1-2.1:1.0
[31719.114429] scsi 33:0:0:0: Direct-Access AzureRTO USBX storage dev 2000 PQ: 0 ANSI: 0
[31719.116051] sd 33:0:0:0: Attached scsi generic sg3 type 0
[31719.123385] sd 33:0:0:0: [sdb] 124735488 512-byte logical blocks: (63.9 GB/59.5 GiB)
[31719.130023] sd 33:0:0:0: [sdb] Write Protect is off
[31719.130033] sd 33:0:0:0: [sdb] Mode Sense: 24 00 00 00
[31719.133542] sd 33:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[31719.257037] scsi_io_completion_action: 4 callbacks suppressed
[31719.257048] sd 33:0:0:0: [sdb] tag#0 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK cmd_age=0s
[31719.257086] sd 33:0:0:0: [sdb] tag#0 CDB: Read(10) 28 00 00 00 00 00 00 00 08 00
[31719.257094] blk_print_req_error: 4 callbacks suppressed
[31719.257102] I/O error, dev sdb, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0
[31719.257113] buffer_io_error: 3 callbacks suppressed
[31719.257120] Buffer I/O error on dev sdb, logical block 0, async page read
[31719.358933] sd 33:0:0:0: [sdb] tag#0 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK cmd_age=0s
[31719.358945] sd 33:0:0:0: [sdb] tag#0 CDB: Read(10) 28 00 00 00 00 00 00 00 08 00
[31719.358953] I/O error, dev sdb, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0
[31719.358964] Buffer I/O error on dev sdb, logical block 0, async page read
[31719.467236] sd 33:0:0:0: [sdb] tag#0 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK cmd_age=0s
[31719.467248] sd 33:0:0:0: [sdb] tag#0 CDB: Read(10) 28 00 00 00 00 00 00 00 08 00
[31719.467257] I/O error, dev sdb, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0
[31719.467268] Buffer I/O error on dev sdb, logical block 0, async page read
[31719.467330] ldm_validate_partition_table(): Disk read failed.
[31719.568589] sd 33:0:0:0: [sdb] tag#0 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK cmd_age=0s
[31719.568601] sd 33:0:0:0: [sdb] tag#0 CDB: Read(10) 28 00 00 00 00 00 00 00 08 00
[31719.568609] I/O error, dev sdb, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0
[31719.568620] Buffer I/O error on dev sdb, logical block 0, async page read
[31719.672232] sd 33:0:0:0: [sdb] tag#0 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK cmd_age=0s
[31719.672244] sd 33:0:0:0: [sdb] tag#0 CDB: Read(10) 28 00 00 00 00 00 00 00 08 00
[31719.672252] I/O error, dev sdb, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0
[31719.672263] Buffer I/O error on dev sdb, logical block 0, async page read
[31719.775962] sd 33:0:0:0: [sdb] tag#0 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK cmd_age=0s
[31719.775973] sd 33:0:0:0: [sdb] tag#0 CDB: Read(10) 28 00 00 00 00 00 00 00 08 00
[31719.775981] I/O error, dev sdb, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0
[31719.775992] Buffer I/O error on dev sdb, logical block 0, async page read
[31719.883865] sd 33:0:0:0: [sdb] tag#0 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK cmd_age=0s
[31719.883877] sd 33:0:0:0: [sdb] tag#0 CDB: Read(10) 28 00 00 00 00 00 00 00 08 00
[31719.883886] I/O error, dev sdb, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0
[31719.883897] Buffer I/O error on dev sdb, logical block 0, async page read
[31719.884026] Dev sdb: unable to read RDB block 0
[31719.988627] sd 33:0:0:0: [sdb] tag#0 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK cmd_age=0s
[31719.988639] sd 33:0:0:0: [sdb] tag#0 CDB: Read(10) 28 00 00 00 00 00 00 00 08 00
[31719.988647] I/O error, dev sdb, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0
[31719.988658] Buffer I/O error on dev sdb, logical block 0, async page read
[31720.107290] sd 33:0:0:0: [sdb] tag#0 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK cmd_age=0s
[31720.107303] sd 33:0:0:0: [sdb] tag#0 CDB: Read(10) 28 00 00 00 00 00 00 00 08 00
[31720.107312] I/O error, dev sdb, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0
[31720.107323] Buffer I/O error on dev sdb, logical block 0, async page read
[31720.219143] sd 33:0:0:0: [sdb] tag#0 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK cmd_age=0s
[31720.219155] sd 33:0:0:0: [sdb] tag#0 CDB: Read(10) 28 00 00 00 00 18 00 00 08 00
[31720.219190] I/O error, dev sdb, sector 24 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0
[31720.219202] Buffer I/O error on dev sdb, logical block 3, async page read
[31720.433781] sdb: unable to read partition table
[31720.435265] sd 33:0:0:0: [sdb] Attached SCSI removable disk
[31764.056929] usb 1-2.1: reset full-speed USB device number 30 using uhci_hcd
Any ideas what might be happening? I have an updated CubeIDE project I can reattach if needed. Fundamentally, it uses a USBX standalone HID example that worked, and then I changed the application files from a working FreeRTOS MSC example. So there might be some USBx settings I haven't defined. I'm grasping at straws at the moment.
