The modern ecosystem of mobile devices requires flexibility from engineers and programmers, especially when it comes to testing on real hardware. The brand's smartphones, including the popular lines Xiaomi, including popular lines Redmi and Poco, occupy a significant market share, which makes them ideal testing grounds for debugging code. However, the standard shell MIUI or the new one HyperOS has specific limitations that can confuse a beginner who is faced with the need for deep integration of the development environment and a mobile device for the first time.

To start full-fledged work, you have to not just connect the cable, but rebuild the logic of interaction with the operating system. This includes unlocking the bootloader, setting permissions through hidden menus, and properly configuring debugging tools. Ignoring these steps will result in your application crashing on startup or not being installed at all due to the manufacturer’s security policies.

In this material we will examine in detail the path from an ordinary user to an advanced tester capable of flashing custom images and using all the capabilities of the platform. Android. You'll learn how to bypass aggressive power saving that often kills background debugger processes, and how to configure the environment so that it runs reliably even on budget models of the series Redmi Note.

Activating developer mode and basic debugging

The first step towards professional development is gaining access to hidden system functions. Unlike stock Android, where you just need to click on the build number several times, in the Xiaomi shell the process has its own nuances related to linking to an account. You need to go to the settings and find the item About phonewhere information about the MIUI version is located.

Click on the field MIUI version seven times in a row until a notification appears that you have become a developer. After this, a new section Advanced or Advanced settingswill appear in the main settings menu, where the item we need is hidden. However, simply turning on the “USB Debugging” toggle switch here is not enough to fully work with ADB.

The system will require you to log into your account Mi Account and turn on your mobile data (even if the phone is connected to Wi-Fi). This is necessary to verify the status of the device on the company servers. Without this step, the computer will not see the phone in debug mode, and the commands adb devices will return an empty list.

⚠️ Attention: When you enable debugging, the system may warn about security risks. This is a standard procedure, but remember that in this mode, any connected device can get full access to your smartphone’s data.

Additionally, it is recommended to activate the option USB debugging (Security Settings). It allows you to confirm the connection of a new computer through a dialog box on the phone screen, which adds a layer of protection against unauthorized access. It is also worth turning on the “Keep the screen on” option when charging so that the device does not go to sleep during long compilation and deployment sessions.

💡

Use an original cable or a certified analogue that supports data transfer. Cheap “charge-only” cables are often the reason why ADB does not see the device, although the charge indicator shows the connection.

Unlocking the bootloader: necessity and risks

For many tasks, such as installing custom recoveries, obtaining root access or testing low-level functions, standard debugging is not enough. Requires an unlocked bootloader (Bootloader). Xiaomi has introduced strict rules: after submitting an application for unlocking, you must wait a certain period, which can range from 7 to 168 hours (7 days).

The process begins by linking the device to an account in a special application Mi Unlock on the smartphone itself. After this, you need to download the utility Mi Unlock Tool on your PC, log into the same account and switch the phone to Fastboot mode by holding down the button combination Volume down + Power. If you try to unlock the device before the timer expires, the utility will display an error and reset the counter.

  • 🔓 Unlocking completely erases all data from the device, so be sure to back up important files before starting the procedure.
  • ⏳ The wait timer is tied to your account and specific device, it is impossible to reset it, you just need to wait.
  • 🛡️ After unlocking, some highly secure banking applications and services may stop working without additional security manipulations.

It is important to understand that an unlocked bootloader reduces the overall security level of the device, making it more vulnerable to attacks like Evil Maid. However, for the developer, this opens up opportunities for testing system recovery scenarios and working with memory partitions, which is impossible on closed devices.

What is Verified Boot?

Verified Boot (AVB) is a mechanism for verifying the integrity of the boot process. By unlocking the bootloader, the phone will display a warning every time you turn it on, informing you that the software is not certified. This is normal for custom firmware, but can be annoying in everyday use.

Setting up the ADB and Fastboot environment

Working with the command line is an integral part of the life of an Android developer. To interact with Redmi you will need to install Platform Tools from Google. This is a set of utilities, including adb and fastboot. They should be downloaded exclusively from the official Android Developers website to avoid modified versions containing malicious code.

After unpacking the archive, add the path to the tools folder to the system environment variable PATH. This will allow you to run commands from any terminal directory without having to enter the full path to the executable files each time. You can check the functionality with the command adb version, which should display the installed version number.

adb start-server

adb devices

adb shell

The first command starts the debugging server, the second shows a list of connected devices, and the third opens a remote shell on the smartphone. If during execution adb devices the device status is displayed as unauthorized, look at the phone screen - a window should appear there asking you to allow debugging from this computer. Click “Allow” and check the “Always allow from this computer” checkbox.

Command Description of action Requirements
adb reboot bootloader Reboot to Fastboot mode Enabled debugging
fastboot devices Checking connection in bootloader mode Unlocked BL or Fastboot mode
adb install app.apk Installing an application on the device Connected phone
adb logcat Real-time system log output Active debugging session

For advanced users, it is useful to know the command adb shell pm grant, which allows you to grant permissions to applications directly, bypassing interface requests. This significantly speeds up the process of testing new versions of software that require access to the camera, microphone or geolocation.

📊 Which debugging tool do you use most often?
Android Studio Logcat
ADB Command Line
Scrcpy
Third-party utilities (ADB AppControl, etc.)

