Flashing an Android device is a process that can either bring a โ€œfermentedโ€ smartphone back to life, or finally turn it into a โ€œbrickโ€ if you approach the matter without preparation. This instruction will help you figure out when flashing is really necessary, and when it is better to refuse it. We will look at all stages: from choosing the appropriate firmware to restoring data after installation.

It is important to understand that firmware is not just updating the system through the settings. This is a complete replacement of the device software, which may require unlocking the bootloader, installing a custom recovery, and even working with the command line. If you have never encountered ADB, Fastboot or TWRP, do not be alarmed: we will explain everything as clearly as possible, taking into account the typical mistakes of beginners.

But before you start, answer two questions for yourself: why you need firmware and Are you ready to possible consequences? If the goal is simply to speed up your smartphone, a factory reset or optimization via Settings โ†’ System โ†’ Resetmay be enough. Firmware is justified when:

  • ๐Ÿ“ฑ The device does not turn on or only boots into bootloop (infinite reboot).
  • ๐Ÿ”„ Official updates are no longer released, and you need new Android functions.
  • ๐Ÿ›ก๏ธ You want to remove the pre-installed operator software (bloater).
  • ๐Ÿ”ง You need to restore functionality after unsuccessful rooting.
๐Ÿ“Š Why do you want to flash an Android device?
Speed up work
Install a new version of Android
Remove viruses/bloater
Recover after failure
Other

1. Preparing for the firmware: what needs to be done before you start

The first and most important step is backup data. The firmware erases all information from the internal memory, including photos, contacts and messages. Even if you plan to use the firmware without wipe, the risk of data loss remains. Here's what you need to save:

  • ๐Ÿ“ Media files (photos, videos, music) - copy to PC or cloud.
  • ๐Ÿ“ž Contacts and SMS - synchronize with Google Account or export through applications like SMS Backup & Restore.
  • ๐ŸŽฎ Application data โ€”use Titanium Backup (requires root) or built-in backup functions in games.
  • ๐Ÿ”‘ Passwords and tokens โ€”export from a password manager or write it down manually.

Next check firmware compatibility with your device model. Installing firmware from a different model or version (for example Global instead of Chinese) may result in non-functioning modules (camera, sensors, mobile network). Check the exact model name in Settings โ†’ About phone โ†’ Model or through the command:

adb shell getprop ro.product.model

Also make sure that:

  • ๐Ÿ”‹ Battery charge is not less 60% (better than 80%).
  • ๐Ÿ”Œ You have an original USB cable (cheap cables can interrupt data transfer).
  • ๐Ÿ’ป Drivers for your device are installed on the PC (for example, Samsung USB Drivers or Mi PC Suite).

Make backup of all data|

Check the device model and firmware version|

Charge the smartphone up to 80%|

Install drivers and ADB/Fastboot|

Download firmware and tools (TWRP, Platform Tools)-->

โš ๏ธ Attention: On some devices (for example, Samsung s Knox, Huawei s Bootloader Locks), unlocking the bootloader may void the warranty or block functions (for example, Samsung Pay or Widevine L1 for Netflix in HD).

2. Selection of firmware: official vs custom

Firmware for Android are divided into two types: official (from the manufacturer) and custom (from the community). The former are more stable, but often contain a blocker and are rarely updated. The latter offer more features, but may be less reliable.

Firmware type Pros Cons Examples
Official (Stock) Maximum stability, support for all device functions Bloater, slow updates, limited customization MIUI for Xiaomi, One UI for Samsung, OxygenOS for OnePlus
Custom (AOSP) Pure Android, regular updates, advanced settings Camera, NFC or wireless charging may not work LineageOS, Pixel Experience, Paranoid Android
Custom (based on Stock) Keeps manufacturer's functions, but with optimizations Fewer updates than AOSP firmware Havoc-OS for Xiaomi, DerpFest for Realme
GSI (Generic System Image) Universal firmware for devices with Project Treble The camera, sensors, phone may not work network Phhussonโ€™s GSI, AndyYanโ€™s GSI

