SlideShare uma empresa Scribd logo
1 de 32
How to Use GSM/3G/4G in
Embedded Linux Systems
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 2
CHAIRMAN
Introduction
Embedded devices connected to the internet are growing every
day. In many cases, these devices will be installed somewhere
without a wire or wireless network connection. A good way to
keep the devices connected to the internet in these situations is by
seeking mobile network coverage. Therefore, this blog post will present
the necessary configurations to connect a device running Linux to the
internet through the PPP (Point-to-Point Protocol) link.and optimize cost.
In simple terms, modularity means that a system can be built by
assembling many small units.
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 3
CHAIRMAN
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 4
CHAIRMAN
Hardware Specification
In this article we will be using the Colibri iMX6S with the base board called
“Colibri Evaluation Board”, both of which, are from Toradex. The Colibri
Evaluation Board is recommended specifically for project evaluation and
development. This product comes with a great number of interfaces like USB,
Ethernet, I2C, SPI, RS242, RS485, CAN and many others. We can also find
some multimedia interfaces like HDMI, LVDS, VGA and LCD already
supported on the Evaluation Board.
To follow this tutorial, you can use any USB or Serial modem to connect to the
internet.
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 5
CHAIRMAN
You just have to adapt the interface created at “/dev/” and check the “AT”
commands supported and implemented for your modem because each modem
has specific AT commands. In this case, we have used for this tutorial a Huawei
E173s 3G modem with a compatible SIM Card with data plan activated.
Kernel Preparing
To use the 3G USB modem through the PPP protocol, it is necessary to select
some features in the kernel configurations and then compile the Kernel. To
understand how to compile the kernel, I suggest following the link below.
http://developer.toradex.com/software-resources/arm-family/linux/board-
support-package/build-u-boot-and-linux-kernel-from-source-code
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 6
CHAIRMAN
Basically, the process to compile the Kernel can be summarized in the
following steps:
• Toolchain configuration
• Download the kernel from the correct repository and branch
• Configure the standard processor features
• Change the features for your application
• Compile
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 7
CHAIRMAN
When you are configuring the kernel features, go into menuconfig and be
sure to enable the following options:
CONFIG_PPP:
PPP (Point to Point Protocol) is a newer and better SLIP. It serves the same
purpose: sending Internet traffic over telephone (and other serial) lines. Ask
your access provider if they support it, because otherwise you can't use it;
most Internet access providers these days support PPP rather than SLIP.
Device Drivers --->
[*] Network device support --->
PPP (point-to-point protocol) support
PPP BSD-Compress compression
PPP Deflate compression
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 8
CHAIRMAN
[*] PPP filtering
PPP MPPE compression (encryption)
[*] PPP multilink support
PPP over Ethernet
PPP support for async serial ports
PPP support for sync tty ports
CONFIG_USB_ACM:
This driver supports USB modems and ISDN adapters which support the
Communication Device Class Abstract Control Model interface.
Please read <file:Documentation/usb/acm.txt> for details.
Device Drivers --->
[*] USB support --->
USB Modem (CDC ACM) support
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 9
CHAIRMAN
Necessary Software Packages
To configure and connect the 3G modem to the internet, Linux uses, in addition to
the kernel drivers, a software which manages the connection. This software is PPP.
Usually Toradex images already have the PPP software installed by default.
In case you do not have PPP installed, just add the following to your local.conf file
for build environments based on Yocto/OpenEmbedded:
Testing Communication with the Modem
After all the necessary drivers and software are installed, it is possible to check if
the module recognizes the 3G modem. The modem interface should appear in /dev.
Basically the driver simulates a USB connection as many serial connections.
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 10
CHAIRMAN
Execute the following command to search for the interfaces /dev/ttyUSB
If the files ttyUSB0, ttyUSB1 … e ttyUSB2 were found, the modem was succesfully
recognized by the system.
In case you want to conduct in-depth testing, it is possible to use a serial terminal
like “minicom” to start communicating with the modem and check if it is working
well. In my case the modem had a baudrate of 115200.
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 11
Configuring the PPP Files
After validating the communication with the modem, it is time to create the
configuration files responsible for connecting to the internet.
You should be able to find a folder inside /etc/ called ppp. Some files need to be
created inside this folder.
First we create the PPP options file:
$ vi /etc/ppp/options
_____________________________________
auth
crtscts
lock
hide-password
modem
mru 296
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 12
CHAIRMAN
mtu 296
lcp-echo-interval 30
lcp-echo-failure 4
noipx
persist
asyncmap 0xa0000
mru 1500
refuse-chap
ipcp-max-failure 30
logfile /home/root/ppp
In my case we use the PAP authentication file (may vary depending on Network
Provider).
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 13
CHAIRMAN
The next step is to create one more file inside /etc/ppp/peer In this file we have
configurations for our network provider and the path for the chat file:
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 14
CHAIRMAN
Now we create the file responsible for sending the AT commands to the modem so it
can connect to the internet. This file varies according to modem models/brands.
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 15
CHAIRMAN
Connecting to the Internet
Next we run ppp and analyze the log files. In the log files we can see when each AT
command has been executed.
After running ppp, we open the log file:
In my case, I received the following output:
tail -f ppp.log
Sent 3940 bytes, received 2843 bytes.
restoring old default route to eth0 [192.168.10.1]
restore default route ioctl(SIOCADDRT): Network is unreachable(101)
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 16
CHAIRMAN
Script /etc/ppp/ip-down started (pid 778)
sent [LCP TermReq id=0x2 "User request"]
rcvd [LCP TermAck id=0x2]
Connection terminated.
Script /etc/ppp/ip-down finished (pid 778), status = 0x0
ATZ
OK
AT+CGDCONT=1,"IP","zap.vivo.com.br"
OK
ATDT*99#
CONNECT
Script chat -v -f /etc/ppp/chat/vivo-3g.chat finished (pid 795), status = 0x0
Serial connection established.
using channel 2
Using interface ppp0
Connect: ppp0 /dev/ttyACM0
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 17
CHAIRMAN
rcvd [LCP ConfReq id=0x1 ]
sent [LCP ConfReq id=0x1 ]
sent [LCP ConfAck id=0x1 ]
rcvd [LCP ConfAck id=0x1 ]
sent [LCP EchoReq id=0x0 magic=0xa068db01]
sent [PAP AuthReq id=0x1 user="vivo" password=]
rcvd [LCP EchoRep id=0x0 magic=0x96baf40f]
rcvd [PAP AuthAck id=0x1 ""]
PAP authentication succeeded
sent [CCP ConfReq id=0x1 ]
sent [IPCP ConfReq id=0x1 ]
rcvd [LCP ProtRej id=0x2 80 fd 01 01 00 0f 1a 04 78 00 18 04 78 00 15]
Protocol-Reject for 'Compression Control Protocol' (0x80fd) received
rcvd [IPCP ConfNak id=0x1 ]
sent [IPCP ConfReq id=0x2 ]
rcvd [IPCP ConfNak id=0x2 ]
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 18
CHAIRMAN
sent [IPCP ConfReq id=0x3 ]
rcvd [IPCP ConfNak id=0x3 ]
sent [IPCP ConfReq id=0x4 ]
rcvd [IPCP ConfNak id=0x4 ]
sent [IPCP ConfReq id=0x5 ]
rcvd [IPCP ConfNak id=0x5 ]
sent [IPCP ConfReq id=0x6 ]
rcvd [IPCP ConfReq id=0x1]
sent [IPCP ConfNak id=0x1 ]
rcvd [IPCP ConfRej id=0x6 ]
sent [IPCP ConfReq id=0x7 ]
rcvd [IPCP ConfReq id=0x2 ]
sent [IPCP ConfAck id=0x2 ]
rcvd [IPCP ConfNak id=0x7 ]
sent [IPCP ConfReq id=0x8 ]
rcvd [IPCP ConfAck id=0x8 ]
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 19
CHAIRMAN
local IP address 179.133.47.109
remote IP address 179.133.47.109
primary DNS address 187.100.246.254
secondary DNS address 187.100.246.251
Script /etc/ppp/ip-up started (pid 805)
Script /etc/ppp/ip-up finished (pid 805), status = 0x0
As seen in the log file, the chat script is executed step-by-step until we get the following:
You can validate the necessary command sequence to get connected using the
serial terminal. Once it is validated, you can create your own customized chat
script.
After checking for an IP address from the network provider, look for whether the
ppp0 network interface is active:
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 20
CHAIRMAN
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 21
CHAIRMAN
Testing the Connection
To test if the connection has been successfully established, ping an external ip address:
To configure DNS, we can use the following command and then ping a URL, for
example:
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 22
CHAIRMAN
Image 1: A
running web
browser
using 3G
connection.
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 23
CHAIRMAN
We can avoid the file being rewritten when system is restarted with the following
command:
Now it is possible to connect using SSH from an external computer:
Configuring a Host Name for our IP Address
Another thing we can do is to associate our IP address to a host name. For this
purpose, we used the NoIP services (www.noip.com). We then created a free
account and added a Host. In our case, we chose toradex.noip.me.
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 24
CHAIRMAN
Image 2: NoIP Add Host page.
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 25
CHAIRMAN
After the Host name is created we can again connect to the module using SSH:
In our case, when the 3G modem connection is restarted, we always receive a new IP
adress. If we try to reconnect to the module, we no longer have access. A workaround
was to use a method called Dynamic DNS(Dynamic Domain Name System). NoIP also
offers Dynamic DNS services. Further information for using this method can be found
here. Basically we send an http request to NoIP with information like IP, hostname,
username and password.
To accomplish this request, a small Python program was made. It gets executed when
we start the 3G modem connection and follows the sequence as listed below:
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 26
CHAIRMAN
Image 3: Python Application Fluxogram.
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 27
CHAIRMAN
#!/usr/bin/python
import sys
import requests
import netifaces as ni
user = 'xxxxxxx'
pswd = 'xxxxxxx'
ni.ifaddresses('ppp0')
ip = ni.ifaddresses('ppp0')[2][0]['addr']
myhostname = 'toradex.noip.me'
payload = {'hostname' : myhostname , 'myip' : ip}
r = requests.get("http://dynupdate.no-ip.com/nic/update", params=payload,
auth=(user,pswd))
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 28
CHAIRMAN
print " "
if "good" in r.text:
print "Hello", user, "!"
print "Your IP was successfully updated to:", ip
print myhostname, "is up and running!"
if "nochg" in r.text:
print "Hello", user, "!"
print "Your IP", ip, "is still active, no change needed"
if "nohost" in r.text:
print "The given Host name", myhostname, "does not exist under specified account"
print "Please review your Host name and try again"
if "badauth" in r.text:
print "Login and/or Username incorrect"
print "Please correct your credentials and try again"
if "911" in r.text:
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 29
CHAIRMAN
print "Sorry for the incovenience but we are experiencing some problems right now"
print "Please try again later"
print "noip.com says:", r.text
print " "
After creating the Python program and making it executable with chmod +x, we can
move it to /etc/ppp/ip-up.d/, which is a folder where scripts are executed after ppp
connection or create a small script which calls our Python program.
Inside /etc/ppp/ we have the files that we created at the beginning of the article as
well as other files like ip-down, ip-up, ppp_on_boot. Feel free to explore each one of
these files.
ip-up is the script which calls another script or program found inside ip-up.d folder.
In this case, we created a small script inside ip-up.d
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 30
CHAIRMAN
Note: the script is not terminated with .sh
Note that all the print commands inside our Python program can be seen in the log file:
If everything is configured correctly, when we receive a new IP from our network
provider, the system automatically updates our host created at NoIP, so it will be
possible to connect to the module despite the IP address being changed.
Based on all the information provided in this article, it is possible to achieve many
other network activities. One of them is to share the 3G modem network with another
computer via Ethernet. For this we configured a basic LAN network between two
machines and ran the following command:
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 31
CHAIRMAN
Apart from internet sharing, it is also possible to conduct port forwarding and many
other network features.
Final Thoughts
As seen in this article, a Linux system has many network functionalities. We just
need to properly configure them and have access to ppp0 network. Another
important point, is that regardless of the used interface, the programming method
remains the same. The task of choosing the interface to use is made automatically by
Linux depending on the routes. For those who require network connection in their
projects and also need system flexibility, the use of Linux in embedded systems is
the way to go.
References
http://metodiew.com/huawei-e173s-and-ubuntu/
http://developer.toradex.com/product-selector/colibri-imx6
http://developer.toradex.com/product-selector/colibri-evaluation-board
|www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 32
Thank
you!

