| #!/bin/sh |
| # usb_init script |
| |
| #wait for telephony ready |
| #sleep 5 |
| #Enable USB configurations |
| echo 0 > /sys/class/android_usb/android0/enable |
| echo 2ecc > /sys/class/android_usb/android0/idVendor |
| echo 3012 > /sys/class/android_usb/android0/idProduct |
| echo 0100 > /sys/class/android_usb/android0/bcdDevice |
| echo Asrmicro > /sys/class/android_usb/android0/iManufacturer |
| |
| atdl_mode=`cat /proc/cmdline | grep "LDTA="` |
| if [ -n "$atdl_mode" ]; then |
| echo "!!!ATDL mode" > /dev/kmsg |
| #wait for atcmd ready |
| loop_atcmdsrv=0 |
| while [ $loop_atcmdsrv -le 20 ] |
| do |
| if [ -e /tmp/atcmdsrv_ok ]; then |
| break |
| else |
| loop_atcmdsrv=$((loop_atcmdsrv+1)) |
| sleep 1 |
| fi |
| done |
| |
| serial_atcmd AT*MRD_SN=R > /tmp/usb_mrd_sn1 |
| sed -n '/MRD_SN/p' /tmp/usb_mrd_sn1 > /tmp/usb_mrd_sn2 |
| MRD_SNUM=`awk -F ',' '{print $3}' /tmp/usb_mrd_sn2` |
| if [ -n "$MRD_SNUM" ]; then |
| echo "USB_MRD_SN: $MRD_SNUM" > /dev/kmsg |
| echo $MRD_SNUM > /sys/class/android_usb/android0/iSerial |
| else |
| echo 123456789ABCD > /sys/class/android_usb/android0/iSerial |
| fi |
| else |
| echo 123456789ABCD > /sys/class/android_usb/android0/iSerial |
| fi |
| |
| # iProduct will displayed on Windows |
| echo Asrmicro > /sys/class/android_usb/android0/iProduct |
| # store function in node functions if os detect is not compiled, |
| # otherwise the functions are stored in win7/win8/apple |
| echo rndis,acm,marvell_diag,marvell_debug,adb > /sys/class/android_usb/android0/functions |
| echo rndis,acm,marvell_diag,marvell_debug,adb > /sys/class/android_usb/android0/win7 |
| echo rndis,acm,marvell_diag,marvell_debug,adb > /sys/class/android_usb/android0/win8 |
| |
| #PIPE mode use rndis, router mode use ncm |
| pipemode=`cat /proc/cmdline | grep "PIPE=1"` |
| if [ -n "$pipemode" ]; then |
| echo rndis,acm,marvell_diag,marvell_debug > /sys/class/android_usb/android0/olinux |
| else |
| echo ncm,acm,marvell_diag,marvell_debug > /sys/class/android_usb/android0/olinux |
| fi |
| |
| echo ncm > /sys/class/android_usb/android0/apple |
| |
| #below items are for enumeraton stage2 |
| echo rndis,acm,marvell_diag,marvell_debug > /sys/class/android_usb/android0/win7_s2 |
| echo rndis,acm,marvell_diag,marvell_debug > /sys/class/android_usb/android0/win8_s2 |
| echo rndis,acm,marvell_diag,marvell_debug > /sys/class/android_usb/android0/olinux_s2 |
| echo ncm > /sys/class/android_usb/android0/apple_s2 |
| echo win7 > /sys/class/android_usb/android0/os |
| echo 239 > /sys/class/android_usb/android0/bDeviceClass |
| echo Asrmicro > /sys/class/android_usb/android0/f_rndis/manufacturer |
| echo 0bb4 > /sys/class/android_usb/android0/f_rndis/vendorID |
| echo 1 > /sys/class/android_usb/android0/f_rndis/wceis |
| echo 1 > /sys/class/android_usb/android0/f_acm/instances |
| echo 1 > /sys/class/android_usb/android0/enable |
| |
| #start mbim early to connect with PC, otherwise AT com port will |
| #be blocked for tens of seconds |
| [ -e /sys/class/android_usb/android0/win8 ] && { |
| mbim_enabled=`cat /sys/class/android_usb/android0/win8 | grep mbim` |
| if [ -n "$mbim_enabled" ]; then |
| /bin/mbim & |
| fi |
| } |
| |
| if grep -q "CPLOG=1" /proc/cmdline && [ ! -e "/NVM/sulog_auto_enable" ] |
| then |
| /bin/sulog & |
| fi |
| |