Wuming 無名

Blog

I Opened Up a DJI 4G Dongle and Found Linux Running Inside (1)

· Technology · English

Next: An SMS and eSIM Gateway on a Raspberry Pi | 中文版:它到底是什么

DJI makes a 4G accessory for its drones and remote controllers: a thing about the size of a USB stick that gets the device online once you put a SIM card in it. They are cheap on the secondhand market, and most people who buy one use it as a plain USB modem.

Plug it into a computer and that is exactly the first impression it gives. macOS does nothing at all, and Linux sprouts a row of devices named ttyUSB0 through ttyUSB3. Pretty unremarkable.

But inside it is a complete LTE module. It runs Linux, it has a debug interface with root access, and it can make phone calls, send and receive SMS, and read and write eSIMs. Over the rest of this series I will hook it up to a Raspberry Pi, a Mac, an iPhone and an Android tablet and make it work as an actual phone. Everything that comes later rests on the handful of things this post figures out.

First, two terms that will keep coming up:

  • Module: a complete cellular chipset with its own CPU, its own operating system and its own radio. The “baseband” in a phone is this kind of thing, just soldered onto the mainboard. Modules sold on their own usually connect to a host over USB or serial, and the host drives them by sending commands.
  • AT commands: the language you use to drive a module. It is a very old text protocol that has survived from last century’s dial-up modems all the way to today. Send it a line of ATI and it replies with a short self-introduction. Every cellular module speaks it.

What Is It, Really

Start by asking it who it is:

ATI
Baiwang
QDC507
Revision: QDC507GLEFM21

After some digging, this is what it turns out to be:

Item Value
USB ID (DJI version) 2CA3:4006
USB ID (generic version) 2C7C:0125 (the same ID as the Quectel EC25 series)
Baseband chip Qualcomm MDM9607, Cat.4 LTE
Module’s internal OS Linux, kernel 3.18.44, debug service runs as root
AT command dialect Quectel family: AT+QCFG, AT+QNETDEVCTL, AT+QGPS and friends

That is a useful finding: pretty much everything written online about the Quectel EC20/EC25 applies here. The AT commands, the USB configuration and the drivers are all the same. For the features we care about, the DJI version and the generic version sold on the open market are no different, so from here on I will just call it the QDC507.

What Actually Shows Up When You Plug It In

A USB device can offer several “interfaces” at once, as if one cable carried several independent channels. Which channels the module exposes is decided by a setting called usbcfg:

AT+QCFG="usbcfg"
+QCFG: "usbcfg",0x2C7C,0x125,1,1,1,1,1,1,1
                             │ │ │ │ │ │ └─ USB audio
                             │ │ │ │ │ └─── ADB
                             │ │ │ │ └───── network interface
                             │ │ │ └─────── Modem
                             │ │ └───────── AT
                             │ └─────────── NMEA (GPS)
                             └───────────── DIAG (diagnostics)

The last two digits are the key to this entire series.

ADB is on, which means you can adb shell into the module’s internal Linux the same way you would debug an Android phone, and you land straight in a root shell. ADB is Android’s debug bridge, and Qualcomm modules commonly ship with it.

Audio is on, which means the module additionally presents itself as a USB sound card. That sound card is where call audio will eventually go in and out.

The DJI unit I have came from the factory with both turned on. My other, generic unit came with both turned off and has to be unlocked first: AT+QADBKEY? returns an 8-digit challenge, you compute the response with MD5-crypt and submit it with AT+QADBKEY="…", and only then can you change usbcfg. After changing it, send AT+CFUN=1,1 to restart the module; USB re-enumerates on its own, no unplugging needed.

One more detail, and it decides the fate of every platform that follows: the first five interfaces are all USB vendor-specific class. USB has a set of standard classes (keyboards are one class, flash drives another, sound cards another), and when an operating system sees a standard class it loads a driver automatically. Vendor-specific class amounts to telling the system “this is my own thing, leave it alone.” The result:

Platform What it sees
Linux The option driver claims these interfaces and ttyUSB0~3 appear; the network interface is claimed by a separate driver
macOS No driver claims them at all, so the module never shows up under /dev/cu.*
Android Likewise no driver; an app has to poke at it itself through the USB Host API

In other words, on the Mac and on Android the usual “send AT commands” channel simply does not exist from the start.

Going Around It: A Channel Inside the Module

If there is no serial port on the outside, go in from the inside. adb shell in and take a look:

adb shell
# ls /dev/smd*
/dev/smd7 ...

/dev/smd7 is a device node inside the module that leads straight to the baseband’s AT interpreter. As long as ADB works, any platform can send AT commands this way:

adb shell "cat /dev/smd7 > /tmp/at.out 2>/dev/null & CP=\$!; sleep 0.3; \
  printf 'ATI\r' > /dev/smd7; sleep 2; kill \$CP 2>/dev/null; cat /tmp/at.out"

It looks awkward, but it works, and it ended up as the shared control channel for both the Mac app and the Android app later on. A platform with no driver can fully drive this module, as long as it can speak ADB.

Four Ways to Get Online

How the module hands the network to the host is configurable too:

AT+QCFG="usbnet",N     requires AT+CFUN=1,1 to restart before it takes effect
N Mode Linux macOS Android
0 QMI Has a driver, but you dial yourself No No
1 ECM Has a driver A network interface just appears Works directly as USB Ethernet
2 MBIM Has a driver No Partial support
3 RNDIS Has a driver No Partial support

