Hi,
We are using iMX6DL. In our design, we need to do some settings based on whether there is a USB device is attached to the USB OTG port.
Is there a way to find out that any USB device/host is currently attached to the USB OTG port?
Thanks,
Winston
Solved! Go to Solution.
udev knows by netlink to mount such as usb disk and knows to invoke usb garget as device.
How udev know that is the way you know that and the answer for your question.
The basic knowledge is netlink of linux. the dmesg is also by netlink link udev. if you write down a netlink program you will get such as usb disk add remove message as udev does.
From the sysfs /sys/class, it also can know the usb role.
It is linux question not a question for i.MX Processors community.
It is too big topic, suggest you to learn the netlink, udev mechanism first.
Yes.
You can run your board to see the host/device mode, when download images to your board, the board will work on device mode, and when system boot up, you can test the usb host mode.
Hi,
Would you please elaborate more? from embedded Linux, what command should I use? or any /sys file I should check?
Regards,
Winston
Which version of BSP are you using? Have you board boot up?
We use BSP 3.14*.
The board boots up without any problem - it is already a product for years. Now we want to add some new feature - do something when a USB device/host is connected to the OTG port. But we need to way to detect that a USB device/host is connected.
You want the usb to work as host? If yes, you need to connect one otg usb line
I want to set USB as host or device only when a USB host/device is connected - that goes back to my original question: How to detect that there is a USB device/host currently connected. It does not make sense to set anything if nothing is connected, right?
udev knows by netlink to mount such as usb disk and knows to invoke usb garget as device.
How udev know that is the way you know that and the answer for your question.
The basic knowledge is netlink of linux. the dmesg is also by netlink link udev. if you write down a netlink program you will get such as usb disk add remove message as udev does.
From the sysfs /sys/class, it also can know the usb role.
It is linux question not a question for i.MX Processors community.
It is too big topic, suggest you to learn the netlink, udev mechanism first.
Have you get your board now?