[Android Software/Hacking General [Developers Only]] Pinczakko:
Hello all,

My first post here.

Just made a guide after painstakingly "wasting" one day to get my Galaxy 5 to work with Linux USB tethering. Here we go..

======== Samsung Galaxy 5 GT-I5503 USB tethering in Slackware64 Linux with Pppd ===========

Samsung Galaxy 5 (Android 2.1 Eclair) is different from other Android phone in the Galaxy lines of products. It doesn't act like a router by default like its more capable brethren, the Samsung Galaxy S. The problem with setting up this device in Linux is: it has a vendor-specific AT command set to set up the device as a modem.

The following is the summary of the steps to use the Galaxy 5 as a USB modem:

1. Disable "automatic data connection" on the Galaxy 5. Deactivate: Settings | Wireless & networks| Mobile networks | Enable always-on mobile. Activating always-on mobile option will force the phone to use data connection (GPRS/EDGE/3G/HSDPA/HSUPA) whenever no WLAN coverage could be used. In that state, the phone acts as the endpoint of the data connection (usually a PPP connection). Because a PPP login account cannot be used by more than one device at a time in the same network, the PPP connection directly from the phone would effectively "disable" new PPP connection from a computer which uses the phone as a modem to connect. That's why you have to deactivate the always-on mobile option.

2. Prepare the configuration files for Galaxy 5

3. Watch syslog message in your PC/Laptop using the

tail -f /var/log/message

command

4. Connect the Galaxy 5 to your PC/Laptop with the USB cable

5. Choose Kies mode when Galaxy 5 ask for the operating mode

6. Syslog will display the phone as one of the tty device. In my case the device is

ttyACM0

7. Run Pppd by using the tty device in the previous step as the tty device

Among the steps above, the ones which need further explanation are the first and the last steps.

The ISP used in this example is represented by the "indosatm2" string in all of the configuration files.

The configuration file that I use as follows.

The /etc/ppp/options is: (disabled options are not shown)

# /etc/ppp/options
#
# $Id: options,v 1.4 1996/05/01 18:57:04 alvar Exp $
#
# Originally created by Jim Knoble
# Modified for Debian by alvar Bray
# Modified for PPP Server setup by Christoph Lameter
# Modified for Slackware by Pat Volkerding
#
# Use the command egrep -v '#|^ *$' /etc/ppp/options to quickly see what
# options are active in this file.

asyncmap 0
crtscts
lock
modem
proxyarp
lcp-echo-interval 30
lcp-echo-failure 4

The "peers" file (/etc/ppp/peers/im2_galaxy5) used to call the ISP as follows:

/dev/ttyACM0 921600 crtscts
connect 'chat -v -f /etc/ppp/chat/im2_galaxy5_connect_chat'
disconnect 'chat -v -f /etc/ppp/chat/im2_galaxy5_disconnect_chat'
defaultroute name your_login debug noipdefault usepeerdns

The "connect" chat file (/etc/ppp/chat/im2_galaxy5_connect_chat) as follows:

ECHO ON
ABORT 'NO CARRIER'
ABORT 'NO DIALTONE'
ABORT 'ERROR'
ABORT 'NO ANSWER'
ABORT 'BUSY'
'' ATZ
OK 'ATE0V1&D2&C1S0=0'
OK 'ATS7=60'
OK 'ATS0=0'
'' ATZ
OK 'ATE0V1&D2&C1S0=0'
OK 'ATS7=60'
OK 'AT+CGDCONT=1,"IP","indosatm2","",0,0'
OK 'ATDT*99#'
CONNECT
~ ''

The "disconnect" chat file (/etc/ppp/chat/im2_galaxy5_disconnect_chat) as follows:

ECHO ON
ABORT 'BUSY'
ABORT 'ERROR'
ABORT 'NO DIALTONE'
SAY "\nSending break to the modem\n"
"" "\K"
"" "\K"
"" "\K"
"" "\d\d+++\d\dATH"
SAY "\nPDP context detached\n"

The "connect" chat file is used to setup the Galaxy 5 (modem) to connect to the ISP while the "disconnect" chat file is used to "reset" the Galaxy 5 (modem) after the connection is closed.

The PAP secret file (/etc/ppp/pap-secrets) as follows:

# Secrets for authentication using PAP
# client server secret IP addresses
your_login * your_password *

Perhaps you're asking where did I found the Samsung Galaxy 5-specific AT command-set shown in the chat file above. I found it in the modem log file in Windows when running tethering with Samsung Kies application. This is the log file in C:\Windows\ModemLog_SAMSUNG Android USB Modem.txt

