User's Manual

www.openmoko.com
32
particular the file /usr/include/linux/usb_gadgetfs.h needs to be present
and if your distribution came with headers older than 2.6.18 or so, then
you need tell the package manager to update them, or you can do that
manually with
# cp -a /usr/src/linux/include/linux/* /usr/include/linux/
(assuming that your kernel sources are in /usr/src/linux). It is important
that this is done before building qemu because the build system checks if
these headers are functional and in case they aren't found it will disable
the USB Slave functionality. Run "grep CONFIG_GADGETFS config-host.h"
in qemu build directory to make sure that the detection succeeded. If it
didn't, correct your linux headers and reconfigure qemu.
After building qemu and before running it, make sure that the modules are
loaded into the kernel. I found it useful to load gadgetfs with the following
command:
# modprobe gadgetfs default_uid=1000 # assuming my User ID is 1000
and added the following line to my /etc/fstab:
gadget /dev/gadget gadgetfs noauto,user,group
0 0
Make sure that the mountpoint /dev/gadget exists:
# mkdir -p /dev/gadget
After that the rest of the procedure can be performed from your regular
user account. Mounting gadgetfs is done with:
$ mount /dev/gadget
The "default_uid" parameter changes the ownership on all files under
/dev/gadget to your own and since the files there are created and
destroyed dynamically, there's no easy way to have that performed by
udev. Now running qemu as you usually do but appending "-usb
-usbgadget" (in the current version of the MokoMakefile this is not
included) should enable the USB Slave functionality. The qemu monitor
commands "info usbslave" and "usb_add gadget" will be useful. The