change crystal to smd
[hardpass.git] / init_usb.sh
CommitLineData
bc85b807 1#!/bin/bash
2# this file is from: https://github.com/ckuethe/usbarmory/wiki/USB-Gadgets
3echo "creating composite mass-storage, serial, ethernet, hid..."
4modprobe libcomposite
5
6# assumes a disk image exists here...
7FILE=/home/pi/hardpass/usbdisk.img
8mkdir -p ${FILE/img/d}
9mount -o loop,ro,offset=2048 -t vfat $FILE ${FILE/img/d}
10cd /sys/kernel/config/usb_gadget/
11
12mkdir -p g1
13cd g1
14#echo '' > UDC
15
16echo 0x1d6b > idVendor # Linux Foundation
17echo 0x0104 > idProduct # Multifunction Composite Gadget
18echo 0x0100 > bcdDevice # v1.0.0
19echo 0x0200 > bcdUSB # USB2
20
21mkdir -p strings/0x409
22echo "fedcba9876543210" > strings/0x409/serialnumber
23echo "girst" > strings/0x409/manufacturer
24echo "Hardpass" > strings/0x409/product
25
26N="usb0"
27mkdir -p functions/acm.$N
28mkdir -p functions/ecm.$N
29mkdir -p functions/hid.$N
30mkdir -p functions/mass_storage.$N
31
32# first byte of address must be even
33HOST="48:6f:73:74:50:43" # "HostPC"
34SELF="42:61:64:55:53:42" # "BadUSB"
35echo $HOST > functions/ecm.$N/host_addr
36echo $SELF > functions/ecm.$N/dev_addr
37
38echo 1 > functions/mass_storage.$N/stall
39echo 0 > functions/mass_storage.$N/lun.0/cdrom
40echo 0 > functions/mass_storage.$N/lun.0/ro
41echo 0 > functions/mass_storage.$N/lun.0/nofua
42echo $FILE > functions/mass_storage.$N/lun.0/file
43
44echo 1 > functions/hid.usb0/protocol
45echo 1 > functions/hid.usb0/subclass
46echo 8 > functions/hid.usb0/report_length
47echo -ne \\x05\\x01\\x09\\x06\\xa1\\x01\\x05\\x07\\x19\\xe0\\x29\\xe7\\x15\\x00\\x25\\x01\\x75\\x01\\x95\\x08\\x81\\x02\\x95\\x01\\x75\\x08\\x81\\x03\\x95\\x05\\x75\\x01\\x05\\x08\\x19\\x01\\x29\\x05\\x91\\x02\\x95\\x01\\x75\\x03\\x91\\x03\\x95\\x06\\x75\\x08\\x15\\x00\\x25\\x65\\x05\\x07\\x19\\x00\\x29\\x65\\x81\\x00\\xc0 > functions/hid.usb0/report_desc
48
49
50C=1
51mkdir -p configs/c.$C/strings/0x409
52echo "Config $C: ECM network" > configs/c.$C/strings/0x409/configuration
53echo 250 > configs/c.$C/MaxPower
54ln -s functions/acm.$N configs/c.$C/
55ln -s functions/ecm.$N configs/c.$C/
56ln -s functions/mass_storage.$N configs/c.$C/
57ln -s functions/hid.$N configs/c.$C/
58
59# this lists available UDC drivers
60ls /sys/class/udc > UDC
61
62ifconfig $N 10.0.0.1 netmask 255.255.255.252 up
63route add -net default gw 10.0.0.2
64echo "done. "
65#echo "initializing demo menu..."
66#while 1; do
67# /home/pi/hardpass/oled/run.sh
68#done &
69echo "starting shutdown 'daemon'"
70/home/pi/hardpass/shutdown/shutdown-button.sh &
Imprint / Impressum