Modemmanager & 4g HAT communication over UART

Hi @aleksander0m,

You can register a free account with a few clicks using your GitHub credentials or by email from our dashboard - https://dashboard.balena-cloud.com/. Afterwards you can share the username with Frans here or by a private message.

He will add you to his application and then you may open a terminal to the host OS through the dashboard and access the device. It is very easy. Alternatively you may install our balena CLI and do a balena login and then balena ssh <DEVICE_UUID> to enter the device.

Please note that our you will need to remount / as read-write with mount -o remount, rw /. Afterwards you may edit the /lib/udev/rules.d/99-mm-serial-debug.rules file that I created with vi (the only editor available on the host OS/user applications are running in separate containers).

The other file I edited is /etc/systemd/system/ModemManager.service.d/ModemManager.conf where I added --debug.

Thanks a lot for looking into this!

Thanks,
Zahari

My user id is balena167 in balena-cloud.com

balena167

Done!

@majorz it seems that the ‘A’ is missing from the ACTION!="add|change|move|bind" in /lib/udev/rules.d/99-mm-serial-debug.rules. A mistake by chance?

I fixed the missing A, that was a mistake.

How do I get minicom installed there?

You may open a terminal to the container (main) and then install it with apt/apt-get (if not already installed).

The container has full permissions by default, so it is able to access the kernel in the same way as if being launched with a host OS terminal.

And it is embarrassing if I left an A out somehow when I edited the file - I blame it to vim :smiley:

I’m already thinking in balena-izing all my small devices, btw

1 Like

Are we sure the hardware doesn’t need some kind of gpio toggle or anything like that in order for the ttyAMA0 to start working? I cannot even talk to it via minicom

@aleksander0m It is indeed possible. Please check above in the same thread: Modemmanager & 4g HAT communication over UART

I was sometimes able to connect via minicom, sometimes not after reboots, so I disregarded it initially, but now looking at the source it seems quite possible.

Someone should solve the need or not of the GPIO setup then, and I’ll jump in again to debug MM once that is solved. If the ttyAMA0 cannot reply to AT commands via minicom, MM will also fail, of course.

Wasn’t this HAT also capable of connecting via USB to the Pi? Why is that not an option? I’d assume that when using USB we may even get full QMI capabilities of the device with a WWAN for networking and such.

BTW, when playing with minicom, make sure ModemManager is stopped. There cannot be two processes trying to talk to the same ttyAMA0 port.

I was just being able to enable back the AT commands through minicom by mangling with the pins. I see however from the kernel now:

[10570.180348] Under-voltage detected! (0x00050005)
[10576.420370] Voltage normalised (0x00000000)

I will test around a bit more and report back.

I am 99% sure that additional GPIO settings are not needed, as normally it IS possible to send AT commands with minicom to ttyAMA0 and get a response. Somehow, occasionally, the modem seems to get into state it doesn’t respond anymore. Hard reset (power cycle) always helps then.

Yes! When using the USB cable everything works out of the box! Except we are planning to use this setup as an IoT sensor with this casing: https://lincolnbinns.com/pi-box-pro.html , so a USB cable connecting to the external USB ports is really not an option.

@FransvanHoogstraten I think it is a power issue. When I reset the modem through GPIO26 both ModemManager and minicom start receiving commands. At different stages however I saw ModemManager stop receiving commands and I need to power reset the modem again - especially after Simple connect state (8/8): All done where I assume it starts to consume more power.

I checked my terminal history from yesterday and I saw after one of the reboots ModemManager actually was receiving messages for a bit. Yesterday I did not fiddle with the GPIOs so that makes me think even more my assumption is correct.

Reference: https://github.com/sixfab/Sixfab_RPi_3G-4G-LTE_Base_HAT/blob/master/schematics/RPi_Base_Hat_v1.0.0.pdf

A lot of USB cables are not good for powering and cause huge voltage drops. It could be a bad power supply as well.

My suggestion is to find a way to check and measure those. I personally have never struggled from this, so I never needed this, but I would assume one of those cheap USB dongles with power meters would do the job. I would use first an adapter instead of cable first and then do it with cable+adapter. So first [power source] -> [meter dongle] -> [usb A to mini adapter] -> [rpi] and then [power source] -> [cable] -> [meter dongle] -> [usb A to mini adapter] -> [rpi] as my assumption is that the voltage drop would not be measured if the cable is after the meter dongle, not before it. There could be better ways for doing this though.

Please let me know what do you think.

Thanks,
Zahari

At different stages however I saw ModemManager stop receiving commands and I need to power reset the modem again - especially after Simple connect state (8/8): All done where I assume it starts to consume more power.

Please note that if you’re just using one single ttyAMA0 port, after Simple connect state (8/8): All done you will definitely not see any more AT commands going through because that’s when the port is converted to data and PPP takes over.

When I reset the modem through GPIO26 both ModemManager and minicom start receiving commands

Please make sure you do not use both at the same time! If MM is running you cannot use minicom and viceversa.

In that case I think I need to do some more testing for a final verification.

Right, what I meant was that I was trying those separately. I masked the ModemManager service so that I can run it manually through the terminal with --debug and avoid its launching it on boot.

@majorz I am on the road now, but will be back with the device in 20min. Would it be an idea that I switch the power supply then for the heaviest I have?

Yes, and also if you have a thicker and/or shorter cable.