After playing around a little bit with CM11 and CM12 on the new Moto X I’ve decided to return back to the stock firmware.

CyanogenMod is absolutely useful on old and cheap phones (ok, well, also on new and crappy ones) but losing all these motorola features (Active Screen, Moto Voice, Moto Assist, …) is a pure idiocy. Have to say also that Motorola is very developer/geek-friendly: the device comes already unlocked, stock firmware along with instructions on how to restore it are publicly available and documentation and tools for that are pretty good.

Said that, I followed some instructions (these and others) on the web that can be summarized this way:

  1. Download the stock firmware for your phone. This can be done directly on the Motorola website or on filefactory. I’m assuming you already know which Moto X phone are you using already. For example I’ve downloaded the XT1052_RETAIL-EU_4.4.4_KXA21.12-L1.26_54_cid7_CFC_1FF.xml.zip firmware version. Once downloaded extract it.
  2. If your firmware package does not include Windows, Linux, Darwin folders (containing a binary file called fastboot) download a version who does. for example TMO_RETAIL_XT1053_4.4.4_213.44.1.ghost_row.Retail.en.US_MR4_CFC.tgz (google that filename to find it). Unzip only the Linux/fastboot file and save it in the previously extracted folder.
  3. All guides about Linux I’ve found (very few, indeed), mention that you can also use the standard fastboot command that comes with the usual Androdid SDK, but to avoid any risk, I prefer to use this one from Motorola. This means that if you have the standard fastboot command available (comes in Debian with the android-tools-fastboot) do not use it. Use instead the extracted one calling with ./fastboot.
  4. I use TWRP as recovery system, so I’ve done a full backup of the CyanogenMod 11 system before proceeding so I can come back to it in case the stock rom does not work or anything else. This means though that I have to reinstall TWRP to restore it.
  5. In the XML file extracted you will find the exact steps to follow. I paste you mine but try to stick to yours. You can encounter some differences as not all the phone versions should be restored the same way. I use sudo because I’ve found in the past that causes less problems. Obviously you should have also adb installed (Debian package android-tools-adb)
sudo adb reboot bootloader
sudo ./fastboot oem fb_mode_set
sudo ./fastboot flash partition gpt.bin
sudo ./fastboot flash motoboot motoboot.img
sudo ./fastboot flash logo logo.bin
sudo ./fastboot flash boot boot.img
sudo ./fastboot flash recovery recovery.img
sudo ./fastboot flash system system.img
sudo ./fastboot flash modem NON-HLOS.bin
sudo ./fastboot erase modemst1
sudo ./fastboot erase modemst2
sudo ./fastboot flash fsg fsg.mbn
sudo ./fastboot erase cache
sudo ./fastboot erase userdata
sudo ./fastboot erase customize
sudo ./fastboot erase clogo
sudo ./fastboot oem fb_mode_clear

*reboot your phone*

So, now you have again your Moto X with the original firmware restored. Obviously all applications, data and so on are lost if you did not backup them. Some thoughts:

  1. A custom recovery can be installed also with the stock ROM: as said, I use TWRP that is very simple to install at this point as the bootloader is still unlocked: download the latest version from here (only for Moto X) and the Philz Touch img file. Then install them with:
sudo adb reboot bootloader
sudo fastboot flash recovery openrecovery-twrp-2.8.4.0-ghost.img
sudo fastboot flash recovery philz_touch_6.57.9-ghost.img

*reboot*

This will allow you to use a custom recovery with touchscreen support to perform various operation (other ROM management, backup, restore, root device, and so on)

  1. The phone will warn you at boot that the device is unlocked. To get rid of this message you could re-lock it (Not tried by myself but should work):
sudo adb reboot bootloader
sudo fastboot oem lock begin
sudo fastboot oem lock

*reboot*

Final note: this post is intended more like a personal reminder on the procedure than a useful/generic guide. Is also very rough and I assume a lot of things (for example that you know how to perform some command on Linux, install package, identify files and phone models, do and restore backups and so on). Do not try if you don’t feel confident about.