Discussion:
qemu usb flash drive (stick)
(too old to reply)
faif
2011-09-19 08:34:05 UTC
Permalink
It seems that I have the same problem with https://groups.google.com/forum/#!searchin/comp.os.plan9/usb/comp.os.plan9/dBpkbPyQrzw/0TagYRLa02MJ

term% usb/usbd
usb/usbd: /dev/usb: no hubs

`ls #u' works (but why is that important?)

I'm also missing the /srv/usb file:
term% usbfat:
mount: can't open /srv/usb: '/srv/usb' does not exist
cannot mount /srv/usb

Any tips?
faif
2011-09-20 09:07:38 UTC
Permalink
I removed the similar topic, sorry for posting twice but the delay was long thus I assumed that this one never reached the group.

I found out that `ls #u' is useful since #u is the short name bound to the usb directory. So if it works it means that usbd is up? Nevertheless the problem still remains, so I'm waiting for your tips :)
Richard Miller
2011-09-20 09:39:33 UTC
Permalink
Post by faif
I found out that `ls #u' is useful since #u is the short name bound to the usb directory. So if it works it means that usbd is up?
No, the existence of '#u' just shows that the kernel usb driver exists
and a usb interface has been found. The user-level usbd program is
needed in order to connect and enumerate any devices. You can use
the ps(1) command to see whether usbd is running.

term% ps|grep usbd
miller 5 0:06 4:02 492K Sleep usbd
miller 7 0:05 0:15 492K Pread usbd
miller 8 0:00 0:00 492K Pread usbd
miller 9 0:00 0:00 492K Rendez usbd
miller 10 0:00 0:00 492K Rendez usbd
miller 68 0:00 0:00 492K Rendez usbd

You said you had seen the error message 'no hubs' when starting usb/usbd.
It's often useful to explore the source code to find more information
about an error message:

term% src -n usb/usbd
/sys/src/cmd/usb/usbd/usbd.c:809
term% grep 'no hubs' /sys/src/cmd/usb/usbd/*.c
/sys/src/cmd/usb/usbd/usbd.c: sysfatal("/dev/usb: no hubs");

Sysfatal exits after printing a message, so that explains why usbd is
not running, and therefore isn't providing the /srv/usb service.

To look for more clues about what's going wrong:

- try 'ls -d /dev/usb' to see if '#u' is bound in /dev
- try 'cat /dev/usb/ctl' to see what the state of your usb interfaces is
- look in /dev/kmesg to see if there are any boot-time error messages
relating to usb
faif
2011-09-21 08:36:26 UTC
Permalink
Thanks for the tips. By trying to avoid thinking about UNIX when I'm on Plan 9 I forgot that some userspace utilities are the same :)
Post by Richard Miller
No, the existence of '#u' just shows that the kernel usb driver exists
and a usb interface has been found. The user-level usbd program is
needed in order to connect and enumerate any devices. You can use
the ps(1) command to see whether usbd is running.
term% ps|grep usbd
miller 5 0:06 4:02 492K Sleep usbd
miller 7 0:05 0:15 492K Pread usbd
miller 8 0:00 0:00 492K Pread usbd
miller 9 0:00 0:00 492K Rendez usbd
miller 10 0:00 0:00 492K Rendez usbd
miller 68 0:00 0:00 492K Rendez usbd
There is one instance of usbd appearing at the output of ps
Post by Richard Miller
You said you had seen the error message 'no hubs' when starting usb/usbd.
It's often useful to explore the source code to find more information
term% src -n usb/usbd
/sys/src/cmd/usb/usbd/usbd.c:809
term% grep 'no hubs' /sys/src/cmd/usb/usbd/*.c
/sys/src/cmd/usb/usbd/usbd.c: sysfatal("/dev/usb: no hubs");
Sysfatal exits after printing a message, so that explains why usbd is
not running, and therefore isn't providing the /srv/usb service.
Thanks, the src command (together with sig) rocks. Yes, the code reaches the sysfatal part and exits. But then I'm wondering how usbd is shown on the ps output?
Post by Richard Miller
- try 'ls -d /dev/usb' to see if '#u' is bound in /dev
Assuming that I'm getting some output how can I know if it is correct? Are there any userspace commands to see what is bound where? bind doesn't seem to support listings, only namespace modifications.
Post by Richard Miller
- try 'cat /dev/usb/ctl' to see what the state of your usb interfaces is
The file is empty
Post by Richard Miller
- look in /dev/kmesg to see if there are any boot-time error messages
relating to usb
Same message here: `/boot:usbd: /dev/usb: no hubs'

Perhaps it's time to look at the source code of usbd? :)
Richard Miller
2011-09-21 10:21:13 UTC
Permalink
Post by faif
Post by Richard Miller
- try 'ls -d /dev/usb' to see if '#u' is bound in /dev
Assuming that I'm getting some output how can I know if it is correct? Are there any userspace commands to see what is bound where? bind doesn't seem to support listings, only namespace modifications.
ns(1) command shows bindings.
Post by faif
Perhaps it's time to look at the source code of usbd? :)
I don't think the problem is within usbd. The 'no hubs' message
really does mean what it says -- it seems the kernel hasn't succeeded
in initialising the usb host interface to the extent where it sees
the built-in hub which usbd needs to enumerate devices.

I think you need input from a qemu expert here -- I've never tried qemu
myself. What version of qemu are you using, on what OS? Maybe there's
a trick to configuring usb on qemu, or maybe that version of qemu just
doesn't emulate usb in quite the way that Plan 9 wants to see.
Bakul Shah
2011-09-21 18:11:46 UTC
Permalink
Post by Richard Miller
I don't think the problem is within usbd. The 'no hubs' message
really does mean what it says -- it seems the kernel hasn't succeeded
in initialising the usb host interface to the extent where it sees
the built-in hub which usbd needs to enumerate devices.
I think you need input from a qemu expert here -- I've never tried qemu
myself. What version of qemu are you using, on what OS? Maybe there's
a trick to configuring usb on qemu, or maybe that version of qemu just
doesn't emulate usb in quite the way that Plan 9 wants to see.
Haven't used qemu much lately. There must be plenty of
examples on the web but from what I remember, you have to tell
qemu a few things.

$ qemu -usb -monitor stdio ...

To find vendor/product ids for a device you want, use lsusb on
linux or usbconfig on freebsd. The host *must not* load any
driver for this device. Tell qemu about it either via command
line with "-usbdevice host:<vendor><product>" or later via its
monitor shell on stdio with "usb_add host:<vendor><product>"
faif
2011-09-22 08:32:42 UTC
Permalink
Thank you for guiding me to the right path guys. The problem was with qemu which needs special settings (http://alien.slackbook.org/dokuwiki/doku.php?id=slackware:qemu#using_an_usb_device_in_qemu) for recognizing USB devices
faif
2011-09-26 08:42:29 UTC
Permalink
Hmmm... I'm still missing something. If usb support is fine and usbd
is running, do I need any other commands than 'usbfat:'? The latter
gives the output 'no usb disks found'.
Richard Miller
2011-09-26 09:02:28 UTC
Permalink
Try usb/probe to see what devices are seen to be attached.

Also check on the host system to see if the usb stick is
attached there instead. You may need to do something to
get the device assigned to qemu instead of to the host system.
faif
2011-11-28 09:38:24 UTC
Permalink
Back after some (actually a long) idle time... :)
sudo qemu -usb -usbdevice host:0e34:1025 plan9.img
Now... It seems that I have a file permission problem.

usbfat:
/n/sdV0.0

touch /n/sdV0.0/a ... create prohibited

I tried to access the drive both with glenda and the custom user that I added some time ago. ls -l says that the /n/sdV0.0 user is bill and the group trog

Tried to log on as adm but rio fails to start (some settings are missing). I noticed that there is no user bill and group trog in /adm/users. Is this the next step?
c***@gmx.de
2011-11-28 10:06:33 UTC
Permalink
dossrv doesnt know about users, bill trog is some
dummy name and probably some inside joke.

the /adm/users file is for fossil/kfs/cwfs and unrelated
to your problem.

usbfat: mounts the device with -c, so creating files
in the root should work on this part.

i'v seen this before and it might be a bug in
dossrv itself on fat32 partitions. it only happend
on the filesystem root directory. run a filesystem
check on the drive with some other operating system.

once followed the exact codepath for that error,
but can't remember.

reformating the drive (with FAT16) fixed the problem.

--
cinap
erik quanstrom
2011-11-28 13:19:28 UTC
Permalink
Post by faif
Back after some (actually a long) idle time... :)
sudo qemu -usb -usbdevice host:0e34:1025 plan9.img
Now... It seems that I have a file permission problem.
/n/sdV0.0
touch /n/sdV0.0/a ... create prohibited
it appears that you paraphrased the output. did you type 9fat:
and touch in the same rio window? that looks like the output
you'd get if there were no mounted disk.

the output of ns(1) would help see what's mounted on /n.

- erik
faif
2011-11-29 10:15:16 UTC
Permalink
Hi Erik,

The output might not be 100% correct since I manually copied it. Using qemu and still investigating how to achieve copy-pasting in the clipboard between guest-host...

AFAIU you mean that if I mounted the drive on one rio window and tried to do anything with it on another it won't work because of the different namespaces. I think that I used the same rio window for everything but I'll make sure that this is the case.
faif
2011-11-29 10:15:41 UTC
Permalink
Thanks cinap, interesting. I'll retry with fat16 and see if the joke still insists :)
faif
2011-11-29 10:16:07 UTC
Permalink
OK that was silly. I noticed that instead of /n/sdU0.0 I was typing /n/sdV0.0 Those rio fonts look so alike! And lc /n/sdU0.0 is not complaining so at first I didn't notice that this directory doesn't exist at all :)

Thanks everyone

Loading...