In this post, we’ll walk through all of the steps needed to configure a specific set of modems under Ubuntu as a reference. We’ll use Quectel EC25 modem in this showcase, if you’re using another modem or another userspace, the details may be different, but the fundamentals will be the same.
- UC15 UMTS/HSDPA : 3.6 Mbit/s DL, 384 Kbit/s UL
- UC20 UMTS/HSPA+ : 14.4 Mbit/s DL, 5.76 Mbit/s UL
- EC21 LTE Cat1 : 10 Mbit/s DL, 5 Mbit/s UL
- EC25 LTE Cat4 : 150 Mbit/s DL, 50 Mbit/s UL
- BG96 LTE Cat M1/NB1 : 375 kbit/s DL and 375 kbit/s UL
- EP06 LTE Cat6 : 300 Mbit/s DL, 50 Mbit/s UL
And from u-blox:
- SARA-R410M-02B LTE Cat M1/NB1 : 300 kbit/s DL and 375 kbit/s UL
- SARA-R410M-52B LTE Cat M1 : 300 kbit/s DL and 375 kbit/s UL
For the impatient
These images contain Freescale-licensed content, so you will need to register on our web-site and log in before you can accept the license agreement and download the images from here:
nitrogen8mm-4.14.x_2.0.1_ga- bionic-en_US-console-modem- weston_aarch64.img.gz
- ubuntu@bionic-dev64:~$ sha1sum -b 20190922*.img.gz
- Update#1 Release Notes
- 20191212-nitrogen8mm-4.14.x_2.0.1_ga-bionic-en_US-console-modem-weston_aarch64_fastboot_8G.tgz (LABEL : sys-09h)
- ubuntu@bionic-dev64m:~$ sha1sum -b *img
- 20191212-nitrogen8mm-4.14.x_2.0.1_ga-bionic-en_US-console-modem-weston_aarch64.img.gz (LABEL : sys-09h)
- ubuntu@bionic-dev64m:~$ sha1sum -b 20191212*.img.gz
- Update#2 Release Notes
- 20200408-nitrogen8mm-4.14.x_2.0.1_ga-bionic-en_US-console-modem-weston_aarch64_fastboot_8G.tgz (LABEL : sys-09h)
- ubuntu@bionic-dev64m:~$ sha1sum -b *img
- 20200408-nitrogen8mm-4.14.x_2.0.1_ga-bionic-en_US-console-modem-weston_aarch64.img.gz (LABEL : sys-09h)
- ubuntu@bionic-dev64m:~$ sha1sum -b 20200408*.img.gz
The above images contain all packages what needed to work with cellular modems, including network-manager and modemmanager and screen packages.
Programming the image
Since the Nitrogen8M_Mini board has an SD card slot, not like Nitrogen8M, you can create an SD card similarly to i.MX6 boards.
The image is a slightly-less-than-8GiB image file containing the partition table. For example, if you want to create an SD card for a console image, you need to do the following :
$ sudo apt install gddrescue xz-utils util-linux $ gunzip 20200408-nitrogen8mm-4.14.x_2.0.1_ga-bionic-en_US-console-weston_aarch64.img.gz $ sudo ddrescue -D --force 20200408-nitrogen8mm-4.14.x_2.0.1_ga-bionic-en_US-console-weston_aarch64.img /dev/sdX
You have to replace sdX with your actual SDHC reader/writer device. Use the
lsblk command to check it.
lsblk with unplugged SDHC reader, then insert the device, and type
lsblk again. A new node will be added , that is your SDHC reader/writer device.
In the rest of this post we’ll walk through the following:
- Software configuration for a headless (No GUI) Ubuntu system
Installing EC25 modem on Nitrogen8M and Nitrogen8M Mini
These boards require a mini PCI-e to USB adapter to connect the EC25 mini PCIe modem. They’re cheap and easy to find (Search Amazon for “mini PCI-e USB wireless SIM” keywords). Th uBlox SARA modem doesn’t need adapter, it has a built-in micro USB connector or its a surface mounted unit on your board.
If you need a free USB port, install a USB HUB, and problem solved.
Using modem on a headless (No GUI) Ubuntu system
Make sure you have the latest kernel installed, but at least the ABI >= 17 :
ubuntu@bionic-dev64:/$ uname -r 4.14.98-17-boundary-17b
If this is not the case, please update your system :
We will solve the modem handling tasks with the modemmanager package. This package provides a unified high level API for communicating with (mobile broadband) modems. ModemManager is a daemon that gets started at boot time.
The modemmanager package provides a command line tool, named mmcli, to control the ModemManager daemon. That will be the tool used below.
We will solve the connection handling tasks with the network-manager package. We can use the NetworkManager’s huge database to use the cellular service provider data and settings. With the NetworkManager we can create connection configuration files, with specific parameters, that makes internet connection handling very easy.
Make sure you have installed modemmanager , networkmanager packages :
ubuntu@bionic-dev64:~$ dpkg -l | grep -e modemmanager -e network-manager ii modemmanager 1.10.0-1~ubuntu18.04.2 arm64 D-Bus service for managing modems ii network-manager 1.10.6-2ubuntu1.1 arm64 network management framework (daemon and userspace tools)
If these packages are not installed, please type the following and then restart the system:
ubuntu@bionic-dev64:/$ sudo apt install modemmanager network-manager uuid
If everything went well, your ModemManager and NetworkManager will start at boot time. You can check it like so:
ubuntu@bionic-dev64:~$ systemctl --no-pager list-units --state=running | grep Manager.service ModemManager.service loaded active running Modem Manager NetworkManager.service loaded active running Network Manager
When ModemManager starts it scans the serial ports for modems and it tries to recognize them. It takes few seconds after the login prompt, so you’ll need to be patient.
Depending on your modem it might be necessary to create the following zero length file (to set your modem managed):
ubuntu@bionic-dev64:~$ sudo touch /etc/NetworkManager/conf.d/10-globally-managed-devices.conf
Testing whether the system recognizes the modem
You can check the presence of the USB modem device using lsusb:
ubuntu@bionic-dev64:~$ lsusb Bus 003 Device 002: ID 152d:0578 JMicron Technology Corp. / JMicron USA Technology Corp. JMS567 SATA 6Gb/s bridge Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 007: ID 0458:018b KYE Systems Corp. (Mouse Systems) Bus 001 Device 006: ID 04d9:a0f8 Holtek Semiconductor, Inc. Bus 001 Device 005: ID 2c7c:0125 Quectel Wireless Solutions Co., Ltd. EC25 LTE modem Bus 001 Device 002: ID 05e3:0608 Genesys Logic, Inc. Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
The 6th one with 2c7c:0125 key, that is our EC25 modem.
You can check the modem’s serial ports :
ubuntu@bionic-dev64:~$ ls -a1 /dev/ttyU* /dev/ttyUSB0 /dev/ttyUSB1 /dev/ttyUSB2 /dev/ttyUSB3
The EC25 modem creates three USB serial ports (ttyUSB1 does not belong to the modem in the above list). Other modems may create fewer or more.
At this point, you can see if modemmanager detects the modem with mmcli -L:
ubuntu@bionic-dev64:~$ mmcli -L /org/freedesktop/ModemManager1/Modem/0 [QUALCOMM INCORPORATED] QUECTEL Mobile Broadband Module
And you can see more details of the modem with mmcli -m:
ubuntu@bionic-dev64:~$ mmcli -m 0 -------------------------------- General | dbus path: /org/freedesktop/ModemManager1/Modem/0 | device id: 94ec3702b44ee6fb7d67141906997d7070bf8198 -------------------------------- Hardware | manufacturer: QUALCOMM INCORPORATED | model: QUECTEL Mobile Broadband Module | revision: EC25EFAR06A04M4G | h/w revision: 10000 | supported: gsm-umts, lte | current: gsm-umts, lte | equipment id: 866758045611098 -------------------------------- System | device: /sys/devices/platform/32e50000.usb/ci_hdrc.1/usb1/1-1/1-1.2/1-1.2.1 | drivers: option1, qmi_wwan | plugin: Quectel | primary port: cdc-wdm0 | ports: ttyUSB0 (qcdm), ttyUSB2 (at), cdc-wdm0 (qmi), wwan0 (net), | ttyUSB3 (at) -------------------------------- Status | lock: sim-pin2 | unlock retries: sim-pin (3), sim-pin2 (3), sim-puk (10), sim-puk2 (10) | state: registered | power state: on | access tech: lte | signal quality: 84% (recent) -------------------------------- Modes | supported: allowed: 2g; preferred: none | allowed: 3g; preferred: none | allowed: 4g; preferred: none | allowed: 2g, 3g; preferred: 3g | allowed: 2g, 3g; preferred: 2g | allowed: 2g, 4g; preferred: 4g | allowed: 2g, 4g; preferred: 2g | allowed: 3g, 4g; preferred: 3g | allowed: 3g, 4g; preferred: 4g | allowed: 2g, 3g, 4g; preferred: 4g | allowed: 2g, 3g, 4g; preferred: 3g | allowed: 2g, 3g, 4g; preferred: 2g | current: allowed: 2g, 3g, 4g; preferred: 4g -------------------------------- Bands | supported: egsm, dcs, utran-1, utran-5, utran-8, eutran-1, eutran-3, | eutran-5, eutran-7, eutran-8, eutran-20, eutran-38, eutran-40, | eutran-41 | current: egsm, dcs, utran-1, utran-5, utran-8, eutran-1, eutran-3, | eutran-5, eutran-7, eutran-8, eutran-20, eutran-38, eutran-40, | eutran-41 -------------------------------- IP | supported: ipv4, ipv6, ipv4v6 -------------------------------- 3GPP | imei: 866758045611098 | operator id: unknown | registration: unknown -------------------------------- 3GPP EPS | ue mode of operation: ps-2 -------------------------------- SIM | dbus path: /org/freedesktop/ModemManager1/SIM/0
ubuntu@bionic-dev64:~$ nmcli dev DEVICE TYPE STATE CONNECTION eth0 ethernet connected Wired connection 1 cdc-wdm0 gsm disconnected -- wlan0 wifi disconnected -- lo loopback unmanaged --
Finding the optimal antenna position
Now we have to stop NetworkManager and ModemManager temporarily, because we want to run some more tests:
ubuntu@bionic-dev64:~$ systemctl --no-pager list-units --state=running | grep Manager.service ModemManager.service loaded active running Modem Manager NetworkManager.service loaded active running Network Manager ubuntu@bionic-dev64:~$ sudo systemctl stop ModemManager.service NetworkManager.service ubuntu@bionic-dev64:~$ systemctl --no-pager list-units --state=running | grep Manager.service ubuntu@bionic-dev64:~$
And we start screen serial console application to communicate with modem on ttyUSB2 (primary AT port of the modem, as shown above).
ubuntu@bionic-dev64:~$ screen /dev/ttyUSB2 115200
Now you get an empty console screen. If local echo is not set, then type ATZ for the modem blindly, and that will reset it.
Now type :
ATI Quectel EC25 Revision: EC25EFAR06A04M4G OK
This tells us that the modem is present and working. Now type the following command, to check if your GSM antenna is set properly:
AT+CSQ +CSQ: 26,99 OK
This is the GSM signal quality in +CSQ: RSSI, BER format, where
RSSI = Received Signal Strength Indication, and
BER = Channel Bit Error Rate 0…7 (in percent) or 99 = Not known or not detectable
The RSSI = 99 (+CSQ: 99,99) means an unknown or undetectable signal level.
Here is a table to calculate the signal levels from RSSI :
|level dBm||-113 dBm||-111 dBm||-109 dBm||-107 dBm||-105 dBm||-103 dBm||-101 dBm||– 99 dBm|
|level dBm||-97 dBm||-95 dBm||-93 dBm||-91 dBm||-89 dBm||-87 dBm||-85 dBm||-83 dBm|
|level dBm||-81 dBm||-79 dBm||-77 dBm||-75 dBm||-73 dBm||-71 dBm||-69 dBm||-67 dBm|
|level dBm||-65 dBm||-63 dBm||-61 dBm||-59 dBm||-57 dBm||-55 dBm||-53 dBm||>-51 dBm|
Move/rotate your antenna and repeat the command above until you find the antenna’s optimal position.
In general we can say:
- RSSI values below 10 will not work
- RSSI values between 10 and 15 will have many disconnections
- RSSI values between 15 and 20 are weak, but could work
- RSSI values between 20 and 25 are good
- RSSI values above 25 are excellent, recommended
For LTE 100 Mbit/s or higher speed connections you’ll need excellent signal quality, RSSI > 25 for reliable service.
Checking the subscriber information
You should check your SIM card, since it provides a lot of information:
AT+CIMI 3100262475092493 OK
This command will query your SIM card’s IMSI number ( International Mobile Subscriber Identity )
The first 3 digits of IMSI number is MCC ( Mobile Country Code )
The following 2 (Europe) or 3 (North America) digits of the IMSI is the MNC ( Mobile Network Code )
The remaining digits is the MIN ( Mobile Identification Number )
You can check your MCC/MNC code in the following page :
For example if your MCC is 310 and your MNC is 026 then you are a T-Mobile subscriber in USA .
Why is this important ? Because on this page :
You can find your APN number based on you MCC and MNC number, and that is necessary, when you want to create a connection setup, to dial up your service provider. Of course you may ask your service provider about these datas.
If you get an error :
AT+CIMI +CME ERROR: Sim failure
Then your SIM card is not inserted properly, or it is locked by the CardLock feature, or its broken.
If the tests above pass, you can exit the screen console application ( <ctrl+A> Q, then Y ) .
Connecting to the internet
For doing that, you have to create a connection setup file as user “root” in the /etc/NetworkManager/system-connections directory, with the following content :
ubuntu@bionic-dev64:/$ sudo cat /etc/NetworkManager/system-connections/MyModem [connection] id=EC25 uuid=15d742f1-2b5a-421e-9f27-fcb1fc26d72d type=gsm autoconnect=false [ipv4] method=auto [gsm] number=*99# #username=user #password=passwd apn=epc.tmobile.com [serial] baud=115200
The username and the password are usually not necessary, or can be anything. The uuid is a unique identifier you can create with the uuid command (which installed earlier) :
ubuntu@bionic-dev64:~$ uuid 15d742f1-2b5a-421e-9f27-fcb1fc26d72d ubuntu@bionic-dev64:~$
The id can be anything that you can memorize easily (“EC25” is not mandatory). The same goes to for the file name “MyModem”. It can be anything. You have to get the apn from your service provider, or from HERE , as described above, earlier.
This is a minimal connection setup file. For detailed instructions, type :
ubuntu@bionic-dev64:/$ man nm-settings
When finished, set the connection setup file’s attribute to 0600 :
ubuntu@bionic-dev64:/$ sudo chmod 600 /etc/NetworkManager/system-connections/MyModem
And make sure that the file’s owner:group is root. If the owner is not root, then the Network Manager will ignore the connection setup.
ubuntu@bionic-dev64:/$ sudo chown root:root /etc/NetworkManager/system-connections/MyModem
Now reboot, and wait for modemmanager to recognize the modem.
Then enable modem :
ubuntu@bionic-dev64:/$ sudo mmcli -m 0 -e successfully enabled the modem ubuntu@bionic-dev64:/$
And check the connections :
ubuntu@bionic-dev64:~$ nmcli con NAME UUID TYPE DEVICE Wired connection 1 355a9384-3ebf-3a20-b822-e3f4b39b4b46 ethernet eth0 EC25 15d742f1-2b5a-421e-9f27-fcb1fc26d72d gsm --
Then you can dial (connect) to any of them :
ubuntu@bionic-dev64:~$ sudo nmcli con up id EC25 Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/2) ubuntu@bionic-dev64:/$
You can see the status of the active connections like this :
ubuntu@bionic-dev64:~$ nmcli con show --active NAME UUID TYPE DEVICE EC25 15d742f1-2b5a-421e-9f27-fcb1fc26d72d gsm cdc-wdm0 Wired connection 1 355a9384-3ebf-3a20-b822-e3f4b39b4b46 ethernet eth0
You can use the internet now, download, upload, browse, launch wget, as you like it. When finished, you can disconnect with the following command. You don’t need to be in a hurry, service providers usually bill for data traffic and not connection time.
ubuntu@bionic-dev64:~$ sudo nmcli con down id EC25 Connection 'EC25' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/2)
Pay close attention to the commands above, since we show both mmcli (modem manager) and nmcli (network manager).
A note: when you restart the system, Network Manager needs about 20 seconds to close and release the network devices. (“A stop job is running for Modem Manager”) Please be patient, the proper shutdown is important as always.
As always please tell us how this works for you. Contact us if you have any trouble or ask a question by posting a reply below.