Skip to content

Instantly share code, notes, and snippets.

@lucasmz-dev
Last active February 21, 2026 22:02
Show Gist options
  • Select an option

  • Save lucasmz-dev/cca7afb146f2908f92eb681b5a4c1e38 to your computer and use it in GitHub Desktop.

Select an option

Save lucasmz-dev/cca7afb146f2908f92eb681b5a4c1e38 to your computer and use it in GitHub Desktop.
How to return back to stock software in Motorola devices on Linux

I am not responsible for any type of damage when you follow this tutorial. You have been warned.

This tutorial was originally designed for the devices: moto g32, g42, and g52. It should also work for the moto g34/45, g84, and g 5g 2024.

Device codenames

It is important to note that these devices are usually referenced using codenames in multiple places, it is important to know which one is yours.

  • g32: devon
  • g42: hawao
  • g52: rhode
  • g34/45: fogos
  • g84: bangkk
  • g 5g (2024): fogo

Any slight variation of these codenames means that it isn't the same device and it will most likely brick your device. (e.g. rhodec, rhodej)

Prerequisites:

  1. Android Platform Tools installed (Fedora)
  2. Keep the device in bootloader mode!
  3. Unlocked bootloader (click here if you're in a locked bootloader)
  4. Stable cable, not using any hubs (preferably the original cable, if it is indeed stable and not damaged)

Finding your device variant

Before downloading the firm/software for your device, you need to figure out what variant of that device you have in order to prevent a brick.

To figure this out, you'll need to run a fastboot command. Run this on your terminal:

fastboot getvar ro.carrier

This should return your device variant, in my case, it is RETBR.

Downloading the firmware

We will be using an unofficial source, as Motorola does not make the firmware easily accessible officially, only via the RSA tool that's only available on Windows.

  1. Visit https://mirrors.lolinet.com/firmware/lenomola/.
  2. Find your device's codename (rhode, devon, hawao) in the list and open it.
  3. Open the folder "official".
  4. Find your device's variant (RETBR, RETAIL, RETEU, RETLA...) in the list and open it.
  5. Download the most recent .zip file. This is the current firmware for your device.

image image

Warning

Do not attempt to downgrade, or use older versions of firmware. While it is possible, you won't be able to relock the bootloader, if so, it will brick your device. Make sure to get the LATEST version available.

Installing motoflash2sh

MotoFlash2SH is a tool created to convert the .xml files inside the .zip into .sh files that we can execute in the terminal. Motorola (for some reason?) uses .xml files, to describe the install process for their firmware. This allows us to run these on Linux.

  1. Install Python3 (search for instructions for your distro)
  2. Add /home/user/.local/bin to PATH
  3. Install motoflash2sh by running:
pip3 install https://github.com/dlenski/motoflash2sh/archive/master.zip

You should be able to run motoflash2sh in the terminal and it be found. (e.g. it will show an error that it won't find the file, but it shouldn't say it's not a recnognized command, if it does, then check PATH.)

Clearing the avb_custom_key

Custom OSes with Verified Boot 2.0 such as Calyx use this partition in order to store their signing key so that Verified Boot with a custom key works properly. It is ideal to remove this before flashing stock.

Caution

This is unsafe on a locked bootloader, other devices should usually disallow this, but for some reason Moto allows erasing this without being on an unlocked bootloader. This can cause a hard brick if you have OEM Unlocking disabled.

Inside a terminal, run the command:

fastboot erase avb_custom_key

Preparation

  1. Create a new empty folder
  2. Put the firmware .zip file inside it.
  3. Extract it

Now, we're going to convert the .xml into a .sh file.

  1. Open the terminal in the extracted firmware folder
  2. Run this command on the terminal
motoflash2sh flashfile.xml

You should now have a .sh file in the folder.

Installation

If you haven't already, open a terminal inside the firmware folder. Now, we'll run the .sh by running:

sh flashfile.sh

Installation should now begin. Keep the cable and device stable and let it run until it finishes. If you got an error, you can also try running it with sudo to see if it works.

Warning

If you notice any errors, failures, anything of that nature, do not continue with relocking the bootloader; as it can make the situation worse.

Relocking the bootloader

If everything has gone smoothly, you should be able to now relock the bootloader. This will restore Verified Boot. To do this, run this command on the terminal:

fastboot flashing lock

Now, confirm the locking on the device.

After boot, you should go into Developer Settings and check that OEM unlocking is off. Doing so will allow FRP to work properly. (This is the steal protection from Google)

Finished!

You should be all set now! You are now back in stock firmware.


@mandeep1152
Copy link

Hello

I have moto g34 5g ,(fogos)
I flashed a custom rom (oxygen os 15) and then I locked the bootloader

Now I'm stuck in fastboot mode
(flashing locked)
I can't boot into recovery mode

I want to ask that if I blankflash will I be able to boot into recovery? And The adb sideload official firmware from lolinet or RSA/LMSA tool

Is this possible
Please reply me I have only one device and it's very hard for me to go to service centre which is so far and also they gonna charge too much money

@lucasmz-dev
Copy link
Author

lucasmz-dev commented Feb 21, 2026

If you can't while in fastboot, run fastboot flashing unlock and unlock the bootloader, you won't be able to recover the device. Only certain ROMs support relocking and are built for that. Personally I haven't been able to get the blankflash thing to work even when I was in the mode, which you need to apparently short things to get into it.

Be fast with my suggestion (run fastboot flashing unlock), it seems the longer people take to re-unlock they get stuck with the device thinking OEM Unlocking was somehow turned off.

@mandeep1152

@mandeep1152
Copy link

@lucasmz-dev

Hey bro thanks for replying
I tried this command many times but this never works I get error it asks me to enable oem unlocking in Android settings

But to do that I need to boot in os first
But I can't boot bcz I'm bricked

@lucasmz-dev

@lucasmz-dev
Copy link
Author

@mandeep1152

Nothing you can do now.

@mandeep1152
Copy link

@lucasmz-dev
I have no other option than trying everything that is in my hand 😿

If you can help me please pm me in telegram at @manxdeep69 this is my telegram username

If you're not comfortable we can continue here only

I can't have a conversation with you here right now cuz it's 3:30 am in my country i gotta sleep

@lucasmz-dev
Copy link
Author

You have nothing else to try. Sorry. I've tried to help people in this situation many times.

Also I don't use Telegram and I don't help people in DMs, I leave it out in the open as to keep that information public.

@mandeep1152
Copy link

@lucasmz-dev

I read somewhere that blankflash restores the recovery mode if it's true I can adb side load official firmware maybe it can allow

@mandeep1152
Copy link

@lucasmz-dev yess yore right keeping information public is better idea someone else can help too

@lucasmz-dev
Copy link
Author

Then try it? There's some files in mirrors.lolinet.com (this stupid domain lol) for that but like I said I don't know how and it didn't work for me when I tried it. Fastboot doesn't allow booting into EDL, you need to short cables to do that, if that even works on these devices, but even getting in that mode through other means didn't work for me when I was finally there.

@mandeep1152
Copy link

Yes I will try it Tommorow and I'll update it here so that if I fail no one wastes his time in this situation

Thank you for guiding

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