blob: d17b3cc7c833737f9328f3d3583347d42ac9e154 [file] [log] [blame]
Harald Welte63653742019-01-03 16:54:16 +01001#!/bin/bash
2
3GADGET_NAME=osmo-ccid
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
Harald Welte6b2ff3b2020-09-03 10:16:42 +020026echo 0x1d50 > idVendor
27echo 0x615f > idProduct
Harald Welte63653742019-01-03 16:54:16 +010028[ -d strings/0x409 ] || mkdir strings/0x409
29echo 2342 > strings/0x409/serialnumber
30echo "sysmocom GmbH" > strings/0x409/manufacturer
31echo "sysmoOCTSIM" > strings/0x409/product
32
33# create config
34[ -d configs/c.1 ] || mkdir configs/c.1
35[ -d configs/c.1/strings/0x409 ] || mkdir configs/c.1/strings/0x409
36echo "sysmoOCTSIM config" > configs/c.1/strings/0x409/configuration
37
38[ -d functions/ffs.usb0 ] || mkdir functions/ffs.usb0
39[ -e configs/c.1/ffs.usb0 ] || ln -s functions/ffs.usb0 configs/c.1
40
41[ -d /dev/ffs-ccid ] || mkdir /dev/ffs-ccid
42[ -e /dev/ffs-ccid/ep0 ] || mount -t functionfs usb0 /dev/ffs-ccid/
43
44# enable device, only works after program has opened EP FDs
45#echo dummy_udc.0 > UDC
46