Skip to content

Instantly share code, notes, and snippets.

@minlexx
Created May 24, 2024 12:51
Show Gist options
  • Save minlexx/263830186d44fb15fd7f812cf6ce6acf to your computer and use it in GitHub Desktop.
Save minlexx/263830186d44fb15fd7f812cf6ce6acf to your computer and use it in GitHub Desktop.
Setup diag-router FunctionFS gadget on pmOS phone with already configured USB gadget
#!/bin/sh
set -x
G1="/sys/kernel/config/usb_gadget/g1"
# turn off the gadget
UDC_NAME=$( cat $G1/UDC )
echo "" > $G1/UDC
sleep 1
# cleanup prev setup
umount /dev/ffs-diag
rm -rf /dev/ffs-diag
# create FunctionFS function
mkdir -p $G1/functions/ffs.diag
# First config (c1) is already pmOS's USB gadget.
# Use Config #2
C2="$G1/configs/c.2"
mkdir -p $C2
mkdir -p $C2/strings/0x409
echo "diag_dun" > $C2/strings/0x409/configuration
rm -f $C2/ffs.diag
ln -s $G1/functions/ffs.diag $C2
echo "Create/mount /dev/ffs-diag"
mkdir -p /dev/ffs-diag
mount -t functionfs diag /dev/ffs-diag
# turn on the gadget
sleep 1
echo $UDC_NAME > $G1/UDC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment