GSM/GPRS

From ArmadeusWiki
Revision as of 08:47, 26 January 2012 by Salocin68 (Talk | contribs)

Jump to: navigation, search

This page will summarize informations to use the GSM/GPRS/3G module of the APF27Wireless board and the APF51Dev (optional).

Introduction

GSM/GPRS are generally driven through the RS-232 bus. AT commands are used to dialog with the module.

  • GSM MODEM of the APF27Wireless extension board (APW) is connected to the UART2 (/dev/ttySMX1) of the APF27.
  • GSM/3G MODEM of the APF51Dev is connected to the i.MX processor through an UART implemented in the FPGA. So the corresponding bitfile has to loaded before trying to access the MODEM.

Both are using a Sagem's Hilo module. Hilo AT commands can be found here

Linux configuration (APF27Dev only)

  • Linux will have to be configured in order to tell that an APW is connected to your APF27Dev:
$ make linux26-menuconfig
System Type  --->
    Freescale MXC Implementations  --->
            ...
            Extension board (Wireless (APW))  --->
       [*] GSM/GPRS Modem (NEW)
       [ ] Bluetooth & WiFi module (NEW)
       [ ] CSI (Camera) pass-through (NEW)
       [ ] GPS module (NEW)
$ make linux26
  • reflash you Linux kernel

Usage

Configure serial port

APF27

# export GSM_DEVICE=/dev/ttySMX1              (or /dev/ttymxc1 on recent kernels)
# stty -F $GSM_DEVICE raw -echo -echoe -echok 115200

APF51Dev

  • Don't forget to put "Wireless" jumper J42 on your APF51Dev (near microSD connector) AND power on FPGA Bank 3 (with corresponding jumper J39).
  • On APF51Dev, GSM/3G module is accessed through serial ports synthetized in APF51's FPGA. So we have to load it first. (Needed dual UARTs FPGA firmware can be found under armadeus-4.0 distribution in firmware/pod_scripts directory, with the POD script needed to regenerate it, and is by default installed in rootfs).
# load_fpga /lib/firmware/fpga/apf51_gsm_gps_firmware.bin

Once firmware loaded, drivers related to FPGA can be used :

# modprobe irq_ocore
# modprobe 8250
Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
# modprobe twin_uarts_irq_mng
# modprobe twin_uarts_16750
serial8250.0: ttyS0 at MMIO 0xb8000020 (irq = 320) is a TI16750
serial8250.0: ttyS1 at MMIO 0xb8000040 (irq = 321) is a TI16750

Bring MODEM out of reset state (POK_IN/PWON pin, connected to PMIC GPIO6):

# modprobe wm831x-gpio
# echo 245 > /sys/class/gpio/export
# echo out > /sys/class/gpio/gpio245/direction
# echo 1 > /sys/class/gpio/gpio245/value
  • Configure serial port:
# ls /dev/ttyS*
/dev/ttyS0  /dev/ttyS1  /dev/ttyS2  /dev/ttyS3
  • If the /dev/ttyS[0-1] files don't exist, create it/them with mknod :
# mknod /dev/ttyS0 c 4 64
# mknod /dev/ttyS1 c 4 65

Then :

# export GSM_DEVICE=/dev/ttyS0
# stty -F $GSM_DEVICE raw -echo -echoe -echok 115200

AT commands

# cu -l $GSM_DEVICE

( To exit cu you will have to type ~. )

  • Check module presence:
ATI3
SAGEM HiC,A.005.00

OK
Note Note: By default, for Hilo v2 module, no echo are printed on serial console. Then you can't see what you type.

To reactivate the echo, use:

ATE1


Note Note: By default, the module starts in auto baudrate. This mays result in loss of communication with baud rate higher than 19200Kbds. To avoid problems, the baud rate has to be fixed:
AT+IPR=115200


  • Get constructor name:
AT+CGMI
SAGEM

OK
  • Get model name:
AT+CGMM
HILO GPRS

OK
  • Enter PIN code (here 0000). !! Use your own and beware that you will only get 3 tries !!:
AT+CPIN="0000"

OK
  • Check PIN code status:
AT+CPIN?
+CPIN: READY

OK
Note Note: Don't launch further AT commands if PIN code wasn't entered successfully


  • Check module status (0 Ready, 1 Unavailable, 2 Status unknown, 3 Ringing, 4 Call in progress, 5 Asleep):
AT+CPAS
+CPAS: 0

OK
  • Get Indicator control (<battchg>[0-4],<signal>[0-4],<service>0/1,<message>0/1,<call>0/1,<smsfull>0/1):
AT+CIND?
+CIND: 0,4,1,0,0,0,1

