mirror of
https://github.com/FunKey-Project/FunKey-OS.git
synced 2025-12-16 17:48:51 +01:00
Compare commits
No commits in common. "master" and "FunKey-OS-2.3.0" have entirely different histories.
master
...
FunKey-OS-
@ -120,9 +120,6 @@ CONFIG_USB_ZERO=m
|
|||||||
CONFIG_USB_ETH=m
|
CONFIG_USB_ETH=m
|
||||||
CONFIG_USB_ETH_EEM=y
|
CONFIG_USB_ETH_EEM=y
|
||||||
CONFIG_USB_G_NCM=m
|
CONFIG_USB_G_NCM=m
|
||||||
CONFIG_USB_FUNCTIONFS=m
|
|
||||||
CONFIG_USB_FUNCTIONFS_ETH=y
|
|
||||||
CONFIG_USB_FUNCTIONFS_RNDIS=y
|
|
||||||
CONFIG_USB_MASS_STORAGE=m
|
CONFIG_USB_MASS_STORAGE=m
|
||||||
CONFIG_USB_G_SERIAL=m
|
CONFIG_USB_G_SERIAL=m
|
||||||
CONFIG_USB_G_ACM_MS=m
|
CONFIG_USB_G_ACM_MS=m
|
||||||
|
|||||||
@ -1,154 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
#set -xv
|
|
||||||
|
|
||||||
SELF=${SELF:-$(basename $0)}
|
|
||||||
|
|
||||||
source /usr/local/lib/utils
|
|
||||||
source usb_gadget
|
|
||||||
|
|
||||||
# The composite gadget directory
|
|
||||||
GADGET=/sys/kernel/config/usb_gadget/FunKey
|
|
||||||
|
|
||||||
# USB VID for Intel
|
|
||||||
ID_VENDOR="0x8087"
|
|
||||||
|
|
||||||
# USB PID for Multifunction Composite Gadget
|
|
||||||
ID_PRODUCT="0x011e"
|
|
||||||
|
|
||||||
# Get the CPU serial number
|
|
||||||
SERIAL="$(grep Serial /proc/cpuinfo | sed 's/Serial\s*: \(\w*\)/\1/')"
|
|
||||||
|
|
||||||
# Initialize the ADB
|
|
||||||
init_adb() {
|
|
||||||
|
|
||||||
# Don't proceed if existing gadget is present
|
|
||||||
if [ -e ${GADGET} ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Get the legacy drivers out of the way
|
|
||||||
modprobe -r g_ether
|
|
||||||
modprobe -r g_mass_storage
|
|
||||||
|
|
||||||
# Load the libcomposite USB driver, configfs and various other drivers
|
|
||||||
modprobe libcomposite
|
|
||||||
modprobe usb_f_serial
|
|
||||||
modprobe usb_f_fs
|
|
||||||
modprobe usb_f_acm
|
|
||||||
|
|
||||||
# USB Device Controller Driver
|
|
||||||
local udc_driver=$(ls /sys/class/udc | cut -f1 | head -n 1)
|
|
||||||
|
|
||||||
# Create our gadget directory
|
|
||||||
mkdir ${GADGET}
|
|
||||||
mkdir ${GADGET}/strings/0x409
|
|
||||||
mkdir ${GADGET}/configs/FunKey.1
|
|
||||||
mkdir ${GADGET}/configs/FunKey.1/strings/0x409
|
|
||||||
mkdir ${GADGET}/functions/acm.GS0
|
|
||||||
mkdir ${GADGET}/functions/ffs.adb
|
|
||||||
|
|
||||||
# USB VID and PID
|
|
||||||
echo ${ID_VENDOR} > ${GADGET}/idVendor
|
|
||||||
echo ${ID_PRODUCT} > ${GADGET}/idProduct
|
|
||||||
|
|
||||||
# Device String Descriptiors
|
|
||||||
echo "Intel" > ${GADGET}/strings/0x409/manufacturer
|
|
||||||
echo "FunKey S" > ${GADGET}/strings/0x409/product
|
|
||||||
echo ${SERIAL} > ${GADGET}/strings/0x409/serialnumber
|
|
||||||
|
|
||||||
# Configuration
|
|
||||||
|
|
||||||
# Maximum power is 120 mA
|
|
||||||
echo 120 > ${GADGET}/configs/FunKey.1/MaxPower
|
|
||||||
|
|
||||||
# Configuration String Descriptors
|
|
||||||
echo "ADB+CDC" > ${GADGET}/configs/FunKey.1/strings/0x409/configuration
|
|
||||||
|
|
||||||
# Add the ACM function to the FunKey.1 configuration
|
|
||||||
ln -s ${GADGET}/functions/acm.GS0 ${GADGET}/configs/FunKey.1
|
|
||||||
|
|
||||||
# Add the FunctionFS function to the FunKey.1 configuration
|
|
||||||
ln -s ${GADGET}/functions/ffs.adb ${GADGET}/configs/FunKey.1
|
|
||||||
|
|
||||||
# Create the function filesystem
|
|
||||||
mkdir /dev/usb-ffs
|
|
||||||
mkdir /dev/usb-ffs/adb
|
|
||||||
|
|
||||||
# Mount the ADB function filesystem
|
|
||||||
mount -t functionfs adb /dev/usb-ffs/adb
|
|
||||||
|
|
||||||
# Bring up the loopback network
|
|
||||||
ifup lo
|
|
||||||
|
|
||||||
# Launch the ADB daemon
|
|
||||||
adbd >/dev/null &
|
|
||||||
|
|
||||||
# Sleeping is required to wait for the UDC to come up
|
|
||||||
sleep 5
|
|
||||||
|
|
||||||
# Bind the USB Gadget
|
|
||||||
echo ${udc_driver} > ${GADGET}/UDC
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# Deinitialize the ADB
|
|
||||||
deinit_adb() {
|
|
||||||
|
|
||||||
# Unbind the device
|
|
||||||
echo > ${GADGET}/UDC
|
|
||||||
|
|
||||||
# Kill the ADB daemon
|
|
||||||
killall adbd
|
|
||||||
|
|
||||||
# Bring down the local network
|
|
||||||
ifdown lo
|
|
||||||
|
|
||||||
# Unmount the ADB function filesystem
|
|
||||||
umount /dev/usb-ffs/adb
|
|
||||||
|
|
||||||
# Delete the function filesystem
|
|
||||||
rmdir /dev/usb-ffs/adb
|
|
||||||
rmdir /dev/usb-ffs
|
|
||||||
|
|
||||||
# Remove functions from configurations
|
|
||||||
rm ${GADGET}/configs/FunKey.1/acm.GS0
|
|
||||||
rm ${GADGET}/configs/FunKey.1/ffs.adb
|
|
||||||
|
|
||||||
# Remove string directories in configurations
|
|
||||||
rmdir ${GADGET}/configs/FunKey.1/strings/0x409
|
|
||||||
|
|
||||||
# Remove configurations
|
|
||||||
rmdir ${GADGET}/configs/FunKey.1
|
|
||||||
|
|
||||||
# Remove functions
|
|
||||||
rmdir ${GADGET}/functions/acm.GS0
|
|
||||||
rmdir ${GADGET}/functions/ffs.adb
|
|
||||||
|
|
||||||
# Remove strings
|
|
||||||
rmdir ${GADGET}/strings/0x409
|
|
||||||
|
|
||||||
# Finallyy remove the gadget
|
|
||||||
rmdir ${GADGET}
|
|
||||||
|
|
||||||
# Unload the kernel modules
|
|
||||||
modprobe -r usb_f_serial usb_f_fs usb_f_acm
|
|
||||||
}
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
|
|
||||||
start)
|
|
||||||
deinit_usb_gadget
|
|
||||||
init_adb
|
|
||||||
;;
|
|
||||||
|
|
||||||
stop)
|
|
||||||
deinit_adb
|
|
||||||
init_usb_gadget
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
die 15 "Usage $0 {start|stop}"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
exit $?
|
|
||||||
@ -6,17 +6,13 @@ SELF=${SELF:-$(basename $0)}
|
|||||||
|
|
||||||
source /usr/local/lib/utils
|
source /usr/local/lib/utils
|
||||||
|
|
||||||
# The composite gadget directory
|
# The composite gadget directory
|
||||||
GADGET=/sys/kernel/config/usb_gadget/FunKey
|
GADGET=/sys/kernel/config/usb_gadget/FunKey
|
||||||
|
|
||||||
# Check if Ethernet over USB network is requested
|
# Check if Ethernet over USB network is requested
|
||||||
[ ! -f /mnt/usbnet ]
|
[ ! -f /mnt/usbnet ]
|
||||||
USBNET=${?}
|
USBNET=${?}
|
||||||
|
|
||||||
# Check if Android Debug Bridge is requested
|
|
||||||
[ ! -f /mnt/adb ]
|
|
||||||
ADB=${?}
|
|
||||||
|
|
||||||
# USB VID for Linux Foundation
|
# USB VID for Linux Foundation
|
||||||
ID_VENDOR="0x1d6b"
|
ID_VENDOR="0x1d6b"
|
||||||
|
|
||||||
@ -41,12 +37,6 @@ init_usb_gadget() {
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ADB has precedence over USB Mass Storage / Ethernet over USB
|
|
||||||
if [ ${ADB} -eq 1 ]; then
|
|
||||||
adb start
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Get the legacy drivers out of the way
|
# Get the legacy drivers out of the way
|
||||||
modprobe -r g_ether
|
modprobe -r g_ether
|
||||||
modprobe -r g_mass_storage
|
modprobe -r g_mass_storage
|
||||||
@ -177,48 +167,3 @@ init_usb_gadget() {
|
|||||||
echo ${udc_driver} > ${GADGET}/UDC
|
echo ${udc_driver} > ${GADGET}/UDC
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Deinitialize the USB gadget
|
|
||||||
deinit_usb_gadget() {
|
|
||||||
|
|
||||||
# Unbind the device
|
|
||||||
echo > ${GADGET}/UDC
|
|
||||||
|
|
||||||
# Remove functions from configurations
|
|
||||||
rm ${GADGET}/configs/FunKey.1/mass_storage.mmcblk0p4
|
|
||||||
if [ ${USBNET} -eq 1 ]; then
|
|
||||||
rm ${GADGET}/configs/FunKey.1/rndis.usb0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Remove string directories in configurations
|
|
||||||
rmdir ${GADGET}/configs/FunKey.1/strings/0x409
|
|
||||||
|
|
||||||
# Remove configurations from OS descriptors
|
|
||||||
if [ ${USBNET} -eq 1 ]; then
|
|
||||||
rm ${GADGET}/os_desc/FunKey.1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Remove configurations
|
|
||||||
rmdir ${GADGET}/configs/FunKey.1
|
|
||||||
|
|
||||||
# Remove extended properties from OS descriptors
|
|
||||||
if [ ${USBNET} -eq 1 ]; then
|
|
||||||
rmdir ${GADGET}/functions/rndis.usb0/os_desc/interface.rndis/Icons
|
|
||||||
rmdir ${GADGET}/functions/rndis.usb0/os_desc/interface.rndis/Label
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Remove functions
|
|
||||||
rmdir ${GADGET}/functions/mass_storage.mmcblk0p4
|
|
||||||
if [ ${USBNET} -eq 1 ]; then
|
|
||||||
rmdir ${GADGET}/functions/rndis.usb0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Remove strings
|
|
||||||
rmdir ${GADGET}/strings/0x409
|
|
||||||
|
|
||||||
# Finallyy remove the gadget
|
|
||||||
rmdir ${GADGET}
|
|
||||||
|
|
||||||
# Unload the kernel modules
|
|
||||||
modprobe -r usb_f_mass_storage usb_f_rndis
|
|
||||||
}
|
|
||||||
|
|||||||
Binary file not shown.
@ -97,7 +97,6 @@ BR2_PACKAGE_FMT=y
|
|||||||
BR2_PACKAGE_ICU=y
|
BR2_PACKAGE_ICU=y
|
||||||
BR2_PACKAGE_DHCPCD=y
|
BR2_PACKAGE_DHCPCD=y
|
||||||
BR2_PACKAGE_DROPBEAR=y
|
BR2_PACKAGE_DROPBEAR=y
|
||||||
BR2_PACKAGE_ANDROID_TOOLS=y
|
|
||||||
BR2_PACKAGE_PROCPS_NG=y
|
BR2_PACKAGE_PROCPS_NG=y
|
||||||
BR2_PACKAGE_SWUPDATE=y
|
BR2_PACKAGE_SWUPDATE=y
|
||||||
BR2_PACKAGE_SWUPDATE_CONFIG="$(BR2_EXTERNAL_FUNKEY_PATH)/board/funkey/swupdate.config"
|
BR2_PACKAGE_SWUPDATE_CONFIG="$(BR2_EXTERNAL_FUNKEY_PATH)/board/funkey/swupdate.config"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user