Telegram

I WANT TO INSTALL LINEAGEOS ON MY SAMSUNG GALAXY M02

Ultimate Guide: Installing LineageOS on a Samsung Galaxy M02 Without TWRP

Navigating the custom ROM landscape on Samsung devices can be a complex endeavor, particularly when dealing with entry-level hardware like the Samsung Galaxy M02. We understand the frustration of encountering boot loops, failed ADB sideloads, and the dreaded Error 21 while attempting to modernize your device. The specific constraints you are facing—specifically the inability to maintain a TWRP installation, the failure of standard fastboot commands, and the verification errors within stock recovery—require a sophisticated, multi-layered approach. This is not a standard installation process; it is a workaround designed for Samsung’s unique bootloader architecture and Samsung’s Odin flashing protocol.

This comprehensive guide is designed specifically for your Samsung Galaxy M02 (Model: SM-M022F/DS, etc.). We will bypass the reliance on TWRP entirely and utilize the powerful Odin flashing tool combined with custom VbMeta images to disable AVB (Android Verified Boot). This method allows us to flash a generic Project Treble GSI (Generic System Image) directly to your device, effectively overcoming the Error 21 and the limitations of your stock recovery.

Understanding the Samsung Galaxy M02 Limitations

Before proceeding, it is crucial to understand why your device is behaving this way. The Samsung Galaxy M02 is based on the MediaTek MT6762M (Helio P22) chipset. Unlike Qualcomm Snapdragon devices, which utilize standard fastboot modes for low-level flashing, MediaTek devices use a proprietary protocol often referred to as Brom (BootROM) mode or a restricted fastboot mode that is locked down by Samsung.

The “No Fastboot” Problem

When you type fastboot devices and see nothing, it confirms that Samsung has disabled the standard Google fastboot interface in favor of their own Odin Protocol. This means that tutorials relying on fastboot flash system system.img will never work for you. We must use the Odin tool (or a variant like Frija or SamFw) to flash firmware partitions.

The “TWRP Boot Loop” Issue

The reason TWRP fails to stick is due to Samsung’s Dynamic Partition System (A/B Slots) and the specific bootloader logic on the M02. The device expects a specific boot.img signature. When TWRP is flashed, the bootloader often rejects it because it cannot verify the recovery partition’s integrity, or it conflicts with the A/B slot switching mechanism, causing an instant boot loop. We will circumvent this by flashing a patched boot.img to the boot_a or boot_b slot rather than attempting to install a separate recovery image.

The “Error 21” Verification Failure

The Error 21 in stock recovery indicates Signature Verification Failure. The stock recovery is strictly checking the digital signature of the ZIP file you are trying to sideload. Since generic LineageOS GSIs are not signed by Samsung, the stock recovery rejects them. To fix this, we cannot use the stock recovery’s ADB Sideload function. Instead, we will use Odin to flash the system image directly to the system partition, bypassing the recovery’s strict verification checks entirely.

Prerequisites and Required Tools

To successfully flash LineageOS on your Galaxy M02 without TWRP, we need a specific set of tools. Ensure you have a Windows PC for the most reliable Odin experience.

  1. Samsung USB Drivers: Essential for your PC to recognize the device in Download Mode.
  2. Odin3 (v3.14.4 or later): The official Samsung flashing tool.
  3. Frija: A tool to download the official stock firmware for your specific model and region.
  4. SamFw Tool: An excellent alternative for bypassing FRP and converting firmware files.
  5. 7-Zip: For extracting firmware files.
  6. GSIs (Generic System Images):
    • LineageOS GSI: We recommend the official LineageOS GSI builds or a trusted variant like Phh-Treble-GSI.
    • Mustang GSI (Optional but recommended): A GSI specifically optimized for MediaTek devices, often resolving hardware compatibility issues better than generic GSIs.
  7. VbMeta Disabler Image: A pre-patched vbmeta.img (usually with --disable-verity --disable-verification flags). This is mandatory to prevent Error 21 style verification failures and bootloops.
  8. Magisk: For root access, which is often required to fix hardware (RIL, Camera, Audio) on GSIs. You can find the latest Magisk APK in the Magisk Module Repository.

Step 1: Preparing the Stock Firmware (The Foundation)

