# USB driver failing to find or power USBs

**URL:** <https://mangoh.discourse.group/t/usb-driver-failing-to-find-or-power-usbs/1033>\
**Category:** mangOH Red\
**Created:** [December 27, 2017, 9:51pm UTC](https://mangoh.discourse.group/t/usb-driver-failing-to-find-or-power-usbs/1033 "2017-12-27T21:51:59Z")\
**Posts on this page:** 1\
**Showing post:** 17

<div class="post-metadata">

**Author:** ![asyal](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/asyal/32/78_2.png) [@asyal](https://mangoh.discourse.group/u/asyal)\
**Post date:** [February 13, 2018, 5:18am UTC](https://mangoh.discourse.group/t/usb-driver-failing-to-find-or-power-usbs/1033/17 "2018-02-13T05:18:29Z")

</div>

Here is a bit more detail on this, again from @davidc ,  
"The second problem

* * *

The above was working for devices that were ‘hotplugged’ (i.e. plugged into the USB host port on the mangOH after it had booted). I still wasn’t seeing the onboard devices appear in the /dev/bus/usb directory. Interestingly, once _one_ device had appeared in the directory, lsusb was happy and could see the rest of the onboard devices. Why? No idea.

Not having device nodes for devices that appear early in the boot sequence is a known problem - it’s called ‘coldplugging’ - and essentially it means that the kernel has recognised the device/loaded module etc before the hotplug manager is alive. So to get around this, mdev has an option ‘-s’ (scan) that forces a manual rescan of /sys/class and re-evaluates all devices found there according to the rules in /etc/mdev.conf. It is intended that ‘mdev -s’ is called during the startup sequence to enumerate any devices that the kernel knowns about, but haven’t been configured yet.

But I found that ‘mdev -s’ was NOT enumerating the USB devices - even after adding the correct rule to mdev.conf. After a lot of head scratching, debugging and looking through the mdev source code, I found that mdev was only scanning /sys/class for device families - and somewhere between kernel 3.6 and 3.18, the kernel was no longer putting usb device descriptors into /sys/class/usb - but only into /sys/bus/usb - so mdev -s could not see the ‘coldplugged’ USB devices.

I found a hint on a forum that you could ‘force’ a hotplug event by echoing data to a file in /sys/bus/usb/devices/xxx/uevent, so I’ve hacked up a script that forces a ‘hotplug’ add event to all devices in /sys/bus/usb/devices - which then trips mdev and evaluates the correct mdev rule - which puts the correct device nodes /dev/bus/usb/

I’m not sure just where to put the re-scan script yet - probably edit the init script that calls mdev -s  
"  
In the short term , see if the following script helps:

#!/bin/sh

# 

# [scanusb.sh](http://scanusb.sh)

# 2018.02.09 D. Clement/Renfell Engineering

# 

# 

# Force a hotplug add event of usb devices in /sys/bus/usb

# This is required because linux kernels newer than

# about 3.10 have moved the USB devices out of /sys/class/usb

# and into /sys/bus/usb. This breaks the mdev -s coldplug

# operation

# 

# /etc/mdev.conf ALSO needs modification to map the USB devices

# into the /dev/bus/usb directory to support libusb

# 

# Add the following line to the end of /etc/mdev.conf

# 

# $DEVNAME=bus/usb/([0-9]+)/(0-9]+) 0:0 0666 =bus/usb/%1/%2

# 

for I in `find /sys/bus/usb/devices -maxdepth 1 -type l` ; do

```
if [-e $I/uevent]; then
    echo add > $I/uevent
fi

```

done

---

_[View the full topic](https://mangoh.discourse.group/t/usb-driver-failing-to-find-or-power-usbs/1033)._
