Modem

There are two different userspace services in postmarketOS that can manage the modem:


 * oFono: Integrated in Glacier and similar Mer-related projects like AsteroidOS or UBports-related projects like Lomiri
 * ModemManager: Integrated in Phosh, Sxmo and Plasma Mobile (KDE switched from oFono to MM from about 21.10 release)

Some modems might be only supported in oFono, while others are only supported in ModemManager. But usually either can be used (but not at the same time).

oFono
oFono can be controlled using the Python oFono test scripts from the command line:

$ sudo apk add ofono-scripts $ /usr/lib/ofono/test/enable-modem $ /usr/lib/ofono/test/online-modem $ /usr/lib/ofono/test/list-modems

Check if the SIM card shows up. If you have a dual SIM Qualcomm device (e.g. Wileyfox Swift), follow this guide.

Unlock the SIM card: $ /usr/lib/ofono/test/enter-pin pin

Eventually, your SIM card should show up as registering in.

is also very useful test tool:

$ sudo apk add ofonoctl $ ofonoctl list

SMS
Use the  and   test scripts (from   package).

$ /usr/lib/ofono/test/send-sms "COUNTRYCODENUMBER" "Test SMS from oFono" 0 Send message using modem /gobi_0 ... /gobi_0/message_9914F33A7C53DD6F080B38755E7D64FD59EA8F8F

ModemManager
ModemManager is integrated into the UI of Phosh and Plasma Mobile. Alternatively it can be controlled using  from the command line:

$ sudo mmcli -m 0 $ sudo mmcli --sim 0 --pin
 * 1) List modems
 * 1) Enter pin

Signal strength information can be viewed by using the following commands:

$ mmcli -m any --signal-setup=120 $ mmcli -m any --signal-get
 * 1) Set the interval
 * 1) Get the information

SMS
How to test SMS functionality with ModemManager:

Mobile Data
To set up mobile data in command line with ModemManager: NetworkManager will then connect mobile network automatically when it's available. To connect manually use.
 * Make sure ModemManager is started.
 * If your SIM is locked, make sure to enter PIN (see above).
 * Look up your modem device name  /   /   in output of.
 * Create network connection for modem:
 * Check if an IP address is assigned to wwan0/rmnet0/etc with.
 * Check if modem is the gateway with  (expect  )
 * Ping something (e.g. ).

See https://gist.github.com/Minecrell/4cc2bfb9fcae18e294386b0a213907d1 for oFono instructions.

Qualcomm Modems
On most Qualcomm SoCs the modem is a separate processor which lives next to the main CPU where Linux is running on. It needs to be given firmware by the host processor to start.

The procedure for getting the modem to work is generally the following:
 * Package and install the Firmware of your modem into the file system, generally the  and   files.
 * Install the package  or   (for most older SoCs on mainline, see below), depending on the kernel you are using (and reboot to activate the udev rules and services).
 * Install  and start it using
 * You should see signs of your firmware being loaded in the dmesg.
 * You can use the ofono test scripts (packaged in  or   to see if the Linux recognized your modem and if it works correctly.
 * On some platforms you may need to manually install, see  Dual-Sim QMI page for some details.

Note: On newer SoCs (e.g. SDM845 or MSM8953), the modem seems to be available only through QRTR, and not through rpmsg channels as on older Qualcomm SoCs. You can see this if  also lists modem services such as. In that case, you can query the modem through libqmi 1.26.0+ like  (get   from the   output). Currently, the QRTR transport does not seem to be supported in modem services like oFono or ModemManager yet. At least for ModemManager there seem to be ongoing efforts to make it work, though. See SDM845 Modem for details and example output.

When switching UI (or debugging modem)
Ofono and ModemManager cannot run at the same time. If you switch UI from Mer- or UBPorts-related projects to Phosh or Plasma Mobile (or vice versa), you might have to make sure that only the correct userspace service is running.

Check if ofono service is running:

Start ofono service (not persistent):

Getting ModemManager logs
1. Open  with your favorite text editor with root permissions

2. Enable debug mode by changing the  line to

3. Output the logs to  by adding   to the same file.

4. Save and restart ModemManager with

5. The logs will now be available at. Note that they contain sensitive information such as your phone number(s), IMEI, etc.! Scrub them when uploading these logs to the Web!

Also note that the logs may take up a lot of space if you leave them running for a long time.

Example of 

#!/sbin/openrc-run supervisor=supervise-daemon command=/usr/sbin/ModemManager command_args="${modemmanager_opts} --debug --log-level=DEBUG" error_log="/var/log/modemmanager.err" description="ModemManager Daemon" depend { need dbus }

Getting eg25-manager logs
This only applies to the PinePhone.

1. Open  with your favorite text editor with root permissions

2. Output the logs to  by adding   to the same file.

4. Save and restart eg25-manager with

5. The logs will now be available at.

Example of 

#!/sbin/openrc-run supervisor=supervise-daemon command=/usr/bin/eg25-manager error_log="/var/log/eg25-manager.err" description="EG25 Manager Daemon"

usbmon logs
The Linux kernel allows you to capture QMI and AT commands over USB using  and can be read using Wireshark. See this page to use it: https://wiki.postmarketos.org/wiki/Create_usbmon_capture

Relevant issues

 * N900: integrate ofono
 * Let's get the cellular modem working! (presenting various stacks, general discussion)
 * Get qualcomm modems working (at the end of the thread scintill wrote a few wrappers and made SMS on a QC modem work with a downstream kernel without userspace blobs!)
 * i9195/Qualcomm modem support (scintill's work integrated)
 * xiaomi-santoni: gets modem to work on the device

Relevant pages

 * QMI
 * Samsung Modem