GSM / 3G / 4G-Modems in eingebetteten Systemen am Beispiel des Quectel EC21 LTE-Modems und des Yocto-Projekts

Bild


Viele GerĂ€te, die auf eingebetteten Systemen basieren, benötigen das Internet. Eine kabelgebundene Internetverbindung ist fĂŒr sie nicht immer möglich. Wenn sich die GerĂ€te innerhalb des Mobilfunkbereichs befinden, können Sie mit GSM / 3G / 4G-Modems eine Verbindung zum Internet herstellen.


In diesem Hinweis wird der Vorgang zum Erstellen einer Linux-Distribution fĂŒr ein eingebettetes System mithilfe des Yocto Project-Toolkits beschrieben, mit dem Sie das GerĂ€t ĂŒber ein GSM / 3G / 4G-Modem und ein PPP-Protokoll mit dem Internet verbinden können.


Inhalt



Hardware und Software


Wir werden die Linux-Distribution fĂŒr das eingebettete System mit Yocto Project Version THUD 2.6.4 auf einem PC mit Ubuntu 18.04 erstellen.


BeagleBone Black Rev. C LTE- Quectel EC21-E. UMTS<E EVB UMTS LTE Quectel. , , . 1.


Bild


1 —



, 50 :


  • Git 1.8.3.1 ;
  • Tar 1.27 ;
  • Python 3.4.0 .

:


$ sudo apt-get install gawk wget git-core diffstat unzip texinfo \
                       gcc-multilib build-essential chrpath socat  \
                       cpio python python3 python3-pip python3-pexpect \
                       xz-utils debianutils iputils-ping libsdl1.2-dev xterm

Yocto Project . Yocto Project Quick Build.



, Poky - . habr-yocto-lte:


~$ mkdir habr-yocto-lte

habr-yocto-lte git :


~$ cd habr-yocto-lte
~/habr-yocto-lte$ git init

git-, , Poky meta-ti:


~/habr-yocto-lte$ git submodule add -b thud git://git.yoctoproject.org/poky.git
~/habr-yocto-lte$ git submodule add -b thud git://git.yoctoproject.org/meta-ti

Poky , , meta-ti – , , Texas Instruments. , Poky - Yocto Project Overview and Concepts Manual.


oe-init-build-env :


~/habr-yocto-lte$ touch oe-init-build-env
~/habr-yocto-lte$ chmod +x oe-init-build-env

:


#!/bin/sh
source $(pwd)/poky/oe-init-build-env build

oe-init-build-env , . :


~/habr-yocto-lte$ source ./oe-init-build-env

~/habr-yocto-lte build, , :


### Shell environment set up for builds. ###

You can now run 'bitbake <target>'

Common targets are:
    core-image-minimal
    core-image-sato
    meta-toolchain
    meta-ide-support

You can also run generated qemu images with a command like 'runqemu qemux86'

, , «»:


  • meta-ti meta-poky-bsp. BBLAYERS, ~/habr-yocto-lte/build/conf/bblayers.conf, :

BBLAYERS ?= " \
        /home/alex/habr/poky/meta \
        /home/alex/habr/poky/meta-poky \
        /home/alex/habr/meta-ti \
        "

  • , beaglebone. , , . ipk . sysvinit systemd. , ~/habr-yocto-lte/build/conf/local.conf :

MACHINE = "beaglebone"
INHERIT += "buildhistory"
BUILDHISTORY_COMMIT = "1"
PACKAGE_CLASSES = "package_ipk"
CORE_IMAGE_EXTRA_INSTALL += " kernel-modules"
DISTRO_FEATURES_append = " systemd"
DISTRO_FEATURES_BACKFILL_CONSIDERED += "sysvinit"
VIRTUAL-RUNTIME_init_manager = "systemd"
VIRTUAL-RUNTIME_initscripts = "systemd-compat-units"

:


~/habr-yocto-lte/build$ bitbake –k core-image-base

, 4 :). .


~/habr-yocto-lte/build/tmp/deploy/images/beaglebone


PPP


, , , LTE- Quectel EC21-E, .. Linux. PPP Linux, ppp , «» bitbake pppd chat, ppp.


:


~/habr-yocto-lte/build$ bitbake virtual/kernel -c menuconfig

menuconfig :


Device drivers --->
    [*] Network device support --->
        <M> PPP (point-to-point protocol) support
            <M> PPP BSD-Compress compression
            <M> PPP Deflate compression
            <*> PPP filtering
            <M> PPP MPPE compression (encryption)
            <*> PPP multilink support
            <M> PPP over Ethernet
            <M> PPP support for async serial ports
            <M> PPP support for sync tty ports 

menuconfig. , , . , defconfig recipes-kernel.


defconfig:


~/habr-yocto-lte/build$ bitbake virtual/kernel -c savedefconfig

defconfig ~/habr-yocto-lte/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.19.94+gitAUTOINC+5a23bc00e0-r22a/build


, , -. meta-habr:


~/habr-yocto-lte/build$ bitbake-layers create-layer ~/habr-yocto-lte/meta-habr

~/habr-yocto-lte meta-habr – -. recipes-example, , , - bblayers.conf:


~/habr-yocto-lte/build$ rm -r ~/ habr-yocto-lte/meta-habr/recipes-example/
~/habr-yocto-lte/build$ bitbake-layers add-layer ~/habr-yocto-lte/meta-habr

Linux. :


~/habr-yocto-lte$  mkdir – p meta-habr/recipes-kernel/linux/linux-ti-staging/beaglebone
~/habr-yocto-lte$  touch meta-habr/recipes-kernel/linux/linux-ti-staging_%.bbappend

defconfig ~/habr-yocto-lte/meta-habr/recipes-kernel/linux/linux-ti-staging/beaglebone


~/habr-yocto-lte$ cp ~/habr-yocto-lte/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.19.94+gitAUTOINC+5a23bc00e0-r22a/build/defconfig  meta-habr/recipes-kernel/linux/linux-ti-staging/beaglebone

linux-ti-staging_%.bbappend :


FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI += "file://defconfig"

, defconfig . , PPP :


~/habr-yocto-lte/build$ bitbake –k core-image-base
~/habr-yocto-lte/build$ cat buildhistory/images/beaglebone/glibc/core-image-base/installed-packages.txt | grep "ppp"
--------------------------------------------------------
kernel-module-ppp-async-4.19.94-g5a23bc00e0_4.19.94+git0+5a23bc00e0-r22a_beaglebone.ipk
kernel-module-ppp-deflate-4.19.94-g5a23bc00e0_4.19.94+git0+5a23bc00e0-r22a_beaglebone.ipk
kernel-module-ppp-generic-4.19.94-g5a23bc00e0_4.19.94+git0+5a23bc00e0-r22a_beaglebone.ipk
kernel-module-ppp-mppe-4.19.94-g5a23bc00e0_4.19.94+git0+5a23bc00e0-r22a_beaglebone.ipk
kernel-module-pppoe-4.19.94-g5a23bc00e0_4.19.94+git0+5a23bc00e0-r22a_beaglebone.ipk
kernel-module-pppox-4.19.94-g5a23bc00e0_4.19.94+git0+5a23bc00e0-r22a_beaglebone.ipk
kernel-module-ppp-synctty-4.19.94-g5a23bc00e0_4.19.94+git0+5a23bc00e0-r22a_beaglebone.ipk

ppp


IMAGE_INSTALL_append. local.conf :


IMAGE_INSTALL_append = " ppp"

, ppp :


~/habr-yocto-lte/build$ bitbake –k core-image-base
~/habr-yocto-lte/build$ cat buildhistory/images/beaglebone/glibc/core-image-base/installed-packages.txt | grep "ppp_"
--------------------------------------------------------
ppp_2.4.7-r0_beaglebone.ipk

