I'm working with an STM32F3DISCOVERY board. I want to provide USB mass storage functionality over the user USB plug on the board (not the one of the ST-LINK).
I'm following ST's video tutorial as closely as possible, with only the following distinctions:
- I use a different chip/board
- I use STM32CubeIDE, Version: 1.3.1, Build: 6291_20200406_0752 (UTC)
- I use a smaller buffer/media size (16K)
When I plug it into windows, it asks me to format the disk just like in the video. However, the formatting process does not complete.
I get the same message as Youtube commenter "Rtek100":
Windows was unable to complete the format.
Trying to format with windows disk management, I got the error message:
The cluster size is too large for the file system
I tried the same thing under linux with the disks utility and got the following result:
What causes this problem?
Is it related to the settings of the high and low speed clock settings? When he assigns "BYPASS Clock Source" to the High Speed Clock, he mentions that it will come from the ST-LINK. Does this mean that I need to power the ST-LINK USB plug?
update
I watched the tutorial again and found that I have missed to increase the heap size. The problem is still the same. On linux the error message changed (see below), although I'm not sure if this is related to the heap size.
comments
On Linux, after it fails, run
dmesg | tail -n100
and look for I/O related errors and post them here.
To my surprise, the error message is now different (for possible reasons, see update above):
I tried dmesg
and the following is what I get for unplugging, replugging the device.
The attempt to format the disk added no further entries to dmesg
.
[ 968.463379] usb 2-1.2: USB disconnect, device number 9
[ 971.502067] usb 2-1.2: new full-speed USB device number 10 using ehci-pci
[ 971.613248] usb 2-1.2: New USB device found, idVendor=0483, idProduct=572a
[ 971.613253] usb 2-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 971.613256] usb 2-1.2: Product: STM32 Mass Storage
[ 971.613258] usb 2-1.2: Manufacturer: STMicroelectronics
[ 971.613260] usb 2-1.2: SerialNumber: 206636734136
[ 971.614248] usb-storage 2-1.2:1.0: USB Mass Storage device detected
[ 971.614759] scsi host0: usb-storage 2-1.2:1.0
[ 972.619001] scsi 0:0:0:0: Direct-Access STM Product 0.01 PQ: 0 ANSI: 2
[ 972.619599] sd 0:0:0:0: Attached scsi generic sg3 type 0
[ 972.620374] sd 0:0:0:0: [sdc] 32 512-byte logical blocks: (16.4 kB/16.0 KiB)
[ 972.621077] sd 0:0:0:0: [sdc] Write Protect is off
[ 972.621080] sd 0:0:0:0: [sdc] Mode Sense: 00 00 00 00
[ 972.621701] sd 0:0:0:0: [sdc] Asking for cache data failed
[ 972.621707] sd 0:0:0:0: [sdc] Assuming drive cache: write through
[ 972.653486] sd 0:0:0:0: [sdc] Attached SCSI removable disk
I ran fdisk
as well:
$ sudo fdisk -l /dev/sdc
Disk /dev/sdc: 16 KiB, 16384 bytes, 32 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
16 kilobytes? Is that the correct size of your device? I think mkfs is telling you that it can't create a filesystem that small.
Yes, that's correct. The tutorial uses 64, but my chip does not have that much SRAM, so I went with a smaller size.
I checked FAT size limits:
FAT32 minimum : 1 sector per cluster × 65,525 clusters = 33,548,800 bytes (32,762.5 KB)
This might be the cause of the problem, but if 33,548,800 bytes is the lower limit, why do the 64k work in the video? What am I missing here?
dmesg | tail -n100
and look for I/O related errors and post them here. \$\endgroup\$