Re: Linux as a USB hub?

2015-12-02 Thread Chris McClimans
On Wed, Dec 2, 2015 at 7:29 AM, Rogan Dawes  wrote:
> On Tue, Dec 01, 2015 at 06:17:54PM -0800, Greg KH wrote:
>> On Wed, Dec 02, 2015 at 01:02:28AM +, Rogan Dawes wrote:
>> > Thanks Greg.
>> >
>> > At a high level, what is needed to implement a new type of USB device 
>> > gadget,
>> > such as a display link device?

> As mentioned originally, I'm trying to come up with an IP KVM, as 
> inexpensively as possible. Realising that the approach that I am following 
> will not allow me to interact with any layers prior to a successfully booted 
> operating system, what I am hoping to do is, at a minimum, be able to observe 
> the DisplayLink traffic flowing from an external computer (i.e. not a VM) 
> over the USB.

> As I understand it, I have a couple of options of achieving this:
>
> 1) Have Linux operate as a general purpose hub, and simply plug in a real 
> displaylink adapter to the host ports, and observe the data flowing from one 
> to the other. At least I don't have to worry about actually convincing 
> upstream that I *am* a DisplayLink device. At this point, I can hopefully 
> decode the data to reconstruct the framebuffer, and make it available via 
> e.g. VNC. This seems to be a difficult option, as you have indicated.

Linux has some built in gadget functions here:
https://github.com/torvalds/linux/tree/master/drivers/usb/gadget/function
but I haven't seen much discussion about creating a f_hub.

> 2) Have Linux operate as some sort of proxy, in a special case of 1). No need 
> to make it general purpose, so long as I can make it work for the DisplayLink 
> adapter I have, I should be good. This may or may not be easier than 1). 
> Again, with access to the data, I can reconstruct the framebuffer.

Might look at using a BeagleBone black with
https://github.com/dominicgs/USBProxy as a mitm to observe the traffic.

> 3) Making use of the Linux driver code already existing for the DisplayLink 
> family, write a gadget driver to act as a DisplayLink device. Using a Windows 
> VM and usbsnoop may make this easier during development. This is obviously 
> the best case, but probably a lot more work than either 1 or 2.

Yea, I'd shoot for USBProxy, Dominic provides a in image for flashing
the BeagleBone to do use it as a proxy for sniffing.

> FWIW, while I'm OK with the result not being acceptable by kernel standards, 
> I do plan to make the code freely available to anyone who would like to build 
> on it.

Another project that might be interesting for you to look at is
https://github.com/pelya/android-keyboard-gadget , @pelya's approach
is to use the camera on the phone, point it at the screen and show up
as a keyboard/mouse gadget to the PC then export the KVM as a VNC
server.

I'm working on something similar but I want to support exporting USB
devices as their bluetooth countparts and visa versa. Also looking
into adding something similar to DriveDroid
http://softwarebakery.com/projects/drivedroid to dynamically export
installation media via mass_storage and network etc...
https://github.com/ii/iikeyboard/wiki
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: uac2 configfs function seems to load incorrectly if loaded other particular functions

2015-11-08 Thread Chris McClimans
It looks like the ordering may be important.
Configuring uac2 as your first function seems to resolve the issue.
Must be a requirement documented somewhere, or an interesting bug. :)
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: uac2 configfs function seems to load incorrectly if loaded other particular functions

2015-11-08 Thread Chris McClimans
Thought it might be useful to include the kernel versions:

usb-host-arch$ uname -a
Linux viii 4.2.3-1-ARCH #1 SMP PREEMPT Sat Oct 3 18:52:50 CEST 2015
x86_64 GNU/Linux

usb-gadget-debian(beaglebone black)$ # uname -a
Linux beaglebone 4.1.12-ti-r26 #1 SMP PREEMPT Fri Oct 30 21:28:17 UTC
2015 armv7l GNU/Linux
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


uac2 configfs function seems to load incorrectly if loaded other particular functions

