Forum: Mikrocontroller und Digitale Elektronik HS USB MSC mit Stm32F4 und USB3300


von Mat. K. (matthias_kornfield)


Lesenswert?

Hi
ich bastele gerade ein ein hisg speed USB MSC mit STM32f4 und USB3300 
external Phy. Ebenso benutze ich CubeMx.
Es läuft soweit ganz stabil, nur dass die Bandbreite bei 1-2MB/s ist.
Wenn ich es richtig sehe ist MSC_MEDIA_PACKET die erste Stellschraube.
Allerdings wenn ich das von 512 auf 1024 oder 256 verändere, wird mein 
USB MSC von Windows nicht mehr erkannt. Laut Docu sind das aber gültige 
Einstellungen. Heap und Stack habe ich angepasst.
Weiss jemand warum?
Wie debugge ich das? Mit Wireshark? Wonach suche ich?
Danke

: Bearbeitet durch User
von Thomas Z. (usbman)


Lesenswert?

Die Bandbreite deutet auf ein FS Device hin dort sind m.M. nur 512 Bytes 
erlaubt. Schau mal mit UsbTreeView ob das Ding auf HS schaltet.

Ich benutze gerne USBLyzer, manchmal auch Bushound. Für beide Programme 
gibt es Patches.

von Mat. K. (matthias_kornfield)


Angehängte Dateien:

Lesenswert?

Hi
sbTreeView -> Danke kannte ich nicht, Danke.
sbTreeView zeigt das selbe, egal ob MSC_MEDIA_PACKET 512 oder 1024 
eingestellt ist. Wenn 1024 , stürzt sbTreeView gerne mal ab. hmm

Auch wenn ich 512 einstelle, sehe ich bei data transfer in wireshark 
sowas:

7131  11.258490  host  2.10.2  USB  27  URB_INTERRUPT in
7132  11.259568  2.11.1  host  USBMS  65563  SCSI: Data In LUN: 0x00 
(Read(10) Response Data)
7133  11.259608  host  2.11.1  USB  27  URB_BULK in
das deutet ja auf einer ordentlichen Datenrate hin mit 65563 byte bulk 
transfer.
Im Vergleich mit meiner USB Festplatte der 50 MB/s transferiert sehe ich 
ein haufen zusätzliche URB_BULK in & outs und URB Interrupt? Was sagt 
das mir?
Bild: Wireshark trace von mein Board!
Vielen Dank

: Bearbeitet durch User
von Thomas Z. (usbman)


Lesenswert?

poste bitte mal den kompletten Descriptor Satz (Ausgabe von USB 
TreeView)
Welche Größe haben deine BULK Eps?

: Bearbeitet durch User
von Thomas Z. (usbman)


Lesenswert?

Mat. K. schrieb:
> das deutet ja auf einer ordentlichen Datenrate hin mit 65563 byte bulk
> transfer.

das zeigt nur dass du einen 64k Buffer hast. Die Größe der USB Transfers 
wird durch die EP Size im Descriptor bestimmt.
Beispiel für einen 512B Sector Read:
BulkOut > Sectorread
BulkIn  < 8 mal 64 Bytes für einen Sector (bei Epsize 64 und sectorsize 
512)

die zusätzlichen Interrupt Ins würde ich erst mal ignorieren.

Meine Annahme: Dein Device verwendet immer noch 64 Byte Eps

von Mat. K. (matthias_kornfield)


Lesenswert?

Vielen dank, dass du dir das anschaust.

    =========================== USB Port5 ===========================

Connection Status        : 0x01 (Device is connected)
Port Chain               : 1-5
Properties               : 0x01
 IsUserConnectable       : yes
 PortIsDebugCapable      : no
 PortHasMultiCompanions  : no
ConnectionIndex          : 5
CompanionIndex           : 0
 CompanionHubSymLnk      : 
