2022-12-12 01:06 PM
I have a custom board using a STM32F446RET6 with a SD micro card slot.
The card is formatted to exFAT with one partition.
Using STM32CUBEMX V6.6.1 with firmware F4 V1.27.1
For testing I have a minimal configuration as follows:
SDIO
Mode SD 4 bits Wide bus
DMA enabled for RX and TX
SDIOCLOCK divide set to 4
SDIO global interrupt enabled
USB_OTG_FS
Mode is Device Only
USB OTG global interrupt enabled
USB_DEVICE
Class for FS IP = Mass Storage Class
MSC_MEDIA_PACKET size is 512 bytes (I have tried increasing this)
MCU
clock 168 MHz
using 12 MHz external crystal
SDIO clock is 48 MHz
USB clock 48 MHz
Running this setup when I plug a usb cable to the board the following shows in the log:
usb 2-1.6: new full-speed USB device number 67 using ehci-pci
usb 2-1.6: New USB device found, idVendor=0483, idProduct=572a, bcdDevice= 2.00
usb 2-1.6: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-1.6: Product: STM32 Mass Storage
usb 2-1.6: Manufacturer: STMicroelectronics
usb 2-1.6: SerialNumber: 207433514638
usb-storage 2-1.6:1.0: USB Mass Storage device detected
scsi host7: usb-storage 2-1.6:1.0
scsi 7:0:0:0: Direct-Access STM Product 0.01 PQ: 0 ANSI: 2
sd 7:0:0:0: Attached scsi generic sg4 type 0
sd 7:0:0:0: [sdd] 65536 512-byte logical blocks: (33.6 MB/32.0 MiB)
sd 7:0:0:0: [sdd] Write Protect is off
sd 7:0:0:0: [sdd] Mode Sense: 22 00 00 00
sd 7:0:0:0: [sdd] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
sd 7:0:0:0: [sdd] Attached SCSI removable disk
The logical blocks is incorrect, should be more like 15126528 512-byte logical blocks: (7.74 GB/7.21 GiB)
which is what is reported using the same sdcard but a commercial adapter in my computer.
It also does not find the partition.
I believe my pcb is ok because with my full configuration using FATFS I am able to open the SD card and read files etc from it.