From owner-freebsd-usb@freebsd.org Mon Nov 9 08:29:32 2015 Return-Path: Delivered-To: freebsd-usb@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CA984A2614E for ; Mon, 9 Nov 2015 08:29:32 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (heidi.turbocat.net [88.198.202.214]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9248E1C6B for ; Mon, 9 Nov 2015 08:29:32 +0000 (UTC) (envelope-from hps@selasky.org) Received: from laptop015.home.selasky.org (unknown [62.141.129.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id EFFD21FE023; Mon, 9 Nov 2015 09:29:28 +0100 (CET) Subject: Re: usbfs (usbdevfs) in Linux Emulation To: Callum Aitchison , freebsd-usb@freebsd.org References: <7558FEE0-F0EF-440B-98C2-9EE428C352E1@aitchison.org> From: Hans Petter Selasky Message-ID: <564059D0.8000400@selasky.org> Date: Mon, 9 Nov 2015 09:31:12 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <7558FEE0-F0EF-440B-98C2-9EE428C352E1@aitchison.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Nov 2015 08:29:32 -0000 On 11/08/15 17:14, Callum Aitchison wrote: > Hi, > I posted on the forum about this issue and was directed here as a better place to ask. > > My question is about usbfs (AKA usbdevfs) emulation within Linux compatibility - it doesn’t get created in the Linuxulator but some binary Linux software (Altera Quartus) I’m using requires it instead of libusb. > > The system is documented here: https://www.kernel.org/doc/Documentation/usb/proc_usb_info.txt > > I have tried unmounting linprocfs and creating my own /compat/linux/proc directory with bus/usb/devices copied from a Linux machine for the USB device listed and then the device location in bus/usb/002/007 symlinked to the FreeBSD USB device in /dev/ugen0.2. This, unsurprisingly, didn’t work since the Linux nodes are obviously different from the FreeBSD nodes. Worth a try. > > When I tried that dmesg printed the errors: > linux: pid 4640 (jtagd): ioctl fd=6, cmd=0x550f ('U',15) is not implemented > linux: pid 4640 (jtagd): ioctl fd=6, cmd=0x5510 ('U',16) is not implemented > > Looking these up in the Linux headers in linux/usbdevice_fs.h I found: > #define USBDEVFS_CLAIMINTERFACE _IOR('U', 15, unsigned int) > #define USBDEVFS_RELEASEINTERFACE _IOR('U', 16, unsigned int) > > Obviously the software was trying to claim and then release the USB interface but the ioctl must differ between FreeBSD and Linux so it doesn’t work, makes sense. > > Unfortunately I don’t understand the FreeBSD or Linux USB systems enough to work out a solution myself but I hope that there is either a pre-existing solution or a solution that could be worked out. > I thought perhaps a translation layer between the Linux /proc/bus/usb/ and FreeBSD /dev/ugen* but have no idea where to start implementing that myself. > > Hopefully it can be sorted, it’d be nice to have all the USB stuff working in Linux emulation, especially to be able to do my FPGA development entirely in FreeBSD. > Hi, The FreeBSD's /dev/ugenX.Y don't support Linux's USBFS. It might be you can build Linux's USBFS support into /usr/ports/multimedia/webcamd, which already emulate the Linux USB stack in user-space. Latest version of webcamd from SVN: http://www.selasky.org/hans_petter/video4bsd --HPS