OK
  • Get signal quality (should be better than 12/99):
AT+CSQ
+CSQ: 24,99

OK
  • Voice call "123456789" (; is important here to signify a voice call, otherwise a data call is tried and may fail if you don't have the right subscribe)
ATD"123456789";
OK
  • Terminate current call:
ATH
OK

Tools to look at

Data tranfers (EDGE/3G)

PPP installation (done by default on APF51)

$ make linux26-menuconfig
Device Drivers  --->
    [*] Network device support  --->
        <M>   PPP (point-to-point protocol) support
        [ ]     PPP multilink support (EXPERIMENTAL)
        [ ]     PPP filtering
        <M>     PPP support for async serial ports
        < >     PPP support for sync tty ports
        < >     PPP Deflate compression
        < >     PPP BSD-Compress compression
        < >     PPP MPPE compression (encryption) (EXPERIMENTAL)
        < >     PPP over Ethernet (EXPERIMENTAL)
$ make menuconfig
Package Selection for the target  --->
    Networking applications  --->
        [*] pppd
        [ ]   filtering
        [ ]   radius
$ make linux26 && make
  • reflash kernel & rootfs

PPP configuration

Note Note: Following instructions are given for the French operator "Bouygtel" and may need to be ajusted accordingly, depending on your operator/country


  • Create a "chat" script that will be used to initiate MODEM dialup (here we use the "cat > xxxx << EOF trick" to automatically create the file, but you can also manually edit it with vi or nano):
# mkdir -p /etc/chatscripts/
# cat > /etc/chatscripts/bouygtel <<EOF
ABORT BUSY ABORT 'NO CARRIER' ABORT VOICE ABORT 'NO DIALTONE' ABORT 'NO ANSWER' ABORT DELAYED ABORT ERROR
'' AT
OK AT+IPR=115200
OK ATE1
OK AT+CPIN="0000"
OK AT+CFUN=1
OK AT+COPS?
OK AT+CSQ
OK 'AT+CGDCONT=1,"IP","ebouygtel.com","",0,0'
OK 'AT&FE0Q0V1'
OK 'ATD*99#'
CONNECT ""
EOF
  • Don't forget to set the baudrate (default: 115200) to have a stable communication between the modem and the processor
  • Don't forget to update "AT+CPIN=" with your real PIN code and "AT+CGDCONT" and "ATD*99#" with your operator parameters.
  • If you want to test your chat script (verbose mode -v, on console -s, with 5 second timeout by default for commands -t 5), then launch:
# /usr/sbin/chat -v -s -t 5 -f /etc/chatscripts/bouygtel > $GSM_DEVICE < $GSM_DEVICE
  • If this test was OK, you may have to poweroff/poweron the MODEM to bring it to its initial state and go further.

For APF51

  • create the PPPd config files (/etc/ppp/peers/bouygtel and /etc/ppp/options.ttyS0):
# mkdir -p /etc/ppp/peers/
# cat > /etc/ppp/peers/bouygtel <<EOF
noauth
connect "/usr/sbin/chat -v -t 5 -f /etc/chatscripts/bouygtel"
debug
ttyS0
defaultroute
noipdefault
usepeerdns
EOF

# cat > /etc/ppp/options.ttyS0 <<EOF
115200
EOF

For APF27

Note Note: Check if /dev/ttySMX1 exists, if not create it with :
mknod /dev/ttySMX1 c 204 42
  • create the PPPd config files (/etc/ppp/peers/bouygtel and /etc/ppp/options.ttySMX1):
# mkdir -p /etc/ppp/peers/
# cat > /etc/ppp/peers/bouygtel <<EOF
noauth
connect "/usr/sbin/chat -v -t 5 -f /etc/chatscripts/bouygtel"
debug
ttySMX1
defaultroute
noipdefault
usepeerdns
EOF

# cat > /etc/ppp/options.ttySMX1 <<EOF
115200
EOF

PPP Usage

  • Load PPP module:
# modprobe ppp          (APF27)
or
# modprobe ppp_async    (APF51)
  • Setup serial port name depending on your platform (/dev/ttyS0 on APF51, /dev/ttySMX1 on APF27)
# export GSM_DEVICE=/dev/ttyS0
or
# export GSM_DEVICE=/dev/ttySMX1
  • Launch the beast:
# pppd $GSM_DEVICE 115200 call bouygtel
  • Might be needed after a successful IP setup:
# cp /etc/ppp/resolv.conf /etc/resolv.conf
# route add default ppp0     (due to defaultroute option in ppp ?)

Test

# ping www.google.fr

Troubleshots

  • To see what happened after having launched pppd or chat:
# tail -f /var/log/messages

Links