USB#ROOT_HUB30#4&1083693b&0&0#{f18a0e88-c30c-11d0-8815-00a0c906bed8}
 CompanionPortNumber     : 14

      ======================== USB Device ========================

        +++++++++++++++++ Device Information ++++++++++++++++++
Device Description       : USB-Massenspeichergerät
Device Path              : 
\\?\usb#vid_0483&pid_572a#378736513530#{a5dcbf10-6530-11d2-901f-00c04fb9 
51ed}
Device ID                : USB\VID_0483&PID_572A\378736513530
Driver KeyName           : {36fc9e60-c465-11cf-8056-444553540000}\0015 
(GUID_DEVCLASS_USB)
Driver                   : C:\Windows\System32\drivers\USBSTOR.SYS 
(Version: 10.0.19041.1949  Date: 2022-10-14)
Driver Inf               : C:\Windows\inf\usbstor.inf
Legacy BusType           : PNPBus
Class                    : USB
Class GUID               : {36fc9e60-c465-11cf-8056-444553540000} 
(GUID_DEVCLASS_USB)
Interface GUID           : {a5dcbf10-6530-11d2-901f-00c04fb951ed} 
(GUID_DEVINTERFACE_USB_DEVICE)
Service                  : USBSTOR
Enumerator               : USB
Location Info            : Port_#0005.Hub_#0002
Location IDs             : PCIROOT(0)#PCI(1400)#USBROOT(0)#USB(5), 
ACPI(SB)#ACPI(PC00)#ACPI(XHCI)#ACPI(RHUB)#ACPI(HS05)
Container ID             : {ef775cde-6018-583b-be67-b514f10ff513}
Manufacturer Info        : Kompatibles USB-Speichergerät
Capabilities             : 0x94 (Removable, UniqueID, SurpriseRemovalOK)
Address                  : 5
Problem Code             : 0
Power State              : D0 (supported: D0, D3, wake from D0)
 Child Device 1          : Laufwerk (Disk2)
  Device ID              : 
USBSTOR\DISK&VEN_STM&PROD_PRODUCT&REV_0.01\378736513530&0
  Class                  : DiskDrive
   Volume                : 
\\?\Volume{94449172-f96c-11ed-97bb-0c9a3c82472b}\
   Kernel Name           : \Device\HarddiskVolume100
   Mountpoint            : F:\

        ---------------- Connection Information ---------------
Connection Index         : 0x05 (5)
Connection Status        : 0x01 (DeviceConnected)
Current Config Value     : 0x01
Device Address           : 0x08 (8)
Is Hub                   : 0x00 (no)
Number Of Open Pipes     : 0x02 (2)
Device Bus Speed         : 0x02 (High-Speed)
Pipe0ScheduleOffset      : 0x00 (0)
Pipe1ScheduleOffset      : 0x00 (0)

        --------------- Connection Information V2 -------------
Connection Index         : 0x05 (5)
Length                   : 0x10 (16 bytes)
SupportedUsbProtocols    : 0x03
 Usb110                  : 1 (yes)
 Usb200                  : 1 (yes)
 Usb300                  : 0 (no)
 ReservedMBZ             : 0x00
Flags                    : 0x00
 DevIsOpAtSsOrHigher     : 0 (Is not operating at SuperSpeed or higher)
 DevIsSsCapOrHigher      : 0 (Is not SuperSpeed capable or higher)
 DevIsOpAtSsPlusOrHigher : 0 (Is not operating at SuperSpeedPlus or 
higher)
 DevIsSsPlusCapOrHigher  : 0 (Is not SuperSpeedPlus capable or higher)
 ReservedMBZ             : 0x00

        ------------------ Device Descriptor ------------------