Mais conteúdo relacionado

Mais procurados

10 step-to-configure-cisco-call-manager-express
10 step-to-configure-cisco-call-manager-express10 step-to-configure-cisco-call-manager-express
10 step-to-configure-cisco-call-manager-express
Nguyen Thanh
 

Mais procurados (19)

Nat
NatNat
Nat
 
Ip tables
Ip tablesIp tables
Ip tables
 
W4 profinet frame analysis, peter thomas
W4 profinet frame analysis, peter thomasW4 profinet frame analysis, peter thomas
W4 profinet frame analysis, peter thomas
 
PLNOG 13: P. Kupisiewicz, O. Pelerin: Make IOS-XE Troubleshooting Easy – Pack...
PLNOG 13: P. Kupisiewicz, O. Pelerin: Make IOS-XE Troubleshooting Easy – Pack...PLNOG 13: P. Kupisiewicz, O. Pelerin: Make IOS-XE Troubleshooting Easy – Pack...
PLNOG 13: P. Kupisiewicz, O. Pelerin: Make IOS-XE Troubleshooting Easy – Pack...
 
Linux Firewall - NullCon Chennai Presentation
Linux Firewall - NullCon Chennai PresentationLinux Firewall - NullCon Chennai Presentation
Linux Firewall - NullCon Chennai Presentation
 
C04 – Avoiding pitfalls in Profinet RT and IRT node implementation - Hans Der...
C04 – Avoiding pitfalls in Profinet RT and IRT node implementation - Hans Der...C04 – Avoiding pitfalls in Profinet RT and IRT node implementation - Hans Der...
C04 – Avoiding pitfalls in Profinet RT and IRT node implementation - Hans Der...
 
Fun with PRB, VRFs and NetNS on Linux - What is it, how does it work, what ca...
Fun with PRB, VRFs and NetNS on Linux - What is it, how does it work, what ca...Fun with PRB, VRFs and NetNS on Linux - What is it, how does it work, what ca...
Fun with PRB, VRFs and NetNS on Linux - What is it, how does it work, what ca...
 
10 step-to-configure-cisco-call-manager-express
10 step-to-configure-cisco-call-manager-express10 step-to-configure-cisco-call-manager-express
10 step-to-configure-cisco-call-manager-express
 
Best Current Operational Practices - Dos, Don’ts and lessons learned
Best Current Operational Practices - Dos, Don’ts and lessons learnedBest Current Operational Practices - Dos, Don’ts and lessons learned
Best Current Operational Practices - Dos, Don’ts and lessons learned
 
Cisco CCNA- NAT Configuration
Cisco CCNA- NAT ConfigurationCisco CCNA- NAT Configuration
Cisco CCNA- NAT Configuration
 
Dynamische Routingprotokolle Aufzucht und Pflege - BGP
Dynamische Routingprotokolle Aufzucht und Pflege - BGPDynamische Routingprotokolle Aufzucht und Pflege - BGP
Dynamische Routingprotokolle Aufzucht und Pflege - BGP
 
66_pfSenseTutorial
66_pfSenseTutorial66_pfSenseTutorial
66_pfSenseTutorial
 
Anycast all the things
Anycast all the thingsAnycast all the things
Anycast all the things
 
Naked BGP
Naked BGPNaked BGP
Naked BGP
 
6. hands on - open mano demonstration in remote pool of servers
6. hands on - open mano demonstration in remote pool of servers6. hands on - open mano demonstration in remote pool of servers
6. hands on - open mano demonstration in remote pool of servers
 
5. hands on - building local development environment with Open Mano
5. hands on - building local development environment with Open Mano5. hands on - building local development environment with Open Mano
5. hands on - building local development environment with Open Mano
 
Basic network training2
Basic network training2Basic network training2
Basic network training2
 
Rhino labs Prese4th ntation At FPGA Camp, Santa Clara, CA
Rhino labs Prese4th ntation At FPGA Camp, Santa Clara, CARhino labs Prese4th ntation At FPGA Camp, Santa Clara, CA
Rhino labs Prese4th ntation At FPGA Camp, Santa Clara, CA
 
AF-23- IPv6 Security_Final
AF-23- IPv6 Security_FinalAF-23- IPv6 Security_Final
AF-23- IPv6 Security_Final
 

Semelhante a How to Use GSM/3G/4G in Embedded Linux Systems

26.1.7 lab snort and firewall rules
26.1.7 lab   snort and firewall rules26.1.7 lab   snort and firewall rules
26.1.7 lab snort and firewall rules
Freddy Buenaño
 
It04 roshan basnet
It04 roshan basnetIt04 roshan basnet
It04 roshan basnet
rosu555
 
Linux hpc-cluster-setup-guide
Linux hpc-cluster-setup-guideLinux hpc-cluster-setup-guide
Linux hpc-cluster-setup-guide
jasembo
 
ccna 1 chapter 2 v5.0 exam answers 2014
ccna 1 chapter 2 v5.0 exam answers 2014ccna 1 chapter 2 v5.0 exam answers 2014
ccna 1 chapter 2 v5.0 exam answers 2014
Đồng Quốc Vương
 

Semelhante a How to Use GSM/3G/4G in Embedded Linux Systems (20)

26.1.7 lab snort and firewall rules
26.1.7 lab   snort and firewall rules26.1.7 lab   snort and firewall rules
26.1.7 lab snort and firewall rules
 
Backtrack Manual Part4
Backtrack Manual Part4Backtrack Manual Part4
Backtrack Manual Part4
 
First Steps Developing Embedded Applications using Heterogeneous Multi-core P...
First Steps Developing Embedded Applications using Heterogeneous Multi-core P...First Steps Developing Embedded Applications using Heterogeneous Multi-core P...
First Steps Developing Embedded Applications using Heterogeneous Multi-core P...
 
It04 roshan basnet
It04 roshan basnetIt04 roshan basnet
It04 roshan basnet
 
Advanced RAC troubleshooting: Network
Advanced RAC troubleshooting: NetworkAdvanced RAC troubleshooting: Network
Advanced RAC troubleshooting: Network
 
Linux hpc-cluster-setup-guide
Linux hpc-cluster-setup-guideLinux hpc-cluster-setup-guide
Linux hpc-cluster-setup-guide
 
CCNA CHAPTER 5 BY jetarvind kumar madhukar
CCNA CHAPTER 5 BY jetarvind kumar madhukarCCNA CHAPTER 5 BY jetarvind kumar madhukar
CCNA CHAPTER 5 BY jetarvind kumar madhukar
 
Running head network design 1 netwo
Running head network design                             1 netwoRunning head network design                             1 netwo
Running head network design 1 netwo
 
ccna 1 chapter 2 v5.0 exam answers 2014
ccna 1 chapter 2 v5.0 exam answers 2014ccna 1 chapter 2 v5.0 exam answers 2014
ccna 1 chapter 2 v5.0 exam answers 2014
 
AIX Advanced Administration Knowledge Share
AIX Advanced Administration Knowledge ShareAIX Advanced Administration Knowledge Share
AIX Advanced Administration Knowledge Share
 
Webinar: Comunicação TCP/IP segura
Webinar: Comunicação TCP/IP seguraWebinar: Comunicação TCP/IP segura
Webinar: Comunicação TCP/IP segura
 
Wireshark Inroduction Li In
Wireshark Inroduction  Li InWireshark Inroduction  Li In
Wireshark Inroduction Li In
 
Networking Concepts and Tools for the Cloud
Networking Concepts and Tools for the CloudNetworking Concepts and Tools for the Cloud
Networking Concepts and Tools for the Cloud
 
Nat mikrotik
Nat mikrotikNat mikrotik
Nat mikrotik
 
BASIC TO ADVANCED NETWORKING TUTORIALS
BASIC TO ADVANCED NETWORKING TUTORIALSBASIC TO ADVANCED NETWORKING TUTORIALS
BASIC TO ADVANCED NETWORKING TUTORIALS
 
maXbox Arduino Tutorial
maXbox Arduino TutorialmaXbox Arduino Tutorial
maXbox Arduino Tutorial
 
CCNA CheatSheet
CCNA CheatSheetCCNA CheatSheet
CCNA CheatSheet
 
TekTape Manual
TekTape ManualTekTape Manual
TekTape Manual
 
Design and Development of ARM9 Based Embedded Web Server
Design and Development of ARM9 Based Embedded Web ServerDesign and Development of ARM9 Based Embedded Web Server
Design and Development of ARM9 Based Embedded Web Server
 
Ccna Imp Guide
Ccna Imp GuideCcna Imp Guide
Ccna Imp Guide
 

Mais de Toradex

Mais de Toradex (20)

Toradex Strengthens Custom Solutions Offering with Acquisition of Linear Comp...
Toradex Strengthens Custom Solutions Offering with Acquisition of Linear Comp...Toradex Strengthens Custom Solutions Offering with Acquisition of Linear Comp...
Toradex Strengthens Custom Solutions Offering with Acquisition of Linear Comp...
 
プレスリリース:ToradexがJapan IT Week【春】2024年に出展
プレスリリース:ToradexがJapan IT Week【春】2024年に出展プレスリリース:ToradexがJapan IT Week【春】2024年に出展
プレスリリース:ToradexがJapan IT Week【春】2024年に出展
 
Introducing Aquila: The Next Generation Toradex SoM Family
Introducing Aquila: The Next Generation Toradex SoM FamilyIntroducing Aquila: The Next Generation Toradex SoM Family
Introducing Aquila: The Next Generation Toradex SoM Family
 
Join Toradex at Japan IT Week Spring 2024
Join Toradex at Japan IT Week Spring 2024Join Toradex at Japan IT Week Spring 2024
Join Toradex at Japan IT Week Spring 2024
 
Toradex announces Titan Eval Kit w/ NXP's i.MX 95 - Early Access Program
Toradex announces Titan Eval Kit w/ NXP's i.MX 95 - Early Access ProgramToradex announces Titan Eval Kit w/ NXP's i.MX 95 - Early Access Program
Toradex announces Titan Eval Kit w/ NXP's i.MX 95 - Early Access Program
 
ToradexがJapan IT Week【春】2023年に出展
ToradexがJapan IT Week【春】2023年に出展ToradexがJapan IT Week【春】2023年に出展
ToradexがJapan IT Week【春】2023年に出展
 
NXP Semiconductors elevates Toradex to Platinum Partner status
NXP Semiconductors elevates Toradex to Platinum Partner statusNXP Semiconductors elevates Toradex to Platinum Partner status
NXP Semiconductors elevates Toradex to Platinum Partner status
 
Webinar: Secure Offline and Online Updates for Linux Devices
Webinar: Secure Offline and Online Updates for Linux DevicesWebinar: Secure Offline and Online Updates for Linux Devices
Webinar: Secure Offline and Online Updates for Linux Devices
 
Toradex opens office in Tokyo, reaffirming its growth strategy in the Asia-Pa...
Toradex opens office in Tokyo, reaffirming its growth strategy in the Asia-Pa...Toradex opens office in Tokyo, reaffirming its growth strategy in the Asia-Pa...
Toradex opens office in Tokyo, reaffirming its growth strategy in the Asia-Pa...
 
Toradex launches Verdin featuring NXP i.MX 8M Mini/Nano SoMs
Toradex launches Verdin featuring NXP i.MX 8M Mini/Nano SoMsToradex launches Verdin featuring NXP i.MX 8M Mini/Nano SoMs
Toradex launches Verdin featuring NXP i.MX 8M Mini/Nano SoMs
 
Ethernet Compliance Testing at Toradex
Ethernet Compliance Testing at ToradexEthernet Compliance Testing at Toradex
Ethernet Compliance Testing at Toradex
 
Webinar On-demand: Introducing the new Colibri SoM based on the NXP i.MX 6ULL...
Webinar On-demand: Introducing the new Colibri SoM based on the NXP i.MX 6ULL...Webinar On-demand: Introducing the new Colibri SoM based on the NXP i.MX 6ULL...
Webinar On-demand: Introducing the new Colibri SoM based on the NXP i.MX 6ULL...
 
Starting with OpenCV on i.MX 6 Processors
Starting with OpenCV on i.MX 6 ProcessorsStarting with OpenCV on i.MX 6 Processors
Starting with OpenCV on i.MX 6 Processors
 
Cloud-Aided Yocto Build Speedup
Cloud-Aided Yocto Build SpeedupCloud-Aided Yocto Build Speedup
Cloud-Aided Yocto Build Speedup
 
Toradex Global Video Montage
Toradex Global Video MontageToradex Global Video Montage
Toradex Global Video Montage
 
Considerations on usage of Computer on Modules for Applications inside Emerge...
Considerations on usage of Computer on Modules for Applications inside Emerge...Considerations on usage of Computer on Modules for Applications inside Emerge...
Considerations on usage of Computer on Modules for Applications inside Emerge...
 
Customizable Embedded 3D Surround View Turn-Key Solution on Apalis iMX6 SoM
Customizable Embedded 3D Surround View Turn-Key Solution on Apalis iMX6 SoMCustomizable Embedded 3D Surround View Turn-Key Solution on Apalis iMX6 SoM
Customizable Embedded 3D Surround View Turn-Key Solution on Apalis iMX6 SoM
 
288 Core ARM® and 13’824 CUDA Core Microserver Cluster with Toradex Apalis Sy...
288 Core ARM® and 13’824 CUDA Core Microserver Cluster with Toradex Apalis Sy...288 Core ARM® and 13’824 CUDA Core Microserver Cluster with Toradex Apalis Sy...
288 Core ARM® and 13’824 CUDA Core Microserver Cluster with Toradex Apalis Sy...
 
Developing Real-Time Systems on Application Processors
Developing Real-Time Systems on Application ProcessorsDeveloping Real-Time Systems on Application Processors
Developing Real-Time Systems on Application Processors
 
Development of Real-Time Systems with Embedded Linux
Development of Real-Time Systems with Embedded LinuxDevelopment of Real-Time Systems with Embedded Linux
Development of Real-Time Systems with Embedded Linux
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

