0

I've connected a LTE usb dongle at raspberry pi 4B which has raspbian buster 10.
I have created a initialization script which consists of the following :

modprobe qmi_wwan
echo 'xxxx xxxx' > /sys/bus/usb/drivers/qmi_wwan/new_id
ip link set dev wwan0 down
echo Y > /sys/class/net/wwan0/qmi/raw_ip
ip link set dev wwan0 up
qmicli --device=/dev/cdc-wdm0 --device-open-proxy --wds-start-network="ip-type=4,apn=apn" --client-no-release-cid

When I run it manually from the home directory

sudo ./init.sh

it works fine.

However when I try to run it as boot up script I always get the error :

couldn't create client for the 'wds' service: CID allocation failed in the CTL client: Transaction timed out

Firstly I tried to add the running of the script at the /etc/rc.local file.

Then I created a service to start up after boot up via systemd. The service file is basically the following:

[Unit]
Description=initialization script
After=remote-fs.target
After=syslog.target

[Service]
Type=simple
ExecStart=/bin/sh /home/pi/init.sh
User=root
[Install]
WantedBy=multi-user.target 

I tried with or without User=root, I also tried After=network.target but in any case I get the above error.

I tried using the following service file suggestef by @Ingo bellow :

[Unit]
Description=initialization script
Wants=network-online.target
After=network-online.target

[Service]
ExecStart=/bin/sh /home/pi/init.sh

[Install]
WantedBy=multi-user.target

But then I got the error:

**Αpr 23 12:41:17 raspberrypi init.sh[418]: Cannot find device "wwan0"
Apr 23 12:41:17 raspberrypi init.sh[418]: /home/pi/init.sh: 6: /home/pi/init.sh: cannot create /sys/class/net/wwan0/qmi/raw_ip: Directory nonexi
Apr 23 12:41:17 raspberrypi init.sh[418]: Cannot find device "wwan0"
Apr 23 12:41:17 raspberrypi init.sh[418]: error: couldn't create QmiDevice: Couldn't query file info: Error when getting information for file “/dev/cdc-wdm0”:**  

My assumption is that it doesn't recognize the ttyUSB on time but I don't know how to check it or fix it.

Does anyone knows what I'm doing wrong here ?

1 Answer 1

2

It seems your script needs the network connection to be complete online. So try to start your service after that target. Services are started as Type=simple with root rights by default, so you don't need that options.

[Unit]
Description=initialization script
Wants=network-online.target
After=network-online.target

[Service]
ExecStart=/bin/sh /home/pi/init.sh

[Install]
WantedBy=multi-user.target

There is only a very limited environment set when running a service, in particular there is no PATH variable set. So you must use full path names in the init.sh script, e.g. /sbin/modprobe ..., /bin/echo ..., /sbin/ip ... and so on.

3
  • Thanks for the suggestion. I tried it but I got a different error. I have updated my question with this outcome. I assume perhaps something is wrong with modprobe command and reboot.
    – dk13
    Apr 23, 2020 at 9:37
  • @dk13 I have updated the answer at the end.
    – Ingo
    Apr 23, 2020 at 9:53
  • I tried with /sbin/modeprobe and /bin/echo etc but get the same error as previous
    – dk13
    Apr 23, 2020 at 10:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.