# EC25 Modem Initialization Failure

**URL:** <https://forums.balena.io/t/ec25-modem-initialization-failure/370315>\
**Category:** balenaOS\
**Tags:** network\
**Created:** [April 16, 2024, 4:04pm UTC](https://forums.balena.io/t/ec25-modem-initialization-failure/370315 "2024-04-16T16:04:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rdecarre11](https://avatars.discourse-cdn.com/v4/letter/r/db5fbb/32.png) [@rdecarre11](https://forums.balena.io/u/rdecarre11)\
**Post date:** [April 16, 2024, 4:04pm UTC](https://forums.balena.io/t/ec25-modem-initialization-failure/370315/1 "2024-04-16T16:04:48Z")

</div>

Similar to a lot of folks out there

> [@Critical issue with ModemManager](https://forums.balena.io/t/critical-issue-with-modemmanager/370021):
>
> Hi I’ve started encountering an issue where the modem is unable to register itself to the cellular network. This is a major problem for devices running in production. I’m using the IOT-GATE-IMX8 paired with a SIMCOM\_SIM7600G modem. In this instance the device is running balenaOS 4.1.3+rev2 I’ve written another post about this issue in the past [Modem manager doesn't reconnect properly](https://forums.balena.io/t/modem-manager-doesnt-reconnect-properly/369712) The issue appears as follows: Operator issues a disconnect to the modem Modem is unable to reconnect, cont…

> [@Balena Fin Cell Modem Failure](https://forums.balena.io/t/balena-fin-cell-modem-failure/350731):
>
> Hello, We have an application deployed on the Balena Fin that requires use of a cell modem. (We typically use the Quectel EC25 modems.). We have deployed our solution to many installations and it generally works well. However, we have seen occasions where a device suddenly goes offline and never recovers, even though the user has not unplugged it. I added application code that detects when the gateway has not communicated with our servers for a while, and reboots the gateway using the follo…

> [@EC25 Modem failing to initialize](https://forums.balena.io/t/ec25-modem-failing-to-initialize/370188):
>
> EC25 on Compulab IOT-GATE-iMX8PLUS 2G-4G DRAM fails to initialize until the ModemManager service is restarted. Upon a boot or reboot, the Modem Manager Logs look like this: Mar 26 19:32:25 localhost ModemManager[1194]: ModemManager (version 1.22.0) starting in system bus... Mar 26 19:32:29 d3bc7f7 ModemManager[1194]: [device /sys/devices/platform/soc@0/32f10108.usb/38200000.usb/xhci-hcd.2.auto/usb3/3-1/3-1.3] creating modem with plugin 'quectel' and '6' ports Mar 26 19:32:29 d3bc7f7 ModemManag…

> [@Modem manager doesn't reconnect properly](https://forums.balena.io/t/modem-manager-doesnt-reconnect-properly/369712):
>
> Hi! I’ve encountered an issue a handful of times where the modem does not reconnect properly until reset (re-activating the connection solves the issue) i.e nmcli con up xxx On this post [Never reconnected after SIM desactivate/activate](https://lists.freedesktop.org/archives/modemmanager-devel/2021-July/008720.html) I found that it may be that the mobile operator issues a disconnection and the modem does not reconnect by itself. I have a gut feeling that this may be the same issue as what I am experiencing. This has happened two or three times now, rendering the device unre…

I have a Quectel EC25 connected to a Raspberry Pi CM4 in an [Edatec Cm4 Sensing](https://docs.edatec.cn/cm4sen/introduction.html#interface-diagram). We have 10 devices deployed and about half of the time, the modem doesn’t initialize properly. We also have a number of devices on which the modem was up, then drops out for a period of time. Basically only a power cycler will work in some cases.  
This is a product we’re looking to scale, so, we need help getting ModemManager, NetworkManager and this modem to work reliably.

---

<div class="post-metadata">

**Author:** ![TimoAtMUV](https://avatars.discourse-cdn.com/v4/letter/t/e56c9b/32.png) [@TimoAtMUV](https://forums.balena.io/u/TimoAtMUV)\
**Post date:** [April 23, 2024, 3:47pm UTC](https://forums.balena.io/t/ec25-modem-initialization-failure/370315/3 "2024-04-23T15:47:30Z")

</div>

Hey, we use many different CM4 based devices with EC25 modems and have no problems at all.

In our experience, however, there are a few steps that are extremely important to follow:

Configuration adjustments:

- Enable UART (sometimes)
- DT parameters must be adjusted correctly
- DT overlays must be adjusted correctly
- GPIO pins must be adjusted correctly

Mostly required custom configuration:

- RESIN\_HOST\_CONFIG\_otg\_mode = 1

Often some files have to be added to the device after flashing

- boot/overlays folder
- boot folder

What are your settings regarding these points?

---

<div class="post-metadata">

**Author:** ![rdecarre11](https://avatars.discourse-cdn.com/v4/letter/r/db5fbb/32.png) [@rdecarre11](https://forums.balena.io/u/rdecarre11)\
**Post date:** [April 26, 2024, 2:12am UTC](https://forums.balena.io/t/ec25-modem-initialization-failure/370315/4 "2024-04-26T02:12:07Z")

</div>

Thanks for the help! The manufacturer recommended the dtoverlays and params. None of them were specifically addressing the Modem, though.  
They also recommended that I reboot the modem on start (a little nuanced in container-land), they have a GPIO attached to the Modem. Doing so once at the start has worked well. There are still times where the modem will show in modem manager’s journal as “unusable”.  
Other than writing code to catch that state and reset it again, I am unsure of what to do.

---

<div class="post-metadata">

**Author:** ![TimoAtMUV](https://avatars.discourse-cdn.com/v4/letter/t/e56c9b/32.png) [@TimoAtMUV](https://forums.balena.io/u/TimoAtMUV)\
**Post date:** [May 14, 2024, 11:43am UTC](https://forums.balena.io/t/ec25-modem-initialization-failure/370315/5 "2024-05-14T11:43:19Z")

</div>

Since the EC25 modem is usually used as a USB device with the CM4, the problem is usually due to some USB problems.

If the modem shows up as “unusable”, does “lsusb” show the EC25 modem?

Can you show me your dtoverlays and params as well as GPIO pins settings?

Have you tried the otg\_mode too?

 ![image](https://global.discourse-cdn.com/balena/original/2X/c/cc41b0b90c58b116e6f0d7ac01d7a70760a7e066.png)

If you need to restart the modem on startup, you can write a small container that sends the necessary AT commands to the modem via USB serial upon startup.

---

<div class="post-metadata">

**Author:** ![the-real-kenna](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/the-real-kenna/32/9598_2.png) [@the-real-kenna](https://forums.balena.io/u/the-real-kenna)\
**Post date:** [June 1, 2024, 1:25am UTC](https://forums.balena.io/t/ec25-modem-initialization-failure/370315/6 "2024-06-01T01:25:30Z")

</div>

For everyone following this thread, we just wanted to share the final solution. The issue was sorted in a Private / Paid Support ticket, but the answer is sharable. 🙂

There are two possible paths we discussed - resetting GPIO from within a container, or by using NetworkManager dispatcher user scripts. The second option was the most effective solution in @rdecarre11’s case, but they both might be useful in different scenarios, so hopefully sharing both is helpful to others!

> **1. Resetting GPIO from within a container**  
> The recommended approach for this option is to use libgpio, which interacts with the GPIO character device (`/dev/gpiochipX` ). You can write a small program that links with libgpio directly, or if the reset process is simple enough, you can use `gpioset` on the command line, which comes with libgpio.
> 
> There are a few ways you can access this device from a container:
> 
> - You can map it into the container in your `docker-compose.yml` under devices
> - You can add `CAP_MKNOD` to the container and create the device node in your entry script using `mknod`
> - You can also run the container privileged, which by default recreates all the host’s devices inside of the container, though this is a greater security and stability risk as it disables much of the sandboxing of your application.
> 
> **2. Using NetworkManager dispatcher scripts**  
> Alternatively, you can add a NetworkManager [dispatcher script](https://docs.balena.io/reference/OS/network/#networkmanager-user-scripts).
> 
> Using the NetworkManager connection check feature, you can detect when the device has lost network connectivity (using the `CONNECTIVITY_STATE` variable), and bring the modem interface down/up.
> 
> You can then use the dispatcher script to reset the modem before the interface is brought up, which should guarantee a known state for the modem when ModemManager finds it.