How to Use GSM/3G/4G in Embedded Linux Systems

  • 1. How to Use GSM/3G/4G in Embedded Linux Systems
  • 2. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 2 CHAIRMAN Introduction Embedded devices connected to the internet are growing every day. In many cases, these devices will be installed somewhere without a wire or wireless network connection. A good way to keep the devices connected to the internet in these situations is by seeking mobile network coverage. Therefore, this blog post will present the necessary configurations to connect a device running Linux to the internet through the PPP (Point-to-Point Protocol) link.and optimize cost. In simple terms, modularity means that a system can be built by assembling many small units.
  • 3. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 3 CHAIRMAN
  • 4. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 4 CHAIRMAN Hardware Specification In this article we will be using the Colibri iMX6S with the base board called “Colibri Evaluation Board”, both of which, are from Toradex. The Colibri Evaluation Board is recommended specifically for project evaluation and development. This product comes with a great number of interfaces like USB, Ethernet, I2C, SPI, RS242, RS485, CAN and many others. We can also find some multimedia interfaces like HDMI, LVDS, VGA and LCD already supported on the Evaluation Board. To follow this tutorial, you can use any USB or Serial modem to connect to the internet.
  • 5. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 5 CHAIRMAN You just have to adapt the interface created at “/dev/” and check the “AT” commands supported and implemented for your modem because each modem has specific AT commands. In this case, we have used for this tutorial a Huawei E173s 3G modem with a compatible SIM Card with data plan activated. Kernel Preparing To use the 3G USB modem through the PPP protocol, it is necessary to select some features in the kernel configurations and then compile the Kernel. To understand how to compile the kernel, I suggest following the link below. http://developer.toradex.com/software-resources/arm-family/linux/board- support-package/build-u-boot-and-linux-kernel-from-source-code
  • 6. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 6 CHAIRMAN Basically, the process to compile the Kernel can be summarized in the following steps: • Toolchain configuration • Download the kernel from the correct repository and branch • Configure the standard processor features • Change the features for your application • Compile
  • 7. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 7 CHAIRMAN When you are configuring the kernel features, go into menuconfig and be sure to enable the following options: CONFIG_PPP: PPP (Point to Point Protocol) is a newer and better SLIP. It serves the same purpose: sending Internet traffic over telephone (and other serial) lines. Ask your access provider if they support it, because otherwise you can't use it; most Internet access providers these days support PPP rather than SLIP. Device Drivers ---> [*] Network device support ---> PPP (point-to-point protocol) support PPP BSD-Compress compression PPP Deflate compression
  • 8. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 8 CHAIRMAN [*] PPP filtering PPP MPPE compression (encryption) [*] PPP multilink support PPP over Ethernet PPP support for async serial ports PPP support for sync tty ports CONFIG_USB_ACM: This driver supports USB modems and ISDN adapters which support the Communication Device Class Abstract Control Model interface. Please read <file:Documentation/usb/acm.txt> for details. Device Drivers ---> [*] USB support ---> USB Modem (CDC ACM) support
  • 9. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 9 CHAIRMAN Necessary Software Packages To configure and connect the 3G modem to the internet, Linux uses, in addition to the kernel drivers, a software which manages the connection. This software is PPP. Usually Toradex images already have the PPP software installed by default. In case you do not have PPP installed, just add the following to your local.conf file for build environments based on Yocto/OpenEmbedded: Testing Communication with the Modem After all the necessary drivers and software are installed, it is possible to check if the module recognizes the 3G modem. The modem interface should appear in /dev. Basically the driver simulates a USB connection as many serial connections.
  • 10. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 10 CHAIRMAN Execute the following command to search for the interfaces /dev/ttyUSB If the files ttyUSB0, ttyUSB1 … e ttyUSB2 were found, the modem was succesfully recognized by the system. In case you want to conduct in-depth testing, it is possible to use a serial terminal like “minicom” to start communicating with the modem and check if it is working well. In my case the modem had a baudrate of 115200.
  • 11. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 11 Configuring the PPP Files After validating the communication with the modem, it is time to create the configuration files responsible for connecting to the internet. You should be able to find a folder inside /etc/ called ppp. Some files need to be created inside this folder. First we create the PPP options file: $ vi /etc/ppp/options _____________________________________ auth crtscts lock hide-password modem mru 296
  • 12. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 12 CHAIRMAN mtu 296 lcp-echo-interval 30 lcp-echo-failure 4 noipx persist asyncmap 0xa0000 mru 1500 refuse-chap ipcp-max-failure 30 logfile /home/root/ppp In my case we use the PAP authentication file (may vary depending on Network Provider).
  • 13. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 13 CHAIRMAN The next step is to create one more file inside /etc/ppp/peer In this file we have configurations for our network provider and the path for the chat file:
  • 14. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 14 CHAIRMAN Now we create the file responsible for sending the AT commands to the modem so it can connect to the internet. This file varies according to modem models/brands.
  • 15. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 15 CHAIRMAN Connecting to the Internet Next we run ppp and analyze the log files. In the log files we can see when each AT command has been executed. After running ppp, we open the log file: In my case, I received the following output: tail -f ppp.log Sent 3940 bytes, received 2843 bytes. restoring old default route to eth0 [192.168.10.1] restore default route ioctl(SIOCADDRT): Network is unreachable(101)
  • 16. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 16 CHAIRMAN Script /etc/ppp/ip-down started (pid 778) sent [LCP TermReq id=0x2 "User request"] rcvd [LCP TermAck id=0x2] Connection terminated. Script /etc/ppp/ip-down finished (pid 778), status = 0x0 ATZ OK AT+CGDCONT=1,"IP","zap.vivo.com.br" OK ATDT*99# CONNECT Script chat -v -f /etc/ppp/chat/vivo-3g.chat finished (pid 795), status = 0x0 Serial connection established. using channel 2 Using interface ppp0 Connect: ppp0 /dev/ttyACM0
  • 17. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 17 CHAIRMAN rcvd [LCP ConfReq id=0x1 ] sent [LCP ConfReq id=0x1 ] sent [LCP ConfAck id=0x1 ] rcvd [LCP ConfAck id=0x1 ] sent [LCP EchoReq id=0x0 magic=0xa068db01] sent [PAP AuthReq id=0x1 user="vivo" password=] rcvd [LCP EchoRep id=0x0 magic=0x96baf40f] rcvd [PAP AuthAck id=0x1 ""] PAP authentication succeeded sent [CCP ConfReq id=0x1 ] sent [IPCP ConfReq id=0x1 ] rcvd [LCP ProtRej id=0x2 80 fd 01 01 00 0f 1a 04 78 00 18 04 78 00 15] Protocol-Reject for 'Compression Control Protocol' (0x80fd) received rcvd [IPCP ConfNak id=0x1 ] sent [IPCP ConfReq id=0x2 ] rcvd [IPCP ConfNak id=0x2 ]
  • 18. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 18 CHAIRMAN sent [IPCP ConfReq id=0x3 ] rcvd [IPCP ConfNak id=0x3 ] sent [IPCP ConfReq id=0x4 ] rcvd [IPCP ConfNak id=0x4 ] sent [IPCP ConfReq id=0x5 ] rcvd [IPCP ConfNak id=0x5 ] sent [IPCP ConfReq id=0x6 ] rcvd [IPCP ConfReq id=0x1] sent [IPCP ConfNak id=0x1 ] rcvd [IPCP ConfRej id=0x6 ] sent [IPCP ConfReq id=0x7 ] rcvd [IPCP ConfReq id=0x2 ] sent [IPCP ConfAck id=0x2 ] rcvd [IPCP ConfNak id=0x7 ] sent [IPCP ConfReq id=0x8 ] rcvd [IPCP ConfAck id=0x8 ]
  • 19. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 19 CHAIRMAN local IP address 179.133.47.109 remote IP address 179.133.47.109 primary DNS address 187.100.246.254 secondary DNS address 187.100.246.251 Script /etc/ppp/ip-up started (pid 805) Script /etc/ppp/ip-up finished (pid 805), status = 0x0 As seen in the log file, the chat script is executed step-by-step until we get the following: You can validate the necessary command sequence to get connected using the serial terminal. Once it is validated, you can create your own customized chat script. After checking for an IP address from the network provider, look for whether the ppp0 network interface is active:
  • 20. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 20 CHAIRMAN
  • 21. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 21 CHAIRMAN Testing the Connection To test if the connection has been successfully established, ping an external ip address: To configure DNS, we can use the following command and then ping a URL, for example:
  • 22. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 22 CHAIRMAN Image 1: A running web browser using 3G connection.
  • 23. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 23 CHAIRMAN We can avoid the file being rewritten when system is restarted with the following command: Now it is possible to connect using SSH from an external computer: Configuring a Host Name for our IP Address Another thing we can do is to associate our IP address to a host name. For this purpose, we used the NoIP services (www.noip.com). We then created a free account and added a Host. In our case, we chose toradex.noip.me.
  • 24. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 24 CHAIRMAN Image 2: NoIP Add Host page.
  • 25. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 25 CHAIRMAN After the Host name is created we can again connect to the module using SSH: In our case, when the 3G modem connection is restarted, we always receive a new IP adress. If we try to reconnect to the module, we no longer have access. A workaround was to use a method called Dynamic DNS(Dynamic Domain Name System). NoIP also offers Dynamic DNS services. Further information for using this method can be found here. Basically we send an http request to NoIP with information like IP, hostname, username and password. To accomplish this request, a small Python program was made. It gets executed when we start the 3G modem connection and follows the sequence as listed below:
  • 26. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 26 CHAIRMAN Image 3: Python Application Fluxogram.
  • 27. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 27 CHAIRMAN #!/usr/bin/python import sys import requests import netifaces as ni user = 'xxxxxxx' pswd = 'xxxxxxx' ni.ifaddresses('ppp0') ip = ni.ifaddresses('ppp0')[2][0]['addr'] myhostname = 'toradex.noip.me' payload = {'hostname' : myhostname , 'myip' : ip} r = requests.get("http://dynupdate.no-ip.com/nic/update", params=payload, auth=(user,pswd))
  • 28. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 28 CHAIRMAN print " " if "good" in r.text: print "Hello", user, "!" print "Your IP was successfully updated to:", ip print myhostname, "is up and running!" if "nochg" in r.text: print "Hello", user, "!" print "Your IP", ip, "is still active, no change needed" if "nohost" in r.text: print "The given Host name", myhostname, "does not exist under specified account" print "Please review your Host name and try again" if "badauth" in r.text: print "Login and/or Username incorrect" print "Please correct your credentials and try again" if "911" in r.text:
  • 29. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 29 CHAIRMAN print "Sorry for the incovenience but we are experiencing some problems right now" print "Please try again later" print "noip.com says:", r.text print " " After creating the Python program and making it executable with chmod +x, we can move it to /etc/ppp/ip-up.d/, which is a folder where scripts are executed after ppp connection or create a small script which calls our Python program. Inside /etc/ppp/ we have the files that we created at the beginning of the article as well as other files like ip-down, ip-up, ppp_on_boot. Feel free to explore each one of these files. ip-up is the script which calls another script or program found inside ip-up.d folder. In this case, we created a small script inside ip-up.d
  • 30. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 30 CHAIRMAN Note: the script is not terminated with .sh Note that all the print commands inside our Python program can be seen in the log file: If everything is configured correctly, when we receive a new IP from our network provider, the system automatically updates our host created at NoIP, so it will be possible to connect to the module despite the IP address being changed. Based on all the information provided in this article, it is possible to achieve many other network activities. One of them is to share the 3G modem network with another computer via Ethernet. For this we configured a basic LAN network between two machines and ran the following command:
  • 31. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 31 CHAIRMAN Apart from internet sharing, it is also possible to conduct port forwarding and many other network features. Final Thoughts As seen in this article, a Linux system has many network functionalities. We just need to properly configure them and have access to ppp0 network. Another important point, is that regardless of the used interface, the programming method remains the same. The task of choosing the interface to use is made automatically by Linux depending on the routes. For those who require network connection in their projects and also need system flexibility, the use of Linux in embedded systems is the way to go. References http://metodiew.com/huawei-e173s-and-ubuntu/ http://developer.toradex.com/product-selector/colibri-imx6 http://developer.toradex.com/product-selector/colibri-evaluation-board
  • 32. |www.toradex.com Toradex® is a registered trademark of Montadex GmbH May’16 32 Thank you!