Since we cannot use TWRP to create a backup, we must ensure we have a solid foundation to return to if things go wrong. We need to extract specific files from your stock firmware.

  1. Identify Your Model: Go to Settings > About Phone. Your model number should be SM-M022F (or similar).
  2. Download Stock Firmware: Use Frija to search for your model number and region (CSC). Download the latest firmware version.
  3. Extract the Firmware: Once downloaded, Frija will extract the firmware into a folder. You will see files like:
    • BL_XXXXXXXX.tar.md5
    • AP_XXXXXXXX.tar.md5
    • CP_XXXXXXXX.tar.md5
    • CSC_XXXXXXXX.tar.md5
  4. Extract system.img: We are not going to flash the stock system.img yet, but we need to understand the partition structure. The AP file is the largest and contains the system partition. We will replace the content of the system partition with the GSI.

Step 2: The Critical Fix - Disabling Verified Boot (AVB)

The primary reason for Error 21 and boot loops is Android Verified Boot (AVB). When the bootloader checks the system partition and finds it is not signed by Samsung, it refuses to boot. We must disable this check.

Acquiring the VbMeta Image

You cannot simply use the vbmeta.img from the stock firmware. You need a modified version.

  1. Search for “vbmeta_disabler.img” specifically for Samsung MediaTek devices. There are generic versions available on XDA Developers or GitHub.
  2. If you cannot find one pre-made, you can create one using a Linux environment or WSL (Windows Subsystem for Linux) with the avbtool if you have the stock vbmeta.img.
    • Command: avbtool make_vbmeta_image --output vbmeta_disabler.img --disable_verity --disable_verification

Note: We will flash this vbmeta_disabler.img to the vbmeta (or vbmeta_samsung) partition. This tells the bootloader, “Trust everything.”

Step 3: Preparing the GSI (LineageOS)

We are moving away from the ZIP file method. The stock recovery cannot handle the GSI ZIP. We need an IMG file.

  1. Download the GSI: Download the LineageOS GSI (usually named something like lineage-20.0-2023xxxx-phylogenetic-arm64-*.img.xz).
  2. Extract: Decompress the .xz file using 7-Zip to get a raw .img file.
  3. Partition Size Check: The Samsung Galaxy M02 typically has a system partition of around 3GB to 4GB. Ensure your extracted GSI image does not exceed this size. If it does, you may need to resize the image or look for a smaller “vanilla” variant of LineageOS (without GApps).

Step 4: The Flashing Procedure (Odin Method)

This is the most critical section. We will use Odin to flash the vbmeta_disabler and the GSI.

Entering Download Mode

  1. Power off your Galaxy M02 completely.
  2. Press and hold Volume Up + Volume Down and connect the USB cable to your PC.
  3. You will see a warning screen. Press Volume Up to enter Download Mode (Odin Mode).

Flashing via Odin

Method A: Using Standard Odin Tabs (If your Odin recognizes GSI images)

  1. Open Odin3 on your PC.
  2. Connect your phone. The ID:COM box should turn blue (or yellow/green).
  3. Load the VbMeta Disabler:
    • Click the VMETA or USERDATA button in Odin (depending on your Odin version, sometimes you can use the AP slot if you rename the file to AP.tar.md5, but usually, USERDATA or CP is safer for custom images).
    • Alternative: If Odin refuses the vbmeta file, we will use SamFw Tool later. For now, let’s focus on the GSI.
  4. Load the GSI (The System Image):
    • Rename your LineageOS .img file to system.img.
    • Compress it into a .tar archive (do not use RAR or 7z, use TAR format).
    • In Odin, click the AP or SYSTEM button (Odin versions vary).
    • Select the system.tar file.
    • Crucial Warning: Do NOT select Re-partition in Odin. This is dangerous for Samsung devices.
  5. Ensure Options are Correct:
    • Uncheck Auto Reboot (We want to control the reboot manually to ensure the flash is successful).
    • Uncheck F. Reset Time (Optional, but safer).
  6. Click Start.
    • This process will take time. Do not disconnect the cable.

Method B: Using SamFw Tool (Recommended for GSI on M02) Standard Odin can sometimes be finicky with non-Samsung system images on MediaTek devices. The SamFw Tool is often more successful.

  1. Open SamFw Tool and connect your phone in Download Mode.
  2. Go to the Flashing tab.
  3. Load your stock firmware files (BL, AP, CP, CSC) just to have the base structure.
  4. Remove System: Remove the loaded CSC or AP (which contains the stock system) and replace it with your GSI TAR file.
    • Better yet: Use the “Fix Android Version” or “GSI Flash” features available in SamFw Tool if you have the Pro version, or simply use the standard Flash button but replace the system.img inside the AP tar with your GSI (using 7-Zip to open the AP tar and swap the system.img).
    • Simpler GSI Method: Extract the stock AP.tar.md5. Open it with 7-Zip. Find system.img (it might be sparse system.img.lz4 or raw). Delete it. Drag and drop your extracted LineageOS GSI .img into the 7-Zip window.
    • Rename the new AP file back to AP.tar.md5.
    • Flash this modified AP file in Odin (Method A).

