Difference between revisions of "Ericsson F3507g Mobile Broadband Module"

From ThinkWiki
Jump to: navigation, search
(available on T400)
Line 1: Line 1:
 
Even though Ericsson claims that their F3507g MiniPCIe WWAN/GPS card is compartible with Linux, they do not provide any information how to make this card work. Here are some basics:
 
Even though Ericsson claims that their F3507g MiniPCIe WWAN/GPS card is compartible with Linux, they do not provide any information how to make this card work. Here are some basics:
  
* the card will not work without inserted SIM, even the GPS function. If you want to use just GPS, any SIM would work, even if it is not attached to any active account with any GSM provider.
+
* the card will not work without an inserted SIM, even the GPS function. If you want to use just GPS, any SIM would work, even if it is not attached to any active account with any GSM provider.
 
* the card provides USB interface, and is recognized by cdc_acm kernel module
 
* the card provides USB interface, and is recognized by cdc_acm kernel module
 
* it registers three pseudo-TTY's, in my case /dev/ttyACM0, /dev/ttyACM1 and /dev/ttyACM2
 
* it registers three pseudo-TTY's, in my case /dev/ttyACM0, /dev/ttyACM1 and /dev/ttyACM2
 
* the card is controlled by sending AT-commands to one of it's pseudo-TTY's
 
* the card is controlled by sending AT-commands to one of it's pseudo-TTY's
* it applears that all three TTY's are identical. So, for example, we can use /dev/ttyACM0 for broadband 3G, /dev/ttyACM1 for controlling the card via AT-commands, and /dev/ttyACM2 for GPS, or in any other order.
+
* it applears that all three TTY's have identical funcionality. So, for example, we can use /dev/ttyACM0 for broadband 3G, /dev/ttyACM1 for controlling the card via AT-commands, and /dev/ttyACM2 for GPS, or in any other order.
  
==Activating the card==
+
==Turning the card on==
Before the card can be used, you have to activate it. It is done by sending  
+
Before the card can be used, you have to turn it on. It is done by sending  
  
 
  AT+CFUN=1
 
  AT+CFUN=1
Line 16: Line 16:
 
  OK
 
  OK
  
