AnsweredAssumed Answered

how to enable NCM function for imx-o8.1.0_1.3.0_8m bsp

Question asked by Baodong Chen on Nov 26, 2018

Hello All,

 

We want test NCM function for evk-8mq board.

Is three anything need to be patched for NCM function to work?

Currently i changed this on android side, please correct me if anything wrong, thanks.

 

device/fsl:

diff --git a/evk_8mq/init.usb.rc b/evk_8mq/init.usb.rc
index 0cb9452..2be2695 100644
--- a/evk_8mq/init.usb.rc
+++ b/evk_8mq/init.usb.rc
@@ -37,6 +37,7 @@ on fs
     mkdir /config/usb_gadget/g1/functions/audio_source.gs3
     mkdir /config/usb_gadget/g1/functions/rndis.gs4
     mkdir /config/usb_gadget/g1/functions/midi.gs5
+    mkdir /config/usb_gadget/g1/functions/ncm.gs6
     mkdir /config/usb_gadget/g1/strings/0x409
     mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409
     # The mount of functionfs for adb must be put AFTER the mkdir for functions in configfs
@@ -116,3 +117,15 @@ on property:sys.usb.ffs.ready=1 && property:sys.usb.config=rndis,adb && property
     write /config/usb_gadget/g1/os_desc/use 1
     write /config/usb_gadget/g1/idProduct 0x4ee4
     write /config/usb_gadget/g1/idVendor 0x18d1
+
+on property:sys.usb.config=ncm && property:sys.usb.configfs=1
+    write /config/usb_gadget/g1/idProduct 0x685d
+    write /config/usb_gadget/g1/idVendor 0x04e8
+
+on property:sys.usb.ffs.ready=1 && property:sys.usb.config=ncm,adb && property:sys.usb.configfs=1
+    write /config/usb_gadget/g1/idProduct 0x685d
+    write /config/usb_gadget/g1/idVendor 0x04e8

 

system/core:

diff --git a/rootdir/init.usb.configfs.rc b/rootdir/init.usb.configfs.rc
index de1aab3..4d5c7a6 100644
--- a/rootdir/init.usb.configfs.rc
+++ b/rootdir/init.usb.configfs.rc
@@ -141,3 +141,26 @@ on property:sys.usb.ffs.ready=1 && property:sys.usb.config=rndis,adb && property
     symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f2
     write /config/usb_gadget/g1/UDC ${sys.usb.controller}
     setprop sys.usb.state ${sys.usb.config}
+
+
+on property:sys.usb.config=ncm && property:sys.usb.configfs=1
+    write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "ncm"
+    rm /config/usb_gadget/g1/configs/b.1/f1
+    rm /config/usb_gadget/g1/configs/b.1/f2
+    rm /config/usb_gadget/g1/configs/b.1/f3
+    symlink /config/usb_gadget/g1/functions/ncm.gs6 /config/usb_gadget/g1/configs/b.1/f1
+    write /config/usb_gadget/g1/UDC ${sys.usb.controller}
+    setprop sys.usb.state ${sys.usb.config}
+
+on property:sys.usb.config=ncm,adb && property:sys.usb.configfs=1
+    start adbd
+
+on property:sys.usb.ffs.ready=1 && property:sys.usb.config=ncm,adb && property:sys.usb.configfs=1
+    write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "ncm_adb"
+    rm /config/usb_gadget/g1/configs/b.1/f1
+    rm /config/usb_gadget/g1/configs/b.1/f2
+    rm /config/usb_gadget/g1/configs/b.1/f3
+    symlink /config/usb_gadget/g1/functions/ncm.gs6 /config/usb_gadget/g1/configs/b.1/f1
+    symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f2
+    write /config/usb_gadget/g1/UDC ${sys.usb.controller}
+    setprop sys.usb.state ${sys.usb.config}
diff --git a/rootdir/init.usb.rc b/rootdir/init.usb.rc
index 3168f40..0b50a23 100644
--- a/rootdir/init.usb.rc
+++ b/rootdir/init.usb.rc
@@ -106,6 +106,31 @@ on property:sys.usb.config=accessory,audio_source,adb && property:sys.usb.config
 on boot && property:persist.sys.usb.config=*
     setprop sys.usb.config ${persist.sys.usb.config}
 
+# ncm
+on property:sys.usb.config=ncm && property:sys.usb.configfs=0
+    write /sys/class/android_usb/android0/enable 0
+    write /sys/class/android_usb/android0/idVendor 04e8
+    write /sys/class/android_usb/android0/idProduct 685d
+    write /sys/class/android_usb/android0/functions ${sys.usb.config}
+    write /sys/class/android_usb/android0/enable 1
+    setprop sys.usb.state ${sys.usb.config}
+
+# ncm,adb
+on property:sys.usb.config=ncm,adb && property:sys.usb.configfs=0
+    write /sys/class/android_usb/android0/enable 0
+    write /sys/class/android_usb/android0/idVendor 04e8
+    write /sys/class/android_usb/android0/idProduct 685d
+    write /sys/class/android_usb/android0/functions ${sys.usb.config}
+    write /sys/class/android_usb/android0/enable 1
+    setprop sys.usb.state ${sys.usb.config}
+    start adbd
+
 #
 # USB type C
 #

Outcomes