Skip to content

Instantly share code, notes, and snippets.

@agichim
Last active April 4, 2024 10:41
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save agichim/fecb65ac6a30140e3f5c24f63bf2a8c5 to your computer and use it in GitHub Desktop.
Save agichim/fecb65ac6a30140e3f5c24f63bf2a8c5 to your computer and use it in GitHub Desktop.
Full guide to flash Moto G8 Power (sofiar)

Moto G8 Power Guide to Flash and Install a custom ROM

BEWARE:
I am not a developer. I put together this guide for my future self and for others. I had help from the Moto G8 Official Telegram channel community. I followed these steps to flash my own Moto G8 Power, except for the steps where I explicityl state I didn't follow myself. Software and tools also get updated over time so stuff here may get old.

For devs: if you think some stuff needs changing or updating or better written, let me know.

Contents:

Unlock Bootloader

This step you only do ONCE.

  1. Install Android SDK
  2. Install the latest Motorola USB Drivers
  3. Download ADB files from Google in C: in a new folder named Android
  4. Put your device in fastboot mode
    1. Power off your device (make sure your device is not connected with the USB cable, or it will power back on immediately)
    2. Hold the power button and the volume down button simultaneously until the screen boots into fastboot (you'll see some small text at the bottom of the screen on a black background)
  5. Connect your device via USB to your computer.
  6. Place the folder of the ADB files from Google in your $PATH
    1. Open Control Panel
    2. Open System
    3. Click on Advanced System settings on the left hand side panel
    4. In the new window click on Environment Variables...
    5. In the bottom pane (System variables) find PATH under the Variable column
    6. Select PATH
    7. Click on Edit...
    8. Below the last row, double click on an empty row
    9. Paste the path of your ADB files. e.g.: C:\Android\platform-tools_r31.0.2-windows\platform-tools → the idea is that the folder is located on your C: partition
    10. Restart your computer
  7. Open a terminal in the path where Android Studio was installed. e.g.: C:\Program Files\Android\Android Studio\bin
  8. Type fastboot devices.
  9. Your device should show like this ZY227F2B6F fastboot
  10. Type fastboot oem get_unlock_data
  11. The returned string will be used to retrieve your unlock key.
(bootloader) 0A40040192024205#4C4D3556313230
(bootloader) 30373731363031303332323239#BD00
(bootloader) 8A672BA4746C2CE02328A2AC0C39F95
(bootloader) 1A3E5#1F53280002000000000000000
(bootloader) 0000000
  1. Copy the whole text where you have (bootloader) in front of each line
  2. Go to Scrub Tools
  3. Paste the copied string in the text box
  4. Click Format my data
  5. It will remove all the extra text and space that do not belong to the string
  6. Copy the formatted string
  7. Go to the Motorola website.
  8. You have to Sign In or Create an account and Sign in.
  9. At the bottom click Next
  10. Now you will see the same instructions as in this guide, you can skip them if needed.
  11. Almost at the bottom, in Step 6 (on the website), paste the formatted string
  12. Click on the blue button Can my device be unlocked?
  13. If your device is unlockable, a "REQUEST UNLOCK KEY" button will now appear at the bottom of this page.
  14. Click I Agree
  15. Click on the blue button REQUEST UNLOCK KEY
  16. You will get the key via email along with instruction to unlock the bootloader
  17. Instruction link
  18. Open a different terminal in the ADB files from Google, inside here C:\Android\platform-tools_r31.0.2-windows\platform-tools
  19. Type fastboot oem unlock UNIQUE_KEYfastboot oem unlock QUXJMX5U3YBFSSTJDFRH
  20. Hit enter
  21. On your phone you should see two option, choose with the Volume key the option at the bottom Unlock bootloader
  22. Device screen will return to fastboot mode and the line before last should say flashing_unlocked. That means you have unlocked the bootloader successfully.

Flash Stock Firmware

Flashing Motorola Stock Firmware is not the same as flashing a Motorola Stock ROM via TWRP. The following steps apply for new devices which have Slots A/B.

IMPORTANT:

The reason you need to flash the Stock Firmware is because this will populate Slot B, which is "empty" by default and by doing this you don't risk bricking your device.

Find out if your device has Slots A/B (or if your device supports Seamless Updates).

Moto G8 Power (sofiar) supports Slots A/B. You can skip this step. Here are two methods checking:

First method

  1. Install Termux, it's a terminal for Android. When the page opens scroll down until you see a Version 0.112 (or any version number) and at the bottom of that version number click on Download APK
  2. Install Termux on your phone. You might get prompted to allow installation of insecure apps. Toggle the button to allow.
  3. Open Termux and type getprop ro.build.ab_update and hit Enter.
  4. Immediately you should see true. If so, it means your device support Seamless Updates.

Second method → I haven't tested this method

  1. You can install this app from Google Play

Assuming your device supports Seamless Updates:

  1. Download the Moto Flash Tool
    1. Download the Tool here
    2. There's also the Telegram channel where you will find the same link (always download the latest version and you can algo get support on Telegram)
    3. Unzip the file
    4. Place the file in your C: drive, preferrably in the Android folder you created earlier in this guide.
    5. IMPORTANT: make sure the PATH of the Tool has no spaces in it. This means that the Title of every higher level folder where the Tool is, should not have any spaces in it. The Tool won't work if there are spaces in its PATH. WRONG: C:\Android\my moto g8 power\moto_flash_tool_windows_v0.6.6moto_flash_tool_windows
      CORRECT: C:\Android\mymotog8power\moto_flash_tool_windows_v0.6.6moto_flash_tool_windows
  2. Download the Stock Firmware for you phone
    1. Find the specific Stork Firmware for your device here
    2. On that website, you need to go into the folder specific to your device
    3. To find out which one is your device, go into fastboot and around the top of the text you should see a similar line (this example is made up) MBM-3.0-sofiar_reteu-3db56gr5f11-223421
    4. The important thing in that line is sofiar_reteu. Depending on your device, those words will be different, go into the folders of each corresponding word
      Moto G Power/G⁸ Power (Sofia/Sofiar)
      Moto G Stylus/G Pro (Sofiap)
      Moto G⁸/G Fast (Rav)
      
      a. open the folder corresponding to the first word
      b. open the folder called official, if there is no official folder, check the folder which has the largest size (that means all the Stock Firmware are in that folder)
      c. inside the official folder find the folder corresponding to the second word (e.g.: reteu).
      d. now you will see several Stock Firmware. Best option is to download the latest one (usually the one at the bottom of the list, or check the Android version number 10, 11 in the title of each Firmware). If you download an earlier Stock Firmware, after you flashed with the Moto Flash Tool you will need to boot your phone and do the OTA updates (meaning you need to into Software Updates in your Settings and update your phone). OTA means Over The Air (updates via Wi-Fi)
    5. The downloaded Stock Firmware is a .zip file. Copy that file inside the Firmware folder which can be found inside the Moto Flash Tool folder.
    6. Boot your phone into fastboot
    7. Connect it to your computer via USB. Make sure that on the fastboot screen at the bottom it says Transfer Mode: USB Connected
    8. Go into the Moto Flash Tool folder and open moto_flash_tool-win.exe
    9. The console will open.
    10. Select Flash/extract stock firmare
    11. Select the .zip file of the Stock ROM
    12. Type n and hit Enter, this will begin the flashing process. This will format data automatically at the end of the process.
    13. The console might no look like it's doing anything, sometimes it hangs, hit Enter and it will show the progress. The third line in the screenshot Invalid sparse file format at header magic is normal.fa
    14. When it finished flashing it will ask you whether to format data or not.
    15. Type y and hit enter, this will format the data.
    16. I don't remember what happens after the data format, but I think you can close the console or select an Exit option if there is one.
    17. Your device will boot into fastbootd
    18. Now boot the phone into system, until you reach the Android homescreen.

Flash TWRP

This step you have to after each time you flash Stock ROM and after each OTA update of a Custom ROM.

Download the TWRP image for your specific device, in the case of Moto G8 Power you can find it in the Telegram channel, make sure to get the latest version. This is a different telegram channel than the one with the Moto Flash Tool. Search for TWRP in the channel.

Download the custom ROM you want from the Telegram channel to flash and place it on a SD Card ← That is another Telegram channel.

If you don't have the custom ROM and Magisk on your SD Card before flashing TWRP, it means that after flashing TWRP you need to boot into system, copy the custom ROM and Magisk on the SD Card and then boot back into recovery.

After you flashed the Stock Firmware and booted on the homescreen follow the next steps:

  1. Power off device, boot into fastboot
  2. Copy the twrp.img (doesn't matter if the name is different) inside the platform-tools folder. You don't really have to this because you included platform-tools in the $PATH earlier.
  3. Inside the platform-tools folder where you copied TWRP open your console (CMD or any other console you have on your computer, devs say PowerShell doesn't work well).
  4. Type fastboot flash recovery twrp.img
    1. In your case copy the name of your TWRP image and the file format .img and paste it after the word recovery from the step above.
  5. Hit Enter
  6. Can't remember what happens next, but it flashes TWRP in a few seconds.
  7. Boot into Recovery if the phone is still in fastboot
  8. Choose recovery with the volume keys and hit the Power button
  9. The phone will boot into TWRP

Flash Custom ROM

  1. Inside TWRP press on the Wipe button
  2. Press Format Data, the button at the bottom on the right-hand side
  3. Go back to main TWRP screen
  4. Press Install → this step assumess you have the custom ROM already on your SD Card.
  5. Press the button at the bottom Select Storage
  6. Select Micro SD card
  7. In the file list, select the custom ROM
  8. Swipe to flash it.
  9. After the ROM flashed DO NOT flash Magisk if you already have it on your SD Card
  10. Boot into System.

Flash Magisk

This step has to be done after each ROM you flash or after each OTA update.
IMPORTANT: After flashing the ROM boot into system and then flash Magisk.

The official source for Magisk is the GitHub repo

  1. Download the .apk file from GitHub and make a copy/duplicate.
  2. Rename the file extension instead of .apk to .zip ← I didn't read these official instructions, but instead download a Magisk.zip file from magisk.me (I'm not sure if this website is official or not, but I was lucky that it was a genuine file.)
  3. Copy the .zip file on your SD Card
  4. Boot into Recovery
  5. Click on Install
  6. Select SD Card as Storage
  7. Find the magisk zip file
  8. Flash it
  9. Boot into system
  10. Check if you have the Magisk app installed, if you don't, install the APK from GitHub
  11. You have Root
@szero
Copy link

szero commented Apr 4, 2024

Hi, I'm not a developer myself but the TWRP part should disclaim in bold font that the TWRP version vache made available for this phone only works for Android 10 roms and nothing above.

@agichim
Copy link
Author

agichim commented Apr 4, 2024

You're right @szero. I'll put that in. The whole things need some polishing too. Will do that soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment