main/postmarketos-mkinitfs: use NCM instead of RNDIS (MR 3670)

As described in [0] let's switch away from RNDIS and use NCM instead.

Since we cannot force all kernels to switch at the same time, let's keep
a fallback to RNDIS in the setup function.

We can also remove usb_f_rndis from modprobe as the module gets loaded
automatically when needed, but instead we need to load libcomposite
manually so that $configfs/usb_gadget gets created.

[0] https://gitlab.com/postmarketOS/pmaports/-/issues/1797

[ci:skip-build] already built successfully in CI
This commit is contained in:
Luca Weiss 2022-11-26 22:49:58 +01:00 committed by Clayton Craft
parent 2df9debe71
commit 2a4320e16e
No known key found for this signature in database
GPG Key ID: 4A4CED6D7EDF950A
4 changed files with 17 additions and 8 deletions

View File

@ -16,5 +16,6 @@ nls_cp437
nls_iso8859_1
nls_utf8
usb_f_rndis
usb_f_ncm
vfat
xts

View File

@ -1,7 +1,7 @@
# Maintainer: Oliver Smith <ollieparanoid@postmarketos.org>
# Co-Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=postmarketos-initramfs
pkgver=2.2.0
pkgver=2.3.0
pkgrel=0
pkgdesc="Base files for the postmarketOS initramfs / initramfs-extra"
url="https://postmarketos.org"
@ -75,12 +75,12 @@ package() {
}
sha512sums="
bed319179bcd0b894d6267c7e73f2890db07bc07df71542936947dfb3bdb17fade8a7b4e7b577f278af4472464427bba07f75aff0a1e454a4167052c088f3b6a 00-default.modules
0f8e57dd6e5169ffc3579d85ee64447d0f89b727db05bd72d31457fd40268aad672ce650b860c3a9e25be4b0705d49101e1df7346b08bd477b6b285710a4b7d1 00-default.modules
5b364300f31c91fd0591eb0715f67cbf5383f45246a5fb9f34b79f7cb2e3b15768b2130e5f32f816cc169950f988c1beabc879ba31645c58ce131a288dbc071d 00-initramfs-base.dirs
ab41b45b0613f25a61114ed8c8b92bc53c60838f6e2e0ba18c76e5369b2984e6023a0661887692673aca3f647f268c468a468f6b1ac424cfee609017a89481dd 00-initramfs-base.files
8a4adad3785af474b36a09a05f6a3b2c4b4f43aac331a53b903abfa51ea12be1e3d1d807b7a6e66a1346815f3b0044daf8cd62e21e2dc75d2db13ee265a72985 00-initramfs-extra-base.files
f2dc71d88964a8c2e8cd2f84965184ef7eb9e28899df2c2621a590463a37216ca8550a5109d96d067c0a40c766f96fc76eea38f386b0948c2e93817dd2ef39b6 init.sh
b4de411bb1e3f610b2d75f8c1e0f753e4550e615bee344b3531d357be77faef6e54ad22b507debec2c7db9930eaa4f9ea3d5f3a131d222480d360933c93ae723 init_functions.sh
701b6252a536dfc7bddef0f5c3ccb16ad680f70efbad872b74d61ef24c98edcf623b19b5e1a2973bc3fa66ca009a515d7ba3563f0d417306a0a2b5680bee7efd init.sh
74cfd8e30811bcf3bb075bcc4db0b59c4f63ba83552cfe371132dacd4c41d73c04c65d309609578369243e9b969feba56b4bdd478eb5e7ebff7099e84f7c0f01 init_functions.sh
ba3275a9af788c7c782322a22a0f144d5e50e3498ea6886486a29331f23ae89cd32d500a3635cfa7cab369afba92edc18aeca64ccbf0cd589061cce23d15b46c unudhcpd.conf
675e7d5bee39b2df7d322117f8dcaccc274d61beaf4d50ead19bbf2109446d64b1c0aa0c5b4f9846eb6c1c403418f28f6364eff4537ba41120fbfcbc484b7da7 mdev.conf
"

View File

@ -25,7 +25,7 @@ setup_firmware_path
if [ "$IN_CI" = "false" ]; then
# shellcheck disable=SC2154
load_modules /lib/modules/initramfs.load "usb_f_rndis"
load_modules /lib/modules/initramfs.load "libcomposite"
setup_framebuffer
show_splash "Loading..."
setup_mdev

View File

@ -591,7 +591,8 @@ setup_usb_network_configfs() {
usb_idVendor="${deviceinfo_usb_idVendor:-0x18D1}" # default: Google Inc.
usb_idProduct="${deviceinfo_usb_idProduct:-0xD001}" # default: Nexus 4 (fastboot)
usb_serialnumber="${deviceinfo_usb_serialnumber:-postmarketOS}"
usb_network_function="${deviceinfo_usb_network_function:-rndis.usb0}"
usb_network_function="${deviceinfo_usb_network_function:-ncm.usb0}"
usb_network_function_fallback="rndis.usb0"
echo " Setting up an USB gadget through configfs"
# Create an usb gadet configuration
@ -609,8 +610,15 @@ setup_usb_network_configfs() {
echo "$deviceinfo_name" > "$CONFIGFS/g1/strings/0x409/product"
# Create network function.
mkdir $CONFIGFS/g1/functions/"$usb_network_function" \
|| echo " Couldn't create $CONFIGFS/g1/functions/$usb_network_function"
if ! mkdir $CONFIGFS/g1/functions/"$usb_network_function"; then
echo " Couldn't create $CONFIGFS/g1/functions/$usb_network_function"
# Try the fallback function next
if mkdir $CONFIGFS/g1/functions/"$usb_network_function_fallback"; then
usb_network_function="$usb_network_function_fallback"
else
echo " Couldn't create $CONFIGFS/g1/functions/$usb_network_function_fallback"
fi
fi
# Create configuration instance for the gadget
mkdir $CONFIGFS/g1/configs/c.1 \