ECM is the least hassle of the lot: the module does NAT and DHCP itself, the host gets a 192.168.225.x address, and the module itself is .1. Plug it in and you are online, nothing to configure. China Mobile SIMs even get native IPv6 handed down directly.

That “no hassle” turns into a problem later, which part 5 covers: it is so hassle-free that you have no idea your traffic is already going out over the SIM card.

The Call Connects, but There Is No Sound

This is the first thing that is genuinely confusing.

ATD10086; dials out, AT+CLCC reports the call as connected, and the other end really does pick up. But neither side hears anything.

The reason is that signaling and audio are two completely separate things. AT commands handle signaling: dialing, ringing, answering, hanging up. Audio travels a different path, and that path is disconnected by default.

Quectel modules traditionally have an AT+QPCMV command that can push call audio out over a USB serial port. On this firmware it is an empty shell: AT+QPCMV=? says it is supported, actually running AT+QPCMV=1,0 returns ERROR, and it does not even appear among the 246 available commands listed by AT+CLAC.

The real path is inside the module: load the voice driver, run an audio calibration, then start a bridge program that connects call audio from the Qualcomm DSP to that USB sound card. What the host sees is a sound card running at 8 kHz, mono, 16-bit, the standard spec for telephone audio.

There are a lot of details on this path, so I am saving them for part 4. For now, remember just one thing: ATD only handles signaling; audio has to be wired up separately, and it has to be checked again before every call.

A Few More Capabilities

  • eSIM: with an eUICC card inserted (a writable eSIM card), you can use AT+CCHO, AT+CGLA and AT+CCHC to talk directly to the management application on the card and run the full eSIM download flow. Covered in part 2.
  • ISIM: the same set of commands can read the ISIM application and run IMS authentication, which is the foundation for Wi-Fi calling. Covered in part 3.
  • GPS: supported, off by default. But this feature is poison: after AT+QGPS=1, location data gets dumped straight into /dev/smd7, drowning out every AT command response, and this firmware does not support redirecting location output to a different port. While GPS is on, calls and SMS all fall apart. If you want GPS, forget about using anything else.

Five Pitfalls You Will Hit Right Away

None of these are deep problems, but each one is enough to eat most of a day.

The USB serial number is 256 bytes of 0xAA

Symptom: on the Mac, adb devices clearly sees the device, but every adb command sent from a program vanishes without a trace and produces no output.

Cause: this firmware’s USB serial number field is 256 bytes of 0xAA, which is not valid UTF-8 text. Swift’s strict decoding simply returns nil, and from then on every command carries an empty serial number and fails silently.

What to do: decode leniently. More importantly, do not use the serial number to tell modules apart, because every single one is identical. Address devices with adb -t <transport_id>, and use the USB physical path (for example usb:1-1.2) as the persistent identity. The transport id changes on every re-enumeration; the USB path does not.

Two identical modules cannot be told apart

Same root cause: on Linux, two 2c7c:0125 units cannot be distinguished by vendor ID, product ID or serial number either. After one re-enumeration, the two modules’ ttyUSB numbers swap as a whole block, and every hard-coded path breaks at once. The real fix is to write rules based on the physical port; part 2 gives the exact rules.

adb forward looks like it worked, but nothing gets through

adb forward tcp:PORT dev:/dev/smd7 sets up fine and returns normally, but no data moves in either direction. Do not build anything on top of it.

Incoming-call notices are not sent where you are reading

AT+QURCCFG="urcport"
+QURCCFG: "urcport","usbat"

Events the module reports on its own initiative (RING for an incoming call, +CLIP for the caller’s number, +CMTI for a new SMS) are called URCs, and this setting says: send URCs only to the USB AT interface.

So a program reading /dev/smd7 over ADB will never receive an incoming-call notification. Your code is fine; the events are going to a different door.

Use both of these fixes together: change the URC port to "all" (it is a parameter that persists across power cycles, so read it before changing it rather than writing it on every startup), and at the same time treat polling AT+CLCC and periodically checking the SMS inbox as the real source of truth, with URCs serving only as a “go take a look” nudge.

AT+CFUN=1,1 wipes everything

This command restarts the module. The module’s /tmp is a RAM disk, so after a restart the loaded voice driver, the calibration marker and the bridge process are all gone, and USB re-enumerates once as well.

The takeaway: any “set it up once and you are done” design will fail here. All state has to be checked every time and rebuilt on demand. This principle runs through the entire series.

Takeaways From This Post

Intuition Reality
A USB modem An LTE module running Linux, with a root debug port
No serial port means no control adb shell in and go through /dev/smd7
A connected call should have sound Audio needs a separate route set up inside the module
Incoming calls will notify you The notices go to the port you are not reading

The next post plugs it into a Raspberry Pi and puts it to work: sending and receiving SMS, managing eSIMs, and sharing 4G with the local network.

The Full Series

  1. What Is It, Really
  2. An SMS and eSIM Gateway on a Raspberry Pi
  3. VoWiFi from Scratch
  4. USB Handsets, Browser Calls and an ESP32
  5. On a Mac
  6. The iPhone Client
  7. An Android Tablet Drives It Directly

This series is a record of personal learning and technical research. The module’s voice driver is a GPL derivative work and is not distributed with the project; you will need to obtain it yourself. Please comply with local laws and regulations and your carrier’s terms of service.

Comments

  1. Loading comments…

Leave a comment

Plain text; links are fine. Comments with many links wait for review.