Untitled Blog.

Sending AT commands to the modem of a Pixel 4a

2023-08-30

ATtention commands are a kind of command protocol spoken by telephone modems since the early 1980s. Amazingly, this protocol is still alive in some form today on modern smart phones and other telephony devices.

The world of cellular modems and AT commands is a bit mired in obscurity, but despite that they're quite simple to work with. Even on a modern Android phone, you can still send AT commands directly to the modem.

This post goes over how I managed to do so using a Pixel 4a featuring a Snapdragon X15 LTE modem. I suspect that it's probably possible on nearly any Android phone you can root, as the Android userland will probably need to be able to send AT commands to function properly as a phone, but most of the posts I came across when searching for this are fairly old, often over a decade, so I was curious how things have changed. As it turns out, not a ton.

Rooting

Google smartphones, for all of their faults, are very easy to root. For reference, here is how I rooted my Pixel 4a:

Sending AT commands

All you have to do now to send AT commands is find out which device you can use to communicate with. I found that on my Pixel 4a, it was /dev/smd7. (I guessed here, because I couldn't figure out a better way to find the right device for the version of Android I am on.)

Anyhow, first of all, enter an adb shell, then run su. If Magisk is properly installed, your phone will prompt you to grant root access to your shell. Go ahead and do that. Then, you can send an AT command like this:

echo -e "AT \r" > /dev/smd7

At this point, though, you can't see what the modem is replying with. So, start another adb shell and run su in it as well, and run:

cat /dev/smd7

Then, you should see your AT commands and the replies they get on this shell.

Refreshingly simple.

Word of warning

Be advised that many warn it is possible to potentially brick your SIM or modem running AT commands. I don't know if it's actually that real of a concern, but you could definitely cause some problems running AT commands. I wouldn't recommend doing it on your main phone line if you can help it :)