Where to download firmware:

  • ๐Ÿญ Official: on manufacturers' websites (Xiaomi โ€” https://new.c.mi.com/global/miuidownload, Samsung โ€” https://samfw.com).
  • ๐ŸŒ Custom: on forums XDA Developers (https://forum.xda-developers.com) or 4PDA (https://4pda.to).
  • ๐Ÿ” GSI: in the repository https://github.com/phhusson/treble_experimentations.

Critical: never download firmware from dubious sites or torrents. They may contain backdoors, miners or spyware. Before installation, check the file hash (MD5/SHA-256) using utilities like 7-Zip or HashMyFiles.

โš ๏ธ Attention: Firmware for devices with processors Mediatek often require special tools (SP Flash Tool), and for Qualcomm โ€” QFil or EDL mode. Please check this point before downloading!

3. Unlocking the bootloader

Most Android devices come with a locked bootloader - this is a protection measure against unauthorized changes. To install custom firmware or TWRPit needs to be unlocked. The process differs depending on the manufacturer:

  • ๐Ÿ“ฑ Xiaomi: requires linking an account Mi and waiting 7 days (on some models). Use Mi Unlock Tool.
  • ๐Ÿค– Google Pixel: unlocked with one command fastboot flashing unlock.
  • ๐ŸŒ Samsung: needed Odin and enabled mode OEM Unlock in the developer settings.
  • ๐ŸŽ OnePlus: unlocked via fastboot oem unlock, but resets all data.

General unlocking algorithm:

  1. Enable USB debugging i OEM Unlock in Settings โ†’ System โ†’ For Developers.
  2. Connect the device to the PC and confirm permission for debugging.
  3. Reboot into Fastboot mode (usually Power + Vol Down).
  4. Execute the unlock command (for example, fastboot oem unlock).
  5. Confirm the action on the device screen (with volume buttons).

After unlocking, the bootloader will reset the device to factory settings. On some devices (for example, Huawei) you may need an unlock code, which is issued on the official website after entering the IMEI.

What is OEM Unlock and why is it not in the settings?

On some devices (especially carrier versions), the option OEM Unlock may be hidden. To enable it, you sometimes need to enter it. command:

adb shell pm uninstall -k --user 0 com.android.phone

or use applications like OEM Unlock Toggle. However, this can lead to loss of mobile communication, so it is better to check the method for your model on the relevant forums.

4. Installing custom recovery (TWRP)

TWRP (Team Win Recovery Project) is an alternative recovery that allows you to install firmware, do backups and restore data. Without it, installation of most custom firmware is impossible.

Installation instructions:

  1. Download the image TWRP for your model from the official website (https://twrp.me) or a trusted source.
  2. Rename the file to twrp.img and place it in the folder with Platform Tools.
  3. Reboot the device to Fastboot mode.
  4. Run the command:
    fastboot flash recovery twrp.img
  5. Immediately after that, reboot to TWRP (not into the system!), holding Power + Vol Up.

If after a reboot TWRP is replaced with stock recovery, then the manufacturer uses A/B sections (for example, Google Pixel, OnePlusIn this case you need:

  1. Install TWRP in both slots:
    fastboot flash recovery twrp.img
    

    fastboot flash boot twrp.img

  2. Or use special scripts (for example, TWRP Installer for Pixel).
โš ๏ธ Attention: On devices with Dynamic Partitions (for example, Xiaomi on Android 10+) you may need a patched image TWRP or manually changing the markup via fastboot resize-logical-partition.

5. instructions

Now that everything is ready, you can start flashing the firmware. Let's consider two main methods: through TWRP and through Fastboot.

Method 1: Firmware via TWRP

This method is suitable for most custom ones. firmware.

  1. Copy the firmware file (usually .zip) to internal memory or SD card.
  2. Reboot into TWRP (Power + Vol Up).
  3. Do backup of current firmware (optional, but recommended): select Backup โ†’ mark Boot, System, Data โ†’ swipe to confirm.
  4. Select Wipe โ†’ Advanced Wipe โ†’ mark Dalvik, Cache, System, Data โ†’ swipe.
  5. Click Install โ†’ select the firmware file โ†’ swipe to install.
  6. After completion, click Reboot System.

Method 2: Firmware via Fastboot

This method is more often used for official firmware (for example, Xiaomi, Google).

  1. Unpack the archive with the firmware (usually .tgz or .zip) to the folder with Platform Tools.
  2. Reboot the device in Fastboot mode.
  3. Run a script file (for example, flash_all.bat for Xiaomi or flash-all.sh for Pixel).
  4. If there is no script, flash it one by one:
    fastboot flash boot boot.img
    

    fastboot flash system system.img

    fastboot flash vendor vendor.img

    fastboot flash dtbo dtbo.img

  5. Run fastboot reboot.

For devices Samsung the app is being used Odin:

  1. Run Odin in administrator mode.
  2. Connect the device in mode Download Mode (Power + Vol Down + Bixby).
  3. Add firmware files to the appropriate fields (BL, AP, CP, CSC).
  4. Press Start and wait for completion.
๐Ÿ’ก

If the firmware via Fastboot is interrupted with an error FAILED (remote: 'Not allowed in Lock State'), then the bootloader is not unlocked. Return to step 3 and repeat the unlocking.

6. Typical errors and their solutions

Even if you follow the instructions exactly, errors may occur. Here are the most common ones and how to correct them:

Error Cause Solution
Error 7 c. TWRP The firmware is not compatible with the device or version of Android Check the device model and firmware version. Try the firmware for a different version of Android
FAILED (remote: 'unknown command') Unsupported Fastboot command or outdated version of the utility Update Platform Tools or use fastboot -w for forced cleaning
The device boots into bootloop Incompatibility of the kernel or modules in the firmware Install another firmware or flash the stock kernel (boot.img)
TWRP asks for a password after installation Data encryption (FBE) is not supported by the firmware Make a full Format Data v TWRP (attention: it will delete everything!) or use supported firmware FBE
Mobile network or Wi-Fi does not work There are no drivers for your region or model Install a patch for the modem or flash the stock one vendor.img

If the device does not turn on after flashing the firmware:

  1. Try booting into Fastboot or Recovery.
  2. If available Fastboot, flash the stock firmware through official utilities (Odin, Mi Flash).
  3. If the device does not respond, try EDL mode (for Qualcomm) or Test Point (for Mediatek).
What to do if the device is not detected by the PC?

If the PC does not see the device in Fastboot or Download Mode, try:

1. Change the USB port (better use USB 2.0 on the back panel of the PC).

2. Disable driver signing in Windows (Run โ†’ bcdedit /set nointegritychecks on).

3. Use another cable (original or with transfer support data).

4. Reinstall the drivers manually via Device Manager (select Android Bootloader Interface).

7. Data recovery and configuration after flashing

After successful flashing, the device will be in the โ€œas afterโ€ state purchases". You will need:

  1. Restore data from backup (if you have one). To do this:
    • ๐Ÿ“ Copy files from the PC back to the device.
    • ๐Ÿ“ž Restore contacts and SMS via Google Account or SMS Backup & Restore.
    • ๐ŸŽฎ Install applications again (game data can be restored via Google Play Games or Titanium Backupif you were root).
  • Customize the system:
    • ๐Ÿ”’ Enable USB debugging i OEM Unlock (if you plan further manipulations).
    • ๐Ÿ”„ Update all applications via Google Play.
    • ๐Ÿ›ก๏ธ Check the status SafetyNet (via Magisk or SafetyNet Test). If it does not pass, some applications (for example, banking) may not work.

    If you installed custom firmware, you may need to:

    • ๐Ÿ”Š Customize ViPER4Android to improve the sound.
    • ๐ŸŽจ Install a theme or launcher (for example, Nova Launcher).
    • ๐Ÿ”‹ Optimize autonomy through Battery Guru or AccA.
    โš ๏ธ Attention: After flashing custom firmware, some functions may not work correctly. For example, LineageOS sometimes does not work Always On Display or gestures navigation. Check the list of known bugs (bugs) on the firmware page on XDA.

    8. How to return the stock firmware

    If the custom firmware does not suit you or critical errors occur, you can return the official software. this:

    1. Download the stock firmware for your model (see section 2).
    2. If you have TWRP, try flashing the stock boot.img and system.img via recovery.
    3. If the device does not boot, use Fastboot or proprietary utilities:
      • For Samsung: Odin + firmware file in the format .tar.md5.
      • For Xiaomi: Mi Flash Tool in clean all.
      • For Google Pixel: script flash-all.sh from the firmware archive.
  • After flashing the firmware, perform a reset via Recovery โ†’ Wipe Data/Factory Reset.
  • On some devices (for example, Huawei) to return to stock firmware may require an official service center, since the manufacturer blocks self-flashing.

    ๐Ÿ’ก

    Returning stock firmware is usually easier than installing custom one, but this does not always reset the bootloader unlock counter (Knox, Bootloader StatusThis may affect the warranty or operation of some functions (for example, Samsung Pay).

    FAQ: Answers to frequently asked questions

    Is it possible to flash Android without unlocking the bootloader?

    No, to install custom firmware or TWRP unlocking is required. However, some official firmware (for example, for Samsung) can be installed via Odin without unlocking, but this will not make it possible to install custom software.

    Will I lose root after the firmware?

    Yes, the firmware removes root. To get it back, after installing the firmware you need to patch it again boot.img via Magisk and flash it via Fastboot or TWRP.

    How to check if the bootloader is unlocked?

    Turn off the device and boot in Fastboot mode (Power + Vol Down). If there is an inscription Unlocked or Device State: Unlockedat the bottom of the screen, then the bootloader is unlocked. You can also check with the command:

    fastboot oem device-info

    and find the line Device unlocked: true.

    Is it possible to flash Android through a computer without TWRP?

    Yes, many official firmwares are installed through Fastboot or proprietary utilities (Odin, Mi Flash). However, for custom firmware TWRP or another custom recovery is usually necessary.

    What is GSI firmware and who is it suitable for?

    GSI (Generic System Image) is a universal firmware compatible with devices that support Project Treble (Android 8.0+). It is suitable for those who do not have special custom firmware, but want to try pure Android. However, GSI often lacks support for specific hardware (camera, sensors).