USB 3G MODEM through usb USB OTG cable?

bigrushdog

Inactive Recognized Developer
Apr 23, 2007
3,547
7,244
263
Here is a link to BRD's new thread in the development section. Please be sure to read the first post and try to honor his request to keep the thread clean.

http://forum.xda-developers.com/showthread.php?t=1513490
Ya that thread will be a constant WIP. Its kinda a brain dump, a place to express myself. :rolleyes: Ill be working on network implementation for all this dongle ethernet business. Stop by later if you wanna see what a USB webcam looks like on Xoom :D
 

HuckFinn

Senior Member
Jul 22, 2008
372
83
0
Chicago
Ya that thread will be a constant WIP. Its kinda a brain dump, a place to express myself. :rolleyes: Ill be working on network implementation for all this dongle ethernet business. Stop by later if you wanna see what a USB webcam looks like on Xoom :D
I'll be honest I read through the other thread and it seems way over my head. ;) I will stay tuned and hope for a walk through or someone else to get it working and post what they did.

Thanks for all the hard work!
 

bigrushdog

Inactive Recognized Developer
Apr 23, 2007
3,547
7,244
263
I'll be honest I read through the other thread and it seems way over my head. ;) I will stay tuned and hope for a walk through or someone else to get it working and post what they did.

Thanks for all the hard work!
Come on now :p I was trying to add an element of simplicity. I don't have a mobile data dongle but my ethernet dongle just arrived. Its likely I'll have to write a helper app so android knows where to look for a default data route. The mobile data dongles are definately more tricky. However, I'm always open to somebody sending me a tester.

Edit: read that thread again nice and slow. I'm just getting started. Grasp the concepts laid out and you will be in the 1% club
 
Last edited:

HuckFinn

Senior Member
Jul 22, 2008
372
83
0
Chicago
Come on now :p I was trying to add an element of simplicity. I don't have a mobile data dongle but my ethernet dongle just arrived. Its likely I'll have to write a helper app so android knows where to look for a default data route. The mobile data dongles are definately more tricky. However, I'm always open to somebody sending me a tester.

Edit: read that thread again nice and slow. I'm just getting started. Grasp the concepts laid out and you will be in the 1% club
You do give me too much credit:rolleyes:. I am truly a newbie, just one who has been around a long time and knows how to follow instructions very carefully.

I do get the gist of it and think I could figure out which modules to load for my dongle, which should just be the RNDIS module. Then to route the traffic is where I may need help. I am thinking that if I load the module and then run the script I already have I may be good. A helper app would be pretty cool though, especially if it could load/unload modules as well. ;)

Thanks again.
 

HuckFinn

Senior Member
Jul 22, 2008
372
83
0
Chicago
BRD,

OK I thought I had a clue what I was doing but I ran into some issues. I downloaded the module pack and copied the rndis modules into /system/lib/modules and then tried using modprobe to load these modules. I entered SU into the terminal window to gain permissions first but ran into some errors.


[email protected]:/system/lib/modules # ls
modules.dep.bb rndis_host.ko rndis_wlan.ko scsi_wait_scan.ko
[email protected]:/system/lib/modules # modprobe rndis_host
modprobe: 'rndis_host.ko': invalid module format
[email protected]:/system/lib/modules # modprobe rndis_wlan
modprobe: 'rndis_host.ko': invalid module format
modprobe: 'rndis_wlan.ko': invalid module format
[email protected]:/system/lib/modules #


What am I doing wrong. I will keep the Q&A in this thread to keep the development thread clean.
 

bigrushdog

Inactive Recognized Developer
Apr 23, 2007
3,547
7,244
263
BRD,

OK I thought I had a clue what I was doing but I ran into some issues. I downloaded the module pack and copied the rndis modules into /system/lib/modules and then tried using modprobe to load these modules. I entered SU into the terminal window to gain permissions first but ran into some errors.


[email protected]:/system/lib/modules # ls
modules.dep.bb rndis_host.ko rndis_wlan.ko scsi_wait_scan.ko
[email protected]:/system/lib/modules # modprobe rndis_host
modprobe: 'rndis_host.ko': invalid module format
[email protected]:/system/lib/modules # modprobe rndis_wlan
modprobe: 'rndis_host.ko': invalid module format
modprobe: 'rndis_wlan.ko': invalid module format
[email protected]:/system/lib/modules #


What am I doing wrong. I will keep the Q&A in this thread to keep the development thread clean.
You gotta flash the kernel. Just delete the modules you don't need from the zip.
 

HuckFinn

Senior Member
Jul 22, 2008
372
83
0
Chicago
You gotta flash the kernel. Just delete the modules you don't need from the zip.
OK I flashed the kernel and then loaded the two rndis modules. I assume they loaded fine as there was no error message. I then plugged in my 4g dongle, waited for it to connect and then tried running the same script I had before and I get the exact same output as before with the RTNETLINK error.

Any suggestions? Thanks again for all the effort.

If you were not so far away I would let you play with the dongle if that would help.
 

zerox981

Member
Feb 27, 2012
23
2
0
I am trying too (for days) to get my Huawei 3g k4605 dongle to work with no success so far.
I am using teameos wingray nightly 79 with development overlay2 and Tiamat 3.0.5 Kernel Driver Module Pack rev 4 (all the modules loaded atm - I know i should unload/delete some.. :)).

When i plug the dongle in lsusb says
Code:
Bus 001 Device 001: ID 1d6b:0002
Bus 002 Device 001: ID 1d6b:0002
Bus 002 Device 002: ID 12d1:14c1
dmesg says
Code:
[17421.610840] usb 2-1: new high speed USB device number 2 using tegra-ehci
[17421.644348] qtouch_force_calibration: Forcing calibration
[17421.645470] usb 2-1: New USB device found, idVendor=12d1, idProduct=14c1
[17421.645981] usb 2-1: New USB device strings: Mfr=3, Product=2, SerialNumber=0
[17421.646259] usb 2-1: Product: Vodafone Mobile Broadband (Huawei)
[17421.646743] usb 2-1: Manufacturer: Vodafone Group (Huawei)
[17421.666613] scsi98 : usb-storage 2-1:1.0
[17421.675956] do_cmd_proc_msg: Self-calibration started.
[17421.700831] scsi99 : usb-storage 2-1:1.1
[17422.672888] scsi 98:0:0:0: CD-ROM            Vodafone CD ROM (Huawei)  2.31 PQ: 0 ANSI: 2
[17422.713570] scsi 99:0:0:0: Direct-Access     Vodafone Storage (Huawei)      PQ: 0 ANSI: 2
[17422.725825] sd 99:0:0:0: [sda] Attached SCSI removable disk
If I let the dongle for a while(5-10 minutes) it sometimes changes mode to 12d1:1003 (but it should be 12d1:14c6) and /dev/ttyUSB0 and /dev/ttyUSB1 apear.
But if I can't get pppd to work with this modem. When I do
Code:
cat /dev/ttyUSB0 & echo AT > /dev/ttyUSB0
or
cat /dev/ttyUSB1 & echo AT > /dev/ttyUSB1
I don't get an "OK" .. just an integer that is incrementing on every call.

example:
Code:
sh-4.1# cat /dev/ttyUSB0 & echo AT > /dev/ttyUSB0
32262
sh-4.1# cat /dev/ttyUSB0 & echo AT > /dev/ttyUSB0
32270
lsusb:
Code:
Bus 001 Device 001: ID 1d6b:0002
Bus 002 Device 001: ID 1d6b:0002
Bus 002 Device 022: ID 12d1:1003
thats the dmesg (it says device number 21.. so it did reset 20times ?)
Code:
[18234.844970] usb 2-1: USB disconnect, device number 21
[18234.869090] done.
[18234.871706] suspend: exit suspend, ret = 0 (2012-03-04 16:58:09.688346000 UTC)
[18234.872010] active wake lock wlan_wake
[18234.872484] suspend: abort suspend
[18235.241762] usb 2-1: new high speed USB device number 22 using tegra-ehci
[18235.282078] usb 2-1: New USB device found, idVendor=12d1, idProduct=1003
[18235.282596] usb 2-1: New USB device strings: Mfr=3, Product=2, SerialNumber=0
[18235.283085] usb 2-1: Product: HUAWEI Mobile
[18235.283351] usb 2-1: Manufacturer: Huawei Technologies
[18235.291546] option 2-1:1.0: GSM modem (1-port) converter detected
[18235.296161] usb 2-1: GSM modem (1-port) converter now attached to ttyUSB0
[18235.299262] option 2-1:1.1: GSM modem (1-port) converter detected
[18235.302053] usb 2-1: GSM modem (1-port) converter now attached to ttyUSB1
I can attach the 1mb dmesg if it helps.

If i do a mode switch with usb_modeswitch to 12d1:14c6 the ttyUSB0 device doesn't appear.
The mode should be 12d1:14c6 because that's the same mode windows is using.
Then I thought the message usb_modeswitch is using is wrong and logged the messages using usbsnoop, but can't realy find out the right message *sigh*

When using usb_modeswitch to switch to 12d1:14c6 dmesg says
Code:
[18634.093870] suspend: exit suspend, ret = -16 (2012-03-04 17:19:14.549901000 UTC)
[18634.122973] usb 2-1: new high speed USB device number 36 using tegra-ehci
[18634.159122] usb 2-1: New USB device found, idVendor=12d1, idProduct=14c6
[18634.159629] usb 2-1: New USB device strings: Mfr=4, Product=3, SerialNumber=0
[18634.160191] usb 2-1: Product: Vodafone Mobile Broadband (Huawei) 
[18634.160486] usb 2-1: Manufacturer: Vodafone Group (Huawei) 
[18635.042872] wake lock wlan_rx_wake, expired
[18635.052286] suspend: enter suspend
/proc/bus/usb/devices
Code:
T:  Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 36 Spd=480  MxCh= 0
D:  Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=12d1 ProdID=14c6 Rev= 0.00
S:  Manufacturer=Vodafone Group (Huawei)
S:  Product=Vodafone Mobile Broadband (Huawei)
C:* #Ifs= 5 Cfg#= 1 Atr=c0 MxPwr=500mA
A:  FirstIf#= 3 IfCount= 2 Cls=02(comm.) Sub=00 Prot=00
I:* If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=01 Prot=31 Driver=(none)
E:  Ad=81(I) Atr=03(Int.) MxPS=  64 Ivl=2ms
E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=4ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=32 Driver=(none)
E:  Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=4ms
I:* If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=33 Driver=(none)
E:  Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=4ms
I:* If#= 3 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=01 Prot=39 Driver=(none)
E:  Ad=85(I) Atr=03(Int.) MxPS=  64 Ivl=2ms
I:* If#= 4 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=38 Driver=(none)
E:  Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=4ms
but no modem at /dev/ttyUSBx
 
Last edited:

zerox981

Member
Feb 27, 2012
23
2
0
I think I am finally getting somewhere. Seems like option doesn't know my device so I added it:
Code:
echo "12d1 14c6" >/sys/bus/usb/drivers/option/module/drivers/usb-serial:option1/new_id
Now /dev/ttyUSB0 and /dev/ttyUSB1 get created after using usb_modeswitch :).

cat /dev/ttyUSB0 & echo AT > /dev/ttyUSB0 returns OK
 

bigrushdog

Inactive Recognized Developer
Apr 23, 2007
3,547
7,244
263
Dude, that was truly one of the most intelligent posts I've seen in a long time. You've restored my faith :D. Now just write a daemon to listen for your dongle, a lib for namespace, and an app to configure :p
 

zerox981

Member
Feb 27, 2012
23
2
0
:D thanks brd.
I think that's about as far as my knowledge goes for now. Maybe if I took a month from work I could do it...(linux programming is not my domain):)

For today I'm satisfied with manually (script manager^^) switching modes & running scripts to get my 3g dongle working.
Don't know why pppd isn't switching the defaultroute and says
Could not determine remote IP address: defaulting to 10.64.64.64
so I just call
Code:
/system/xbin/route del default
/system/xbin/route del default 
/system/xbin/route add default gw $IPREMOTE dev ppp0
in the /etc/pppd/ip-up script

It's doesn't look best but it works.
 

gnet26

New member
Mar 6, 2012
4
2
0
BRD,

I have an Option Velocity ATT USB air card. The card is identified, and when I go to switch the cards mode to data mode using usb_modeswitch, it locks up my Xoom then it reboots. Any ideas?


Thanks,
gnet26
 

bigrushdog

Inactive Recognized Developer
Apr 23, 2007
3,547
7,244
263
Could anyone link the steps to do it?
I saw bigrushdog saying that its possible, but didnt see any link.
From the way it looks, there's no one way to do this. I don't have a data dongle so I'm just going off what these guys are posting. Just read the thread then read it again.

BRD,

I have an Option Velocity ATT USB air card. The card is identified, and when I go to switch the cards mode to data mode using usb_modeswitch, it locks up my Xoom then it reboots. Any ideas?


Thanks,
gnet26
Sounds similar to the rndis_host tether lockup. Post up a logcat and dmesg of the reboot.
 

dimm2k

New member
Mar 19, 2012
1
0
0
Need for help or suggestion