LTE-. pppd chat, ppp, . ppp.


pppd chat


habrppp, habr-chat-connect habr-chat-disconnect :


  • habrppp
    /dev/ttyUSB3
    921600
    user "beeline"
    password "beeline"
    connect 'chat -s -v -f /etc/ppp/peers/habr-chat-connect'
    disconnect 'chat -s -v -f /etc/ppp/peers/habr-chat-disconnect'
    hide-password
    noauth
    debug
    defaultroute
    noipdefault
    persist
  • habr-chat-connect
    ABORT "BUSY"
    ABORT "NO CARRIER"
    ABORT "NO DIALTONE"
    ABORT "ERROR"
    ABORT "NO ANSWER"
    TIMEOUT 30
    "" AT
    OK ATE0
    OK ATI;+CSUB;+CSQ;+CPIN?;+COPS?;+CGREG?;&D2
    OK AT+CGDCONT=1,"IP","static.beeline.ru",,0,0
    OK ATD*99#
    CONNECT ""
  • habr-chat-disconnect
    ABORT "ERROR"
    ABORT "NO DIALTONE"
    "" +++
    "" +++
    "" +++

.
LTE- Quectel EC21-E :


  • ttyUSB0 –
  • ttyUSB1 – GPS NMEA
  • ttyUSB2 – AT-
  • ttyUSB3 – PPP

USB-, , , , . , habrppp PPP /dev/ttyUSB3.


user password habrppp, APN AT+CGDCONT habr-chat-connect, .


ppp


-. ppp:


~/habr-yocto-lte$ mkdir –p meta-habr/recipes-connectivity/ppp/ppp/beaglebone
~/habr-yocto-lte$ touch meta-habr/recipes-connectivity/ppp/ppp_%.bbappend

, ~/habr-yocto-lte/meta-habr/recipes-connectivity/ppp/ppp/beaglebone ppp_%.bbappend:


FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" 

SRC_URI += "file://habrppp \             
            file://habr-chat-connect \             
            file://habr-chat-disconnect \             
            file://20-habr-modem.rules \             
            " 

do_install_append () {  
        install -m 0755 ${WORKDIR}/habrppp ${D}${sysconfdir}/ppp/peers/habrppp  
        install -m 0755 ${WORKDIR}/habr-chat-connect ${D}${sysconfdir}/ppp/peers/habr-chat-connect  
        install -m 0755 ${WORKDIR}/habr-chat-disconnect ${D}${sysconfdir}/ppp/peers/habr-chat-disconnect    
        mkdir -p ${D}${sysconfdir}/udev/rules.d     
        install -m 0755 ${WORKDIR}/20-habr-modem.rules ${D}${sysconfdir}/udev/rules.d/20-habr-modem.rules 
}

, , , 20-habr-modem.rules. udev, ttyUSB3 pppd . USB-. 20-habr-modem.rules:


SUBSYSTEM=="tty", KERNEL=="ttyUSB3", TAG+="systemd", ENV{SYSTEMD_WANTS}="ppp@habrppp.service"


, balenaEtcher microSD . :


~$ ifconfig
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

ppp0      Link encap:Point-to-Point Protocol
          inet addr:XXX.XXX.XXX.XXX  P-t-P:XXX.XXX.XXX.XXX  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:13 errors:0 dropped:0 overruns:0 frame:0
          TX packets:17 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:432 (432.0 B)  TX bytes:611 (611.0 B)

PPP , pon poff. :


~$ pon habrppp

:


~$ poff habrppp



Das Projekt ist unter https://gitlab.com/amamaev/habr-yocto-lte verfĂŒgbar . FĂŒhren Sie den folgenden Befehl aus, um das Repository zu klonen:


~$ git clone --recursive https://gitlab.com/amamaev/habr-yocto-lte.git

Vergessen Sie nicht, den Pfad zu den Ebenen in der Datei bblayers.conf anzupassen

All Articles