blob: 3689c9f3bc52f11cc225f240d0b56b32b0542814 [file] [log] [blame]
Harald Weltea7c1eb02019-09-12 15:16:43 +02001#!/bin/bash
2
3GADGET_NAME=osmo-hub
4
5
6
7GADGET_CONFIGFS=/sys/kernel/config/usb_gadget
8
9die() {
10 echo ERROR: $1
11 exit 2
12}
13
14modprobe configfs
15modprobe usb_f_fs
16modprobe dummy_hcd is_high_speed=0 is_super_speed=0
17
18[ -d $GADGET_CONFIGFS ] || die "usb_gadget configfs not mounted"
19
20gadgetdir="$GADGET_CONFIGFS/$GADGET_NAME"
21
22# create gadget
23[ -d $gadgetdir ] || mkdir $gadgetdir || die "Cannot create $gadgetdir. Permission problem?"
24set -e -x
25cd $gadgetdir
26echo 0x2342 > idVendor
27echo 0x4200 > idProduct
28echo 0x09 > bDeviceClass
29echo 1 > bDeviceProtocol
30[ -d strings/0x409 ] || mkdir strings/0x409
31echo 2342 > strings/0x409/serialnumber
32echo "sysmocom GmbH" > strings/0x409/manufacturer
33echo "sysmoHUB" > strings/0x409/product
34
35# create config
36[ -d configs/c.1 ] || mkdir configs/c.1
37[ -d configs/c.1/strings/0x409 ] || mkdir configs/c.1/strings/0x409
38echo "sysmoHUB config" > configs/c.1/strings/0x409/configuration
39
40[ -d functions/ffs.usb0 ] || mkdir functions/ffs.usb0
41[ -e configs/c.1/ffs.usb0 ] || ln -s functions/ffs.usb0 configs/c.1
42
43[ -d /dev/ffs-hub ] || mkdir /dev/ffs-hub
44[ -e /dev/ffs-hub/ep0 ] || mount -t functionfs usb0 /dev/ffs-hub/
45
46# enable device, only works after program has opened EP FDs
47#echo dummy_udc.0 > UDC
48