bLength                  : 0x12 (18 bytes)
bDescriptorType          : 0x01 (Device Descriptor)
bcdUSB                   : 0x201 (USB Version 2.01)
bDeviceClass             : 0x00 (defined by the interface descriptors)
bDeviceSubClass          : 0x00
bDeviceProtocol          : 0x00
bMaxPacketSize0          : 0x40 (64 bytes)
idVendor                 : 0x0483 (STMicroelectronics)
idProduct                : 0x572A
bcdDevice                : 0x0200
iManufacturer            : 0x01 (String Descriptor 1)
 Language 0x0409         : "STMicroelectronics"
iProduct                 : 0x02 (String Descriptor 2)
 Language 0x0409         : "STM32 Mass Storage"
iSerialNumber            : 0x03 (String Descriptor 3)
 Language 0x0409         : "378736513530"
bNumConfigurations       : 0x01

        ------------------ String Descriptors -----------------
             ------ String Descriptor 0 ------
bLength                  : 0x04 (4 bytes)
bDescriptorType          : 0x03 (String Descriptor)
Language ID[0]           : 0x0409 (English - United States)
             ------ String Descriptor 1 ------
bLength                  : 0x26 (38 bytes)
bDescriptorType          : 0x03 (String Descriptor)
Language 0x0409          : "STMicroelectronics"
             ------ String Descriptor 2 ------
bLength                  : 0x26 (38 bytes)
bDescriptorType          : 0x03 (String Descriptor)
Language 0x0409          : "STM32 Mass Storage"
             ------ String Descriptor 3 ------
bLength                  : 0x1A (26 bytes)
bDescriptorType          : 0x03 (String Descriptor)
Language 0x0409          : "378736513530"
             ------ String Descriptor 4 ------
bLength                  : 0x16 (22 bytes)
bDescriptorType          : 0x03 (String Descriptor)
Language 0x0409          : "MSC Config"
             ------ String Descriptor 5 ------
bLength                  : 0x1C (28 bytes)
bDescriptorType          : 0x03 (String Descriptor)
Language 0x0409          : "MSC Interface"

      ---------------- Configuration Descriptor -----------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x02 (Configuration Descriptor)
wTotalLength             : 0x0020 (32 bytes)
bNumInterfaces           : 0x01
bConfigurationValue      : 0x01
iConfiguration           : 0x04 (String Descriptor 4)
 Language 0x0409         : "MSC Config"
bmAttributes             : 0xC0
 D7: Reserved, set 1     : 0x01
 D6: Self Powered        : 0x01 (yes)
 D5: Remote Wakeup       : 0x00 (no)
 D4..0: Reserved, set 0  : 0x00
MaxPower                 : 0x32 (100 mA)

        ---------------- Interface Descriptor -----------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x04 (Interface Descriptor)
bInterfaceNumber         : 0x00
bAlternateSetting        : 0x00
bNumEndpoints            : 0x02 (2 Endpoints)
bInterfaceClass          : 0x08 (Mass Storage)
bInterfaceSubClass       : 0x06 (SCSI transparent command set)
bInterfaceProtocol       : 0x50 (Bulk­Only Transport)
iInterface               : 0x05 (String Descriptor 5)
 Language 0x0409         : "MSC Interface"

        ----------------- Endpoint Descriptor -----------------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x05 (Endpoint Descriptor)
bEndpointAddress         : 0x81 (Direction=IN EndpointID=1)
bmAttributes             : 0x02 (TransferType=Bulk)
wMaxPacketSize           : 0x0200 (max 512 bytes)
bInterval                : 0x00 (never NAKs)

        ----------------- Endpoint Descriptor -----------------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x05 (Endpoint Descriptor)
bEndpointAddress         : 0x01 (Direction=OUT EndpointID=1)
bmAttributes             : 0x02 (TransferType=Bulk)
wMaxPacketSize           : 0x0200 (max 512 bytes)
bInterval                : 0x00 (never NAKs)

      ---------- Other Speed Configuration Descriptor -----------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x07 (Other_speed_configuration Descriptor)
