Tracking the system on Android Xiaomi: a complete guide for users

Have you ever encountered a situation where a Xiaomi smartphone starts to slow down, apps crash for no reason, or the battery runs out in a few hours? In such cases, engineers and experienced users often resort to system tracing, a powerful diagnostic tool that captures all the processes that occur in the Android operating system. But what is it in practice and how does it work on Xiaomi devices?

Tracing (or trailing) is the process of collecting detailed logs about the operation of the OS kernel, applications and hardware components. On Xiaomi smartphones, this mechanism is integrated deeper than on β€œpure” Android, thanks to the branded shell. MIUI. It allows you to track everything from processor load to errors in the graphics driver, but not all users understand that enabling traces unnecessarily can lead to leakage of sensitive data through system logs if the device falls into the wrong hands.

In this article, we will discuss what types of tracing exist on Xiaomi, how to activate them (including through hidden developer menus), what risks this entails, and how to correctly interpret the collected logs.

What is a tracing system and why it is needed

System tracing is the process of recording events occurring in the operating system and hardware components of a smartphone. β†’ The phone. β†’ Version. MIUI β†’ Error logs), tracer captures data with high detail and frequency, which allows you to detect:

  • πŸ” Interface freezes - when MIUI slows down when swipes or opening applications.
  • πŸ”‹ Abnormal battery consumption - what processes "eat" the charge in the background.
  • 🚨 App crashes – why WhatsApp or Google Play suddenly shut down.
  • πŸ“‘ Networking problems – why Wi-Fi or 4G/5G runaway.

On Xiaomi devices, tracing is implemented through several subsystems:

  1. Linux kernel – captures events at the processor, memory and driver level.
  2. Android Framework – monitors the operation of system services (for example, SurfaceFlinger for graphics).
  3. MIUI Layer adds logs to proprietary features such as Second Space or Game Turbo.

It's important to understand that tracing is not a magic wand. It generates huge amounts of data (up to 500 MB in a few minutes) that require special tools for analysis, such as the Kernel Trace Analyzer to read the kernel logs, and the Kernel Trace Analyzer to analyze. MIUI-specific events – utilities from Xiaomi that are not distributed publicly.

πŸ“Š Have you ever used a tracing on your smartphone?
Yeah, to diagnose problems.
Yes, on expert advice.
No, but I've heard of this feature.
No, I don't plan on.

Types of tracing on Xiaomi smartphones

There are several types of tracing available on Xiaomi devices, each of which solves its own problems, and they can be divided into hardware (processor dependent) and software (implemented through Android and other devices). MIUI). Below is a comparative table of the main species:

Type of tracingWhat's fixingHow to turn it onLimitations
ftraceLinux kernel events (interruptions, task scheduler, driver operation).Through the adb shell or the developer menu.Requires root or unlocked bootloader on some models.
atraceThe work of Android applications and system services (graphics, audio, Binder) IPC).Adb shell atrace command.It does not record events at the core level.
MIUI LoggerLogs of proprietary functions (Theme Engine, Security App).Enabled via the engineering menu (#4636##).Data is encrypted, a decryptor from Xiaomi is required.
PerfettoUnified Tracing (combines ftrace, atrace and user events)Through adb shell perfetto.High load on the processor during recording.

The most versatile tool today is the Perfetto, which Xiaomi is actively integrating into new models (starting with the Redmi Note). 11 Xiaomi 12 It allows you to record traces from multiple sources at the same time, which makes it easier to diagnose complex problems, for example, if the smartphone overheats when playing, Perfetto will show the download and download. CPU/GPU, and activity of the SurfaceFlinger graphics stack, and temperature sensors.

But there's a downside to this: tracing can cause problems, such as log logging via ftrace on budget models (e.g. Redmi). 9A) capable of loading the processor 30-40%, This will cause additional heat and discharge of the battery, so you should only use it when you really need it.

πŸ’‘

If you need trace to send to Xiaomi Support, use the built-in log collection feature in the Settings menu. β†’ The phone. β†’ It's safer than manual activation of ftrace.

How to turn on tracing on Xiaomi: step-by-step instructions

Before you activate the trace, make sure that your device is allowed to develop mode.

  1. Go to Settings. β†’ The phone.
  2. Tap 7 times on the MIUI version.
  3. Enter the password from your Mi Account if required.

Then on the Settings menu β†’ And then there's a developer section, and then you can start setting up the tracing, and let's look at two basic ways:

Method 1: Through ADB (universalism)

This method works on all Xiaomi models, but requires a computer connection.

  • πŸ–₯️ Computer with installed ADB-driver.
  • πŸ“± USB-cable (preferably original).
  • πŸ”§ Included debugging by USB developer-setting.

Steps:

  1. Connect your smartphone to your PC and open the terminal (or Command Prompt).
  2. Enter the command to check the connection: Adb devices Make sure the device appears in the list.
  3. To start the trace through ftrace, use: adb shell echo 1 > /sys/kernel/debug/tracing/tracing_on
  4. To save logs to file: adb shell cat /sys/kernel/debug/tracing/trace > trace.log

Battery charge > 50%|Debugging by USB included|USB-cable connected to port USB 3.0|PCs are installed. ADB-driver-->

Method 2: Through the Engineering Menu (without PC)

Some Xiaomi models, for example, POCO F3 or Mi 11) supports activation of tracing through hidden menus:

  1. Open the phone app and enter the combination: ##4636##
  2. In the menu that appears, select Usage statistics (or Usage Statistics).
  3. Click on the three dots in the top right corner and select Enable tracing.
  4. Enter the duration of the recording (not more than 30 seconds for the first test is recommended).

