mirror of
https://github.com/libretro/Lakka-LibreELEC.git
synced 2024-11-28 08:34:37 +00:00
4f8d2a57e9
* Initial fully buildable/bootable Odin Support * Rework NX-Boot to FAT32 Boot for shared usage between switch and odin * Move shared packages from switch/odin to main packages folder
65 lines
2.1 KiB
Bash
65 lines
2.1 KiB
Bash
#!/bin/bash
|
|
|
|
manufacturer="Nintendo"
|
|
product="Switch(@DISTRO@)"
|
|
#vid/pid defaults if not ran as attackmode.... Defaults are default for linux
|
|
vid_default="0x057e" #Nintendo Co.
|
|
pid_default="0x2000" #Switch
|
|
serialnumber="00000001"
|
|
|
|
gadget_config="/sys/kernel/config"
|
|
udc=$(ls /sys/class/udc | head -1 )
|
|
|
|
if [ "${udc}" = "" ]; then
|
|
exit 1
|
|
fi
|
|
|
|
create_gadget_framework() {
|
|
#create basic gadget framework to work with
|
|
mkdir -p $gadget_config
|
|
mount -t configfs none $gadget_config
|
|
mkdir -p $gadget_config/usb_gadget/g
|
|
chmod -R 666 $gadget_config/usb_gadget/g
|
|
echo $vid_default > $gadget_config/usb_gadget/g/idVendor
|
|
echo $pid_default > $gadget_config/usb_gadget/g/idProduct
|
|
echo 0x0100 > $gadget_config/usb_gadget/g/bcdDevice # v1.0.0
|
|
echo 0x0200 > $gadget_config/usb_gadget/g/bcdUSB # USB 2.0
|
|
mkdir -p $gadget_config/usb_gadget/g/strings/0x409
|
|
echo $serialnumber > $gadget_config/usb_gadget/g/strings/0x409/serialnumber
|
|
echo $manufacturer > $gadget_config/usb_gadget/g/strings/0x409/manufacturer
|
|
echo $product > $gadget_config/usb_gadget/g/strings/0x409/product
|
|
echo 0xEF > $gadget_config/usb_gadget/g/bDeviceClass
|
|
echo 0x02 > $gadget_config/usb_gadget/g/bDeviceSubClass
|
|
echo 0x01 > $gadget_config/usb_gadget/g/bDeviceProtocol
|
|
mkdir -p $gadget_config/usb_gadget/g/configs/c.1
|
|
echo 32 > $gadget_config/usb_gadget/g/configs/c.1/MaxPower
|
|
}
|
|
|
|
create_ffs_mtp() {
|
|
mkdir -p $gadget_config/usb_gadget/g/functions/ffs.mtp
|
|
ln -s $gadget_config/usb_gadget/g/functions/ffs.mtp $gadget_config/usb_gadget/g/configs/c.1/
|
|
mkdir -p /dev/ffs-umtp
|
|
mount mtp /dev/ffs-umtp -t functionfs
|
|
}
|
|
|
|
create_serial() {
|
|
mkdir -p $gadget_config/usb_gadget/g/functions/acm.usb0
|
|
ln -s $gadget_config/usb_gadget/g/functions/acm.usb0 $gadget_config/usb_gadget/g/configs/c.1/
|
|
}
|
|
|
|
finalize_gadget_framework() {
|
|
echo $udc > $gadget_config/usb_gadget/g/UDC
|
|
udevadm settle -t 5 || :
|
|
}
|
|
|
|
if [ "$1" = "init" ]; then
|
|
create_gadget_framework
|
|
#create_ffs_mtp
|
|
create_serial
|
|
elif [ "$1" = "finalize" ]; then
|
|
while [ ! "$(cat $gadget_config/usb_gadget/g/UDC)" = "$udc" ]
|
|
do
|
|
finalize_gadget_framework
|
|
done
|
|
fi
|