wTotalLength             : 0x0020 (32 bytes)
bNumInterfaces           : 0x01
bConfigurationValue      : 0x01
iConfiguration           : 0x04 (String Descriptor 4)
 Language 0x0409         : "MSC Config"
bmAttributes             : 0xC0
 D7: Reserved, set 1     : 0x01
 D6: Self Powered        : 0x01 (yes)
 D5: Remote Wakeup       : 0x00 (no)
 D4..0: Reserved, set 0  : 0x00
MaxPower                 : 0x32 (100 mA)

        ---------------- Interface Descriptor -----------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x04 (Interface Descriptor)
bInterfaceNumber         : 0x00
bAlternateSetting        : 0x00
bNumEndpoints            : 0x02 (2 Endpoints)
bInterfaceClass          : 0x08 (Mass Storage)
bInterfaceSubClass       : 0x06 (SCSI transparent command set)
bInterfaceProtocol       : 0x50 (Bulk­Only Transport)
iInterface               : 0x05 (String Descriptor 5)
 Language 0x0409         : "MSC Interface"

        ----------------- Endpoint Descriptor -----------------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x05 (Endpoint Descriptor)
bEndpointAddress         : 0x81 (Direction=IN EndpointID=1)
bmAttributes             : 0x02 (TransferType=Bulk)
wMaxPacketSize           : 0x0040 (max 64 bytes)
bInterval                : 0x00 (never NAKs)

        ----------------- Endpoint Descriptor -----------------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x05 (Endpoint Descriptor)
bEndpointAddress         : 0x01 (Direction=OUT EndpointID=1)
bmAttributes             : 0x02 (TransferType=Bulk)
wMaxPacketSize           : 0x0040 (max 64 bytes)
bInterval                : 0x00 (never NAKs)

      ---------- Binary Object Store (BOS) Descriptor -----------
bLength                  : 0x05 (5 bytes)
bDescriptorType          : 0x0F (Binary Object Store)
wTotalLength             : 0x000C (12 bytes)
bNumDeviceCaps           : 0x01

        ------------- USB 2.0 Extension Descriptor ------------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x10 (Device Capability Descriptor)
bDevCapabilityType       : 0x02 (USB 2.0 Extension)
bmAttributes             : 0x02
 LPMCapable              : 1 (Link Power Management protocol is 
supported)
 BESLAndAlternateHIRD    : 0 (BESL & Alternate HIRD definitions are not 
supported)
 BaselineBESLValid       : 0 (not valid)
 DeepBESLValid           : 0 (not valid)
 BaselineBESL            : 0
 DeepBESL                : 0

von Mat. K. (matthias_kornfield)


Lesenswert?

Bevor ich deine Zeit zusehr verschwende, bitte bedenke: mein Stm32 kann 
aktuell nur 6 MB/s aus der SD Karte lesen. Da arbeite ich auch gerade an 
der Optimierung.
Windows braucht aber 30 sekunden für einen 64MB file zum rauskopieren.

von Thomas Z. (usbman)


Lesenswert?

Das sieht gut aus, das Device ist im HS Mode, die Bulk Eps sind 
512Bytes.
Was ich nicht verstehe sind die Interrupt Ins da kein Interrupt Ep 
deklariert ist. Was die mit dem Bos Descriptor machen verstehe ich auch 
nicht.

von Thomas Z. (usbman)


Lesenswert?

Mat. K. schrieb:
> Bevor ich deine Zeit zusehr verschwende, bitte bedenke: mein Stm32 kann
> aktuell nur 6 MB/s aus der SD Karte lesen

das ist mir schon bewusst dass dass nicht hyperschnell sein kann.

von Thomas Z. (usbman)


Lesenswert?

Was macht MSC_MEDIA_PACKET? Ist das die Sector Size des Mediums?
Wieviel Zeit vergeht bis ein SD Sektor bereitsteht?

Ev bekommst du einfach ein paar NAKs weil der Sektor noch nicht bereit 
steht.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.