You can do it with any terminal terminal program like "minicom", or using "cu" in "expect" script as [http://redmonk.com/sogrady/2008/09/24/apone/ here]. But we are not done yet. If you SIM is protected by a PIN-code, we may have to unlock it. This is done by sending
+
You can do it with any terminal terminal program like "minicom". But we are not done yet. If you SIM is protected by a PIN-code, we may have to unlock it. This is done by sending
  
 
  AT+CPIN="YOUR-PIN"
 
  AT+CPIN="YOUR-PIN"
  
to /dev/ttyACM1. If your SIM is not protected by a PIN-code, or it is configured not to require one on connecting to the network, the last command is not necessary. Anyway, your card is not active until it responds with
+
to /dev/ttyACM1. If your SIM is not protected by a PIN-code, or it is configured not to require one on connecting to the network, the last command is not necessary. Anyway, your card cannot be used for communication until it responds with
  
 
  +PACSP0
 
  +PACSP0
Line 35: Line 35:
 
  AT+CFUN=0
 
  AT+CFUN=0
  
to /dev/ttyACM1. Be carefull with the last command. It turns the card completely off, and it will no longer accept any AT-commands before the hard reset (which can be done either by rebooting the computer, or physically removing the power from the card).
+
to /dev/ttyACM1. Be carefull with the last command. It turns the card completely off, and it will no longer accept any AT-commands before the hard reset. To physically reset the card flip the wireless switch off, and then on. You can do the same by sending "0" to "/sys/devices/platform/thinkpad_acpi/wwan_enable" (to turn off) and then "1" to "/sys/devices/platform/thinkpad_acpi/wwan_enable" (to turn on).
On x200 at least, flipping the wireless on/off switch will cause the card to reinitialize and be put back into service, without a reboot.
 
  
 
==Using the card as a wireless modem==
 
==Using the card as a wireless modem==
Once the card is active, we can use it to connect to 3G network in the same way as any GPRS modem. For example to connect to AT&T Wireless network, your wvdial.conf would have to be something like this
+
Once the card is turned on, we can use it to connect to a 3G network in the same way as any GPRS modem. For example to connect to AT&T Wireless network, your wvdial.conf would have to be something like this
  
 
  [Dialer att]
 
  [Dialer att]
Line 49: Line 48:
 
  Password = *
 
  Password = *
  
==Using the card as GPSr==
+
==Using the card as a GPS receiver==
Once the card is active, we can use it to get GPS info via NMEA protocol. First, you have to configure the a few NMEA options. It is done by sending  
+
Once the card is turned on, we can use it to get GPS info via NMEA protocol. First, you have to configure the a few NMEA options. It is done by sending  
  
 
  AT*E2GPSCTL=X,Y,Z
 
  AT*E2GPSCTL=X,Y,Z
Line 79: Line 78:
  
 
==Other thoughts==
 
==Other thoughts==
While "AT+CFUN=*" and "AT+CPIN=*" are pretty standard commands for wireless modems and are well-documented (e.g. [http://www.sics.se/~bg/GC75-AT-Commands-R2A.pdf here] and [http://www.gsm-modem.de/gsm-modem-faq.html here]), it appears that the commands "AT*E2GPSCTL" and "AT*E2GPSNPD" are unique for Ericsson F3507g card. All credit for discovering them goes to N Z who left a comment in this [http://redmonk.com/sogrady/2008/09/24/apone/ thread]. I imagine one could find them via a USB sniffer on a working Windows machine (or a Linux machine with Windows running in a virtual machine). Another way to get them it to try to look for "gps" string in Windows drivers. What is interesting, is that F3507g supports few other AT-commands with "GPS" substring (you can get all supported AT-commands by sending "AT*" to /dev/ttyACM1 after activating it with "AT+CFUN=1").
+
While "AT+CFUN=*" and "AT+CPIN=*" are pretty standard commands for wireless modems and are well-documented (e.g. [http://www.sics.se/~bg/GC75-AT-Commands-R2A.pdf here] and [http://www.gsm-modem.de/gsm-modem-faq.html here]), it appears that the commands "AT*E2GPSCTL" and "AT*E2GPSNPD" are unique for Ericsson F3507g card. All credit for discovering them goes to "N Z" who left a comment in this [http://redmonk.com/sogrady/2008/09/24/apone/ thread]. I imagine one could find them via a USB sniffer on a working Windows machine (or a Linux machine with Windows running in a virtual machine). Another way to get them is to try to look for "gps" string in the Windows drivers. What is interesting, F3507g supports a few other AT-commands with "GPS" substring (you can get all supported AT-commands by sending "AT*" to /dev/ttyACM1 after activating it with "AT+CFUN=1").
  
 
==Scripting everything==
 
==Scripting everything==
 
On my {{X301}} I have a simple script to power up and initialise the 3G device, dial out with wvdial and then power everything down again when I've finished online. This is worth doing because on the {{X301}} running the 3G device increases the power consumption by more than 10% (note: I have not tested how much more power is used if the device is not online and configured in low power mode, but it seems sensible to assume it is more than zero). I am using a UK spec {{X301}} with the supplied Vodafone SIM card. I needed to activate the SIM card on the Vodafone web site before this would work.
 
 
This script works fine on Debian but may require changes for other distributions. This worked up to kernel 2.6.28; with kernels after 2.6.28 the name of the serial devices associated with the 3G device has changed from "/dev/ttyACM" to "/dev/ttyUSB", I have noted changes required below.
 
  
 
First you need to install the "ppp", "sysfsutils" and "wvdial" packages with
 
First you need to install the "ppp", "sysfsutils" and "wvdial" packages with
Line 91: Line 86:
 
  apt-get install ppp wvdial sysfsutils
 
  apt-get install ppp wvdial sysfsutils
  
I use sysfsutils to completely power off the 3G WWAN device on boot, in order to save power. I also power off the bluetooth, disable the white LED in the power button, and instruct the kernel to use the "noop" scheduler for the SSD. Edit /etc/sysfs.conf to look like this:
+
I use sysfsutils to completely power off the F3507g card on boot, in order to save power (this is worth doing because on my {{X301}} running the 3G device increases the power consumption by more than 10%. I have not tested how much more power is used if the device is not online and configured in low power mode, but it reasonable to assume it is more than zero). I also power off the bluetooth, disable the white LED in the power button, and instruct the kernel to use the "noop" scheduler for the SSD. Edit /etc/sysfs.conf to look like this:
  
 
  block/sda/queue/scheduler = noop
 
  block/sda/queue/scheduler = noop
Line 123: Line 118:
 
  Password = *
 
  Password = *
  
If you are using kernel 2.6.28 or later, replace "/dev/ttyACM0" with "/dev/ttyUSB2".
+
If you are using kernel 2.6.28 or later, replace "/dev/ttyACM0" with "/dev/ttyUSB0".
  
 
If you are using a SIM from a mobile provider other than Vodafone UK you may need to change the access point name (APN) in the Init1 string. I found that Vodafone UK uses the APN "Internet" and T-mobile use the APN "general.t-mobile.uk", presumably other providers also use different APN values. AT&T will work using the APN string "ISP.CINGULAR".
 
If you are using a SIM from a mobile provider other than Vodafone UK you may need to change the access point name (APN) in the Init1 string. I found that Vodafone UK uses the APN "Internet" and T-mobile use the APN "general.t-mobile.uk", presumably other providers also use different APN values. AT&T will work using the APN string "ISP.CINGULAR".
Line 136: Line 131:
 
  novjccomp
 
  novjccomp
  
Create a file called "/usr/local/bin/3g-dialup" containing the following:
+
Create a file called "/usr/local/bin/F3507g" containing the following:
  
 
  #!/bin/sh
 
  #!/bin/sh
 
   
 
   
  WWANDEVICE=/dev/ttyACM2
+
  CONTROL_DEVICE=/dev/ttyACM1
+
  GPS_DEVICE=/dev/ttyACM2
  ## Check we have appropriate permissions
 
if [ `whoami` != "root" ]; then
 
    echo Run this script as root
 
    exit 0
 
fi
 
 
   
 
   
  ## Enable the WWAN hardware
+
  powerup_F3507g () {
echo -n "Powering up WWAN device .."
+
        echo -n "Powering up F3507g card.."
echo 1 > /sys/devices/platform/thinkpad_acpi/wwan_enable
+
        echo 1 > /sys/devices/platform/thinkpad_acpi/wwan_enable
while [ ! -c $WWANDEVICE ]; do sleep 0.5; echo -n "."; done
+
        while [ ! -c $CONTROL_DEVICE ]; do sleep 0.5; echo -n "."; done
echo " OK"
+
        echo "done"
 +
}
 
   
 
   
  echo -n "Initialising WWAN modem ..."
+
  turnon_F3507g () {
/usr/sbin/chat -v "" "AT+CFUN=1" "+PACSP0" "AT" "OK" > $WWANDEVICE < $WWANDEVICE
+
        echo -n "Turning on F3507g card..."
echo " OK"
+
        /usr/sbin/chat -v "" "AT+CFUN=1" "+PACSP0" "AT" "OK" > $CONTROL_DEVICE < $CONTROL_DEVICE
 +
        echo "done"
 +
}
 
   
 
   
  echo "Starting PPP -- hit Ctrl+C when finished"
+
  turnoff_F3507g () {
/usr/bin/wvdial 3G
+
        echo -n "Turning off F3507g card..."
 +
        /usr/sbin/chat -v "" "AT+CFUN=4" "OK" > $CONTROL_DEVICE < $CONTROL_DEVICE
 +
        echo "done"
 +
}
 
   
 
   
  echo -n "Shutting down WWAN modem ..."
+
  powerdown_F3507g () {
/usr/sbin/chat -v "" "AT+CFUN=4" "OK" > $WWANDEVICE < $WWANDEVICE
+
        echo -n "Powering down F3507g card.."
  echo " OK"
+
        echo 0 > /sys/devices/platform/thinkpad_acpi/wwan_enable
 +
        while [ -c $CONTROL_DEVICE ]; do sleep 0.5; echo -n "."; done
 +
        echo "done"
 +
  }
 
   
 
   
  ## Disable the WWAN hardware, save power
+
  turnon_GPS () {
echo -n "Powering down WWAN device .."
+
        echo -n "Starting NMEA stream on $GPS_DEVICE..."
echo 0 > /sys/devices/platform/thinkpad_acpi/wwan_enable
+
        /usr/sbin/chat -v "" "AT*E2GPSCTL=1,3,1\r" "OK" "AT*E2GPSNPD\r" "GPGGA" > $GPS_DEVICE < $GPS_DEVICE
while [ -c $WWANDEVICE ]; do sleep 0.5; echo -n "."; done
+
        echo " done"
  echo " OK"
+
  }
  
You'll need to make this script executable with "chmod a+x /usr/local/bin/3g-dialup".
+
Make this script executable with "chmod a+x /usr/local/bin/F3507g". If you want, you can add a line to turnon_GPS() function which will start gpsd daemon on $GPS_DEVICE. If you are using kernel 2.6.28 or later, replace "/dev/ttyACM*" with "/dev/ttyUSB*".
  
If you are using kernel 2.6.28 or later, replace "/dev/ttyACM2" in the script with "/dev/ttyUSB2".
+
Append the following lines to your /etc/network/interfaces file
  
Now I can fire up a 3G connection trivially with "sudo 3g-dialup" in an xterm. Once pppd has acquired an IP address you can use the Internet. Once you're finished simply hit Ctrl+C in the xterm and it will close the PPP session and power down the modem again. It's probably a good idea to shut down the connection in this way before you put the laptop to sleep.
+
iface 3G inet wvdial
 +
pre-up /bin/sh -c ". /usr/local/bin/F3507g; powerup_F3507g; turnon_F3507g"
 +
post-down /bin/sh -c ". /usr/local/bin/F3507g; turnoff_F3507g; powerdown_F3507g"
 +
provider 3G
 +
 +
iface gps inet manual
 +
pre-up /bin/sh -c ". /usr/local/bin/F3507g; powerup_F3507g; turnon_F3507g; turnon_GPS"
 +
post-down /bin/sh -c ". /usr/local/bin/F3507g; turnoff_F3507g; powerdown_F3507g"
  
If the system stays waiting for the device to power up forever check if you are running kernel 2.6.28 or later, you may need to adjust the device names from "/dev/ttyACM*" to "/dev/ttyUSB*" as described above.
+
Now 3G connection could be started in the same way as you start any other connection interface, just by saying "sudo ifup 3G". To shut it down, say "sudo ifdown 3G". Similarly, GPS interface is started by "sudo ifup gps" and turned off by "sudo ifdown gps".
  
 
==Models==
 
==Models==

Revision as of 22:09, 25 January 2009

Even though Ericsson claims that their F3507g MiniPCIe WWAN/GPS card is compartible with Linux, they do not provide any information how to make this card work. Here are some basics:

  • the card will not work without an inserted SIM, even the GPS function. If you want to use just GPS, any SIM would work, even if it is not attached to any active account with any GSM provider.
  • the card provides USB interface, and is recognized by cdc_acm kernel module
  • it registers three pseudo-TTY's, in my case /dev/ttyACM0, /dev/ttyACM1 and /dev/ttyACM2
  • the card is controlled by sending AT-commands to one of it's pseudo-TTY's
  • it applears that all three TTY's have identical funcionality. So, for example, we can use /dev/ttyACM0 for broadband 3G, /dev/ttyACM1 for controlling the card via AT-commands, and /dev/ttyACM2 for GPS, or in any other order.

Turning the card on

Before the card can be used, you have to turn it on. It is done by sending

AT+CFUN=1

to /dev/ttyACM1. The responce should be

OK

You can do it with any terminal terminal program like "minicom". But we are not done yet. If you SIM is protected by a PIN-code, we may have to unlock it. This is done by sending

AT+CPIN="YOUR-PIN"

to /dev/ttyACM1. If your SIM is not protected by a PIN-code, or it is configured not to require one on connecting to the network, the last command is not necessary. Anyway, your card cannot be used for communication until it responds with

+PACSP0

Don't try to do anything until you see it.

Turning the card off

To put the card into energy-saving mode (this is the default), you can send

AT+CFUN=4

to /dev/ttyACM1. To remove all power from the card, send

AT+CFUN=0

to /dev/ttyACM1. Be carefull with the last command. It turns the card completely off, and it will no longer accept any AT-commands before the hard reset. To physically reset the card flip the wireless switch off, and then on. You can do the same by sending "0" to "/sys/devices/platform/thinkpad_acpi/wwan_enable" (to turn off) and then "1" to "/sys/devices/platform/thinkpad_acpi/wwan_enable" (to turn on).

Using the card as a wireless modem

Once the card is turned on, we can use it to connect to a 3G network in the same way as any GPRS modem. For example to connect to AT&T Wireless network, your wvdial.conf would have to be something like this

[Dialer att]
Modem = /dev/ttyACM0
Init1 = AT+CGDCONT=1,"IP","proxy"
Stupid mode = 1
phone= *99#
Username = *
Password = *

Using the card as a GPS receiver

Once the card is turned on, we can use it to get GPS info via NMEA protocol. First, you have to configure the a few NMEA options. It is done by sending

AT*E2GPSCTL=X,Y,Z

to /dev/ttyACM1. Here

  • X can be 0 (NMEA stream turned off) or 1 (NMEA stream turned on)
  • Y can be an integer form 1 to 60, and sets the frequency of how often the card emits the NMEA sentences
  • Z can be 0 (DGPS is turned off) or 1 (DGPS is turned on)

so, to configure the GPSr to update every 5 seconds, and turn DGPS on, you would send

AT*E2GPSCTL=1,5,1

to /dev/ttyACM1. Once the GPSr is configured, we can get the NMEA stream on /dev/ttyACM2 by sending

AT*E2GPSNPD

to /dev/ttyACM2. Once you do that, /dev/ttyACM2 will no longer accept any new AT-commands. But you still can change the the behavior of the NMEA stream by sending the appropriate

AT*E2GPSCTL=X,Y,Z

to /dev/ttyACM1. Now you can read the NMEA stream by saying

cat /dev/ttyACM2

or better yet, start gpsd interface on /dev/ttyACM2.

Other thoughts

While "AT+CFUN=*" and "AT+CPIN=*" are pretty standard commands for wireless modems and are well-documented (e.g. here and here), it appears that the commands "AT*E2GPSCTL" and "AT*E2GPSNPD" are unique for Ericsson F3507g card. All credit for discovering them goes to "N Z" who left a comment in this thread. I imagine one could find them via a USB sniffer on a working Windows machine (or a Linux machine with Windows running in a virtual machine). Another way to get them is to try to look for "gps" string in the Windows drivers. What is interesting, F3507g supports a few other AT-commands with "GPS" substring (you can get all supported AT-commands by sending "AT*" to /dev/ttyACM1 after activating it with "AT+CFUN=1").

Scripting everything

First you need to install the "ppp", "sysfsutils" and "wvdial" packages with

apt-get install ppp wvdial sysfsutils

I use sysfsutils to completely power off the F3507g card on boot, in order to save power (this is worth doing because on my X301 running the 3G device increases the power consumption by more than 10%. I have not tested how much more power is used if the device is not online and configured in low power mode, but it reasonable to assume it is more than zero). I also power off the bluetooth, disable the white LED in the power button, and instruct the kernel to use the "noop" scheduler for the SSD. Edit /etc/sysfs.conf to look like this:

block/sda/queue/scheduler = noop
devices/platform/thinkpad_acpi/bluetooth_enable = 0
devices/platform/thinkpad_acpi/wwan_enable = 0
class/leds/tpacpi::power/brightness = 0

These will now be applied on boot, but when the laptop wakes from sleep the BIOS seems to undo some of these settings, so create a script named "/etc/pm/sleep.d/sysfsutils":

#!/bin/bash
case $1 in
    (hibernate|suspend)
        ;;
    (thaw|resume)
        /etc/init.d/sysfsutils start
        ;;
    *)  echo "somebody is calling me totally wrong."
        ;;
esac

Don't forget to "chmod a+x /etc/pm/sleep.d/sysfsutils". This script will be called when the laptop wakes up and it will power-off the 3G WWAN device again.

Now we need to set up "wvdial" to work with the 3G WWAN device. Edit /etc/wvdial.conf to look like this:

[Dialer 3G]
Modem = /dev/ttyACM0
Init1 = AT+CGDCONT=1,"IP","Internet"
Stupid mode = 1
phone= *99#
Username = *
Password = *

If you are using kernel 2.6.28 or later, replace "/dev/ttyACM0" with "/dev/ttyUSB0".

If you are using a SIM from a mobile provider other than Vodafone UK you may need to change the access point name (APN) in the Init1 string. I found that Vodafone UK uses the APN "Internet" and T-mobile use the APN "general.t-mobile.uk", presumably other providers also use different APN values. AT&T will work using the APN string "ISP.CINGULAR".

Edit /etc/ppp/peers/wvdial to look like this:

noauth
name wvdial
usepeerdns
noccp
novj
novjccomp

Create a file called "/usr/local/bin/F3507g" containing the following:

#!/bin/sh

CONTROL_DEVICE=/dev/ttyACM1
GPS_DEVICE=/dev/ttyACM2

powerup_F3507g () {
        echo -n "Powering up F3507g card.."
        echo 1 > /sys/devices/platform/thinkpad_acpi/wwan_enable
        while [ ! -c $CONTROL_DEVICE ]; do sleep 0.5; echo -n "."; done
        echo "done"
}

turnon_F3507g () {
        echo -n "Turning on F3507g card..."
        /usr/sbin/chat -v "" "AT+CFUN=1" "+PACSP0" "AT" "OK" > $CONTROL_DEVICE < $CONTROL_DEVICE
        echo "done"
}

turnoff_F3507g () {
        echo -n "Turning off F3507g card..."
        /usr/sbin/chat -v "" "AT+CFUN=4" "OK" > $CONTROL_DEVICE < $CONTROL_DEVICE
        echo "done"
}

powerdown_F3507g () {
        echo -n "Powering down F3507g card.."
        echo 0 > /sys/devices/platform/thinkpad_acpi/wwan_enable
        while [ -c $CONTROL_DEVICE ]; do sleep 0.5; echo -n "."; done
        echo "done"
}

turnon_GPS () {
        echo -n "Starting NMEA stream on $GPS_DEVICE..."
        /usr/sbin/chat -v "" "AT*E2GPSCTL=1,3,1\r" "OK" "AT*E2GPSNPD\r" "GPGGA" > $GPS_DEVICE < $GPS_DEVICE
        echo " done"
}

Make this script executable with "chmod a+x /usr/local/bin/F3507g". If you want, you can add a line to turnon_GPS() function which will start gpsd daemon on $GPS_DEVICE. If you are using kernel 2.6.28 or later, replace "/dev/ttyACM*" with "/dev/ttyUSB*".

Append the following lines to your /etc/network/interfaces file

iface 3G inet wvdial
pre-up /bin/sh -c ". /usr/local/bin/F3507g; powerup_F3507g; turnon_F3507g"
post-down /bin/sh -c ". /usr/local/bin/F3507g; turnoff_F3507g; powerdown_F3507g"
provider 3G

iface gps inet manual
pre-up /bin/sh -c ". /usr/local/bin/F3507g; powerup_F3507g; turnon_F3507g; turnon_GPS"
post-down /bin/sh -c ". /usr/local/bin/F3507g; turnoff_F3507g; powerdown_F3507g"

Now 3G connection could be started in the same way as you start any other connection interface, just by saying "sudo ifup 3G". To shut it down, say "sudo ifdown 3G". Similarly, GPS interface is started by "sudo ifup gps" and turned off by "sudo ifdown gps".

Models