⚠️ Note: Some firmware (e.g. global version) MIUI 14) this method may not work due to manufacturer limitations, in which case only the option of c ADB.

What to do if the engineering menu is not opened?
On new models (e.g. Xiaomi 13 or Redmi Note 12), access to the engineering menu may be blocked.In this case, try: 1. MTK Engineering Mode (for devices on MediaTek). 2. Install Activity Launcher from Google Play and through it run hidden activity com.android.settings.TestingSettings. 3. Update the firmware to the latest version – sometimes Xiaomi returns access to the menu in new builds.

Log analysis: how to read tracing

The tracing logs collected are text files with thousands of lines of data, which are almost impossible to understand without special knowledge, but there are a few key points to consider:

  • ⏱️ Time stamps – indicate when an event occurred (e.g., [123.456789] means 123 milliseconds from the start of the recording).
  • πŸ”„ Process identifiers (PID) β€” help track which application or service caused the event (e.g. pid)=1234).
  • ⚠️ Keywords: WARN or ERR β€” mistake. sched_switch β€” switching tasks (useful for analyzing lags). thermal - events associated with overheating.

For visualization of logs can be used:

  • πŸ“Š Perfetto UI β€” Web interface from Google (ui.perfetto.dev).
  • πŸ–₯️ Trace Compass – Desktop Software for Deep Analysis.
  • πŸ“± Catlog – an application for viewing logs directly on a smartphone (suitable for basic analysis).

Example of decryption of a line from ftrace:

[  123.456789] sched_switch: prev_comm=com.android.launcher/1234 prev_pid=1234 prev_prio=120 prev_state=S ==> next_comm=kworker/0:1/0 next_pid=0 next_prio=120

You can see here that the process com.android.launcher MIUI) suspended (prev_state=S and control is transferred to the system worker (kworker.

πŸ’‘

If you see repeated errors in the same logs PID, It's probably an application that's the problem. Try clearing the cache or reinstall it.

Risks and safety: What you need to know

Tracing the system is a powerful tool, but it carries some serious risks:

  1. Leaked sensitive data. Logs may include: Application names (including banking) and location metadata (if enabled) GPS). Fragments of correspondence (if the work of messengers is traced).

System load

Conflicts with MIUI

MIUI 13

India

⚠️ Note: If you send trace logs to Xiaomi support or forums (e.g, 4PDA), You can delete personal information from them:

sed -i 's/[0-9]\{10,\}/[PHONE]/g' trace.log

This command will replace all long numerical sequences (such as phone numbers) with [PHONE].

Another important point: on devices with a locked bootloader (most Xiaomi smartphones are sold in this state), some traces may be limited, for example, the recording of kernel events (ftrace) will be available only for system applications. To circumvent this limitation, you will need to unlock the bootloader through the Mi Unlock Tool, but this will void the warranty.

Disabling tracing and cleaning the logs

Once the diagnosis is complete, it is important to disable the tracer to avoid unnecessary system loads, and this can be done in several ways:

  • πŸ›‘ Through ADB: adb shell echo 0 > /sys/kernel/debug/tracing/tracing_on
  • πŸ”„ Through the engineering menu (if the tracing was included there).
  • πŸ“± Reboot device – resets most types of tracing (except for MIUI Logger).

To delete the saved logs, do:

  1. For ftrace: adb shell echo > /sys/kernel/debug/tracing/trace
  2. For atrace, logs are stored in a temporary folder and deleted automatically after rebooting.
  3. For MIUI Logger – Cleaning through Settings β†’ Memory. β†’ Cleaning (not always effective).

⚠️ Note: On some models (e.g. Xiaomi Mi) A3 With Android One, trace logs can be saved in a hidden partition /data/log. In order to remove them completely, you will need to:

  1. Get root access.
  2. Use a file manager with superuser rights (e.g., Root Explorer).
  3. Manually delete the contents of the folder /data/log.

If you do not plan to continue working with tracing, it is recommended to disable the developer mode, as it opens up additional vectors for attacks (for example, through the use of tracing). ADB).

