02-06-2018 05:52 AM
In our project we use Zynq 7000 (XC7Z010) in our custom module with Petalinux kernel version 4.6.0. The zynq module has been used as a USB peripheral (Slave) device. In system-top.dts, USB device tree node property “dr_mode” changed as “peripheral” which controls the mode of the device driver.
Kernel configuration: http://www.wiki.xilinx.com/Zynq+Linux+USB+Device+Driver
Logs:
# dmesg | grep -i USB
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
gadgetfs: USB Gadget filesystem, version 24 Aug 2004
# lsusb
unable to initialize libusb: -99
# lsmod
Not tainted
usb_f_mass_storage 30347 2 - Live 0xbf025000
libcomposite 34188 6 usb_f_mass_storage, Live 0xbf014000
configfs 22169 3 usb_f_mass_storage,libcomposite, Live 0xbf008000
gadgetfs 15217 0 - Live 0xbf000000
Directory /sys/class/udc is empty
so i could not attach the gadget to the UDC driver
> udc-core: couldn't find an available UDC - added [g1] to list of pending drivers
Though I have enabled ChipIdea device controller as mentioned in Xilinx wiki.
Under /sys/class/udc I see no available udc drivers. The expected ci_hdrc.0 doesn't show up.
Any technical suggestions would be appreciated.
02-07-2018 01:34 AM
Looks that might be order of inserting modules matter,
I am adding the steps below , you can follow it even this is different petalinux version but should work.
Can you please try to insert modules as mentioned below:
cd lib/modules/4.9.0-xilinx-v2017.3/
cd kernel/fs/configfs/
modprobe configfs.ko
cd ../..
cd drivers/usb/gadget
modprobe libcomposite.ko
cd function/
insmod usb_f_mass_storage.ko
cd ../legacy/
insmod gadgetfs.ko
dd if=/dev/zero of=/tmp/mydev count=256 bs=1M
insmod g_mass_storage.ko file=/tmp/mydev removable=1
After this step connect the USB male to male cable between target USB port and host USB port, it will detect as a USB drive.
and Make sure change the jumper settings as per peripheral mode.
In case if you still face issues let me know, i will try my end and update you.
Thanks & Regards
Aravind
02-07-2018 04:42 AM
Thanks for your reply.
I have issue with UDC as i have mentioned earlier.
# insmod g_mass_storage.ko file=/tmp/mydev removable=1
udc-core: couldn't find an available UDC - added [g_mass_storage] to list of pending drivers
>> Though I have enabled ChipIdea device controller as mentioned in Xilinx wiki.
>> Under /sys/class/udc I see no available udc drivers. The expected ci_hdrc.0 doesn't show up.
Any suggestions/tips are welcome.
02-07-2018 06:34 PM
I cannot understand why people are still using those multiple commands like 'insmod' and others. At least for Microzed this is totally useless because if you properly update device tree the USB memory sticks are detected and mounted automatically.
02-08-2018 03:25 AM
HI,
I just enabled extra Config options along with default config & I inserted modules in mentioned order, and its working fine. I have verified on zc702 board.
I have attached the config options for your reference what to enable & in device tree you should add dr_mode="peripheral" in usb node like shown in attachment.
"> udc-core: couldn't find an available UDC - added [g1] to list of pending drivers" --> The reason for this issue is, you are providing "dr_mode=host", in device tree ,then only you will get this error , this already verified now before commenting.
root@xilinx-zc702-2017_3:/lib/modules/4.9.0-xilinx-v2017.3/kernel/drivers/usb/gadget# ls
function legacy libcomposite.ko
root@xilinx-zc702-2017_3:/lib/modules/4.9.0-xilinx-v2017.3/kernel/drivers/usb/gadget# modprobe libcomposite.ko
root@xilinx-zc702-2017_3:/lib/modules/4.9.0-xilinx-v2017.3/kernel/drivers/usb/gadget/function# insmod usb_f_mass_storage.ko
root@xilinx-zc702-2017_3:/lib/modules/4.9.0-xilinx-v2017.3/kernel/drivers/usb/gadget/function# cd ../legacy/
root@xilinx-zc702-2017_3:/lib/modules/4.9.0-xilinx-v2017.3/kernel/drivers/usb/gadget/legacy# ls
g_mass_storage.ko g_zero.ko gadgetfs.ko
root@xilinx-zc702-2017_3:/lib/modules/4.9.0-xilinx-v2017.3/kernel/drivers/usb/gadget/legacy# insmod gadgetfs.ko
gadgetfs: USB Gadget filesystem, version 24 Aug 2004
root@xilinx-zc702-2017_3:/lib/modules/4.9.0-xilinx-v2017.3/kernel/drivers/usb/gadget/legacy# dd if=/dev/zero of=/tmp/mydev count=256 bs=1M
256+0 records in
256+0 records out
root@xilinx-zc702-2017_3:/lib/modules/4.9.0-xilinx-v2017.3/kernel/drivers/usb/gadget/legacy# ls
g_mass_storage.ko g_zero.ko gadgetfs.ko
root@xilinx-zc702-2017_3:/lib/modules/4.9.0-xilinx-v2017.3/kernel/drivers/usb/gadget/legacy# insmod g_mass_storage.ko file=/tmp/mydev removable=1
Mass Storage Function, version: 2009/09/11
LUN: removable file: (no medium)
LUN: removable file: /var/volatile/tmp/mydev
Number of LUNs=1
g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
g_mass_storage gadget: userspace failed to provide iSerialNumber
g_mass_storage gadget: g_mass_storage ready
root@xilinx-zc702-2017_3:/lib/modules/4.9.0-xilinx-v2017.3/kernel/drivers/usb/gadget/legacy# g_mass_storage gadget: high-speed config #1: Linux File-Backed Storage
g_mass_storage gadget: high-speed config #1: Linux File-Backed Storage
root@xilinx-zc702-2017_3:/lib/modules/4.9.0-xilinx-v2017.3/kernel/drivers/usb/gadget/legacy#
Thanks & regards
Aravind
---------------------------------------------------------------------------
Don’t forget to Reply, Kudo, and Accept as Solution.
---------------------------------------------------------------------------
11-22-2018 08:26 PM
Hi,
I have issue with UDC
I inserted modules in the mentioned order but When I tried to insert g_mass_storage.ko,still this issue is there
udc-core: couldn't find an available UDC - added [g_mass_storage] to list of pending drivers
ci_hdrc.0 is not found under /sys/class/udc.
I'm using petalinux 2017.2 and PS is Z-7014S. config options are same as you have specified in the usb_config_enable.txt file, dr_mode = "peripheral" in the device tree and 'Userspace-driven configuration filesystem' is
File systems --->
Pseudo filesystems --->
-*- Userspace-driven configuration filesystem
I can not change it to "*" or "M".
Any suggestions would be appreciated.