Thanks, but that is not an option at this point.
It looks like linux 4.14 changed to use configfs for the usb_gadget,
/home/mango/m21/swi-linux-src/meta-swi-wp/meta-swi-wp/recipes-bsp/system-core/files/composition-sierra_dev
#!/bin/sh
Copyright (c) 2013, The Linux Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of The Linux Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE DISCLAIMED. IN NO
EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
DESCRIPTION: DIAG+ADB+ECM
configure_android_gadget()
{
local gadget_fs=/sys/class/android_usb/android${num}
#echo $mode > /sys/bus/platform/devices/usb_bam/enable
echo 0 > ${gadget_fs}/enable
echo $vid > ${gadget_fs}/idVendor
echo $pid > ${gadget_fs}/idProduct
echo $devclass > ${gadget_fs}/bDeviceClass
echo $devsubclass > ${gadget_fs}/bDeviceSubClass
echo $devprotocol > ${gadget_fs}/bDeviceProtocol
echo $diagstr > ${gadget_fs}/f_diag/clients
echo $serialstr > ${gadget_fs}/f_serial/transports
echo QTI,BAM_DMUX > ${gadget_fs}/f_rmnet/transports
echo BAM_DMUX > ${gadget_fs}/f_usb_mbim/mbim_transports
echo $compstr > ${gadget_fs}/functions
echo $remotewakeup > ${gadget_fs}/remote_wakeup
echo $manufacturer > ${gadget_fs}/iManufacturer
echo $product > ${gadget_fs}/iProduct
echo $serial > ${gadget_fs}/iSerial
compstr=`grep -w ffs ${gadget_fs}/functions || true`
if [[ $mode = "hsusb" && ! -z "$compstr" && -d ${gadget_fs}/f_ffs ]] ; then
echo adb > ${gadget_fs}/f_ffs/aliases
fi
echo 1 > ${gadget_fs}/enable
}
configure_configfs_gadget()
{
local configfs_home=/sys/kernel/config/usb_gadget
local gadget_home=${configfs_home}/g$((num+1))
local strings_home=${gadget_home}/strings/0x409
local config_home=${gadget_home}/configs/c.$((num+1))
local cstring_home=${config_home}/strings/0x409
local gdev=ls -1 /sys/class/udc/
local supported=" serial:gser.0"
" modem:cser.dun.0"
" ecm:ecm.usb0"
" ncm:ncm.ncm"
" diag:diag.diag"
" nmea:cser.nmea.1"
" rmnet:rmnet_bam.rmnet_bam_dmux"
" usb_mbim:mbim.mbim"
" ffs:ffs.adb"
" rawdat:cser.raw.2"
" storage:mass_storage.0"
# Disable gadget in case it was enabled
if [ -w ${gadget_home}/UDC ]; then
if [ ! -z `cat ${gadget_home}/UDC` ]; then
echo "" > ${gadget_home}/UDC
fi
fi
if [ ! -d ${configfs_home} ]; then
mount none /sys/kernel/config -t configfs
mkdir ${gadget_home}
fi
echo "0x$vid" > ${gadget_home}/idVendor
echo "0x$pid" > ${gadget_home}/idProduct
mkdir -p ${strings_home}
echo ${manufacturer} > ${strings_home}/manufacturer
echo ${product} > ${strings_home}/product
if [ -s "/etc/adb_devid" ] && [ "$( cat /etc/adb_devid )" != "" ]; then
cat /etc/adb_devid > ${strings_home}/serialnumber
else
serial_no=`egrep -o "androidboot\.serialno=[0-9a-fA-F]+" /proc/cmdline |cut -f2 -d=`
if [ ! -z ${serial_no} ]; then
echo $serial_no > ${strings_home}/serialnumber
else
cat /proc/sys/kernel/random/boot_id | cut -d- -f5 > ${strings_home}/serialnumber
fi
cat ${strings_home}/serialnumber > /etc/adb_devid
fi
mkdir -p ${config_home}
# Update bmAttributes if remotewakup enabled.
# Referring include/uapi/linux/usb/ch9.h,
# D7: Reserved (set to one)
# D6: Self-powered
# D5: Remote Wakeup
# D4...0: Reserved (reset to zero)
[ $remotewakeup == "1" ] && echo 0xA0 > ${config_home}/bmAttributes
# Replace "serial" in compstr with the interface list (nmea, modem);
# Translate interface list into function names.
# smdnmea --> nmea
# smd --> modem (if CMUX over USB disabled)
# tty --> modem (if CMUX over USB enabled)
# rawdat --> rawdat
local serialif=`echo "${serialstr}"| sed -r -e 's/smdnmea/nmea/g' -e 's/(smd|tty)/modem/g'`
# update compstr to replace "serial" with the interface list.
compstr="${compstr/serial/${serialif}}"
# Space separated list
complist=`echo ${compstr} | sed -e 's/,/ /g'`
# Clear and symlink gadget configuration files, build configuration string
cd ${gadget_home}
idx=0
configuration=""
rm -f configs/c.$((num+1))/f*
for comp in ${complist}; do
match=`echo ${supported} | xargs -n1 | grep -i "${comp}"`
if [ -n "${match}" ]; then
idx=$((idx+1))
func=`echo ${match} | cut -f 2 -d':'`
name=`echo ${func} | cut -f 1 -d'.'`
if [ ${idx} -eq 1 ]; then
configuration="${name}"
else
configuration="${configuration}_${name}"
fi
mkdir -p functions/${func}
ln -s functions/${func} configs/c.$((num+1))/f${idx}
fi
done
cd
# Write configuration string
mkdir -p ${cstring_home}
echo "${configuration}" > ${cstring_home}/configuration
if echo "${compstr}" | grep -wq "ffs"; then
# mount FunctionFS and start adb daemon
mkdir -p /dev/usb-ffs/adb
mount -o uid=2000,gid=2000 -t functionfs adb /dev/usb-ffs/adb
mount -o remount,gid=5,mode=620 /dev/pts
mkdir -p /system/bin 2>/dev/null && ln -s /bin/sh /system/bin/sh
# change directory to root directory to align to msm-3.18 "adb shell" entry point
cd /
start-stop-daemon -S -b -a /sbin/adbd
cd -
sleep 1
fi
# Enable gadget
echo "${gdev}" > ${gadget_home}/UDC
}
set_frmnet_module_param()
{
local frmnet_module_param1=/sys/module/g_android/parameters/num_rmnet_swi
local frmnet_module_param2=/sys/module/usb_f_rmnet_bam/parameters/num_rmnet_swi
if [ -w "${frmnet_module_param1}" ]; then
frmnet_module_param=${frmnet_module_param1}
elif [ -w "${frmnet_module_param2}" ]; then
frmnet_module_param=${frmnet_module_param2}
else
return
fi
numnet=$(/usr/bin/ud_getusbinfo NUMNET)
if [ $? -eq 0 ]; then
echo $numnet > ${frmnet_module_param}
fi
}
echo “Switching to composition sierra_dev (1199:68C0)”
if [ “x$1” = “xy” ]; then
num=“1”
mode=“hsic”
else
num=“0”
mode=“hsusb”
fi
vid=$(/usr/bin/ud_getusbinfo VID)
if [ $? -ne 0 ];
then
echo “ud_getusbinfo gets VID failed”
vid=1199
fi
pid=$(/usr/bin/ud_getusbinfo PID)
if [ $? -ne 0 ];
then
echo “ud_getusbinfo gets PID failed”
pid=68C0
fi
devclass=$(/usr/bin/ud_getusbinfo DEVC)
if [ $? -ne 0 ];
then
echo “ud_getusbinfo gets DEVC failed”
devclass=239
fi
devsubclass=$(/usr/bin/ud_getusbinfo DEVS)
if [ $? -ne 0 ];
then
echo “ud_getusbinfo gets DEVS failed”
devsubclass=2
fi
devprotocol=$(/usr/bin/ud_getusbinfo DEVP)
if [ $? -ne 0 ];
then
echo “ud_getusbinfo gets DEVP failed”
devprotocol=1
fi
diagstr=$(/usr/bin/ud_getusbinfo DIAGSTR)
if [ $? -ne 0 ];
then
echo “ud_getusbinfo gets DIAGSTR failed”
diagstr=‘diag’
fi
serialstr=$(/usr/bin/ud_getusbinfo SERIALSTR)
if [ $? -ne 0 ];
then
echo “ud_getusbinfo gets SERIALSTR failed”
serialstr=‘smd,tty’
fi
compstr=$(/usr/bin/ud_getusbinfo COMPSTR)
if [ $? -ne 0 ];
then
echo “ud_getusbinfo gets COMPSTR failed”
compstr=‘diag,ffs,serial’
fi
filter out adb gadget if adbd is not installed
if [ ! -x /sbin/adbd ]; then
compstr=echo $compstr | sed -e s/^ffs,//g -e s/,ffs//g -e s/^ffs$//g
fi
remotewakeup=$(/usr/bin/ud_getusbinfo REM)
if [ $? -ne 0 ];
then
echo “ud_getusbinfo gets REM failed”
remotewakeup=1
fi
manufacturer=$(/usr/bin/ud_getusbinfo MANU)
if [ $? -ne 0 ];
then
echo “ud_getusbinfo gets MANU failed”
manufacturer=‘Sierra Wireless, Incorporated’
fi
product=$(/usr/bin/ud_getusbinfo PROD)
if [ $? -ne 0 ];
then
echo “ud_getusbinfo gets PROD failed”
product=‘AR758x’
fi
serial=$(/usr/bin/ud_getusbinfo SER)
if [[ $? -ne 0 || “${serial}” == “” ]];
then
echo “ud_getusbinfo gets SER failed or SN is blank”
serial=‘0123456789ABCDEF’
fi
Pass number of rmnets, to driver
set_frmnet_module_param
Check if configfs gadget is supported and configure accordingly
configfs_g_support=zcat /proc/config.gz |grep CONFIG_USB_CONFIGFS=y
configfs_fs_support=zcat /proc/config.gz |grep CONFIG_CONFIGFS_FS=y
if [[ “x${configfs_g_support}” = “x” || “x${configfs_fs_support}” = “x” ]]
then
configure_android_gadget
else
configure_configfs_gadget
fi
root@fx30s:/dev# ls -ls
0 crw-rw---- 1 root root 235, 0 Dec 31 1969 android_mbim
0 crw-rw---- 1 root root 242, 5 Dec 31 1969 apr_apps2
0 crw-rw---- 1 root root 242, 3 Dec 31 1969 at_mdm0
0 crw-rw---- 1 root root 242, 4 Dec 31 1969 at_mdm1
0 crw-rw---- 1 root root 242, 6 Dec 31 1969 at_mdm2
0 crw-rw---- 1 root root 506, 1 Dec 31 1969 at_usb0
0 crw-rw---- 1 root root 506, 0 Dec 31 1969 at_usb1
0 crw-rw---- 1 root root 506, 2 Dec 31 1969 at_usb2
0 drwxr-xr-x 3 root root 60 Dec 31 1969 bus
0 crw------- 1 root root 5, 1 Dec 31 1969 console
0 crw-rw---- 1 root root 10, 59 Dec 31 1969 cpu_dma_latency
0 crw-rw---- 1 root root 241, 0 Dec 31 1969 diag
0 brw-rw---- 1 root root 254, 0 Dec 31 1969 dm-0
0 brw-rw---- 1 root root 254, 1 Dec 31 1969 dm-1
0 crw-rw---- 1 root root 236, 1 Dec 31 1969 dpl_ctrl
0 crw-rw-rw- 1 root root 1, 7 Dec 31 1969 full
0 crw-rw---- 1 root root 254, 0 Dec 31 1969 gpiochip0
…
0 crw-rw---- 1 root root 254, 4 Dec 31 1969 gpiochip4
0 crw-rw---- 1 root root 10, 183 Dec 31 1969 hwrng
0 crw-rw---- 1 root root 89, 4 Dec 31 1969 i2c-4
0 crw-rw---- 1 root root 248, 0 Dec 31 1969 iio:device0
0 prw------- 1 root root 0 Dec 31 1969 initctl
0 drwxr-xr-x 2 root root 60 Dec 31 1969 input
0 crw-rw-rw- 1 root root 10, 63 Dec 31 1969 ion
4 -rw-r–r-- 1 root root 2 May 30 09:40 ipa
0 crw-rw---- 1 root root 1, 11 Dec 31 1969 kmsg
0 srw-rw-rw- 1 root root 0 Dec 31 1969 log
0 crw-rw---- 1 root root 10, 237 Dec 31 1969 loop-control
0 brw-r----- 1 root disk 7, 0 Dec 31 1969 loop0
…
0 brw-r----- 1 root disk 7, 7 Dec 31 1969 loop7
0 drwxr-xr-x 2 root root 80 Dec 31 1969 mapper
0 crw-r----- 1 root kmem 1, 1 Dec 31 1969 mem
0 crw-rw---- 1 root root 10, 56 Dec 31 1969 memory_bandwidth
0 drwxrwxrwt 2 root root 40 Dec 31 1969 mqueue
0 crw-rw---- 1 root root 256, 0 Dec 31 1969 msm-rng
0 crw-rw---- 1 root root 10, 54 May 30 09:40 msm_audio_cal
0 crw-rw---- 1 root root 10, 53 May 30 09:40 msm_rtac
0 crw-rw---- 1 root root 253, 0 Dec 31 1969 msm_sps
0 crw-rw---- 1 root root 90, 0 Dec 31 1969 mtd0
…
0 crw-rw---- 1 root root 90, 19 Dec 31 1969 mtd9ro
0 brw-rw---- 1 root root 31, 0 Dec 31 1969 mtdblock0
…
0 brw-rw---- 1 root root 31, 9 Dec 31 1969 mtdblock9
0 drwxr-xr-x 2 root root 60 Dec 31 1969 net
0 crw-rw---- 1 root root 10, 58 Dec 31 1969 network_latency
0 crw-rw---- 1 root root 10, 57 Dec 31 1969 network_throughput
0 prw-rw-rw- 1 root root 0 May 31 08:45 nmea
0 crw-rw-rw- 1 root root 1, 3 Dec 31 1969 null
0 crw-rw---- 1 root root 108, 0 Dec 31 1969 ppp
0 crw-rw---- 1 root root 249, 0 Dec 31 1969 pps0
0 crw-rw-rw- 1 root tty 5, 2 May 31 11:48 ptmx
0 drwxr-xr-x 2 root root 0 Dec 31 1969 pts
0 crw-rw---- 1 root root 2, 176 Dec 31 1969 ptya0
…
0 crw-rw---- 1 root root 2, 175 Dec 31 1969 ptyzf
0 brw-r----- 1 root disk 1, 0 Dec 31 1969 ram0
…
0 brw-r----- 1 root disk 1, 9 Dec 31 1969 ram9
0 crw-rw---- 1 root root 245, 1 Dec 31 1969 ramdump_microdump_modem
0 crw-rw---- 1 root root 245, 0 Dec 31 1969 ramdump_modem
0 crw-rw-rw- 1 root root 1, 8 Dec 31 1969 random
0 prw–w---- 1 root rebooter 0 May 31 08:45 rebooterdev
0 crw-rw---- 1 root root 236, 0 Dec 31 1969 rmnet_ctrl
0 lrwxrwxrwx 1 root root 9 Dec 31 1969 root → gpiochip0
0 crw-rw---- 1 root root 250, 0 Dec 31 1969 rtc0
0 drwxrwxrwx 2 root root 40 Dec 31 1969 shm
0 crw-rw---- 1 root root 10, 62 Dec 31 1969 sierra_smem
0 crw-rw---- 1 root root 10, 61 Dec 31 1969 sierra_ssmem
0 crw-rw---- 1 root root 242, 8 Dec 31 1969 smd10
0 crw-rw---- 1 root root 242, 10 Dec 31 1969 smd11
0 crw-rw---- 1 root root 242, 11 Dec 31 1969 smd21
0 crw-rw---- 1 root root 242, 1 Dec 31 1969 smd22
0 crw-rw---- 1 root root 242, 7 Dec 31 1969 smd7
0 crw-rw---- 1 root root 242, 9 Dec 31 1969 smd8
0 crw-rw---- 1 root root 242, 12 Dec 31 1969 smd_pkt_loopback
0 crw-rw---- 1 root root 242, 0 Dec 31 1969 smdcntl0
0 crw-rw---- 1 root root 242, 2 Dec 31 1969 smdcntl8
0 drwxr-xr-x 2 root root 1140 May 30 09:40 snd
0 crw-rw---- 1 root root 246, 0 Dec 31 1969 subsys_modem
0 crw-rw-rw- 1 root tty 5, 0 Dec 31 1969 tty
…
0 lrwxrwxrwx 1 root root 9 Dec 31 1969 ttyAT → /dev/smd8
0 crw-rw---- 1 root dialout 243, 0 Dec 31 1969 ttyHS0
0 crw------- 1 root root 243, 1 Dec 31 1969 ttyHS1
…
0 crw-rw-rw- 1 root tty 3, 175 Dec 31 1969 ttyzf
0 crw-rw---- 1 root root 10, 60 Dec 31 1969 tzdev
0 crw-rw---- 1 root root 511, 0 Dec 31 1969 ubi0
…
0 crw-rw---- 1 root root 508, 1 Dec 31 1969 ubi4_0
0 crw-rw---- 1 root root 10, 55 Dec 31 1969 ubi_ctrl
0 brw-rw---- 1 root root 253, 0 Dec 31 1969 ubiblock0_0
…
0 brw-rw---- 1 root root 253, 3 Dec 31 1969 ubiblock2_1
0 crw-rw---- 1 root root 10, 223 Dec 31 1969 uinput
0 crw-rw-rw- 1 root root 1, 9 Dec 31 1969 urandom
0 crw-rw---- 1 root root 239, 0 Dec 31 1969 usbmon0
0 crw-rw---- 1 root root 239, 1 Dec 31 1969 usbmon1
0 crw-rw---- 1 root tty 7, 0 Dec 31 1969 vcs
0 crw-rw---- 1 root tty 7, 1 Dec 31 1969 vcs1
0 crw-rw---- 1 root tty 7, 128 Dec 31 1969 vcsa
0 crw-rw---- 1 root tty 7, 129 Dec 31 1969 vcsa1
0 crw-rw-rw- 1 root root 1, 5 Dec 31 1969 zero
I have not figured out what the script is actually doing ?
but this seems to be where the configuration takes place?