Closed lbthomsen closed 2 years ago
Hi, My observation MCU 411CE Total Endpoints 3 (Excluding EP0) CDC requires 2 IN EP & 1 OUT MSC requires 1 IN & 1 OUT at this point you have consumed all IN endpoint Total PMA Buffer is 1.25KB (1280 Bytes)
HAL_PCDEx_SetTxFiFo takes size in WORDS, minimum is 16 words. so total buffer consumption is EP OUT Common (128 4) is 512 bytes EP0 IN (644) 256
CDC IN1 (128 4) 512 CDC IN2 (64 4) 256 MSC IN (128 * 4)512
as above calculation suggest you have exhausted PMA buffer
my suggestion will be to partition PMA as
EP OUT Common (512 Bytes) 128 as param to HAL_PCDEx_SetTxFiFo()
EP0 IN (64 Bytes) 16 CDC IN1 (128 Bytes) 32 CDC IN2 (64 Bytes) 16 MSC IN (128 Bytes) 32
So - in the setup it is possible to add 2 CDC interfaces but how would that ever be possible - 2 IN EP's per device is 4 already + EP0 would be five.
I will try with HID + MSC only!
And yes - CDC + MSC only with the buffers you suggested works:
[356454.344290] usb 2-4.5.4: new full-speed USB device number 5 using xhci_hcd
[356454.446124] usb 2-4.5.4: New USB device found, idVendor=0483, idProduct=52a4, bcdDevice= 2.00
[356454.446126] usb 2-4.5.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[356454.446127] usb 2-4.5.4: Product: STM32 COMPOSITE DEVICE
[356454.446128] usb 2-4.5.4: Manufacturer: STMicroelectronics
[356454.446129] usb 2-4.5.4: SerialNumber: 318A34583030
[356454.458855] cdc_acm 2-4.5.4:1.0: ttyACM1: USB ACM device
[356454.459382] usb-storage 2-4.5.4:1.2: USB Mass Storage device detected
[356454.459566] scsi host7: usb-storage 2-4.5.4:1.2
[356455.460723] scsi 7:0:0:0: Direct-Access STM Product 0.01 PQ: 0 ANSI: 2
[356455.460947] sd 7:0:0:0: Attached scsi generic sg4 type 0
[356455.461339] sd 7:0:0:0: [sde] 200 512-byte logical blocks: (102 kB/100 KiB)
[356455.461589] sd 7:0:0:0: [sde] Write Protect is off
[356455.461591] sd 7:0:0:0: [sde] Mode Sense: 22 00 00 00
[356455.461819] sd 7:0:0:0: [sde] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[356455.495957] sd 7:0:0:0: [sde] Attached SCSI removable disk
First of all - let me apologize up front if this issue is a bit of a mess. I am still trying to nail down exactly what is happening and this issue should probably be split into 2-3 different issues.
After the announcement of this project on Reddit (https://www.reddit.com/r/embedded/comments/pqql3v/stm32_usb_composite_class_wrapper/) I immediately tried and ran into an issue of no enumeration (trying a composite with cdc, hid and msc). On Reddit it was suggested to change
usbd_conf.c
:To:
Which made the device enumerate.
These experiments were all done on a regular "black pill" board with stm32f411ce mcu. According to the reference manual that MCU has got "1.25 kB" of dedicated USB FIFO buffer memory (presumably that is 1280 byte or 0x0500), so it is quite obvious why the change suggested is necessary (at least on this particular MCU).
However, even with this change there are still some issues. trying the composite cdc, hid, msc and changing the fifo values to:
Enumerates like this:
This experiment is here: https://github.com/lbthomsen/blackpill/tree/master/comptest
I have not yet tested the HID, but oddities are as follows:
The CDC resets 4 times (as seen above). This does not happen when using ST's own HAL CDC. It does however work (at lest for transmitting). Using:
works - serial data is received on
/dev/ttyACMx
.The mass storage device however doesn't register as a storage device. Using ST's MSC driver (example here: https://github.com/lbthomsen/blackpill/tree/master/msc), enumerates like this:
This lead me to suspect that the communication with the MSC device is not really working in the composite.