Reseting mobile connection - Librem 5

It seems like after suspending and resuming about 3 or 4 times the mobile broadband will not comeback. The options actually disappears in settings as well.

I am wondering if there is a terminal command I can use to force it to come back?

Probably this issue:

Most annoying.

I am aware of one workaround: I created a cron job to ping the outside world once every two seconds, that seems to be often enough so that suspend/resume does not happen, then this problem does also not happen anymore. Of course the battery drains faster then.

Maybe ping instead? I would think once a minute would be good enough.

Maybe, but that’s not going to send any traffic through the mobile connection.

I would have thought that there are easier ways of ensuring that suspend does not happen i.e. disable it.

Is that what keeps the phone from going to sleep? I just figured it’d be easier on the battery.

I don’t know.

I recover automatically and it worked so far very good on my L5.

I sketched how I reused the scripts from the issue here (no calls nor sms anymore - modem/usb-hub problem):

1 Like


Would anyone here be able to help me at the as a service? Right now I’m starting it manually through terminal, and just leaving it running, but I am curious if this is wasting more power than it would if this was running as a service automatically?

Thanks in advance!

This watch script seems to be doing the trick to keep the modem running. It is crazy to me though how many times it is having to do it’s job. Then I reboot, and it doesn’t need to do anything. It seems to be after coming back from standby that such a thing is necessary.

Edit: I am noticing that almost 100% of the time when I use firefox esr or vivaldi to access web client for chat platforms that the modem is resetting or dropping off. Before I do this on a fresh boot the modem is super stable. After using a web browser to access chat clients (threema, rocket chat, discord, telegram) I get nearly instant cellular drop outs, followed by nearly every minute the script restarting the service.

This is incredibly frustrating to say the least.

This is how I remember I did it:

Put the scripts into /home/purism/bin (,

purism@pureos:~$ ls -l bin/*modem* 
-rwxr-xr-x 1 root   root    310  2. Jun 11:00 bin/
-rwxr-xr-x 1 purism purism 1404  2. Jun 10:56 bin/ is called as root (using sudo) - make it belong to root (like shown above) using this command:

sudo chmod 775 /home/purism/bin/; sudo chown root:root /home/purism/bin/

Edit your sudoers configuration to let purism run as root: sudo visudo /etc/sudoers.d/11_recover-modem

Copy the following into the editor and save the file:

Cmnd_Alias RECOVER_MODEM_CMD = /home/purism/bin/
User_Alias RECOVER_MODEM_GRP  = purism


Put the service file into /home/purism/.config/systemd/user/watchmodem.service

purism@pureos:~$ ls -l .config/systemd/user/watchmodem.service
-rw-r--r-- 1 purism purism 158 27. Mai 12:46 .config/systemd/user/watchmodem.service

Reload systemd config: systemctl --user daemon-reload

Enable the service: systemctl --user enable watchmodem
Check the service: systemctl --user status watchmodem

My output looks like this:

purism@pureos:~$ systemctl --user status watchmodem
● watchmodem.service - Watch Modem of Librem5
     Loaded: loaded (/home/purism/.config/systemd/user/watchmodem.service; enabled; preset: enabled)
     Active: active (running) since Fri 2022-09-23 12:24:38 CEST; 3 days ago
   Main PID: 796 (
      Tasks: 3 (limit: 3124)
     Memory: 40.4M
        CPU: 2min 14.411s
     CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/watchmodem.service
             ├─796 /bin/bash /home/purism/bin/
             ├─800 journalctl -f SYSLOG_IDENTIFIER=ModemManager
             └─801 /bin/bash /home/purism/bin/

Sep 26 08:56:06 pureos /home/purism/bin/[15249]: found: 'QMI endpoint hangup: removed'
Sep 26 08:56:06 pureos[15252]: Playing WAVE '/home/purism/.local/share/sounds/__custom/glass.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
Sep 26 08:56:17 pureos /home/purism/bin/[15386]: seems like modem recovered by itself

Didn’t re-install and check all the steps like written down here - so follow with care and if anything doesn’t work let me know.

I agreed to build a package of this as a temporary solution until the cause for the disconnects is found and taken care of. Will be part of bm818-tools.

If anybody installs this manually it will have to be removed when the package is ready and might be installed via dependencies. I’ll write about it in this thread so that anybody will be informed (you can watch the thread or watch the repo for the merge request that’ll come sometimes).


Hmm, followed your instructions but the service is exiting.

Not quite sure I know why…

What does systemctl --user status watchmodem show?

what the picture shows is what systemctl reports when running that command.

I’m not quite sure why it is doing that.

What output do you get when you run the script directly from command line by running ˋwatch-modem.shˋ (or if you need to give the path ˋ~/bin/watch-modem.shˋ?

I looked at the script again and found that there are some commands needed that might not be installed by default. The existence of those commands is checked at the beginning and the scripts exits if they do not exist. Would be the most simple explanation …

well the script runs and works. I had to source my own glass.wav and put it in the __custom directory but other than that it works. parallel.

running does give me an error 3: [[: not found

I guess one question I have is whether I really should have been putting these in /home/purism/bin instead of /bin directly? Was that intentional?

Not saying that this is the problem but you need to be careful with that check since PATH may differ depending on the context and in particular there is an interaction between sudo and PATH (for security reasons).

Since the multiple references to those two scripts are explicitly as /home/purism/bin/ then, yes, the scripts are intentionally in /home/purism/bin and that probably is a better place for something that is hopefully a temporary hack. I’m sure you could get it working if you put the scripts somewhere else and adjusted all the references.

(Edit: Having said that, I am not totally convinced that it is secure to put the recover script in /home/purism/bin and change the ownership of the script to root because perhaps a malicious user can move his bin directory out of the way and replace it with a new bin directory with a new recover script. @ChriChri ?)

Are you doing something weird and overriding which shell is in use? That might be the result of using sh (dash?) rather than bash.

To comment further on that, I generally try to avoid putting my own hacky efforts in any existing system directory for executables.

O.k., we’ll have to find out why - this is probably the same reason the service doesn’t start.

Are you sure the #!/bin/bash beginning of the script is in the file and the files mode is correct? For me it looks like this:

purism@pureos:~$ ls -l /home/purism/bin/; head -n1 /home/purism/bin/
-rwxr-xr-x 1 purism purism 1404  2. Jun 10:56 /home/purism/bin/

I just checked my directories and they are set - let’s say - quiet liberal. I can’t remember changing the mode and even less why I should have done that. How do yours look?

purism@pureos:~$ ls -ld /home /home/purism /home/purism/bin
drwxr-xr-x  3 root   root   4096  4. Sep 14:40 /home
drwxr-xr-x 38 purism purism 4096 27. Sep 09:42 /home/purism
drwxr-xr-x  2 purism purism 4096 22. Aug 20:57 /home/purism/bin

I put these inside the home directory to have them somewhere where they will not conflict with any files that might be installed by packages.

If one would choose to install the same solution as root the files would belong to /usr/local/bin or /usr/local/sbin.

My plan is to install these files as a package in a slightly improved version that respects the global setting for quiet and silent.

From the package the files will end up in /usr/bin/, /usr/sbin/ and /usr/lib/systemd/.

I’m neither. This is just a hack or prove of work. If you’re unsure about any aspect of it and you’re in need of an immediate solution (in contrast to waiting for the package) and you’re need for security is high you should adopt this hack to your needs.

so you’re probably not going to like this, but I will able to get it working by setting to root for user purism.

In other news the stability of my cellular connection is garbage as of late. Very frustrating. Has anyone else been able to work with Telekom in Germany? I’m thinking about switching to Aldi Talk, so I’d be interested in experience there as well.

:hear_no_evil: :see_no_evil: :speak_no_evil:

You mean suid bit?