Optimizing MIUI/HyperOS for stable work

Xiaomi shells are notorious for their aggressive memory management and power saving. The system seeks to “kill” any background process that it perceives as consuming battery. For the developer, this is a disaster, since the application being debugged or the debugging service can be terminated at the most inopportune moment, interrupting the session.

To prevent this, find the item ApplicationsApplication managementin the settings. Find your IDE (such as Android Studio via a companion app) or the app you're testing itself. Go to the section Battery and select the option No restrictions. This will prevent the system from freezing the process.

You also need to disable MIUI optimization. This feature is hidden in the developer menu. Scroll down the list to the very end, find the item Enable MIUI optimization and turn it off. The system will ask to reboot. After this, many hidden functions will become available, and the system behavior will become more predictable for third-party software.

⚠️ Attention: Disabling MIUI optimization may cause the system interface to become less responsive, and some system functions (for example, themes or desktops) may not work correctly. Return the setting to its original state after completing work.

Another important aspect is autostart. In the same application management menu, make sure that the switch Autostart activated for necessary services. Without this, the application will not be able to start after rebooting the device, which is critical when testing services running in the background.

💡

Comprehensive power saving settings (No restrictions + Autostart + Disable MIUI optimization) is a prerequisite for stable debugging of complex applications on Xiaomi devices.

Installing custom firmware and recovery

When standard functionality is not enough, developers turn to custom solutions. Installing a custom recovery, such as TWRP or OrangeFox, allows you to make full backups of partitions (Nandroid backup), clear the Dalvik cache and install modified versions of Android. This is an indispensable tool for testing compatibility.

The process of flashing the recovery firmware occurs through Fastboot mode. The command looks like this: fastboot flash recovery twrp.img. However, on modern devices with dynamic partitions (A/B partition), the command may differ, requiring the use of a slot suffix, for example, fastboot flash recovery_a twrp.img.

After installing the recovery, it is important to immediately boot into it to prevent overwriting by the stock recovery. To do this, use the command adb reboot recovery or hold down Volume up + Power. In the recovery environment, you can set superuser rights (Root) via Magisk, which opens access to system files for deep modification.

  • 📦 Custom firmware (LineageOS, Pixel Experience) allows you to test the application on “pure” Android without MIUI layers.
  • 🔧 Magisk modules allow you to enable system functions on the fly without flashing the entire image.
  • 💾 Always backup EFS and Persist partitions before any manipulations so as not to lose IMEI and sensor calibration.

It is worth noting that the use of custom software will void the device warranty. In addition, some hardware features specific to Xiaomi (for example, improving call quality or working with an infrared port) may not work correctly on third-party builds due to the lack of proprietary drivers.

Why does the camera not work in custom firmware?

The camera depends on closed libraries (blobs), which the manufacturer does not always share with the developer community. This is often solved by installing ported camera applications (GCam) or waiting for driver updates from the firmware creators.

Diagnosing problems and working with logs

Even with ideal settings, errors can occur. The developer’s main weapon in such a situation is logging. The command adb logcat prints a stream of system messages. To filter out the unnecessary stuff and find a specific bug in your application, use tags and priorities. For example, adb logcat -s MyAppTag:E will only show errors from your application.

A common problem on Redmi is loss of ADB connection via Wi-Fi. The wireless debugging feature appeared in Android 11 and higher, but on MIUI it may work unstable due to the aggressive sleep mode of the Wi-Fi module. In Wi-Fi settings, enable the “Keep Wi-Fi on in sleep mode” option and select the “Always” operating mode.

Use the built-in profiler tools to analyze performance. If the application is slow, check whether the processor is throttling due to overheating. Redmi, especially budget models, can reduce frequencies under prolonged load, which distorts the results of performance tests.

⚠️ Attention: Interfaces and menu item names may vary depending on the HyperOS version and regional firmware (Global, China, EEA). Always check the current screenshots for your specific model.

If the device is “bricked” after unsuccessful firmware, EDL (Emergency Download Mode) is often the last chance. Entering it usually requires disassembling the case and short-circuiting test points on the board, or using special authorized service center accounts for flashing firmware via MiFlash.

☑️ Checklist before flashing

Done: 0 / 5

Frequently asked questions (FAQ)

Why does the computer not see Redmi in ADB mode?

Check the cable (it should support data transfer), whether the driver is installed Xiaomi USB Driver on PC, and whether the resolution is confirmed on the phone screen. Also try changing the USB port or restarting the adb service using the command adb kill-server i adb start-server.

Is it possible to unlock the bootloader without waiting 7 days?

Officially - no. The timer is linked to Xiaomi servers. There are unofficial methods and paid services that promise instant unlocking, but they are associated with high security risks and can lead to the device being blocked by IMEI.

How to return stock firmware after custom?

You will need to download the official firmware in Fastboot format (.tgz extension), unpack it and use the MiFlash Tool utility. Be sure to select the “Clean all” mode to correctly install the partitions and return the device to its factory state.

Is it safe to use root access on Redmi for development?

For test devices - yes, this gives full control. However, applications with banking functions and some games with anti-cheat may refuse to work. Magisk Hide or Zygisk modules are used to bypass, but this is a constant “arms race” with application developers.

Where to download official firmware for Redmi?

The best source is the site xiaomifirmwareupdater.com, which aggregates links to official Xiaomi servers. There you can find firmware for all regions and models, including archived versions.