Using a Sprint PCS Connection Card (Novatel Merlin S620) On Linux

From Nearline Storage
Jump to: navigation, search

Particpants in the "S&D Sprint/Wireless Productivity Tools" program recently received an upgraded Sprint PCS Connection Card. We received a Novatel Merlin S620 card to replace our Novatel Merlin C201 cards. This new card implements the 1xEV-DO communications standard. In locations where Sprint provides Mobile Broadband service this card can support very high speed connections. Those locations are very limited however and outside of Mobile Broadband coverage areas the card supports connection speeds that are the same as our old cards. In Mobile Broadband coverage areas Sprint says that the new cards will operate at average download speeds between 400 to 700 Kbps with peak rates up to 2 Mbps. Outside of those areas Sprint says the cards will operate at average download speeds between 40 to 70 Kbps with peak rates up to 144 Kbps.

Sprint ships the Merlin S620 with Windows software and drivers. I use Linux and there is no official Linux support. These notes are about how I got this card working on Linux, specifically on my ThinkPad X31 running Fedore Core 3. (Later on these same instructions worked for my ThinkPad Z60m running Fedora Core 4.)

My new Merlin S620 was not activated when I received it. Although it would have been sufficient to have just called the activation phone number provided and given the operator the number off the back of the card, I did go ahead and install Sprint's Windows software from the CD onto a Windows system and activate the card following the procedure in the booklet that came with the card. It took several hours for activation to be completed and for the card to start working. Once it worked on Windows I moved it over to my Linux laptop.

The Merlin S620 emulates two USB serial ports. The first of these provides a serial modem interface through which I set up a PPP session with Sprint's network. The second is a control channel that I ignore in my setup. Fedora Core 3 does not automatically insert the usbserial module when the card is inserted in the system nor does it create the device nodes. These steps must be done manually. Here's what I did to set up my system to use this card:

Create /etc/ppp/peers/evdo:

/dev/ttyUSB0
230400
lock
crtscts
defaultroute
debug
persist
usepeerdns
noauth
connect '/usr/sbin/chat -v -f /etc/ppp/chat-evdo'

Create /etc/ppp/chat-evdo:

'' 'AT'
'OK' 'ATE0V1&F&D2&C1&C2S0=0'
'OK' 'ATE0V1'
'OK' 'ATS7=60'
'OK' 'AT+CSQ;ATDT#777'
'CONNECT'

The “AT+CSQ” command above outputs the signal strength to the system log where my toggleEVDO script below collects it and displays it.

Create /etc/ppp/ip-up.local:

#!/bin/bash

## Insert nameservers into /etc/resolv.conf

if [ -n "${USEPEERDNS}" ]; then
  sudo mv -f /etc/resolv.conf /etc/resolv.save
  sudo rm -f /tmp/resolv.conf
  echo "; set up by /etc/ppp/ip-up.local">/tmp/resolv.conf
  echo "domain localdomain">>/tmp/resolv.conf
#  echo "nameserver ${DNS1}">>/tmp/resolv.conf
#  echo "nameserver ${DNS2}">>/tmp/resolv.conf
# Use local caching nameserver
  echo "nameserver 127.0.0.1">>/tmp/resolv.conf
  sudo mv -f /tmp/resolv.conf /etc/resolv.conf
  sudo chmod 744 /etc/resolv.conf
fi

I use a caching nameserver on my local machine to speed up name resolution. I don't describe how to set up that nameserver here. If you prefer not to do this and to use Sprint's nameservers instead, simply swap the commented/uncommented nameserver lines in the script above and comment out the three lines in the script below that stop and start the “named” service.

I created ~/bin/toggleEVDO as a script I can execute to start and stop an EVDO connection. It is assigned to an icon on my task bar.

#!/bin/sh

# Start/Stop Merlin S620 EV-DO connection

PID=`sudo /sbin/pidof pppd`
if [[ -z ${PID} ]]; then

	/usr/X11R6/bin/xmessage -center -timeout 3 \
	  "Starting EV-DO connection" &

	# Stop any running nameserver
	sudo /sbin/service named stop >/dev/null 2>/dev/null

	# Insert the usbserial module
	sudo /sbin/modprobe -s usbserial vendor=0x1410 product=0x1110

	# Create the associated device nodes
	if [[ ! -c /dev/ttyUSB0 ]]; then
		sudo mknod /dev/ttyUSB0 c 188 0
	fi
	if [[ ! -c /dev/ttyUSB1 ]]; then
		sudo mknod /dev/ttyUSB1 c 188 1
	fi

	# Connect
	sudo /usr/sbin/pppd call evdo

	# Wait for connection to come up
	while [[ ! `/sbin/ifconfig | grep [p]pp0` ]]; do
		sleep 1
	done

	# Start up a local caching nameserver
	sudo /sbin/service named start >/dev/null 2>/dev/null

	# Tell them we're running
	ADDR=`/sbin/ifconfig ppp0 | grep "inet addr:" | awk '{print $2}' \
	  | awk -F : '{print $2}'`
        for VAL in `sudo grep -A 6 "AT+CSQ" /var/log/messages | grep ", 99^M" | cut -d: -f 4 | cut -d, -f 1`; do
	  	QUAL="${VAL}"
	done
	/usr/X11R6/bin/xmessage -center -timeout 5 \
	  "EV-DO connection started with ${ADDR}, quality = ${QUAL}/31" &
else
	#  EVDO is running, ask them if they want to stop
	ADDR=`/sbin/ifconfig ppp0 | grep "inet addr:" | awk '{print $2}' \
	  | awk -F : '{print $2}'`
	/usr/X11R6/bin/xmessage -center -buttons "Yes:1,No:0" "EV-DO connection is up, using $ADDR.  Do you want to stop it?"
        if (( $? == 1 )); then

		# Stop any running nameserver
		sudo /sbin/service named stop >/dev/null 2>/dev/null

		# Stop the adapter
		for PID in `sudo /sbin/pidof pppd`; do
			while `sudo kill -s 0 ${PID} 2>/dev/null`; do
				sudo kill -s SIGTERM ${PID} &>/dev/null
				sleep 2
			done
		done
	fi
fi

If you need to do some troubleshooting, pppd does produce syslog output messages. The chat portion of the session will be output to /var/log/messages. This shows the results of the commands in the /etc/ppp/chat-evdo file above. Because I included the "debug" option in the /etc/ppp/peers/evdo file, session setup debugging messages are also logged through syslog with facility "daemon" and level "debug." This information can be directed to a file so that you can monitor it by setting up /etc/syslog.conf appropriately (see "man syslog.conf").