0
0
mirror of https://github.com/libretro/Lakka-LibreELEC.git synced 2024-12-16 05:38:51 +00:00
GavinDarkglider 1c3e314011
Lakka-v4.x:Switch: More fixes/workarounds (#1807)
* Switch: Initial kernel cleanup

* Switch: Mariko: Attempt to fix gadget attach to UDC issue

* Switch: Cleanup initramfs and copy XUSB firmware for mariko to initramfs

* Retroarch: Add Switch lite Controller Workaround to pre-start script

* Switch: bootloader: Fix R2P syntax issue with new driver

* L4T: Fix get_l4t-kernel-sources script sha256 checks
This is far from the finished version, but it should fix kernel nightly issues

* L4T: Switch: update config/script packages versions for nightly

* L4T:Switch:Bootloader: Small cleanups, and add hekate icon for LibreELEC
2023-01-22 00:18:58 +01:00

63 lines
2.2 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="700d0000.xudc"
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/
}
if [ "$1" = "init" ]; then
create_gadget_framework
create_ffs_mtp
create_serial
elif [ "$1" = "finalize" ]; then
systemctl start umtp-responder
sleep 1 #Wait for umtp-responder to start
echo $udc > $gadget_config/usb_gadget/g/UDC
cat $gadget_config/usb_gadget/g/UDC
udevadm settle -t 5 || :
systemctl start usb-tty
elif [ "$1" = "disconnect" ]; then
systemctl start usb-tty
echo "" > $gadget_config/usb_gadget/g/UDC
udevadm settle -t 5 || :
systemctl stop umtp-responder
fi