From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754080AbcLIRID (ORCPT ); Fri, 9 Dec 2016 12:08:03 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:50275 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750827AbcLIRIB (ORCPT ); Fri, 9 Dec 2016 12:08:01 -0500 X-AuditID: cbfee61b-f796f6d000004092-4c-584ae4ee4a0c From: Krzysztof Opasiak To: shuah@kernel.org Cc: valentina.manea.m@gmail.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Krzysztof Opasiak Subject: [PATCH] tools: usb: usbip: Add simple script to show how to setup vUDC Date: Fri, 09 Dec 2016 18:07:33 +0100 Message-id: <20161209170733.23332-1-k.opasiak@samsung.com> X-Mailer: git-send-email 2.9.3 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrHLMWRmVeSWpSXmKPExsVy+t9jAd13T7wiDPbtMbJoXryezeL2xGls Fpd3zWGzWLSsldliyst17BbvLs1ld2Dz2DnrLrvHplWdbB77565h9+jbsorR4/MmuQDWKDeb jNTElNQihdS85PyUzLx0W6XQEDddCyWFvMTcVFulCF3fkCAlhbLEnFIgz8gADTg4B7gHK+nb JbhlvH/cz1SwXL3iX+cxlgbGnYpdjJwcEgImEide7GeFsMUkLtxbz9bFyMUhJLCUUeL0yS+M EM4vRokFTbeZuhg5ONgE9CXm7RIFaRAREJF4P3s2C0gNs8BiRone40/ZQGqEBfwl9i6xAzFZ BFQl/n72BCnnFbCSeDXnDtQuOYlL274wT2DkXsDIsIpRIrUguaA4KT3XKC+1XK84Mbe4NC9d Lzk/dxMjOCyfSe9gPLzL/RCjAAejEg/vjCNeEUKsiWXFlbmHGCU4mJVEePkeA4V4UxIrq1KL 8uOLSnNSiw8xmgLtn8gsJZqcD4yZvJJ4QxNzE3NjAwtzS0sTIyVx3sbZz8KFBNITS1KzU1ML Uotg+pg4OKUaGAvsZ82d2iDxhv+5sJSNFbvUMk81K6+448kXAt7Vn87Z+CxbIflU3OxP7UJn tf8yH70n0tBWsWPqJFnvmI9OhpyFrN1b5nD9b00/lncrs2YWo4UtW1T9rJP+d0LlGtzrrrRz HdE/nW36SrSqe91GrdULb7XOcOMNlorIurgnivtiwELh/UualViKMxINtZiLihMBF1cjfGEC AAA= X-MTR: 20000000000000000@CPGS Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 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..59c5130f85b3 --- /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 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 server you may use: +# +# $ usbip attach -r $SERVER_IP -d usbip-vudc.0 +# +################################################################################ -- 2.9.3