use CDC-NCM instead of RNDIS

fix https://github.com/milk-v/milkv.io/issues/45

Signed-off-by: FUKAUMI Naoki <naoki@milkv.io>
This commit is contained in:
FUKAUMI Naoki
2024-06-13 11:54:06 +09:00
parent bc680ca7c9
commit 66f41db1eb
22 changed files with 241 additions and 18 deletions

View File

@ -5,12 +5,14 @@ MSC_PID=0x1008
RNDIS_PID=0x1009
UVC_PID=0x100A
UAC_PID=0x100B
NCM_PID=0x100C
ADB_VID=0x18D1
ADB_PID=0x4EE0
ADB_PID_M1=0x4EE2
ADB_PID_M2=0x4EE4
MANUFACTURER="Cvitek"
PRODUCT="USB Com Port"
PRODUCT_NCM="NCM"
PRODUCT_RNDIS="RNDIS"
PRODUCT_UVC="UVC"
PRODUCT_UAC="UAC"
@ -39,6 +41,11 @@ case "$2" in
cvg)
CLASS=cvg
;;
ncm)
CLASS=ncm
PID=$NCM_PID
PRODUCT=$PRODUCT_NCM
;;
rndis)
CLASS=rndis
PID=$RNDIS_PID
@ -62,7 +69,7 @@ case "$2" in
;;
*)
if [ "$1" = "probe" ] ; then
echo "Usage: $0 probe {acm|msc|cvg|rndis|uvc|uac1|adb}"
echo "Usage: $0 probe {acm|msc|cvg|ncm|rndis|uvc|uac1|adb}"
exit 1
fi
esac
@ -86,6 +93,11 @@ res_check() {
EP_IN=$(($EP_IN+$TMP_NUM))
EP_OUT=$(($EP_OUT+$TMP_NUM))
INTF_NUM=$(($INTF_NUM+$TMP_NUM))
TMP_NUM=$(find $CVI_GADGET/functions/ -name "ncm*" | wc -l)
TMP_NUM=$(($TMP_NUM * 2))
EP_IN=$(($EP_IN+$TMP_NUM))
EP_OUT=$(($EP_OUT+$TMP_NUM))
INTF_NUM=$(($INTF_NUM+$TMP_NUM))
TMP_NUM=$(find $CVI_GADGET/functions/ -name "rndis*" | wc -l)
EP_OUT=$(($EP_OUT+$TMP_NUM))
TMP_NUM=$(($TMP_NUM * 2))
@ -117,6 +129,10 @@ res_check() {
EP_IN=$(($EP_IN+1))
EP_OUT=$(($EP_OUT+1))
fi
if [ "$CLASS" = "ncm" ] ; then
EP_IN=$(($EP_IN+1))
EP_OUT=$(($EP_OUT+1))
fi
if [ "$CLASS" = "rndis" ] ; then
EP_IN=$(($EP_IN+2))
EP_OUT=$(($EP_OUT+1))
@ -197,6 +213,9 @@ probe() {
if [ "$CLASS" = "mass_storage" ] ; then
echo $MSC_FILE >$CVI_GADGET/functions/$CLASS.usb$FUNC_NUM/lun.0/file
fi
if [ "$CLASS" = "ncm" ] ; then
ln -s $CVI_FUNC/ncm.usb$FUNC_NUM $CVI_GADGET/configs/c.1
fi
if [ "$CLASS" = "rndis" ] ; then
#OS STRING
echo 1 >$CVI_GADGET/os_desc/use
@ -284,7 +303,7 @@ case "$1" in
ls /sys/class/udc/ >$CVI_GADGET/UDC
;;
*)
echo "Usage: $0 probe {acm|msc|cvg|uvc|uac1} {file (msc)}"
echo "Usage: $0 probe {acm|msc|cvg|ncm|uvc|uac1} {file (msc)}"
echo "Usage: $0 start"
echo "Usage: $0 stop"
exit 1

View File

@ -0,0 +1,28 @@
#!/bin/sh
/etc/uhubon.sh device >> /tmp/ncm.log 2>&1
/etc/run_usb.sh probe ncm >> /tmp/ncm.log 2>&1
if test -e /usr/bin/burnd; then
/etc/run_usb.sh probe acm >> /tmp/ncm.log 2>&1
fi
/etc/run_usb.sh start ncm >> /tmp/ncm.log 2>&1
sleep 0.5
ifconfig usb0 192.168.42.1
count=`ps | grep dnsmasq | grep -v grep | wc -l`
if [ ${count} -lt 1 ] ;then
echo "/etc/init.d/S80dnsmasq start" >> /tmp/ncm.log 2>&1
/etc/init.d/S80dnsmasq start >> /tmp/ncm.log 2>&1
fi
sleep 2
mkdir -p /lib/firmware
if test -e /usr/bin/burnd; then
burnd &
if test -e /lib/firmware/arduino.elf; then
sleep 2
echo stop > /sys/class/remoteproc/remoteproc0/state
echo start > /sys/class/remoteproc/remoteproc0/state
fi
fi

View File

@ -0,0 +1,28 @@
#!/bin/sh
/etc/uhubon.sh device >> /tmp/ncm.log 2>&1
/etc/run_usb.sh probe ncm >> /tmp/ncm.log 2>&1
if test -e /usr/bin/burnd; then
/etc/run_usb.sh probe acm >> /tmp/ncm.log 2>&1
fi
/etc/run_usb.sh start ncm >> /tmp/ncm.log 2>&1
sleep 0.5
ifconfig usb0 192.168.42.1
count=`ps | grep dnsmasq | grep -v grep | wc -l`
if [ ${count} -lt 1 ] ;then
echo "/etc/init.d/S80dnsmasq start" >> /tmp/ncm.log 2>&1
/etc/init.d/S80dnsmasq start >> /tmp/ncm.log 2>&1
fi
sleep 2
mkdir -p /lib/firmware
if test -e /usr/bin/burnd; then
burnd &
if test -e /lib/firmware/arduino.elf; then
sleep 2
echo stop > /sys/class/remoteproc/remoteproc0/state
echo start > /sys/class/remoteproc/remoteproc0/state
fi
fi

View File

@ -0,0 +1,28 @@
#!/bin/sh
/etc/uhubon.sh device >> /tmp/ncm.log 2>&1
/etc/run_usb.sh probe ncm >> /tmp/ncm.log 2>&1
if test -e /usr/bin/burnd; then
/etc/run_usb.sh probe acm >> /tmp/ncm.log 2>&1
fi
/etc/run_usb.sh start ncm >> /tmp/ncm.log 2>&1
sleep 0.5
ifconfig usb0 192.168.42.1
count=`ps | grep dnsmasq | grep -v grep | wc -l`
if [ ${count} -lt 1 ] ;then
echo "/etc/init.d/S80dnsmasq start" >> /tmp/ncm.log 2>&1
/etc/init.d/S80dnsmasq start >> /tmp/ncm.log 2>&1
fi
sleep 2
mkdir -p /lib/firmware
if test -e /usr/bin/burnd; then
burnd &
if test -e /lib/firmware/arduino.elf; then
sleep 2
echo stop > /sys/class/remoteproc/remoteproc0/state
echo start > /sys/class/remoteproc/remoteproc0/state
fi
fi

View File

@ -1 +1 @@
usb-rndis.sh
usb-ncm.sh

View File

@ -0,0 +1,28 @@
#!/bin/sh
/etc/uhubon.sh device >> /tmp/ncm.log 2>&1
/etc/run_usb.sh probe ncm >> /tmp/ncm.log 2>&1
if test -e /usr/bin/burnd; then
/etc/run_usb.sh probe acm >> /tmp/ncm.log 2>&1
fi
/etc/run_usb.sh start ncm >> /tmp/ncm.log 2>&1
sleep 0.5
ifconfig usb0 192.168.42.1
count=`ps | grep dnsmasq | grep -v grep | wc -l`
if [ ${count} -lt 1 ] ;then
echo "/etc/init.d/S80dnsmasq start" >> /tmp/ncm.log 2>&1
/etc/init.d/S80dnsmasq start >> /tmp/ncm.log 2>&1
fi
sleep 2
mkdir -p /lib/firmware
if test -e /usr/bin/burnd; then
burnd &
if test -e /lib/firmware/arduino.elf; then
sleep 2
echo stop > /sys/class/remoteproc/remoteproc0/state
echo start > /sys/class/remoteproc/remoteproc0/state
fi
fi

View File

@ -0,0 +1,28 @@
#!/bin/sh
/etc/uhubon.sh device >> /tmp/ncm.log 2>&1
/etc/run_usb.sh probe ncm >> /tmp/ncm.log 2>&1
if test -e /usr/bin/burnd; then
/etc/run_usb.sh probe acm >> /tmp/ncm.log 2>&1
fi
/etc/run_usb.sh start ncm >> /tmp/ncm.log 2>&1
sleep 0.5
ifconfig usb0 192.168.42.1
count=`ps | grep dnsmasq | grep -v grep | wc -l`
if [ ${count} -lt 1 ] ;then
echo "/etc/init.d/S80dnsmasq start" >> /tmp/ncm.log 2>&1
/etc/init.d/S80dnsmasq start >> /tmp/ncm.log 2>&1
fi
sleep 2
mkdir -p /lib/firmware
if test -e /usr/bin/burnd; then
burnd &
if test -e /lib/firmware/arduino.elf; then
sleep 2
echo stop > /sys/class/remoteproc/remoteproc0/state
echo start > /sys/class/remoteproc/remoteproc0/state
fi
fi

View File

@ -0,0 +1,28 @@
#!/bin/sh
/etc/uhubon.sh device >> /tmp/ncm.log 2>&1
/etc/run_usb.sh probe ncm >> /tmp/ncm.log 2>&1
if test -e /usr/bin/burnd; then
/etc/run_usb.sh probe acm >> /tmp/ncm.log 2>&1
fi
/etc/run_usb.sh start ncm >> /tmp/ncm.log 2>&1
sleep 0.5
ifconfig usb0 192.168.42.1
count=`ps | grep dnsmasq | grep -v grep | wc -l`
if [ ${count} -lt 1 ] ;then
echo "/etc/init.d/S80dnsmasq start" >> /tmp/ncm.log 2>&1
/etc/init.d/S80dnsmasq start >> /tmp/ncm.log 2>&1
fi
sleep 2
mkdir -p /lib/firmware
if test -e /usr/bin/burnd; then
burnd &
if test -e /lib/firmware/arduino.elf; then
sleep 2
echo stop > /sys/class/remoteproc/remoteproc0/state
echo start > /sys/class/remoteproc/remoteproc0/state
fi
fi

View File

@ -1 +1 @@
usb-rndis.sh
usb-ncm.sh

View File

@ -0,0 +1,28 @@
#!/bin/sh
/etc/uhubon.sh device >> /tmp/ncm.log 2>&1
/etc/run_usb.sh probe ncm >> /tmp/ncm.log 2>&1
if test -e /usr/bin/burnd; then
/etc/run_usb.sh probe acm >> /tmp/ncm.log 2>&1
fi
/etc/run_usb.sh start ncm >> /tmp/ncm.log 2>&1
sleep 0.5
ifconfig usb0 192.168.42.1
count=`ps | grep dnsmasq | grep -v grep | wc -l`
if [ ${count} -lt 1 ] ;then
echo "/etc/init.d/S80dnsmasq start" >> /tmp/ncm.log 2>&1
/etc/init.d/S80dnsmasq start >> /tmp/ncm.log 2>&1
fi
sleep 2
mkdir -p /lib/firmware
if test -e /usr/bin/burnd; then
burnd &
if test -e /lib/firmware/arduino.elf; then
sleep 2
echo stop > /sys/class/remoteproc/remoteproc0/state
echo start > /sys/class/remoteproc/remoteproc0/state
fi
fi

View File

@ -1 +1 @@
usb-rndis.sh
usb-ncm.sh