Frequent mistakes and their solutions

When working with tracing on Xiaomi, users often face typical problems, and here are the most common ones and how to solve them:

Problem.Possible causeDecision
The adb shell command is not working.No driver or debugging is installed on USB switched off.Set up Mi. PC Suite and check the developer settings.
Logs are empty or not written downLack of rights or the tracing buffer is overflowing.Clean the buffer with the adb shell echo command > /sys/kernel/debug/tracing/trace.
The device overheats when tracingHigh CPU load (especially on Snapdragon) 4xx).Reduce the recording frequency or use Perfetto with a limited CPU.
Engineering menu not openBlocked by the manufacturer or firmware.Try alternative codes (e.g. #284## for sensor test).

If you encounter an error that is not in the table, check the logs for keywords:

  • permission denied – problems with rights (root or unlock the bootloader is needed).
  • No such file or directory is the wrong path to the trace file (relevant for custom firmware).
  • device not found β€” ADB Does not see the device (check the cable and drivers).

To diagnose complex cases, you can use the Xiaomi Log Tool, which is sometimes provided by brand support, which automatically analyzes logs and gives recommendations. However, this tool is not officially distributed, it can only be found in specialized forums (for example, in the Internet, XDA Developers).

πŸ’‘

If tracing is needed for warranty repairs, do not edit logs manually. Xiaomi's service center may refuse repairs if it detects signs of interference.

FAQ: Answers to Frequent Questions

Can I turn on the tracing without root rights?
Yes, most tracing (like atrace or Perfetto) works without root. However, some models require unlocking the bootloader or obtaining superuser rights to access kernel logging, and without root, you can't clear some system logs stored in protected partitions.
How does tracing affect smartphone performance?
Log writing puts additional strain on the processor and memory, for example, tracing through ftrace can take up to a few hours. 10-15% CPU on weak chipsets (for example, Snapdragon) 439 redmi 8). On flagships (for example, Xiaomi) 13 Pro with Snapdragon 8 Gen 2) The effect is minimal, but still noticeable with long recording. 30-60 second-by-second.
Can tracing be used to catch spy apps?
Theoretically, yes, but in practice, it's hard. Spyware usually masquerades as system processes and leaves no obvious traces in logs. More effective methods: Check network activity through NetGuard or PCAPdroid. Security scanner. MIUI (Settings β†’ Memory. β†’ Viral scanning? Monitoring application permissions through Settings β†’ Annexes β†’ Permissions. Tracing here will only help if you know exactly what to look for (e.g., suspicious). PID).
Why is my Xiaomi not having trace option in the engineering menu?
This may be due to: Regional firmware (e.g., on devices for the Chinese market some features are hidden). MIUI, which has been removed from the menu (to be used for the MIUI 14+). Hardware restrictions (on some MediaTek models, such as the Redmi Note 10, tracing is blocked at the chipset level). ADB or the use of third-party utilities such as MTK Engineer Mode (for MediaTek).
How to send trace logs in support of Xiaomi?
The most reliable way is to use the built-in log collection function: Go to Settings β†’ The phone. β†’ Review. Select System Problems and describe the problem. Click Send Review β€” the system automatically collects and archives logs. If you need to submit logs manually (for example, to a forum), archive them to.zip and delete personal information (see the security section).