Step 5: Handling the VbMeta Partition

If you failed to flash the vbmeta_disabler in Step 4, you must do it now. If you cannot find a slot for it in Odin, we can force it.

  1. Using SamFw Tool:

    • Connect in Download Mode.
    • Go to the “FRP/Remove FRP” tab (sometimes has a “Vbmeta” feature) or “Misc” features.
    • Look for an option to “Flash Vbmeta”.
    • If not present, go to the “ROM Flash” tab, select your vbmeta_disabler.img, and select the partition name as vbmeta or vbmeta_samsung. (You may need to try both). Click Flash.
  2. Fixing “Secure Check Fail (system)” / Custom Binary Block:

    • After flashing the GSI, you might get an error blocking boot.
    • You must flash the Pit File (if available for M02) or perform a “Re-partition” in Odin only if you have the correct PIT file. WARNING: This is risky.
    • Safer: Flash the stock firmware (AP, BL, CP, CSC) via Odin. This restores the phone to working condition. Then, repeat Step 3 and 4, but only flash the vbmeta_disabler and the system.tar (GSI), leaving the stock boot.img alone.

Step 6: The First Boot (Post-Installation)

Once the flash is complete (and you have disconnected the cable):

  1. Force Reboot: Press and hold Volume Down + Power for 10 seconds to force a shutdown, then immediately press Volume Up + Power to boot into Recovery Mode.
  2. Wipe Data:
    • Since we are jumping Android versions (likely from 10/11 stock to Android 13/14 GSI), you must wipe data.
    • Select Wipe data/factory reset.
    • Select Format data/factory reset (Type ‘yes’ to confirm).
  3. Reboot System:
    • Select Reboot system now.

Note: The first boot will take a long time (10-20 minutes). Do not panic. If it takes longer than 30 minutes, you may have a kernel incompatibility.

Step 7: Troubleshooting GSI on Galaxy M02

If you boot into LineageOS but face issues, here is the checklist.

No RIL (Mobile Data / Calls)

MediaTek GSIs often fail to pass RIL data.

  1. Download the Magisk Manager APK (latest canary build).
  2. Flash Magisk via the “Install to Inactive Slot” method if possible, or patch the stock boot.img using Magisk Manager, rename it to boot.img, pack it to boot.tar.md5, and flash it via Odin in the BOOT slot.
  3. Once rooted, install Magisk Modules:
    • MTK Settings (Crucial for MTK hardware).
    • RIL Fix modules specific to Samsung M02 (search the Magisk Module Repository for “Samsung M02” or “M02 RIL”).

Camera Issues

GSI cameras often fail.

  1. Look for “Gcam” (Google Camera) ports optimized for MediaTek.
  2. Install Magisk modules like “libsupercamera” or specific “Camera2API” enablers.

Sensors Not Working

The accelerometer or gyroscope might be missing.

  1. Flash the Sensor Disable Magisk module (if you don’t mind losing some sensors) or search for “Sensor Fix” modules in the Magisk Repository.

Stuck in Bootloop

If the device keeps restarting:

  1. Re-enter Download Mode.
  2. Flash the Stock Stock firmware (AP, BL, CP, CSC) to restore the device to 100% working order.
  3. Re-attempt the GSI flash, but this time try a different GSI variant (e.g., switch from LineageOS 20 to ArrowOS or Pixel Experience). Not all GSIs are created equal for the MT6762M chipset.

Conclusion: Success

By following this guide, you have successfully bypassed the limitations of the Samsung Galaxy M02’s locked bootloader and stock recovery. We utilized Odin to inject a Patched VbMeta and a Generic System Image, effectively circumventing the Error 21 verification failure.

This process is advanced and requires patience. The key to success on the M02 is the VbMeta Disabler and the understanding that Fastboot is not an option. Stick to the Odin protocol, keep the stock firmware ready for recovery, and utilize the Magisk Module Repository to fix the inevitable hardware quirks of running a GSI on a budget Samsung device.

Explore More
Redirecting in 20 seconds...