~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/usb/usbip/vudc/vudc_server_example.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/bash
  2 
  3 ################################################################################
  4 # This is free and unencumbered software released into the public domain.
  5 #
  6 # Anyone is free to copy, modify, publish, use, compile, sell, or
  7 # distribute this software, either in source code form or as a compiled
  8 # binary, for any purpose, commercial or non-commercial, and by any
  9 # means.
 10 #
 11 # In jurisdictions that recognize copyright laws, the author or authors
 12 # of this software dedicate any and all copyright interest in the
 13 # software to the public domain. We make this dedication for the benefit
 14 # of the public at large and to the detriment of our heirs and
 15 # successors. We intend this dedication to be an overt act of
 16 # relinquishment in perpetuity of all present and future rights to this
 17 # software under copyright law.
 18 #
 19 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 20 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 21 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 22 # IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 23 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 24 # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 25 # OTHER DEALINGS IN THE SOFTWARE.
 26 #
 27 # For more information, please refer to <https://unlicense.org/>
 28 ################################################################################
 29 
 30 ################################################################################
 31 # This is a sample script which shows how to use vUDC with ConfigFS gadgets
 32 ################################################################################
 33 
 34 # Stop script on error
 35 set -e
 36 
 37 ################################################################################
 38 # Create your USB gadget
 39 # You may use bare ConfigFS interface (as below)
 40 # or libusbgx or gt toool
 41 # Instead of ConfigFS gadgets you may use any of legacy gadgets.
 42 ################################################################################
 43 CONFIGFS_MOUNT_POINT="/sys/kernel/config"
 44 GADGET_NAME="g1"
 45 ID_VENDOR="0x1d6b"
 46 ID_PRODUCT="0x0104"
 47 
 48 cd ${CONFIGFS_MOUNT_POINT}/usb_gadget
 49 # Create a new USB gadget
 50 mkdir ${GADGET_NAME}
 51 cd ${GADGET_NAME}
 52 
 53 # This gadget contains one function - ACM (serial port over USB)
 54 FUNC_DIR="functions/acm.ser0"
 55 mkdir ${FUNC_DIR}
 56 
 57 # Just one configuration
 58 mkdir configs/c.1
 59 ln -s ${FUNC_DIR} configs/c.1
 60 
 61 # Set our gadget identity
 62 echo ${ID_VENDOR} > idVendor
 63 echo ${ID_PRODUCT} > idProduct
 64 
 65 ################################################################################
 66 # Load vudc-module if vudc is not available
 67 # You may change value of num param to get more than one vUDC instance
 68 ################################################################################
 69 [[ -d /sys/class/udc/usbip-vudc.0 ]] || modprobe usbip-vudc num=1
 70 
 71 ################################################################################
 72 # Bind gadget to our vUDC
 73 # By default we bind to first one but you may change this if you would like
 74 # to use more than one instance
 75 ################################################################################
 76 echo "usbip-vudc.0" > UDC
 77 
 78 ################################################################################
 79 # Let's now run our usbip daemon in a USB device mode
 80 ################################################################################
 81 usbipd --device &
 82 
 83 ################################################################################
 84 # Now your USB gadget is available using USB/IP protocol.
 85 # To prepare your client, you should ensure that usbip-vhci module is inside
 86 # your kernel. If it's not then you can load it:
 87 #
 88 # $ modprobe usbip-vhci
 89 #
 90 # To check availability of your gadget you may try to list devices exported
 91 # on a remote server:
 92 #
 93 # $ modprobe usbip-vhci
 94 # $ usbip list -r $SERVER_IP
 95 # Exportable USB devices
 96 # ======================
 97 # usbipd: info: request 0x8005(6): complete
 98 #  - 127.0.0.1
 99 # usbip-vudc.0: Linux Foundation : unknown product (1d6b:0104)
100 #            : /sys/devices/platform/usbip-vudc.0
101 #            : (Defined at Interface level) (00/00/00)
102 #
103 # To attach this device to your client you may use:
104 #
105 # $ usbip attach -r $SERVER_IP -d usbip-vudc.0
106 #
107 ################################################################################

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php