Add ConfigFS based usb network configuration

This extends the initramfs init script to setup USB networking on kernels
using USB_CONFIGFS.
This commit is contained in:
ryang 2017-07-13 11:17:48 -04:00
parent fbf4ff7c59
commit 0cf22ffebf
2 changed files with 25 additions and 1 deletions

View file

@ -28,7 +28,7 @@ package() {
"$pkgdir/etc/postmarketos-mkinitfs/hooks/"
}
sha512sums="22418d8869448b456a775f03b18d7b4e13f3cac1129233ced42caf67c3aea4abcc6488fcba2acb5e20dd72f2a6da6419938ac44751a5ba175f02eab586573c43 init.sh.in
66f442648fb38529ec594e62ee2307269ca875c7f9340726adcb211e9be42a6ba60fd296af0503a65c7f230c25cf3494783e4282f2468c63116b9500f5d184c6 init_functions.sh
7f72b71efb3d4e4d09b4311c019ee39477bb9dcb1098f0a34d4a5e28d69661fac4ab6eb4d2d4585ce9a4ba6d772173df36686565944d53bd7cc80d87a0b4b551 init_functions.sh
3026c45c14ae6d83e28e322c46b151e962493587d7ea9bdf3acfbf6c859d405800b0e3fcf2b509f06f26d5af625951a1bedff1ed7fda0eeaddcb46dc2d39dc13 mkinitfs.sh
81d001ab185a8db1b9335d7c8c278d49ab0446bc15bb00dd22e4de16633433a183888f3f1096399bfe361ed719dcc4203afdf4b4f10e74a9c1e50bbbfc46951c 10-usb-unlock.sh
35a8eabad947347afec7e3f5860d31ab9e3534972c0960ccf553c7e1cc9262316bfdddb8d61d3588db1ee2261077597617806080b9956798b3e5088d6f9b596b splash1.ppm.gz

View file

@ -25,6 +25,9 @@ mount_proc_sys_dev() {
mount -t proc -o nodev,noexec,nosuid proc /proc
mount -t sysfs -o nodev,noexec,nosuid sysfs /sys
mkdir /config
mount -t configfs -o nodev,noexec,nosuid configfs /config
# /dev/pts (needed for telnet)
mkdir -p /dev/pts
mount -t devpts devpts /dev/pts
@ -102,6 +105,26 @@ setup_usb_network_android() {
printf "%s" "1" >"$SYS/enable"
}
setup_usb_network_configfs() {
CONFIGFS=/config/usb_gadget
[ -e "$CONFIGFS" ] || return
mkdir $CONFIGFS/g1
printf "%s" "18D1" >"$CONFIGFS/g1/idVendor"
printf "%s" "D001" >"$CONFIGFS/g1/idProduct"
mkdir $CONFIGFS/g1/strings/0x409
mkdir $CONFIGFS/g1/functions/rndis.usb0
mkdir $CONFIGFS/g1/configs/c.1
mkdir $CONFIGFS/g1/configs/c.1/strings/0x409
printf "%s" "rndis" > $CONFIGFS/g1/configs/c.1/strings/0x409/configuration
ln -s $CONFIGFS/g1/functions/rndis.usb0 $CONFIGFS/g1/configs/c.1
echo "$(ls /sys/class/udc)" > $CONFIGFS/g1/UDC
}
setup_usb_network() {
# Only run once
_marker="/tmp/_setup_usb_network"
@ -110,6 +133,7 @@ setup_usb_network() {
# Run all usb network setup functions (add more below!)
setup_usb_network_android
setup_usb_network_configfs
}
start_udhcpd() {