This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

how to make android usb-modeswitch tools



   Hi,

          I have a 3g modul named Huawei E1750. Now it doest work,because it need to transform Mass storage to usb-serial mode. So  It need a tool like usb-modeswitch.

There are  some differences between linux compile tool and andriod .  so I failed . Could you tell me a way to compile the usb-modeswitch source?

        Appreciate your respose!

  • Hi,

    We have added 3G modem configuration support in settings app for AM335x EVM (Android 4.1.2 sources).

    Please re-sync your sources with rowboat-jb-4.1.2-am335x.xml manifest to get 3G modem patches.
        $ repo init -u git://gitorious.org/rowboat/manifest.git -m rowboat-jb-4.1.2-am335x.xml
        $ repo sync

    If you are using platform other than AM335x EVM, you can extract 3G modem related patches from following repositories and integrate it in your sources.

    • Full hardware /hardware/ril  repository. (rowboat-jb-4.1 branch)
    • system/core
      • http://gitorious.org/rowboat/system-core/commit/2d6c3f2bd789a807e3749cfaee004d4041eabf4d
    • system/vold
      • http://gitorious.org/rowboat/system-vold/commit/8c0196d121d0c241e4a33627459919b9d0841f94
    • device/ti/am335xevm
      • http://gitorious.org/rowboat/vendor-ti-am335xevm/commit/6e44cccaba28aea8ddb0a3c191be3c79b1c19085
      • http://gitorious.org/rowboat/vendor-ti-am335xevm/commit/e131234fa45aa7931fbe84f2e3087429b0bac7c7
      • http://gitorious.org/rowboat/vendor-ti-am335xevm/commit/c31d8d0a57cbc489ab57ae00901ee9671c70de9e
      • http://gitorious.org/rowboat/vendor-ti-am335xevm/commit/bbcb8455ce139e91febfe038f7d6b264396dc267
      • http://gitorious.org/rowboat/vendor-ti-am335xevm/commit/a6166220573aeaec91a2a702efe4863cfe1e77c5
      • http://gitorious.org/rowboat/vendor-ti-am335xevm/commit/b5e566b052924eb4a39d04ed24d89fd4f2b86e65

    Steps:

    1. Build sources for AM335x EVM and create a bootable SD card. You can follow instructions mentioned in below developer guide.
    2. Download USB mode switch pre-complied binary from
    3. Copy usb_modeswitch binary to Android Filesystem (system/bin location)
      • $ sudo cp usb_modeswitch-1.1.9-arm-static /media/rootfs/system/bin/usb_modeswitch
    4. Bootup the board.
    5. Connect USB 3G modem to board.
    6. Wait for around 8-10 secs to get 3G modem detected and configured.
    7. Go to Settings Application -> More -> Mobile networks option.
    8. Select appropriate APN from the mentioned APN list.
    9. Mark "Data Enabled" check box.
    10. Check whether browser works.

    Feel free to get in touch in case of any issues.


    Thanks and Regards,

    Pankaj Bharadiya

  • Hi Pankaj,

    thanks a lot for sharing this useful tutorial. I'm using it to integrate the 3G module into this tablet JB (https://groups.google.com/forum/#!forum/renesas-emev-osp). Sorry if it's not TI-specific, but I found very hard to find public info abpout RIL and PPPD integration, so I hope you can help me...

    The modem is an internal ZTE MF-212 one and when powered up (by GPIO switching in kernel) it immediately appears as /dev/ttyUSB0 to /dev/ttyUSB2, so, no need to use usb_modeswitch in my case.

    I still have a few doubts though:

    1) Thought not explicitly mentioned in your tutorial, should we remove the "no-RIL" option in init.rc?

         setprop ro.radio.noril yes

    What is the effect of this? I've noticed AOSP devices haven't this set...

    2) Any suggestion about debug-logging rild? I see no logcat message when powering up the 3G module, though /dev/ttyUSB* are there.

    3) What are the most modem-specific customizations introduced in reference-ril? Anything that needs to be changed, for a different modem?

    4) I see no phone signal icon at all on UI, though I do have the mobile network options (with an empty APN list... in spite the apns-conf.xml is there). I'm wondering if there's anything else requiring customizations, in the AOSP code, apart from the commits you list above. I haven't downloaded the full rowboat-jb code, yet...

    Thanks a lot in advance for any help,

     Fabio Fumi

    Rome - Italy

     

  • Hi Fabio,

    1.  You can remove this entry from init.rc.
         setprop ro.radio.noril yes

    2. Run "logcat -b radio" command to see logcat messages.

    3. The reference ril worked for me with little modifications. We have not done any modem specific configuration here in reference ril.

    4. The APN list will get populated in mobile networks option only when modem is detected and configured properly. Android will read some specific information from modem and populate APN list accordingly.

    Thanks and Regards,

    Pankaj Bharadiya

  • Hi, thanks for answering.

    the following is waht I get from the radio log, as soon as I power the 3G module up. It's not easy for me to understand what's going wrong... For example, what is the repeated "ATE0Q0V1" command about? Could you help please? Thanks.

    I/RIL     (   79): Setting speed
    D/RILC    (   79): [UNSL]< UNSOL_RESPONSE_RADIO_STATE_CHANGED  {RADIO_OFF}
    D/AT      (   79): AT> ATE0Q0V1
    D/RILJ    (  384): [UNSL]< UNSOL_RESPONSE_RADIO_STATE_CHANGED RADIO_OFF
    D/RILB    (  384): Notifying: radio available
    D/RILJ    (  384): [0006]> SCREEN_STATE: true
    D/RILJ    (  384): [0007]> RADIO_POWER on
    D/GSM     (  384): [GsmSST] Poll ServiceState done:  oldSS=[1 home null null null  Unknown CSS not supported -1 -1 RoamInd=-1 DefRoamInd=-1 EmergOnly=false] newSS=[3 home null null null  Unknown CSS not supported -1 -1 RoamInd=-1 DefRoamInd=-1 EmergOnly=false] oldGprs=1 newData=1 oldMaxDataCalls=1 mNewMaxDataCalls=1 oldReasonDataDenied=-1 mNewReasonDataDenied=-1 oldType=Unknown newType=Unknown
    D/GSM     (  384): [GsmSST] operatorNumeric is null
    D/GSM     (  384): [GsmDCT] handleMessage msg={ what=270337 when=-8ms obj=android.os.AsyncResult@41096e68 }
    D/GSM     (  384): [GsmDCT] onRadioAvailable
    D/GSM     (  384): [GsmDCT] overall state is IDLE
    D/RILJ    (  384): [0008]> BASEBAND_VERSION
    D/RILJ    (  384): [0009]> GET_IMEI
    D/RILJ    (  384): [0010]> GET_IMEISV
    D/AT      (   79): AT> ATE0Q0V1
    D/AT      (   79): AT> ATE0Q0V1
    D/AT      (   79): AT> ATE0Q0V1
    D/AT      (   79): AT> ATE0Q0V1
    D/AT      (   79): AT> ATE0Q0V1
    D/AT      (   79): AT> ATE0Q0V1
    D/AT      (   79): AT> ATE0Q0V1
    D/AT      (   79): AT> ATE0Q0V1

  • Its shows that RIL cant communicate with your modem. Check you have opened correct path in rild ?

  • Indeed. I later realized there's a communication problem with the modem, which I still can't understand the reason of.

    Being out of the RIL integration scope, I've posted another question here: http://stackoverflow.com/questions/16696356/3g-usb-modem-not-responding-to-at-commands .

    If anyone here also could give me any hint about how to debug it, I'd greatly appreciate that!

    Thanks

  • Hi,

    I'm not really sure what I did, but looks like AT chatting with modem goes through as expected now... I made some kernel and OASP recompilation, but I can't tell what has changed.

    I need to complete end-to-.end testing, but at least now I can see AT commands and responses from 'logcat -b radio'. e.g

    ...
    D/RIL-AT  ( 1265): AT> AT+CGSN
    D/RILJ    (  374): [0063]< GET_IMEI
    D/RIL-AT  ( 1265): AT< 352037031361039
    D/RIL-AT  ( 1265): AT< OK
    D/RILC    ( 1265): [0064]< GET_IMEISV {352037031361039}

    ...

    One question I have, for my undertanding, is - why the need to customize the reference ril library, if there's nothing modem specific? What is there in the AOSP JB lib that doesn't work?

    thanks
    Fabio

  • Hi ,

    after some more test and debugging, I finally managed to get to the point where pppd is issued. This is what I get:

    (radio logcat)

    D/GSM     (  380): [GsmDCT] isDataPossible(cbs): possible=true isDataAllowed=true apnTypePossible=true apnContextisEnabled=false apnContextState()=IDLE
    D/GSM     (  380): [GsmDCT] get active apn string for type:cbs
    I/RIL     (   79): Executing '/system/bin/pppd /dev/ttyUSB3 115200 linkname datakey unit 1 crtscts usepeerdns noauth defaultroute noipdefault ipcp-accept-local ipcp-accept-remote ipcp-max-failure 30 lcp-echo-interval 5 lcp-echo-failure 30 modem dump debug kdebug 8'
    I/RIL     (   79): Waiting For Property
    E/RIL     (   79): Timeout waiting net.ppp1.local-ip - giving up!

    (system logcat)

    I/pppd    ( 1517): pppd options in effect:
    I/pppd    ( 1517): debug        # (from command line)
    I/pppd    ( 1517): kdebug 8        # (from command line)
    I/pppd    ( 1517): linkname datakey        # (from command line)
    I/pppd    ( 1517): unit 1        # (from command line)
    I/pppd    ( 1517): dump        # (from command line)
    I/pppd    ( 1517): noauth        # (from command line)
    I/pppd    ( 1517): /dev/ttyUSB3        # (from command line)
    I/pppd    ( 1517): 115200        # (from command line)
    I/pppd    ( 1517): crtscts        # (from command line)
    I/pppd    ( 1517): modem        # (from command line)
    I/pppd    ( 1517): lcp-echo-failure 30        # (from command line)
    I/pppd    ( 1517): lcp-echo-interval 5        # (from command line)
    I/pppd    ( 1517): ipcp-accept-local        # (from command line)
    I/pppd    ( 1517): ipcp-accept-remote        # (from command line)
    I/pppd    ( 1517): noipdefault        # (from command line)
    I/pppd    ( 1517): ipcp-max-failure 30        # (from command line)
    I/pppd    ( 1517): defaultroute        # (from command line)
    I/pppd    ( 1517): usepeerdns        # (from command line)
    D/pppd    ( 1518): using channel 1
    I/pppd    ( 1518): Using interface ppp1
    I/pppd    ( 1518): Connect: ppp1 <--> /dev/ttyUSB3
    D/pppd    ( 1518): sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0xd2320724> <pcomp> <accomp>]
    D/pppd    ( 1518): rcvd [LCP ConfReq id=0x0 <asyncmap 0x0> <auth chap MD5> <magic 0x1268532> <pcomp> <accomp>]
    D/pppd    ( 1518): No auth is possible
    D/pppd    ( 1518): sent [LCP ConfRej id=0x0 <auth chap MD5>]
    D/pppd    ( 1518): rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0xd2320724> <pcomp> <accomp>]
    D/pppd    ( 1518): rcvd [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x1268532> <pcomp> <accomp>]
    D/pppd    ( 1518): sent [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0x1268532> <pcomp> <accomp>]
    D/pppd    ( 1518): sent [LCP EchoReq id=0x0 magic=0xd2320724]
    D/pppd    ( 1518): sent [CCP ConfReq id=0x1 <deflate 15> <deflate(old#) 15> <bsd v1 15>]
    D/pppd    ( 1518): sent [IPCP ConfReq id=0x1 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
    D/pppd    ( 1518): rcvd [LCP DiscReq id=0x2 magic=0x1268532]
    D/pppd    ( 1518): rcvd [LCP EchoRep id=0x0 magic=0x1268532 01 26 85 32]
    D/pppd    ( 1518): rcvd [LCP ProtRej id=0x3 80 fd 01 01 00 0f 1a 04 78 00 18 04 78 00 15 03 2f]
    D/pppd    ( 1518): rcvd [IPCP ConfNak id=0x1 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
    D/pppd    ( 1518): sent [IPCP ConfReq id=0x2 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14>]
    D/pppd    ( 1518): rcvd [IPCP ConfNak id=0x2 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
    D/pppd    ( 1518): sent [IPCP ConfReq id=0x3 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14>]
    D/pppd    ( 1518): rcvd [IPCP ConfNak id=0x3 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
    D/pppd    ( 1518): sent [IPCP ConfReq id=0x4 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14>]
    D/pppd    ( 1518): rcvd [IPCP ConfNak id=0x4 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
    D/pppd    ( 1518): sent [IPCP ConfReq id=0x5 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14>]
    D/pppd    ( 1518): rcvd [IPCP ConfReq id=0x0]
    D/pppd    ( 1518): sent [IPCP ConfNak id=0x0 <addr 0.0.0.0>]
    D/pppd    ( 1518): rcvd [IPCP ConfRej id=0x5 <compress VJ 0f 01>]
    D/pppd    ( 1518): sent [IPCP ConfReq id=0x6 <addr 0.0.0.0> <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14>]
    D/pppd    ( 1518): rcvd [IPCP ConfReq id=0x1]
    D/pppd    ( 1518): sent [IPCP ConfAck id=0x1]
    D/pppd    ( 1518): rcvd [IPCP ConfNak id=0x6 <addr 109.112.40.122> <ms-dns1 83.224.66.134> <ms-dns3 83.224.70.93>]
    D/pppd    ( 1518): sent [IPCP ConfReq id=0x7 <addr 109.112.40.122> <ms-dns1 83.224.66.134> <ms-dns3 83.224.70.93>]
    D/pppd    ( 1518): rcvd [IPCP ConfAck id=0x7 <addr 109.112.40.122> <ms-dns1 83.224.66.134> <ms-dns3 83.224.70.93>]
    W/pppd    ( 1518): Could not determine remote IP address: defaulting to 10.64.64.65
    I/pppd    ( 1518): local  IP address 109.112.40.122
    I/pppd    ( 1518): remote IP address 10.64.64.65
    I/pppd    ( 1518): primary   DNS address 83.224.66.134
    I/pppd    ( 1518): secondary DNS address 83.224.70.93
    W/pppd    ( 1518): Can't execute /etc/ppp/ip-up-datakey: Invalid argument

    This last line is unexpected to me.

    I have your /etc/ppp/ip-up-datakey in place, i.e.

    ---------------------

    #!/system/bin/sh
    case $1 in
        ppp1)
            /android/bin/iptables --flush;
            /android/bin/iptables --table nat --flush;
            /android/bin/iptables --delete-chain;
            /android/bin/iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE;
            /android/bin/iptables --append FORWARD --in-interface ppp1 -j ACCEPT;
            echo 0 > /proc/sys/net/ipv4/ip_forward;
            echo 1 > /proc/sys/net/ipv4/ip_forward;
            ;;
        ppp0)
        /system/bin/setprop "net.interfaces.defaultroute" "ppp1";
        ;;
    esac

    /system/bin/setprop "net.ppp1.dns1" "$DNS1"
    /system/bin/setprop "net.ppp1.dns2" "$DNS2"
    /system/bin/setprop "net.ppp1.local-ip" "$IPLOCAL"
    /system/bin/setprop "net.ppp1.remote-ip" "$IPREMOTE"
    /system/bin/setprop "net.ppp1.gw" "$IPREMOTE"
    /system/bin/setprop "net.ppp1.if" "$IFNAME"

    ---------------------

    Can you please review what could be wrong yet?

    Thanks a lot for this precious tutorial, anyway!

    Fabio

  • Ok, it was just a permissioning issue.

    Fixed after this:

        chmod 755 /system/etc/ppp/ip-up-datakey
        chmod 755 /system/etc/ppp/ip-down-datakey

  • Hello Fabio

                       Glad to know that you have done it.

                       Can you give us detailed procedure for this work, it will be more useful for many members.    

    Thanks

  • Hi,

    after closely following the steps initially described here at the beginning of this post (see above), I also had to hack the kernel a bit, to adapt to my board-speciic hardware, namely with some GPIO reset pins being required at power up. Note how mine is NOT a USB 3G-dongle but an on-board mini-PCI modem daugher board. No modemswitch was required as the modem appears on the USB as a new tty device as soon as it's powered up

    This kernel fix allowed RIL system to successfully issue AT commands to the modem and establish a connection.

    Unfortunately, I still missed the APNs, so I had to do another little change, after debugging, which is to enforce this flag in TelephonyProvider.java package:

        private boolean isLteOnCdma() {
            return true; //BaseCommands.getLteOnCdmaModeStatic() == Phone.LTE_ON_CDMA_TRUE;

        }

    as I noticed from logcat the initDatabase() wasn't ever called on bootup, and analyzing code I found the same being controlled by that flag.

    After that change, the carrier DB was correctly initialized.

    But that wasn't enough yet... as I had to add the 'chmod' commands below to my init.<board>.rc, to make the pppd succesfully issue the ip-up-datakey script and complete the ip interface setup

      chmod 755 /system/etc/ppp/ip-up-datakey
      chmod 755 /system/etc/ppp/ip-down-datakey

    I have one last point that doesn't work as I expect, i.e. I can't find a "3G" , or any other label next to the phone signal icon... But that doesn't prevent the tablet to succesfully browse the internet over 3G.