2015-11-07 Thread Chris McClimans
I'm trying to create a configfs based multi function gadget using the
most minimal configs for uac2 and other devices, but I'm finding very
few combinations that work. Was looking for some suggestions on how to
debug, or what information to gather to make it work. I've included
some of the combinations and results below:

Working combinations:
uac2 by itself
uac2 + mass_storage
uac2 + hid

Non-working combinations:

no host errors, device shows up in /proc/sound/acards, but not in pulse audio:
uac2 + mass_storage + hid
uac2 + midi

If I load uac2 w/ acm, rndis or ecm:
Host error: Interface #0 referenced by multiple IADs, Interface #1
referenced by multiple IADs

If Loaded with 3 or more functions:
Host error: Audio class v2 interfaces need an interface association
uac2 + hid + acm
uac2 + hid + rndis
uac2 + hid + midi # also Interface #0+1 referenced by multiple IADs
uac2 + acm + midi  # also Interface #0+1 referenced by multiple IADs
uac2 + acm + rdnis  # also Interface #0+1+2 referenced by multiple IADs
uac2 + acm + mass_storage  # also Interface #0+1+2 referenced by multiple IADs
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: f_hid, f_mass_storage, and f_rdnis via configfs on platform/intel-mid

2015-02-04 Thread Chris McClimans
Hi Andrzej,

Thank you for your time.

I'd like to take a stab at FunctionFS before I start looking at
backporting hid and uvc from 3.19+

I found a lot of information (mainly from you [1] [2]) on gadget
ConfigFS and hid, but I'm
having less luck finding information on FunctionFS and the required daemons.

On Thu, Jan 22, 2015 at 7:33 AM, Andrzej Pietrasiewicz
andrze...@samsung.com wrote:

 These days instead of gadgetfs one should probably use FunctionFS.
 The purpose of the two is delegating actual usb function implementation
 to userspace with some filesystem being the interface to the kernel.

It looks like I should be able to combine Ethernet, Mass Storage, and
HID this way.
(and it's supported all the way back to 3.10)
However I haven't found any ffs-daemon examples, including the
hid-daemon mentioned
in the kernel source.

Also I'm not quite sure how the loading g_ffs enables Ethernet in the docs.
Is g_ffs loaded after a g_multi that included Ethernet?

 from Documentation/usb/functionfs.txt
One can imagine a gadget that has an Ethernet, MTP and HID interfaces
where the last two are implemented via FunctionFS. On user space
level it would look like this:

$ insmod g_ffs.ko idVendor=ID iSerialNumber=string functions=mtp,hid
$ mkdir /dev/ffs-mtp  mount -t functionfs mtp /dev/ffs-mtp
$ ( cd /dev/ffs-mtp  mtp-daemon ) 
$ mkdir /dev/ffs-hid  mount -t functionfs hid /dev/ffs-hid
$ ( cd /dev/ffs-hid  hid-daemon ) 


[1] 
http://events.linuxfoundation.org/sites/events/files/slides/LinuxConNA2013-andrzej.pietrasiewicz-usb-gadget-configfs_0.pdf
[2] 
https://wiki.tizen.org/wiki/USB/Linux_USB_Layers/Configfs_Composite_Gadget/Usage_eq._to_g_hid.ko
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: f_hid, f_mass_storage, and f_rdnis via configfs on platform/intel-mid

2015-01-22 Thread Chris McClimans
The devices in embedded space accept kernel updates at various speeds.
The raspberry pi is at 3.18, and the Intel Edison is bit lagging at 3.10.
I thought it would probably be useful to the embedded community if I at
least took a stab at back porting the hid gadgetfs function to 3.18 for use
on the raspberry pi. Going farther back with more modules if there is interest.

I searched through the kernel source and I think I've found the definitive
list of gadget functions (grepping for DECLARE_USB_FUNCTION_INIT),
and noted when they were introduced.

3.19 midi, hid
3.18 uvc, uac2, uac1
3.14 fs
3.13 mass_storage
3.11 subset, rndis, phonet, ncm, eem, ecm
3.10 serial, obex, acm

I figured this list was probably the best place to ask if there were any
caveats to taking usb/gadget/function/f_hid.c back one kernel rev.

On Tue, Jan 13, 2015 at 11:49 AM, Felipe Balbi ba...@ti.com wrote:
 then you need to backport patches yourself. The community can't really
support older kernels :-)
 I guess you don't have other way but keep in mind you'll, essentially,
be on your own

Any obvious dragons be aware of before I head out on my own?

Is there a better list to or talk/discuss backporting of usb gadget functions?
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


f_hid, f_mass_storage, and f_rdnis via configfs on platform/intel-mid

2015-01-13 Thread Chris McClimans
Thanks for all the direction and feedback thus far, configfs is the
way to go but I would need f_hid, f_mass_storage, and f_rdnis which
aren't available in v3.10. Configfs f_hid is relatively recent,
f_rndis + f_mass_storage where merged into v3.11, but similar
functions actual entered the kernel in v3.10... which is what gives me
hope that the porting may be simple.

Porting the platform/intel-mid forward to a new kernel version without
communication from Intel would probably result in needless duplication
of effort. Would it be advisable for me to backport the
drivers/usb/gadget/function/* from 3.19-rc1 and compile them in
3.10.17? I doubt it would be as simple as copying them over and
modifying the Makefile, but one can hope.

https://lkml.org/lkml/2014/12/14/274 -  v3.19-rc1 for f_hid

https://lkml.org/lkml/2013/7/1/388 - v3.11-rc1 for f_rndis and f_mass_storage

https://lkml.org/lkml/2013/4/29/248 - v3.10-rc1 for f_acm (which seems
to load and configure **)

**root@edison-3.10.17:/# cat
/sys/kernel/config/usb_gadget/gadget/functions/acm.usb0/port_num
0
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Is g_multi with g_hid possible?

2015-01-13 Thread Chris McClimans
Is it possible to appear as a USB gadget hid (kb + mouse),
mass_storage, and ethernet at the same time?

My goal is to try and create a device that when attached during boot
to a PC would be able to send keys as a hid keyboard to select booting
from a USB mass storage.

Booting from the mass storage would then load ipxe and perform dhcp
over the USB RDNIS device. The nic would probably be bridged to wifi,
or at least connected to some type of boot control process.

It has been necessary to unload g_multi in order to load g_hid on the
Edison on 3.10.17 so far and wanted to make sure the end goal was
possible at all.

Cheers,
chris
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: USB HID Gadget Support for Intel Edison

2015-01-12 Thread Chris McClimans
The upstream sources for platform/intel-mid aren't in any public git
repos and are distributed
as a tarball. I  have been unable to find any platform/intel-mid
specific mailing lists, so
I created my own repos and tickets to track my progress. I haven't
done much work in the
kernel, but I'm trying to learn. If there are more appropriate or
effective ways to approach Intel,
the Linux (usb) community, or a solution... please let me know. :)

On Fri, Jan 9, 2015 at 1:16 AM, Andrzej Pietrasiewicz
andrze...@samsung.com wrote:
 In the very same file there is an example platform driver; well, at least
 the most important hid-specific parts of it. You must add the usual
 module boilerplate code and in module's init do platform_device_register(),
 while in module's exit do platform_device_unregister().

This ticket tracks my progress as I attempt to understand what parts
of platform/intel-mid to edit.
https://github.com/instantinfrastructure/edison-src/issues/1
I'm currently trying to figure out what all the *_init functions do
hoping I can find where to place the module boilerplate
platform_device_[un]register functions.
I found some references to folks just adding directly to
drivers/usb/gadget/hid.c
https://github.com/instantinfrastructure/linux-yocto-3.10/commit/4a7c648b3d0cf96ccaf6b6fd133577293984ca45
but I still get errors:

# modprobe g_hid
[11677.348746] Device 'hidg.0' does not have a release() function, it
is broken and must be fixed.
modprobe: ERROR: could not insert 'g_hid': No such device

 You might also want to have a look at a configfs-composed gadget

configfs looks awesome! Having just been added to 3.19.0-rc series,
I'm not sure I could get it that kernel to work on the Edison.
There are quite a few differences in platform/intel-mid  in 3.10.17 w/
the intel patches and the vanilla 3.19.0-rc series.
I've tried reaching out to someone from the platform/intel-mid team at
Intel, but have as of yet been unsuccessful.

I also looked at gadgetfs but get failed to start errors:

```
root@edison:~# mkdir /dev/gadget
root@edison:~# rmmod g_multi
root@edison:~# mount -t gadgetfs gadetfs /dev/gadget
[   54.781038] nop dwc3-device.1: failed to start (null): -120
root@edison:~# ls /dev/gadget
dwc3-gadget
root@edison:~# ls /dev/gadget/dwc3-gadget/
ls: /dev/gadget/dwc3-gadget/: Not a directory
root@edison:~# dmesg | tail -10
[   44.184839] g_multi gadget: unbind function 'acm'/f5d7f840
[   44.184862] g_multi gadget: unbind function 'Mass Storage Function'/f5c8c380
[   44.184878] g_multi gadget: unbind
[   44.184947]  lun0: close backing file
[   44.284976] gs_close: ttyGS0 (f5453400,f5e8c300) ...
[   44.285005] gs_close: ttyGS0 (f5453400,f5e8c300) done!
[   44.286415] usb0: stop stats: rx/tx 0/20, errs 0/0
[   54.779953] gadgetfs: USB Gadget filesystem, version 24 Aug 2004
[   54.781010] udc dwc3-device.1: registering UDC driver [(null)]
[   54.781038] nop dwc3-device.1: failed to start (null): -120
root@edison:~# uname -a
Linux edison 3.10.17-poky-edison+ #6 SMP PREEMPT Fri Jan 9 19:27:34
UTC 2015 i686 GNU/Linux
```

= Upstream sources and the resultant repos 
The edison-src build system and platform/intel-mid patch (Yocto derived BSP from
  https://downloadcenter.intel.com/Detail_Desc.aspx?DwnldID=24389)

* https://github.com/instantinfrastructure/edison-src)

The yocto-3.10.17 sources with the patch applied
(https://github.com/instantinfrastructure/edison-src/blob/master/device-software/meta-edison/recipes-kernel/linux/files/upstream_to_edison.patch)

* https://github.com/instantinfrastructure/linux-yocto-3.10
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


USB HID Gadget Support for Intel Edison

2015-01-08 Thread Chris McClimans
I'm trying to get the g_hid module working with the Intel Edison.

I tried just compiling intel's patch(1) to 3.10.17 with
CONFIG_USB_GADGETFS=m CONFIG_USB_G_HID=m but I get an error trying to
load the module:

modprobe: ERROR: could not insert 'g_hid': No such device

According to https://www.kernel.org/doc/Documentation/usb/gadget_hid.txt:

g_hid is a platform driver, so to use it you need to add
 struct platform_device(s) to your platform code defining the
 HID function descriptors you want to use

It's not clear to me what part of the platform code I should be
adding, but I assume it's something under:
https://github.com/instantinfrastructure/linux-yocto-3.10/tree/edison/arch/x86/platform/intel-mid

I have a thread open(2) on the intel community forums, but I figured
going straight to the source would be a good approach.

Thanks heaps,
Chris McClimans
ch...@hippiehacker.org

(1)* 
https://github.com/instantinfrastructure/edison-src/blob/master/device-software/meta-edison/recipes-kernel/linux/files/upstream_to_edison.patch

(2)* https://communities.intel.com/thread/58917?sr=stream
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html