-
How to physically connect an LTE modem to Intel Galileo.
-
How to make Intel Galileo communicate with and configure the modem to camp in your preferable carrier provider.
-
How to create a network adaptor in the Linux userspace context to make the data change possible.
http://www.3gpp.org/DynaReport/27007.htm
.An Introduction to XMM7160 and XMM7260
Feature | XMM 7160 | XMM 7260 |
---|---|---|
Launch year | 2013 | 2014 |
LTE category | 4 | 6 |
Peak downlink speed (downstream) | 150 Mbits/s | 300 Mbits/s |
Supports 2G(GSM/Edge) | Yes | Yes |
3G(HSPA+) | Yes | Yes |
4G (LTE) | Yes | Yes |
Bands supported | Quadband GSM/EDGE 8-band WCDMA 15-band LTE | Quadband GSM/EDGE 8-band WCDMA 21-band LTE |
Project Details
Materials List
Quantity | Components |
---|---|
1 | LTE modem card with mPCIe or NGFF bus. Intel XMM 7160 or Intel XMM 7260 is recommended. |
1 | USB OTG mPCIe or NGFF adaptor with SIM card slot (generic). |
1 | NGFF to mPCIe or mPCIe to NGFF adaptor (only if the OTG-USB adaptor contains an incompatible bus with the modem module used; read “The NGFF/mPCIe Adaptor”). |
2 | LTE/UMTS antennas with SMA male connector (part number TG.30.8111) Apex Taoglas or GA-107 Taoglas (part number GA.107.201111). |
1 | Micro-SIM card with data plan already set (depends on your carrier/plan). |
1 | OTG-USB 2.0 adaptor with micro-USB male to USB A female, only if your board is Intel Galileo instead of Intel Galileo Gen 2. This is for physical connection only because OTG-USB is not supported in this case. |
2 | SMA bulkhead female/jack to IPEX MHF (part number 071113-04). |
1 | Serial debugger cable (FTDI if your board is Intel Galileo Gen2 or audio jack serial if it is Intel Galileo). |
-
If your OTG USB adaptor with the SIM card slot contains an incompatible connector with your modem card. You will need a NGFF to mPCIe or mPCIe to NGFF adaptor.
-
If your OTG USB adaptor contains a SIM card slot that’s incompatible with your SIM card format. For example, if your OTG USB adaptor accepts micro-SIM cards, but your SIM card is nano, you will need a nano-SIM to micro-SIM adaptor.
-
If you want to debug the modem with more than one shell, you might also need an Ethernet cable or a WiFi mPCIe card to open several shells using SSH.
Quantity | Components |
---|---|
1 | NGFF to mPCIe or mPCIe to NGFF adaptor if your modem form factor does not match the connector type provided by the USB-OTG adaptor. |
1 | Ethernet cable or WiFi mPCIe if you want more than one terminal for debugging using an SSH connection. |
1 | Nano-to-micro-SIM card adaptor if your SIM card is not micro-SIM. |
1 | Scissors and tape or needle-nosed pliers (read “Connecting the Modem Card”). |
Considerations Related to Antennas
datasheet
folder of this chapter. You also can find them at
http://taoglas.com/images/product_images/original_images/TG.30.8111.pdf
and
http://www.taoglas.com/images/product_images/original_images/GA.107%20Magnetic%20Telematic%20Cellular%20Penta-band%20Antenna%20300410.pdf
.Preparing the Hardware
Step 1: Preparing the SIM Card
Step 2: The NGFF/mPCIe Adaptor
Step 3: Adapting the Modem Card
Step 4: Connecting the Antennas
Step 5: Connecting the Modem to Intel Galileo
Preparing the Software
Step 1: Checking the Modem
root@clanton:∼#
lsusb
Bus 002 Device 006: ID 1519:f214
Bus 001 Device 001: ID 1d6b:0001
Bus 002 Device 001: ID 1d6b:0002
lsusb
command is the modem and it means a new device was recognized in OTG-USB with the respective vendor and product IDs.Step 2: Loading the CDC-ACM Driver
modprobe
command.root@clanton:∼# modprobe cdc-acm
[ 135.720822] cdc_acm 2-1:1.2: This device cannot do calls on its own. It is not a modem.
[ 135.738315] cdc_acm 2-1:1.2: ttyACM0: USB ACM device
[ 135.748033] cdc_acm 2-1:1.4: This device cannot do calls on its own.
It is not a modem.
[ 135.765753] cdc_acm 2-1:1.4:
ttyACM1: USB ACM device
[ 135.775111] cdc_acm 2-1:1.6: This device cannot do calls on its own.
It is not a modem.
[ 135.792294] cdc_acm 2-1:1.6:
ttyACM2
:
USB ACM device
[ 135.801241] cdc_acm 2-1:1.8: This device cannot do calls on its own.
It is not a modem.
[ 135.818946] cdc_acm 2-1:1.8:
ttyACM3
:
USB ACM device
[ 135.827775] cdc_acm 2-1:1.10: This device cannot do calls on its own.
It is not a modem.
[ 135.845711] cdc_acm 2-1:1.10:
ttyACM4
:
USB ACM device
[ 135.860799] usbcore: registered new interface driver cdc_acm
[ 135.866545] cdc_acm: USB Abstract Control Model driver for USB modems and ISD N adapters
.../linux/driverusb/class/cdc-acm.c
driver code:/*
* USB driver structure.
*/
static const struct usb_device_id acm_ids[]
= {
/* quirky and broken devices */
{ USB_DEVICE(0x0870, 0x0001), /* Metricom GS Modem */
.driver_info = NO_UNION_NORMAL, /* has no union descriptor */
},
...
...
...
{ USB_DEVICE(YOUR_VENDOR_ID, YOUR_PRODUCT_ID) }, /* ADD YOUR MODEM HERE !!!!!!*/
...
...
...
/* Motorola H24 HSPA module: */
{ USB_DEVICE(0x22b8, 0x2d91) }, /* modem */
{ USB_DEVICE(0x22b8, 0x2d92) }, /* modem + diagnostics */
{ USB_DEVICE(0x22b8, 0x2d93) }, /* modem + AT port */
{ USB_DEVICE(0x22b8, 0x2d95) }, /* modem + AT port + diagnostics */
...
...
...
ttyACM
device available. If it is the first time you have connected the modem and you did not block any ttyACM devices, the ttyACM0
should be available. You can check it with a simple ls
command:root@clanton:∼#
ls /dev/ttyACM0
/dev/ttyACM0
ttyACM0
is not found, you should see a message like this one:root@clanton:∼#
ls /dev/ttyACM0
ls: /dev/ttyACM0: No such file or directory
Step 3: Checking if the Modem Responds to AT Commands
ttyACM
device to echo the commands and responses. In order to change the ttyACM setting, use the sty
command as follows:root@clanton:∼#
stty -F /dev/ttyACM0 -echo
-F
specifies the device to be changed, such as ttyACM0
, and the -echo
option enables the echo of input commands with their respective responses as well.ttyACM
device when an AT command is sent, you should keep watching the device’s responses. You have two options at this point. If you have only one cable for debugging using serial, you can keep watching the ttyACM
device in the background. For example:root@clanton:∼#
cat /dev/ttyACM0
&
ttyACM
responses and do not need to run cat in background:root@clanton:∼#
cat /dev/ttyACM0
root@clanton:∼#
echo "AT" > /dev/ttyACM0
root@clanton:∼# AT
OK
ttyACM0
replies. In this example, the modem successfully responded with OK
, which means the system is operational and ready to be configured.ttyACM
device and re-check the hardware.Step 4: Checking the SIM Card Connection
root@clanton:∼#
AT+CPIN?
+CPIN: READY
OK
Step 5: Configuring the APN and Attaching it to the Network
-
APN: Phone number
-
Username: Not necessary
-
Password: Not necessary
-
MCC: 310
-
MNC: 410
-
APN protocol: IPv4
echo AT+CGDCONT?
command as follows:root@clanton:∼#
echo "AT+CGDCONT?" > /dev/ttyACM0
+CGDCONT: 1,"IPV4V6","","",0,0
OK
CGDCONT
AT command, but send the APN name, the protocol type, and the APN number in the modem card list. Considering there is only one APN, if you want to include a second one, you just specify the number 2 in the command and include the second one. If you want to replace the APN already set, just use the number 1. This example includes a second APN so you can see how a modem card with several APNs is configured.AT+CGDCONT=2,"IP","phone"
2
indicates that you are adding a second APN and preserving the first one, "IP"
is because the protocol is IPv4, and "phone"
is the APN name used by AT&T for 4G.echo
in the Linux terminal, if you type echo
without the double quotes, the modem will not understand the command. If the string requires double quotes, you must also differentiate between echo's
double quotes and the string’s double quotes. To do this, you need to use \"
.root@clanton:∼#
echo "AT+CGDCONT=2,\"IP\",\"phone\"" > /dev/ttyACM0
OK
OK
means the command was accepted and the APN was created. Recheck the list of APNs running using the AT+CGDCONT? command.root@clanton:∼#
echo "AT+CGDCONT?" > /dev/ttyACM0
+CGDCONT: 1,"IPV4V6","","",0,0
+CGDCONT: 2,"IP","phone","0.0.0.0",0,0,0,0,0,0
OK
root@clanton:∼#
echo "AT+CGACT=1,2" > /dev/ttyACM0
OK
AT+CGDCONT
command. If you want to deactivate the PDP later, you can send the same command but use 0 instead of 1
as the first argument.AT+COPS
command. The following example shows the AT&T network operator code in the United States:root@clanton:∼#
echo "AT+COPS=1,2,\"310410\"" > /dev/ttyACM0
OK
AT+
CGDATA
and it’s responsible for opening the data stream with the modem to establish a connection with the network. An LTE modem uses the M-RAW_IP
mode; the 1
argument means “attach” as shown in the following example:root@clanton:∼#
echo "AT+CGDATA=\"M-RAW_IP\",1" > /dev/ttyACM0
CONNECT
Step 6: Creating an IP Interface with pppd
pppd
(Point to Point Protocol Daemon) that creates this local IP and establishes the link with the Internet.pppd
. This configuration file contains relevant information about how to communicate with the modem card. Transfer the configuration file in the code
folder named options-att to your board in the /etc/ppp/peers directory. Listing 12-1 shows the contents of this file.options-att
Configuration FilettyACM0
115200
lock
crtscts
passive
novj
defaultroute
noipdefault
usepeerdns
noauth
hide-password
persist
holdoff 10
maxfail 5
debug
connect '/usr/sbin/chat -f /etc/ppp/isp_chat'
https://ppp.samba.org/pppd.html
. They are adapted to Intel Galileo in the following list:
-
ttyACM0: Uses the serial port called
ttyname
to communicate with the peer. -
115200: A decimal number that’s taken as the desired baud rate for the serial device. This is the maximum rate for the USB with Intel Galileo.
-
Lock: Specifies that
pppd
should create a UUCP-style lock file for the serial device to ensure exclusive access to the device. -
Crtscts: Specifies that
pppd
should set the serial port to use hardware flow control using the RTS and CTS signals. -
Passive: Enables the
passive
option in the LCP (Link Control Protocol). With this option,pppd
will attempt to initiate a connection. If no reply is received from the peer,pppd
will wait passively for a valid LCP packet from the peer, instead of exiting, as it would without this option. -
Novj: Disables Van Jacobson-style TCP/IP header compression in both the transmit and the receive directions.
-
Defaultroute: Adds a default route to the system routing tables, using the peer as the gateway, when IPCP negotiation is successfully completed. This entry is removed when the PPP connection is broken.
-
Noipdefault: Disables the default behavior when no local IP address is specified, which is to determine (if possible) the local IP address from the hostname. With this option, the peer will have to supply the local IP address during IPCP negotiation (unless it specified explicitly on the command line or in an
options
file). -
Usepeerdns: Asks the peer for up to two DNS server addresses. The addresses supplied by the peer (if any) are passed to the
/etc/ppp/ip-up
script in theDNS1
andDNS2
environment variables, and theUSEPEERDNS
environment variable will be set to 1. In addition,pppd
will create an/etc/ppp/resolv.conf
file containing one or two nameserver lines with the address(es) supplied by the peer. -
Noauth: Does not require the peer to authenticate itself. This option is privileged.
-
hide-password: When logging the contents of PAP packets, this option causes
pppd
to exclude the password string from the log. This is the default. -
Persist: Does not exit after a connection is terminated; instead tries to reopen the connection. The
maxfail
option still has an effect on persistent connections. -
holdoff n: Specifies how many seconds to wait before re-initiating the link after it terminates. This option has an effect only when the
persist
ordemand
options are used. The holdoff period is not applied if the link was terminated because it was idle. -
maxfail n: Terminates after n consecutive failed connection attempts. A value of 0 means no limit. The default value is 10 and you are using 5.
-
Debug: Enables connection-debugging facilities. If this option is given,
pppd
will log the contents of all control packets sent or received in a readable form. The packets are logged through syslog with facility daemon and level debug. This information can be directed to a file by setting up/etc/syslog.conf
appropriately. -
connect “script”: Usually you need to do something to prepare the link before the PPP protocol can be started; for instance, with a dial-up modem, commands need to be sent to the modem to dial the appropriate phone number. This option specifies a command for
pppd
to execute (by passing it to a shell) before attempting to start PPP negotiation. The chat program is often useful here, as it provides a way to send arbitrary strings to a modem and respond to received characters.
/usr/sbin/chat -f /etc/ppp/isp_chat
. The isp_chat
file is available in the code
folder of this chapter and you need to copy this file into the /etc/ppp
directory.pppd
daemon. The -f
option specifies the script that the chat program must run before connecting.isp_chat
script.isp_chat
Script'' ATD*99#
TIMEOUT 30
CONNECT
''
nothing is expected as a response and this is the case of the first line of the isp_chat
script. The ''
makes a pair with ATD*99##
that represents the dial string to the modem.TIMEOUT
with the maximum of 30 seconds.CONNECT
and nothing is sent as a reply.mknod
and pppd
commands.root@clanton:∼#
mknod /dev/ppp c 108 0
mknod
command is necessary only when you are using the regular Intel Galileo release and want to create a device that can open a file node to communicate with the modem using PPP. However, if you recompiled the kernel enabling all options to support PPP, your customized kernel will have the /dev/ppp
device already available and ready to be used. In the c 108 0
option, the c
stands for character file non-buffered, the and 108
and 0
refer to the major and minor numbers, respectively, used to identify the device. It’s the same methodology used with any regular char driver. Then you call pppd
as follows:root@clanton:∼#
pppd call options-att debug nodetach
Script
/usr/sbin/chat -t3 -f /etc/ppp/isp_chat
finished (pid 1486), status = 0x0
Serial connection established.
using channel 1
Using interface ppp0
Connect: ppp0 <
-->
/dev/ttyACM0
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0xbcbf1398> <pcomp> <accomp>]
rcvd [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x52181044> <pcomp> <accomp>]
sent [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0x52181044> <pcomp> <accomp>]
rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0xbcbf1398> <pcomp> <accomp>]
kernel does not support PPP filtering
[ 921.149938] PPP Deflate Compression module registered
sent [CCP ConfReq id=0x1 <deflate 15> <deflate(old#) 15>]
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns2 0.0.0.0>]
rcvd [LCP ProtRej id=0x2 80 fd 01 01 00 0c 1a 04 78 00 18 04]
Protocol-Reject for 'Compression Control Protocol' (0x80fd) received
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns2 0.0.0.0>]
rcvd [IPCP ConfReq id=0x1]
sent [IPCP ConfNak id=0x1 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x1 <addr 10.8.194.5> <ms-dns1 172.26.38.1> <ms-dns2 172.26.38.2>]
sent [IPCP ConfReq id=0x2 <addr 10.8.194.5> <ms-dns1 172.26.38.1> <ms-dns2 172.26.38.2>]
rcvd [IPCP ConfReq id=0x2 <addr 10.8.194.5>]
sent [IPCP ConfAck id=0x2 <addr 10.8.194.5>]
rcvd [IPCP ConfAck id=0x2 <addr 10.8.194.5> <ms-dns1 172.26.38.1> <ms-dns2 172.26.38.2>]
local IP address 10.8.194.5
remote IP address 10.8.194.5
primary DNS address 172.26.38.1
secondary DNS address 172.26.38.2
Script /etc/ppp/ip-up started (pid 1501)
Script /etc/ppp/ip-up finished (pid 1501), status =
0x0
pppd
command will start the PPP daemon, calling an options-att
file (do not worry, you will learn about this later) in debug mode. nodetach
means the pppd
will not detach until you or any other input device asks to kill it. For example, if you press Ctrl+C, you will kill the daemon.ppp0
will be available with a local IP.Step 7: Testing the Internet Connection
ping
a server to check if the interface works.root@clanton:∼#
ping www.google.com
PING www.google.com (74.125.239.145): 56 data bytes
64 bytes from 74.125.239.145: seq=0 ttl=54 time=49.897 ms
64 bytes from 74.125.239.145: seq=1 ttl=54 time=78.188 ms
64 bytes from 74.125.239.145: seq=2 ttl=54 time=78.101 ms
Testing the Internet Bandwidth
speedtest-cli.py
that you can download from
https://pypi.python.org/pypi/speedtest-cli
.
www.speedtest.net
. Python must be available in your Intel Galileo image. In this case, if you are using BSP SD card images, the regular image contains Python packages.tar -zxvf <package_file_name>
if you are using Linux or OSX. Use Winzip or 7Zip if you are using Windows.speedtest_cli.py
that must be transferred to your Intel Galileo. If you do not know how to transfer files, see Chapter 5 and choose the best alternative for you.root@clanton:∼/speedtest#
python speedtest_cli.py
Why Aren’t the Download/Upload Bandwidths Optimal?
Ideas for Improving the Project
Improving the Chat Script
isp_chat
listed in Listing 12-2 accepts AT commands.AT+CPIN?
+CPIN: READY
OK
AT+CGDCONT=2,"IP","phone"
OK
AT+CGACT=1,2
OK
AT+COPS=1,2,"310410"
OK
AT+CGDATA="M-RAW_IP",1
CONNECT
isp_chat
script, as shown in Listing 12-3.isp_att_chat
ScriptOK AT+CPIN?
OK AT+CGDCONT=2,"IP","phone"
OK AT+CGACT=1,2
OK AT+COPS=1,2,"310410"
'' AT+CGDATA="M-RAW_IP",1
TIMEOUT 10
'' ATD*99#
TIMEOUT 30
CONNECT
isp_att_chat
script.ttyACM0
115200
lock
crtscts
passive
novj
defaultroute
noipdefault
usepeerdns
noauth
hide-password
persist
holdoff 10
maxfail 5
debug
connect '/usr/sbin/chat -f /etc/ppp/isp_att_chat'
pppd
command again:root@clanton:∼#
pppd call options-att debug nodetach
Loading the cdc-acm Driver Automatically
modprobe cdc-acm
manually every time your board boots, you can load it automatically. The procedure is very simple if you are using BSP SD card images:
/etc/modules-load.quark
directory by typing:root@clanton:∼#
cd /etc/modules-load.quark
galileo_gen2.conf
file; otherwise, you need to edit galileo.conf
if your board is Intel Galileo. You can edit directly in the Linux terminal using the vi
editor or any other method. These files represent a configuration file with all the modules that must be loaded just after the boot.cdc-acm
line into the configuration file.pch-udc
g-serial vendor=0x8086 product=0xBABE
stmmac
ehci_hcd
ohci_hcd
ehci-pci
usb_storage
gpio_sch
intel_qrk_gip
gpio-pca953x
pca9685
at24
i2c_dev
spidev
spi-pxa2xx-pci
spi-pxa2xx
industrialio
adc1x8s102
iwlwifi
btusb
usbhid
evdev
sdhci-pci
mmc-block
cdc-acm
reboot
and pressing Enter.yocto
build. In this case the configuration files galileo.conf
and galileo_gen2.conf
are present in the directory .../meta-clanton_v1.0.3/meta-clanton-bsp/recipes-kernel/quark-init/files
. Do the same changes mentioned in Step 4, rebuild your SPI image, and flash your Intel Galileo with your new custom SPI image.cdc-acm
drive must be loaded automatically. You can check it by typing lsmod
into the Linux terminal shell.