Skip to content

Instantly share code, notes, and snippets.

@eexit
Last active November 28, 2020 17:37
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eexit/4176f8264f35e63a79b09c16a31e2792 to your computer and use it in GitHub Desktop.
Save eexit/4176f8264f35e63a79b09c16a31e2792 to your computer and use it in GitHub Desktop.
Getting a Moto X back to stock on OSX

Getting a Moto X back to stock on OSX

Backup, first!

  1. Downloads the Android SDK Command Line Tools

     $ unzip android-sdk-macosx.zip
     $ cd android-sdk-macosx
    
  2. Create a backup folder

     $ mkdir backup
    
  3. Plug your phone and make sure you have the Developer Options enabled (tap 7 times on Settings > About phone > Build number)

  4. Make sure you can interact with your phone from the Terminal

     $ ./platform-tools/adb devices
     List of devices attached
     XXXXXXXXXX	device
    
  5. Backup your SDCard content

     $ ./platform-tools/adb pull -p /storage/sdcard0/ ./backup/
     $ ...
    

Flash stock images back

  1. Grab the OSX moto-fastboot version of fastboot here

     $ unzip moto-fastboot-osx.zip -d moto-fastboot-osx
     $ cd moto-fastboot-osx
    
  2. Grab the appropriate stock firmware here (or here) (you want the one that matches your Android build number in Settings > About phone > System version)

     $ unzip XT1052_GHOST_RETEU_5.1_LPA23.12-15_cid7_CFC.xml.zip -d rom
     Archive:  XT1052_GHOST_RETEU_5.1_LPA23.12-15_cid7_CFC.xml.zip
     inflating: rom/motoboot.img
       inflating: rom/recovery.img
       inflating: rom/fsg.mbn
       inflating: rom/gpt.bin
       inflating: rom/boot.img
       inflating: rom/system.img
       inflating: rom/logo.bin
       inflating: rom/NON-HLOS.bin
       inflating: rom/flashfile.xml
       inflating: rom/servicefile.xml
       inflating: rom/factory_version_info_cfc.txt
    

You can ensure you have the right version by checking version/model/build, etc. in factory_version_info_cfc.txt.

  1. Boot your phone into the bootloader (Power down phone > Hold Volume Down and Power > Release Power button after a few seconds)

  2. Verify your phone is available

     $ ./moto-fastboot-osx64 devices
     XXXXXXXXXX	fastboot
    
  3. Generally, flashing these images is enough

     $ ./moto-fastboot-osx64 flash boot rom/boot.img
     $ ./moto-fastboot-osx64 flash recovery rom/recovery.img
     $ ./moto-fastboot-osx64 flash system system.img
     $ ./moto-fastboot-osx64 reboot
    

If you need a complete factory reset (including data/app reset), you can basically play all the commands that are in rom/flashfile.xml:

$ ./moto-fastboot-osx64 getvar max-download-size
$ ./moto-fastboot-osx64 oem fb_mode_set
$ ./moto-fastboot-osx64 flash partition rom/gpt.bin
$ ./moto-fastboot-osx64 flash motoboot rom/motoboot.img
$ ./moto-fastboot-osx64 reboot-bootloader
$ ./moto-fastboot-osx64 flash logo rom/logo.bin
$ ./moto-fastboot-osx64 flash boot rom/boot.img
$ ./moto-fastboot-osx64 flash recovery rom/recovery.img
$ ./moto-fastboot-osx64 flash system rom/system.img
$ ./moto-fastboot-osx64 flash modem rom/NON-HLOS.bin
$ ./moto-fastboot-osx64 erase modemst1
$ ./moto-fastboot-osx64 erase modemst2
$ ./moto-fastboot-osx64 flash fsg rom/fsg.bin
$ ./moto-fastboot-osx64 erase cache
$ ./moto-fastboot-osx64 erase userdata
$ ./moto-fastboot-osx64 erase customize
$ ./moto-fastboot-osx64 erase clogo
$ ./moto-fastboot-osx64 oem fb_mode_clear
$ ./moto-fastboot-osx64 reboot

References

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