Hi!
I have MZ604 and modem ZTE MF100 through OTG cable. How i can make it work? What kind of ROM helps to me? I have installed unoficial cyanogen 9 but in dmesg can't see anything about modem connection when i plug in the modem in OTG cable. Please help.. and sorry for my bad English.
 

gamming

Member
Jan 8, 2012
26
3
0
:D thanks brd.
I think that's about as far as my knowledge goes for now. Maybe if I took a month from work I could do it...(linux programming is not my domain):)

For today I'm satisfied with manually (script manager^^) switching modes & running scripts to get my 3g dongle working.
Don't know why pppd isn't switching the defaultroute and says
Could not determine remote IP address: defaulting to 10.64.64.64
so I just call
Code:
/system/xbin/route del default
/system/xbin/route del default 
/system/xbin/route add default gw $IPREMOTE dev ppp0
in the /etc/pppd/ip-up script

It's doesn't look best but it works.
well this is how i do it too.
about to be thinking out of the box

i buy a new ainol aurora because of the IPS screen and the capabilities on video that xoom can not handle it.

when i use it i just plug the modem and set the internet APN (Access point names) and booom its work out of the box.

so there must be something we do not have here.
if brb need the firmware i have it. soo u can try something out of this little box here.

the ainol is using android 4.0.3 with mini usb otg cable to modem
aurora is WIFI only.
my xoom is wifi only too.

i did not buy the LTE or 3G version because too expensive and cannot using call function. so why i need that. lol
 

zerox981

Member
Feb 27, 2012
23
2
0
How to get the Vodafone K4605 3G dongle working with xoom

This is the way I get my dongle (Vodafone K4605) working with the latest TeamEOS nightly wingray (84 atm :)).

Tools I use:
WinSCP - http://winscp.net/eng/index.php
SSHdroid - https://play.google.com/store/apps/details?id=berserker.android.apps.sshdroid&hl=en
putty - http://www.chiark.greenend.org.uk/~sgtatham/putty/

1) Download the latest development overlay from this thread:
http://forum.xda-developers.com/showthread.php?t=1513490

2) Delete the drivers you don't need from the zip file. (xoom_dev_overlay_v4.zip\data\local\lib\modules\).
For my needs it's enough to keep only the option.ko and usb_wwan.ko.

3) Flash the dev. overlay.

4) Install pppd, usb_modeswitch and chat binary
Now you need to install pppd, usbmodeswitch and the chat binary the kernel is missing. You can google them or use my 3gdongle.zip file with my configs:).
Run sshdroid so you can ssh to your android device (or use adb shell etc.).
Connect to your andrid device with putty.
Then run
Code:
sysrw
so you can write to your system folder.
Copy the contents of the zip file in the root folder using WinSCP.
Add the execute permission on
/system/xbin/chat
/system/xbin/usb_modeswitch
/system/bin/pppd
/system/etc/ppp/ip-up
/system/etc/ppp/ip-down
(using WinSCP or with chattr via ssh)

5) Plug the dongle to your windows machine & using Vodafone windows application disable pin authentication. (You can let it enabled but you have to modify the gprs-connect-chat i guess).

6) Disable the CD-ROM mode (I think it's not required because we are using usb_modeswitch, but i did it a long time ago and I'm too lazy to enable it back:D).
Under Control Panel->Phone and Modem look in the Modems tab. There should be the COM port written in the "Attached To" column.
Using putty & connection type serial connect to your modem and disable the CD-ROM mode using the command
Code:
AT^SETPORT="A1;1,2,3"
You can also check if your modem is responding with the AT command (it should write back OK).
Using te ATI command you should get the modem information back.
ex:
Code:
Manufacturer: Vodafone (Huawei)
Model: K4605
Revision: 11.113.21.00.11
IMEI: 353148040378952
+GCAP: +CGSM,+DS,+ES

