2024-06-07 08:40 AM
Hi
I have the same problem as described in the topic below:
https://community.st.com/t5/stm32-mpus-products/usb-composite-in-stm32mp157c/td-p/142734
I tried the solution from the above link. I see that I can set up several USB gadget devices, like NCM Ethernet + multiple ACM serial. But it doesn't work, e.g. I can set the 'usb0' interface link to 'up' and set the IP address to it, but I can't ping it from my laptop. At the same time, I can ping it when I have ONLY NCM Ethernet (without ACM devices).
The same situation with ACM devices, it works only if I have only one. If I have more than one USB gadget device (at least 2), serial port either is always busy or transfer works only in one side (from device to laptop).
I'm working on STM32MP135 Discovery kit (STM32MP135F-DK) with mickledore yocto provided by ST (https://wiki.st.com/stm32mpu/wiki/STM32MP1_Distribution_Package).
My otg config:
usbotg_hs: usb@49000000 {
compatible = "st,stm32mp15-hsotg", "snps,dwc2";
reg = <0x49000000 0x40000>;
clocks = <&rcc USBO_K>;
clock-names = "otg";
resets = <&rcc USBO_R>;
reset-names = "dwc2";
interrupts-extended = <&exti 44 IRQ_TYPE_LEVEL_HIGH>;
g-rx-fifo-size = <256>;
g-np-tx-fifo-size = <32>;
g-tx-fifo-size = <128 128 128 128 64 32 16 16>;
dr_mode = "otg";
otg-rev = <0x200>;
usb33d-supply = <&scmi_usb33>;
power-domains = <&pd_core>;
wakeup-source;
feature-domains = <&etzpc STM32MP1_ETZPC_OTG_ID>;
status = "disabled";
};
My configfs commands:
$ modprobe libcomposite
$ cd /sys/kernel/config/usb_gadgets
$ mkdir g1 && cd g1
$ echo 0xabcd > idVendor
$ echo 0x1234 > idProduct
$ mkdir strings/0x409
$ echo myserial > strings/0x409/serialnumber
$ echo mymfg > strings/0x409/manufacturer
$ echo myproduct > strings/0x409/product
$ mkdir configs/c.1
$ echo 120 > configs/c.1/MaxPower
$ modprobe usb_f_acm
$ modprobe usb_f_ncm
$ mkdir functions/acm.0
$ mkdir functions/ncm.0
$ ln -s functions/acm.0 configs/c.1
$ ln -s functions/ncm.0 configs/c.1
$ ls /sys/class/udc > UDC
No errors or warnings.
Even when I enable some USB gadget precomposed configurations (like g_cdc or g_multi), it works in the same way - set up without problem but doesn't work.
Any suggestions?
2024-06-24 01:57 AM
Hello @yahniukov ,
Can you test with the following configuration and tell me if it solves the problem ?
Script :
#!/bin/bash -e
modprobe libcomposite
cd /sys/kernel/config/usb_gadget/
mkdir g && cd g
echo 0x1d6b > idVendor # Linux Foundation
echo 0x0104 > idProduct # Multifunction Composite Gadget
echo 0x0100 > bcdDevice # v1.0.0
echo 0x0200 > bcdUSB # USB 2.0
echo 0xEF > bDeviceClass
echo 0x02 > bDeviceSubClass
echo 0x01 > bDeviceProtocol
mkdir -p strings/0x409
tr -d '\0' < /proc/device-tree/serial-number > strings/0x409/serialnumber
echo "STMICROELECTRONICS" > strings/0x409/manufacturer
echo "STM32MP1" > strings/0x409/product
mkdir -p functions/ncm.usb0 # network
mkdir -p functions/acm.usb0 # serial 0
mkdir -p functions/acm.usb1 # serial 1
mkdir -p functions/acm.usb2 # serial 2
mkdir -p configs/c.1
echo 250 > configs/c.1/MaxPower
echo 0xC0 > configs/c.1/bmAttributes # self powered device
ln -s functions/ncm.usb0 configs/c.1/
ln -s functions/acm.usb0 configs/c.1/
ln -s functions/acm.usb1 configs/c.1/
ln -s functions/acm.usb2 configs/c.1/
udevadm settle -t 5 || :
ls /sys/class/udc/ > UDC
Device tree :
usbotg_hs: usb@49000000 {
compatible = "st,stm32mp15-hsotg", "snps,dwc2";
reg = <0x49000000 0x40000>;
clocks = <&rcc USBO_K>;
clock-names = "otg";
resets = <&rcc USBO_R>;
reset-names = "dwc2";
interrupts-extended = <&exti 44 IRQ_TYPE_LEVEL_HIGH>;
g-rx-fifo-size = <128>;
g-np-tx-fifo-size = <32>;
g-tx-fifo-size = <128 128 128 128 64 64 64 64>;
dr_mode = "peripheral";
otg-rev = <0x200>;
usb33d-supply = <&scmi_usb33>;
power-domains = <&pd_core>;
wakeup-source;
feature-domains = <&etzpc STM32MP1_ETZPC_OTG_ID>;
status = "disabled";
};
I have some doubt if for your number of gadgets, fifos have the right size or not. The above test seems to work on my side.
Kind regards,
Erwan.