Skip to content

Commit

Permalink
Merge pull request #17 from arrase/improve_scripts
Browse files Browse the repository at this point in the history
Improve scripts
  • Loading branch information
arrase authored Apr 22, 2017
2 parents a239c39 + de8cb1d commit 20d20dc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
4 changes: 2 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ grep bluetoothd\ --compat /lib/systemd/system/bluetooth.service || sudo sed 's/b
[ -d $ETC_DIR/keyboard_layouts ] || sudo cp -r etc/raspiducky/keyboard_layouts $ETC_DIR/keyboard_layouts
[ -d $ETC_DIR/onboot_payload ] || sudo mkdir $ETC_DIR/onboot_payload

echo "$CONFIG_DISK $ETC_DIR vfat loop,rw 0 2" | sudo tee --append /etc/fstab
sudo cp $ETC_DIR/keyboard_layouts/db/QWERTY-ES_es.py $ETC_DIR/keyboard_layouts/current.py
grep $CONFIG_DISK /etc/fstab || (echo "$CONFIG_DISK $ETC_DIR vfat loop,rw 0 2" | sudo tee --append /etc/fstab)
[ -f $ETC_DIR/keyboard_layouts/current.py ] || sudo cp $ETC_DIR/keyboard_layouts/db/QWERTY-ES_es.py $ETC_DIR/keyboard_layouts/current.py

# BOOT CONFIG
grep "dtoverlay=dwc2" /boot/config.txt || (echo "dtoverlay=dwc2" | sudo tee --append /boot/config.txt)
Expand Down
37 changes: 21 additions & 16 deletions scripts/hid.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,57 @@

. /etc/raspiducky/raspiducky.conf

N="usb0"
C=1
D="raspiducky"

cd /sys/kernel/config/usb_gadget/
mkdir -p g1
cd g1
mkdir -p $D
cd $D

echo 0x1d6b > idVendor # Linux Foundation
echo 0x0104 > idProduct # Multifunction Composite Gadget
echo 0x0100 > bcdDevice # v1.0.0
echo 0x0200 > bcdUSB # USB2

mkdir -p strings/0x409
echo "fedcba9876543210" > strings/0x409/serialnumber
echo "Parasite Team" > strings/0x409/manufacturer
echo "Raspiducky" > strings/0x409/product
N="usb0"

mkdir -p configs/c.$C/strings/0x409
echo "Config $C: ECM network" > configs/c.$C/strings/0x409/configuration
echo 250 > configs/c.$C/MaxPower

# KEYBOARD
mkdir -p functions/hid.$N
echo 1 > functions/hid.usb0/protocol
echo 1 > functions/hid.usb0/subclass
echo 8 > functions/hid.usb0/report_length
echo -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
C=1
mkdir -p configs/c.$C/strings/0x409
echo "Config $C: ECM network" > configs/c.$C/strings/0x409/configuration
echo 250 > configs/c.$C/MaxPower
ln -s functions/hid.$N configs/c.$C/
# End KEYBOARD

# STORAGE
if [ $STORAGE_MODE != "none" ]
then
mkdir -p functions/mass_storage.usb0
echo 1 > functions/mass_storage.usb0/stall
echo 0 > functions/mass_storage.usb0/lun.0/removable
echo 0 > functions/mass_storage.usb0/lun.0/cdrom
echo 0 > functions/mass_storage.usb0/lun.0/ro
echo 0 > functions/mass_storage.usb0/lun.0/nofua
mkdir -p functions/mass_storage.$N
echo 1 > functions/mass_storage.$N/stall
echo 0 > functions/mass_storage.$N/lun.0/removable
echo 0 > functions/mass_storage.$N/lun.0/cdrom
echo 0 > functions/mass_storage.$N/lun.0/ro
echo 0 > functions/mass_storage.$N/lun.0/nofua

if [ $STORAGE_MODE = "disk" ]
then
[ -d $STORAGE_MOUNT ] || mkdir $STORAGE_MOUNT
mount -o loop,rw -t vfat $STORAGE_FILE $STORAGE_MOUNT
echo $STORAGE_FILE > functions/mass_storage.usb0/lun.0/file
echo $STORAGE_FILE > functions/mass_storage.$N/lun.0/file
else
echo $CONFIG_DISK > functions/mass_storage.usb0/lun.0/file
echo $CONFIG_DISK > functions/mass_storage.$N/lun.0/file
fi

ln -s functions/mass_storage.usb0 configs/c.$C/
ln -s functions/mass_storage.$N configs/c.$C/
fi
# End STORAGE

Expand Down

0 comments on commit 20d20dc

Please sign in to comment.