OK
7) Plug the modem into your android device. You can check if the necessary moodules are loaded with lsmod:
Code:
sh-4.1# lsmod
option 13380 0 - Live 0xbf016000
usb_wwan 8789 1 option, Live 0xbf00d000
8) Check the dmesg or use lsusb to get your devices vendor and product id
dmesg>
Code:
[ 1903.631599] usb 2-1: new high speed USB device number 3 using tegra-ehci
[ 1903.689362] usb 2-1: New USB device found, idVendor=12d1, idProduct=14c1
[ 1903.689606] usb 2-1: New USB device strings: Mfr=3, Product=2, SerialNumber=0
[ 1903.689739] usb 2-1: Product: Vodafone Mobile Broadband (Huawei)
[ 1903.689970] usb 2-1: Manufacturer: Vodafone Group (Huawei)
[ 1903.695541] scsi1 : usb-storage 2-1:1.0
[ 1904.701649] scsi 1:0:0:0: CD-ROM            Vodafone CD ROM (Huawei)  2.31 PQ: 0 ANSI: 2
lsusb>
Code:
Bus 001 Device 001: ID 1d6b:0002
Bus 002 Device 001: ID 1d6b:0002
Bus 002 Device 003: ID 12d1:14c1
9) Switch usb mode using usb_modeswitch and the config file for your device. In my case it's 12d1:14c1.
Code:
usb_modeswitch  -c /etc/usb_modeswitch.d/12d1_14c1
If the switch was succsessful you should see the correct productid now (in my case 14c6):
Code:
sh-4.1# lsusb
Bus 001 Device 001: ID 1d6b:0002
Bus 002 Device 001: ID 1d6b:0002
Bus 002 Device 005: ID 12d1:14c6
10) optional - K4605 or other unrecognized devices
After the modeswitch you should see your device under /dev/ttyUSB*. But with the K4605 we don't because option.ko doesn't know our device. So we need to call
Code:
echo "12d1 14c6" >/sys/bus/usb/drivers/option/module/drivers/usb-serial:option1/new_id
and our device appears:).

11) check if modem is responding:
Code:
cat /dev/ttyUSB0 & echo AT > /dev/ttyUSB0
You should get an OK.

12) Set the config files. If you installed my 3gdongle.zip file you will find my config files under /system/etc/ppp .
You have to edit the gprs-connect-chat file and the peers/gprs file.
I will not go into detail about this config files. There is a lot of information about it on xda forums and google should be your best friend too ;).

bonus) I use this scripts to enable and disable internet via my 3G dongle using the scriptmanager app (https://play.google.com/store/apps/details?id=os.tools.scriptmanager&hl=en)

01_init3g.sh - Run it after plugging the 3g dongle to your android device (k4605 specific)
Code:
# My modem Vodafone K4605 is unknown to option.ko so we manually add it
# you can delete this line if your modem is recognized by option.ko
echo "12d1 14c6" >/sys/bus/usb/drivers/option/module/drivers/usb-serial:option1/new_id
# switch modes with usb_modeswitch
usb_modeswitch  -c /etc/usb_modeswitch.d/12d1_14c1
02_connect via 3g.sh - Connect to the internet (you have to wait 10-20sec after using init because the modem has to initialize first)
Code:
#!/system/bin/sh
#save old route & primary dns
OLDROUTE=`/system/xbin/netstat -r | /system/xbin/grep default | /system/xbin/awk '{print $2}' | /system/xbin/head -n1`
OLDDNS=`/system/bin/getprop net.dns1` 
/system/xbin/echo $OLDROUTE > /data/ppp/ppp0.route;
/system/xbin/echo $OLDDNS >> /data/ppp/ppp0.route;
# just some logging for debugging. Can be removed :)
/system/bin/log -pw -t zeroxPPPD "OldRoute: $OLDROUTE"
/system/bin/log -pw -t zeroxPPPD "OldDNS: $OLDDNS"

#connect to the internet
pppd call gprs
03_restore wlan.sh - Disconnect the 3g dongle & restore WLAN
Code:
#!/system/bin/sh
# restore the old route & primary dns (you can extend the script to add the secondary dns..
OLDROUTE=`cat /data/ppp/ppp0.route | head -n1`
OLDDNS=`cat /data/ppp/ppp0.route | tail -n1`

/system/bin/setprop "net.dns1" "$OLDDNS"
/system/xbin/route add default gw $OLDROUTE dev wlan0

# delete the settings file
/system/xbin/rm /data/ppp/ppp*.route
 

Attachments

bigrushdog

Inactive Recognized Developer
Apr 23, 2007
3,547
7,244
263
Wow. And there you have it folks. Looks like win to me! Perhaps its possible to build some form of unified solution. I would be happy to assist. Keeping in mind, I don't have a dongle for testing. Also, I have a adhoc solution similar to the above post. However, the situation requires that I consult with folks as the solution is not entirely my work.
 

bigrushdog

Inactive Recognized Developer
Apr 23, 2007
3,547
7,244
263
Actually, somebody mentioned Modding option.c to recognize the dongles. I haven't looked at the source but if anybody has input on this I'm all ears. Also, I'd be happy to add these resources to the overlay. Keeping in mind, the whole purpose of the overlay was to assist in hardware development and feature implementation. Seems to me this dongle work fits right in.