10-23-2010 03:18:58.312 - File: C:\WINDOWS\system32\tapisrv.dll, Version 5.1.2600
10-23-2010 03:18:58.312 - File: C:\WINDOWS\system32\unimdm.tsp, Version 5.1.2600
10-23-2010 03:18:58.312 - File: C:\WINDOWS\system32\unimdmat.dll, Version 5.1.2600
10-23-2010 03:18:58.312 - File: C:\WINDOWS\system32\uniplat.dll, Version 5.1.2600
10-23-2010 03:18:58.328 - File: C:\WINDOWS\system32\drivers\modem.sys, Version 5.1.2600
10-23-2010 03:18:58.328 - File: C:\WINDOWS\system32\modemui.dll, Version 5.1.2600
10-23-2010 03:18:58.328 - File: C:\WINDOWS\system32\mdminst.dll, Version 5.1.2600
10-23-2010 03:18:58.328 - Modem type: SAMSUNG Android USB Modem
10-23-2010 03:18:58.328 - Modem inf path: oem30.inf
10-23-2010 03:18:58.328 - Modem inf section: SAMSUNG.Install
10-23-2010 03:18:58.328 - Matching hardware ID: usb\vid_04e8&pid_689e&mi_00&os_nt
10-23-2010 03:18:58.343 - 921600,8,N,1, ctsfl=0, rtsctl=1
10-23-2010 03:18:58.343 - Initializing modem.
10-23-2010 03:18:58.343 - DSR is low while initializing the modem. Verify modem is turned on.
10-23-2010 03:18:58.343 - CD is high while initializing modem.
10-23-2010 03:18:58.359 - Send: AT
10-23-2010 03:18:58.359 - Recv: AT
10-23-2010 03:18:58.359 - Command Echo
10-23-2010 03:18:58.359 - Recv: OK
10-23-2010 03:18:58.359 - Interpreted response: OK
10-23-2010 03:18:58.359 - Send: ATE0V1&D2&C1S0=0
10-23-2010 03:18:58.359 - Recv: ATE0V1&D2&C1S0=0
10-23-2010 03:18:58.359 - Command Echo
10-23-2010 03:18:58.359 - Recv: OK
10-23-2010 03:18:58.359 - Interpreted response: OK
10-23-2010 03:18:58.375 - Send: ATS7=60
10-23-2010 03:18:58.375 - Recv: OK
10-23-2010 03:18:58.375 - Interpreted response: OK
10-23-2010 03:18:58.375 - Waiting for a call.
10-23-2010 03:18:58.390 - Send: ATS0=0
10-23-2010 03:18:58.390 - Recv: OK
10-23-2010 03:18:58.390 - Interpreted response: OK
10-23-2010 03:18:58.390 - 921600,8,N,1, ctsfl=1, rtsctl=2
10-23-2010 03:18:58.390 - Initializing modem.
10-23-2010 03:18:58.390 - DSR is low while initializing the modem. Verify modem is turned on.
10-23-2010 03:18:58.390 - CD is high while initializing modem.
10-23-2010 03:18:58.406 - Send: AT
10-23-2010 03:18:58.406 - Recv: OK
10-23-2010 03:18:58.406 - Interpreted response: OK
10-23-2010 03:18:58.406 - Send: ATE0V1&D2&C1S0=0
10-23-2010 03:18:58.406 - Recv: OK
10-23-2010 03:18:58.406 - Interpreted response: OK
10-23-2010 03:18:58.421 - Send: ATS7=60
10-23-2010 03:18:58.421 - Recv: OK
10-23-2010 03:18:58.421 - Interpreted response: OK
10-23-2010 03:18:58.421 - Dialing.
10-23-2010 03:18:58.437 - Send: ATDT*###
10-23-2010 03:19:01.468 - Recv: CONNECT 115200
10-23-2010 03:19:01.468 - Interpreted response: Connect
10-23-2010 03:19:01.468 - Connection established at 115200bps.
10-23-2010 03:19:01.468 - Error-control off or unknown.
10-23-2010 03:19:01.468 - Data compression off or unknown.
10-23-2010 03:19:31.468 - Read: Total: 3711, Per/Sec: 122, Written: Total: 3553, Per/Sec: 117
10-23-2010 03:21:31.468 - Read: Total: 994835, Per/Sec: 8259, Written: Total: 83780, Per/Sec: 668

A note about the the chat configuration file

Anyway, perhaps what is not so clear in the chat file is the "~" character in the last line. It actually tells the chat script to expect a "~" (tilde) as a response after the serial connection with the remote PPP endpoint is established.

The following excerpt from PPP-HOWTO explain about it.

Another thing in the chat script is: Samsung Galaxy 5 will emit a "CONNECT" string when the serial connection is established with the remote endpoint.