Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752640AbcLLMFv (ORCPT ); Mon, 12 Dec 2016 07:05:51 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:52983 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751544AbcLLMFt (ORCPT ); Mon, 12 Dec 2016 07:05:49 -0500 X-AuditID: cbfee61b-f796f6d000004092-e3-584e929badb8 Subject: Re: [PATCH v2] tools: usb: usbip: Add simple script to show how to setup vUDC To: shuah@kernel.org, gregkh@linuxfoundation.org References: <20161209171515.23491-1-k.opasiak@samsung.com> <0d70962e-4651-7774-b0ad-5c6e54ef164a@kernel.org> Cc: valentina.manea.m@gmail.com, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Shuah Khan From: Krzysztof Opasiak Message-id: Date: Mon, 12 Dec 2016 13:05:41 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-version: 1.0 In-reply-to: <0d70962e-4651-7774-b0ad-5c6e54ef164a@kernel.org> Content-type: text/plain; charset=windows-1252 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrHIsWRmVeSWpSXmKPExsVy+t9jAd3Zk/wiDE428Fo0L17PZnF51xw2 i0XLWpktprxcx24x9csHFot3l+ayO7B57Jx1l91j06pONo/9c9ewe2zpB3I/b5ILYI1ys8lI TUxJLVJIzUvOT8nMS7dVCg1x07VQUshLzE21VYrQ9Q0JUlIoS8wpBfKMDNCAg3OAe7CSvl2C W8bddbfZCmaYV7zvlGhg3K3bxcjJISFgIvH5xWtmCFtM4sK99WxdjFwcQgJLGSXWbelhhHAe Mkrc2HITrEpYIEJixtR+VhBbRMBA4tq6VUwQRYcYJY5s/w7WwSzQwCjxbflKIIeDg01AX2Le LlGQBl4BO4mLOzYygdgsAqoSE89/BbNFgYbeetjBAlEjKPFj8j0wmxOovuXKXbAxzAJ6Evcv aoGEmQXkJTavecs8gVFgFpKOWQhVs5BULWBkXsUokVqQXFCclJ5rlJdarlecmFtcmpeul5yf u4kRHFfPpHcwHt7lfohRgINRiYfXIdU3Qog1say4MhfoLQ5mJRFefmBUCvGmJFZWpRblxxeV 5qQWH2I0BXpjIrOUaHI+MObzSuINTcxNzI0NLMwtLU2MlMR5G2c/CxcSSE8sSc1OTS1ILYLp Y+LglGpgPPT+ZaJfeNCkKYo+G1lWvK4rcL+WF653a+/b55FPKmMkajI9umbf2upqwOfjxrx7 04SCe0v0ql8av86/MWnJcnPnPTE3H77m0xDWKb0n292jpbdhoqqe/NZks2Wzun2yL7y5N3uZ yotY3mj+z9X7fs1YnZ3MeOvc1Ph/cxLMY53jdL/HLN0kqcRSnJFoqMVcVJwIAAJoHsbBAgAA X-MTR: 20000000000000000@CPGS Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6894 Lines: 172 Hi, On 12/09/2016 10:40 PM, Shuah Khan wrote: > Hi Krzysztof, > > Thanks for getting to this so quickly. Couple of comments below: > > On 12/09/2016 10:15 AM, Krzysztof Opasiak wrote: >> Add some simple script which creates a USB gadget using ConfigFS >> and then exports it using vUDC. >> >> This may be useful for people who just started playing with >> USB/IP and vUDC as it shows exact steps how to setup all stuff. >> >> Signed-off-by: Krzysztof Opasiak >> --- >> Changes since v1: >> - Fix terminology mistake (server instead of client) >> --- >> tools/usb/usbip/vudc/vudc_server_example.sh | 100 ++++++++++++++++++++++++++++ >> 1 file changed, 100 insertions(+) >> create mode 100755 tools/usb/usbip/vudc/vudc_server_example.sh > > Looks like it also includes client side, would it make sense to not name is server > and call it vudc_export_example.sh? > This script is intended to be run on a server side not on client or both. It contains only couple of comments with suggestion what you should do on a client side but any of those commands won't be executed as the are all placed inside comments. Moreover, our goal while developing vUDC was to make it compatible with existing USB/IP infrastructure. That's why client side usage is pretty the same for both vUDC and stub driver. >> >> diff --git a/tools/usb/usbip/vudc/vudc_server_example.sh b/tools/usb/usbip/vudc/vudc_server_example.sh >> new file mode 100755 >> index 000000000000..9bd1fd58d592 >> --- /dev/null >> +++ b/tools/usb/usbip/vudc/vudc_server_example.sh >> @@ -0,0 +1,100 @@ >> +#!/bin/bash >> + >> +################################################################################ >> +# This is free and unencumbered software released into the public domain. >> +# >> +# Anyone is free to copy, modify, publish, use, compile, sell, or >> +# distribute this software, either in source code form or as a compiled >> +# binary, for any purpose, commercial or non-commercial, and by any >> +# means. >> +# >> +# In jurisdictions that recognize copyright laws, the author or authors >> +# of this software dedicate any and all copyright interest in the >> +# software to the public domain. We make this dedication for the benefit >> +# of the public at large and to the detriment of our heirs and >> +# successors. We intend this dedication to be an overt act of >> +# relinquishment in perpetuity of all present and future rights to this >> +# software under copyright law. >> +# >> +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, >> +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF >> +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. >> +# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR >> +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, >> +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR >> +# OTHER DEALINGS IN THE SOFTWARE. >> +# >> +# For more information, please refer to >> +################################################################################ > > This is the first file under usbip with a different license. Why did you chose > this over GPL that is what is in all oter source files in this module? The reason is very simple. It's just an *example* of vUDC usage, nothing more. There is no new or useful functionality inside this script so I don't see any reason to guard it with GPL license. As far as I'm familiar with this license (please correct me if I'm wrong), it simply allows everyone to use this script as their code base and modify it to fit their needs and put them into products without publishing the code. Which I think may be useful for some people. > > Greg! Do you have any recommendation on this? > >> + >> +################################################################################ >> +# This is a sample script which shows how to use vUDC with ConfigFS gadgets >> +################################################################################ >> + >> +# Stop script on error >> +set -e >> + >> +################################################################################ >> +# Create your USB gadget >> +# You may use bare ConfigFS interface (as below) >> +# or libusbgx or gt toool >> +# Instead of ConfigFS gadgets you may use any of legacy gadgets. >> +################################################################################ >> +CONFIGFS_MOUNT_POINT="/sys/kernel/config" >> +GADGET_NAME="g1" >> +ID_VENDOR="0x1d6b" >> +ID_PRODUCT="0x0104" >> + >> +cd ${CONFIGFS_MOUNT_POINT}/usb_gadget >> +# Create a new USB gadget >> +mkdir ${GADGET_NAME} >> +cd ${GADGET_NAME} >> + >> +# This gadget contains one function - ACM (serial port over USB) >> +FUNC_DIR="functions/acm.ser0" >> +mkdir ${FUNC_DIR} >> + >> +# Just one configuration >> +mkdir configs/c.1 >> +ln -s ${FUNC_DIR} configs/c.1 >> + >> +# Set our gadget identity >> +echo ${ID_VENDOR} > idVendor >> +echo ${ID_PRODUCT} > idProduct >> + >> +################################################################################ >> +# Load vudc-module if vudc is not available >> +# You may change value of num param to get more than one vUDC instance >> +################################################################################ >> +[[ -d /sys/class/udc/usbip-vudc.0 ]] || modprobe usbip-vudc num=1 >> + >> +################################################################################ >> +# Bind gadget to our vUDC >> +# By default we bind to first one but you may change this if you would like >> +# to use more than one instance >> +################################################################################ >> +echo "usbip-vudc.0" > UDC >> + >> +################################################################################ >> +# Let's now run our usbip daemon in a USB device mode >> +################################################################################ >> +usbipd --device & >> + >> +################################################################################ >> +# Now your USB gadget is available using USB/IP protocol. >> +# To check this you may try to list available devices: >> +# >> +# $ usbip list -r $SERVER_IP >> +# Exportable USB devices >> +# ====================== >> +# usbipd: info: request 0x8005(6): complete >> +# - 127.0.0.1 >> +# usbip-vudc.0: Linux Foundation : unknown product (1d6b:0104) >> +# : /sys/devices/platform/usbip-vudc.0 >> +# : (Defined at Interface level) (00/00/00) >> +# >> +# To attach this device to your client you may use: >> +# > > Are you missing > modprobe usbip-vhci > Hmm... true. Usually I just simply build in this module in my test setup and that's why I forgot about it;) I'll add this in next version. Best regards, -- Krzysztof Opasiak Samsung R&D Institute Poland Samsung Electronics