· 3 min read · Gaia Lab
Seeing what the modem does not tell: a debug mode in the MediaTek
The location message never reaches the operating system: the modem terminates it. To see it we had to build a debug mode on top of its trace channel.
In a Linux phone, the modem is another computer. Our test bench is a FuriPhone FLX1
, a handset running FuriOS from Furi Labs whose modem is a MediaTek MT6877 with its own firmware and its own protocol stack. When the network sends a RequestLocationInformation, the message comes in over NAS, the modem decodes it, decides the positioning method, talks to the GNSS and answers. The phone’s operating system sees none of that.
The only clue on the AP side #
What does show up in the system log is a consequence: the GPS is opened by a requester that is not an application but the modem itself (requestor_id=Mediatek Modem). It is a very good clue —it says that someone has asked for a position— but it does not say who, or with which method, or what was answered.
For that you have to go one level down.
The trace channel #
The modem exposes a debug channel over CCCI, the interface that connects it to the application processor: a log ring buffer accessed like any other device. The problem is that the firmware does not emit everything it knows. It only dumps the modules allowed by a filter that has to be loaded when the capture starts and that the modem validates. With the stock filter you get boot and hardware messages; not a single NAS, RRC or LPP trace.
With a filter that enables those modules, the log changes completely: records with a trace identifier start to appear. The LPP one, for instance, is 0x2E70.
From the binary to the readable message #
The dump is written to a container compressed in blocks. Our decoder opens it, validates each record against its signature, extracts the identifier and translates it with the name base that ships with the firmware —tens of thousands of entries—. The result is reading things like MSG_ID_LPP_EVAL_DATA_IND or lpp rcv src=[MOD_LPP_CP] at the moment they happen, with their timestamp.
Three things we learned #
- Without the filter there is nothing. This is the first place where hours get lost: the log looks empty and it is actually filtering.
- With the filter opened too wide, the modem floods. Several megabytes per second and captures of gigabytes; you have to choose which modules you want and accept the cost.
- The AP and the modem see different worlds. Debugging positioning by looking only at the operating system is looking at the shadow, not at the object.
With this we could already see the request and the response. The next question was the obvious one: what if we do not want to answer?
The code behind this chapter lives in three repositories: furimodem-tool , the tool we use to talk to the modem from the phone itself; furimodem-debug , the modem’s debug mode; and mtk-debug-log-visor , the dump viewer. The last two do not have published code yet.
Next instalment: cutting the request in the modem.
Glossary #
- NAS (Non-Access Stratum): signalling between the terminal and the core that travels inside the radio access.
- RRC (Radio Resource Control): the signalling layer of the radio access: it sets up the connection, configures bearers and handles handovers.
- LPP (LTE Positioning Protocol): the 3GPP protocol through which the network asks the terminal for a position or for measurements.
- PDU (Protocol Data Unit): a protocol’s message once encoded, exactly as it travels.
- GNSS : satellite navigation constellations (GPS, Galileo, GLONASS, BeiDou).