[Linaro-validation] identifying USB devices
michael.hudson at linaro.org
Tue Apr 24 04:57:44 UTC 2012
Part of the whole SD card mux game involves finding the card reader the SD
card for a particular board is plugged into.
Following a lead provided by Zygmunt, it seems that you can address
devices by USB topology by looking in /sys/bus/usb/devices/ -- for
example, the front right USB port on my laptop seems to correspond to a
directories called "1-1.2" and "1-1.2:1.0" in here, the back left port
corresponds to "3-1" and "3-1:1.0" and a particular port on a USB hub
plugged into the front left USB port seems to correspond to "2-1.2.3"
and "2-1.2.3:1.0". So this seems to be reasonably straightforward
(although I don't know if the mapping is necessarily stable across
reboots or kernel upgrades -- seems like it should be though).
The next fun is mapping this directory to a block device. Poking finds
that (with the card reader plugged into the last location mentioned
above) the directory at:
contains a directory called 'sdb' and indeed the sd card is mounted as
/dev/sdb. Playing around shows that the 31 here is a number that gets
incremented each time you plug/unplug the reader (or maybe any USB
device). So this suggests that we could address the card reader in this
port as "2-1.2.3:1.0" and to e.g. run l-m-c targetting the card in the
reader, we should look at
which seems like it would work but frankly also seems like a total hack.
Do any of you know if this can be done in a cleaner way?
More information about the linaro-validation