Rooting and Installing Custom ROM CyanogenMod 12.1 on Moto G 2014 (2nd Gen) – a Complete Guide

It is always fun to hack gadgets to customize the way you want it to be. Here is my attempt to install Cyanogenmod 12.1 (CM 12.1) on Moto G 2014 (2nd Gen) device. Why Cyanogenmod? It is damn simple, highly customized and customizable, good support, actively maintained and great stability! And also you can find my another post on restore back to Official Stock Android 6.0 Marshmallow here.

I use to hack a Nexus 4 multiple times, but never bothered to write a post on it. But in this case (Moto G) it is a locked device. But good thing is Motorola supports officially to hack the device – obviously losing your warranty.

It involves the following steps:

  1. Installing Software – We will install Android tools and Motorola drivers.
  2. Unlocking the boot loader – Boot loader helps the OS to get loaded and running. It is locked by Motorola for security. If it is open boot loader may load malicious software to collect your data. In this case we are going to unlock it so that we can install safer Open Source Cyanogenmod which is based on Android.
  3. Install Recovery software – this software is loaded by bootloader. This software helps us to install new Android ROM images, customize the system and provide necessary system tools.
  4. Install Cyanogenmod software – this is the Android ROM image we are going to load. CM ROM 12.1 is built-in with Root capability so you need not to do anything special to get it rooted.

 

Disclaimer: This post is for reference purpose only. It involves a lot of hacks which is not supported by Motorola and there is a chance of losing your data and warranty. It is at your own risk to follow the guide.

Installing Software:

  1. Download and install Android SDK (which provides adb and fastboot tools) and Motorola USB Drivers too.
  2. In case you have Linux machine, you can skip Drivers download. But ensure that you have udev configuration file for this Mobile as given below:
    1. Create a udev configuration file /etc/udev/rules.d/99-android.rules with content below – replacing “username” with your user login name:
      SUBSYSTEMS=="usb", ATTRS{idVendor}=="22b8", ATTRS{idProduct}=="2e80", MODE="0666", OWNER="username" # Fastboot mode
      SUBSYSTEMS=="usb", ATTRS{idVendor}=="22b8", ATTRS{idProduct}=="2e76", MODE="0666", OWNER="username" # MTP mode, USB debug On
      SUBSYSTEMS=="usb", ATTRS{idVendor}=="22b8", ATTRS{idProduct}=="2e82", MODE="0666", OWNER="username" # MTP mode, USB debug Off
      SUBSYSTEMS=="usb", ATTRS{idVendor}=="22b8", ATTRS{idProduct}=="2e83", MODE="0666", OWNER="username" # PTP mode, USB debug Off
      SUBSYSTEMS=="usb", ATTRS{idVendor}=="22b8", ATTRS{idProduct}=="2e84", MODE="0666", OWNER="username" # PTP mode, USB debug On
    2. Issue following command in shell to restart udev service.

$ sudo service udev restart

Unlocking the boot loader:

  1. From your PC, go to Motorola Bootloader Unlock web site. Get to know about what you are going to do and what are the risks it involves.
  2. Follow the next button at end of that web page, you will be asked to login. Here you can use your Google login or Motorola login.
  3. Now you should be in Device unlocker guide page. Leave it here.
  4. Enable Developer options in your phone: Settings -> About Phone -> Seven times tap “Build Number” quickly -> Go back -> Developer Options -> Enable USB debugging.
  5. Shutdown the phone. Press and hold Volume Down + Power button simultaneously till you get simple text screen, which shows that you are in Bootloader fastboot mode.
  6. Connect your phone to PC through USB cable. It should recognize the phone. In case of Windows it takes a few minutes to recognize and configure driver. In Cmd Prompt, Run “fastboot devices” (You may need to run this command from where you installed Android ADB tools) to ensure that your device is listed down.
  7. In case device is not listed, ensure that Drivers are installed properly in case of Windows and udev rules setup properly in case of Linux. Even if it works here, there is a chance of any write to device may fail while further commands we are going to issue – most probable reason could be this USB port compatibility issues. Culprit may be your ageing old USB ports. None of the USB ports in my 6 years old PC were working with either in Windows or Linux. So I had setup this in another machine.

  8. In Cmd Prompt, Run “fastboot oem get_unlock_data” to get device unlock data from mobile. It will display hexadecimal numbers similar to shown below:

    (bootloader) 0A40040192024205#4C4D3556313230
    (bootloader) 30373731363031303332323239#BD00
    (bootloader) 8A672BA4746C2CE02328A2AC0C39F95
    (bootloader) 1A3E5#1F53280002000000000000000
    (bootloader) 0000000

  9. Strip off all “(bootloader)” words and form a string of hexadecimal number only. Paste this string in Motorola web page we were in and Press “Can my device be unlocked?” button. Then it will display “REQUEST UNLOCK KEY” button, agree to T&C and press the button.
  10. Now will get email from Motorola with your Unlock key. Note down this unlock key.
  11. Run “fastboot oem unlock <unlock key>“. You should see “Unlocked” message on phone screen.
  12. Reboot phone from screen. Enable “Developer options” on phone again to enable USB debugging. Now reboot again. You should see following warning banner while booting your phone.
Motorola Bootloader Warning
Motorola Bootloader Warning

Install Recovery software:

  1. Download latest stable version of Recovery and CM ROM from Official CM Download Page for Titan devices (Moto G 2nd Gen).
  2. Connect the phone which is running Android with unlocked bootloader with PC through USB cable.
  3. Now run following commands from Cmd prompt in sequence to flash this Recovery .img file.
    1. adb reboot bootloader
    2. Once rebooted issue “fastboot devices” to ensure that it is connected properly.
    3. Now issue “fastboot flash recovery your-downloaded-recovery.img” to flash recovery image.
    4. Now reboot phone to “Recovery” from fastboot menu on screen (you may need a power cycle again to fastboot mode to get into new installed Recovery mode).
    5. Now you should see Recovery Menu screen.

Install Cyanogenmod ROM:

  1. Download minimum Google Apps package from here for 12.1. This contains Google Play Store so that you can install other Apps in your phone later. Note that the CM ROM you are going to flash is open source code which does not contain proprietary Google Base packages – that is why we download this Google Apps package.
  2. Copy already downloaded CM ROM image zip file and GApps package zip file to your Phone memory Internal Storage. This can be done either through File copy when it is connected to your PC or through “adb push <your-zip-file> /sdcard/” command.
  3. Now again boot the phone to Recovery mode.
  4. You should see an option to install Zip package. Select that option and install CM ROM zip file by selecting from sdcard.
  5. Similarly install GApps package zip file too.
  6. Now reboot the phone.
  7. Now you have welcome screen of your shiny new Cyanogenmod powered Moto G.
  8. If you want to root your phone so that you can install useful Adaway kind of programs to disable adware: Settings -> Developer Options -> Enable Root. Now you are rooted.
Reference

Restore back to Official Stock Android 6.0 Marshmallow.

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *