[GUIDE/TUTORIAL/HOWTO] Motorola Moto G 4G Peregrine stock to Android 9/LineageOS 16

Search This thread

djibe89

Senior Member

[GUIDE/TUTORIAL/HOWTO] Motorola Moto G 4G Any version to Android 9 Pie/LineageOS 16
[GUIDE/TUTORIAL/HOWTO] Motorola Moto G 4G/LTE 2013 Peregrine XT1039 Any version to Android 9 Pie/LineageOS 16

Complete guide to install Android 9 on your Motorola Moto G 4G/LTE.
This tutorial only applies to this model, to check the correct version:
in Android, go to Settings > About, make sure it is this model: Motorola Moto G 4G 2013 Peregrine XT1039.

We will only use a USB 2.0 port and a phone fully charged (but USB3 works too).


CHANGELOG

v14. TWRP 3.5, Magisk 22, BitGApps
v13. Rework tutorial (TWRP 3.4 manipulation, latest Magisk)
v12. Latest fastboot binary, TWRP 3.4, USB drivers for 32/64 bits, Magisk root, boot logo and simpler tutorial
v11. LOS 16 2020 Septembre update (thx to @sdembiske)
v10. LOS 16 2020 May update
v9. Updated pack with TWRP recovery 3.3.1-0, fix glitches in tutorial
v8. Moved tutorial for Android 9 and updated pack with TWRP recovery 3.3.0-0 and Addonsu 16
v7. Updated pack v5 with newest TWRP and removed outdated custom kernel, added links for newest ROMs
v6. Added Google Mobile Services (GMS) certification
v5. Added custom Bootlogo flash
v4. Recovery TWRP 3.2.1-0, MD5 signature for kernel and recovery
v3. Custom kernel, overclock, recovery TWRP 3.1.1-0, no /cache in F2FS (bootloops)
v2. Moved to Android 7.1 Nougat
v1. Initial release


1 ) WHAT YOU NEED

- djibe Moto G 4G pack (~20 Mo): http://bit.ly/motoGLTEdjibepackv5
(Contains link to Motorola Bootloader unlock + flashable Bootloader unlocked logo + TWRP Recovery 3.5.0_9-0 + Magisk root + Motorola USB drivers x32/64 + fastboot)

+ ROM LineageOS Unofficial 16: https://forum.xda-developers.com/moto-g/4g-development/rom-lineageos-16-0-t3835030
Download latest build available here: https://mega.nz/file/haBkzLCA#Aw4qZ09cKi5Jqs-p6SiUaDpxD_bMOQ8PzXACT1xKhr0

Want older and stable versions ?
Use this if you want to give/sell your phone to someone.
Grab Lineage OS 14.1 for peregrine here: https://forum.xda-developers.com/t/rom-lineageos-14-1-substratum-for-moto-g-lte-peregrine.3967207/

+ BitGApps ARM 9 R13: https://xiaomifirmware.com/download/16147/
For LineageOS 14.1, use this package: https://opengapps.org/?arch=arm&api=7.1&variant=pico

+ a microSD card formatted in FAT32 : copy ROM, GApps, Magisk and logo.zip on it.

You can chose another boot logo from this collection: https://forum.xda-developers.com/showthread.php?t=2686441
And download the file according here: https://androidfilehost.com/?w=files&flid=49201


2 ) INSTALL DRIVERS

Install Motorola 64 bits drivers (32 or 64 bits depending on your Windows version).
Then plug Moto G to PC and let the install go on.


3 ) BACKUP YOUR DATA

When your phone is connected to Windows, search for all .jpg, .mp3, .mp4 files on your phone and make copies on your PC.

Then, with an app like Backupyourmobile, backup all your SMS, MMS, contacts.
Make sure the backup is located on microSD card.


4 ) UNLOCK BOOTLOADER

Update your Moto G to the latest official Android 5.1 Lollipop.
In Android, go to Settings > About > Updates. Make sure you have latest version.

Then, go to Motorola website (shortcut in my archive or right below):
[/URL]
Subscribe using your Google Account or email.

Shut down phone.
Power it on in fastboot mode: Hold Power et Volume- during 3-4 secondes and release.
Screen is black with lines of text, starting with AP Fastboot Flash Mode (S).
Connect phone to USB2, wait for fastboot drivers to install.

In Windows, select the /flash subfolder you unzipped from my archive.
On keyboard, make a combo Shift + right click -> Open command windows here.
Write this command in Windows terminal :
Code:
fastboot oem get_unlock_data
confirm using Enter.
Command sends back a message like this :
Code:
$ fastboot oem get_unlock_data
(bootloader) 0A40040192024205#4C4D3556313230
(bootloader) 30373731363031303332323239#BD00
(bootloader) 8A672BA4746C2CE02328A2AC0C39F95
(bootloader) 1A3E5#1F53280002000000000000000
(bootloader) 0000000
OKAY [  0.146s]

Select all text -> right click -> select all.
Open a notepad editor, and paste text.
Rework the text to get it on 1 line, and remove all spaces and "(bootloader)" messages.
It should look like this : 0A40040192024205#4C4D355631323030373731363031303332323239#BD008A672BA4746C2CE02328A2AC0C39F951A3E5#1F532800020000000000000000000000

Now, copy this text line and paste it in Motorola website : https://motorola-global-portal.custhelp.com/app/standalone/bootloader/unlock-your-device-b
Below, click on Verify Eligibility.
Next, I Agree.
You get the unlock key by email, looking like : 56ITMEJ2BFHX5JVXMA4J

Use this unlock key in the following Windows command :
Code:
fastboot oem unlock YOUR_UNLOCK_CODE
Confirm with enter and wait a moment ... till success is confirmed : "Unclock Completed, wait to reboot",
don't disconnect it from PC !
phone reboots to Android with a blank screen "Warning, Bootloader unlocked".
Keep Windows command opened.


4 ) FLASH RECOVERY & BOOTLOADER LOGO

Shutdown phone again.
Power on in fastboot mode: Hold Power et Volume- during 3-4 secondes and release.
In Windows command, use this command:
Code:
fastboot flash recovery twrp-3.5.0_9-0-peregrine.img
confirm with Enter.
Terminal confirms : "Finished. Total time: 0.670s".
### In bootloader screen, you see error "mismatched partition size (recovery)" ? No problem. TWRP is smaller than stock recovery.
### For future TWRP updates, TWRP binary can be flashed from TWRP recovery itself (Install > Install Image)

Now, on the phone in fastboot mode, press Volume- to select the Recovery option. Confirm with Volume+.
Welcome to TWRP 3.5 recovery.
TWRP asks for Keep System Read Only ? -> check "Never show this screen during boot again" and Swipe to Allow Modifications.
### You don't see this waring screen? Then you'll get "TWRP unable to mount storage" while trying to wipe partitions.
### > in TWRP, go to Reboot > Recovery so Recovery will refresh and popup the partition writing privilege.


5 ) WIPE PARTITIONS

In TWRP home screen, go to Wipe > Format data.
Type yes and confirm to format partition.

Go to Wipe > Advanced wipe,
select Dalvik, Cache, System, Data, Internal Storage (if you really made a backup from step 2), then Swipe to Wipe,
then back.

### Don't try F2FS, it won't work.

Go to Reboot > Recovery.
Let phone reboot.


6 ) FLASH ROM, OPENGAPPS AND BOOTLOGO

Back to TWRP Home menu. Then tap on Install > choose lineage*.zip,
(if you don't see the files, tap on Select Storage and make sure Micro SDCard is active).
then Add more Zips > BiTGApps*.zip,
optional: then Add more Zips > logo*.zip,
then Swipe to confirm Flash.
Wait for operation to end.
### Don't flash Magisk now

Then tap Wipe cache/dalvik, swipe to confirm,
then Reboot System.

Wait for the phone to boot during 10 minutes.


7 ) ROOT ACCESS AND DEVELOPER MENU

With Magisk, you are root once phone is started. No extra manipulation needed.

For developer menu: open the Settings menu > About Phone.
Tap on the "Build number" entry seven times. You should be notified, that the developer settings are now active.
Now go to Settings menu > System > Developer settings.
Switch Advanced restart on.

Now use menus to Restart > Recovery.

Back to TWRP, go to Install > magisk*.zip
Reboot.
You are root.


8 ) ENHANCE PHONE

Go to Settings > Developer options
In drawing, set Windows animation scale, Transition animation scale to Animation off (or 0.5x).

Install Greenify, grant Superuser privileges and follow tutorial to set as System app.
Switch on:
- Smart hibernation > Enabled
- Light hibernation
- Aggressive sleep
- Automatic hibernation

That's it.

### When I play music, it comes out of the phone speaker but not the headphone jack.
Use stock AudioFX app to fix this.

Enjoy,
djibe
 
Last edited:

Robert Steed

Member
Mar 5, 2017
8
0
Works, except no sound from headphone jack

This worked for me today which I was chuffed about until I started to use the phone and found that when I played music it came out of the phone speaker but not the headphone jack. Any ideas?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 7

    [GUIDE/TUTORIAL/HOWTO] Motorola Moto G 4G Any version to Android 9 Pie/LineageOS 16
    [GUIDE/TUTORIAL/HOWTO] Motorola Moto G 4G/LTE 2013 Peregrine XT1039 Any version to Android 9 Pie/LineageOS 16

    Complete guide to install Android 9 on your Motorola Moto G 4G/LTE.
    This tutorial only applies to this model, to check the correct version:
    in Android, go to Settings > About, make sure it is this model: Motorola Moto G 4G 2013 Peregrine XT1039.

    We will only use a USB 2.0 port and a phone fully charged (but USB3 works too).


    CHANGELOG

    v14. TWRP 3.5, Magisk 22, BitGApps
    v13. Rework tutorial (TWRP 3.4 manipulation, latest Magisk)
    v12. Latest fastboot binary, TWRP 3.4, USB drivers for 32/64 bits, Magisk root, boot logo and simpler tutorial
    v11. LOS 16 2020 Septembre update (thx to @sdembiske)
    v10. LOS 16 2020 May update
    v9. Updated pack with TWRP recovery 3.3.1-0, fix glitches in tutorial
    v8. Moved tutorial for Android 9 and updated pack with TWRP recovery 3.3.0-0 and Addonsu 16
    v7. Updated pack v5 with newest TWRP and removed outdated custom kernel, added links for newest ROMs
    v6. Added Google Mobile Services (GMS) certification
    v5. Added custom Bootlogo flash
    v4. Recovery TWRP 3.2.1-0, MD5 signature for kernel and recovery
    v3. Custom kernel, overclock, recovery TWRP 3.1.1-0, no /cache in F2FS (bootloops)
    v2. Moved to Android 7.1 Nougat
    v1. Initial release


    1 ) WHAT YOU NEED

    - djibe Moto G 4G pack (~20 Mo): http://bit.ly/motoGLTEdjibepackv5
    (Contains link to Motorola Bootloader unlock + flashable Bootloader unlocked logo + TWRP Recovery 3.5.0_9-0 + Magisk root + Motorola USB drivers x32/64 + fastboot)

    + ROM LineageOS Unofficial 16: https://forum.xda-developers.com/moto-g/4g-development/rom-lineageos-16-0-t3835030
    Download latest build available here: https://mega.nz/file/haBkzLCA#Aw4qZ09cKi5Jqs-p6SiUaDpxD_bMOQ8PzXACT1xKhr0

    Want older and stable versions ?
    Use this if you want to give/sell your phone to someone.
    Grab Lineage OS 14.1 for peregrine here: https://forum.xda-developers.com/t/rom-lineageos-14-1-substratum-for-moto-g-lte-peregrine.3967207/

    + BitGApps ARM 9 R13: https://xiaomifirmware.com/download/16147/
    For LineageOS 14.1, use this package: https://opengapps.org/?arch=arm&api=7.1&variant=pico

    + a microSD card formatted in FAT32 : copy ROM, GApps, Magisk and logo.zip on it.

    You can chose another boot logo from this collection: https://forum.xda-developers.com/showthread.php?t=2686441
    And download the file according here: https://androidfilehost.com/?w=files&flid=49201


    2 ) INSTALL DRIVERS

    Install Motorola 64 bits drivers (32 or 64 bits depending on your Windows version).
    Then plug Moto G to PC and let the install go on.


    3 ) BACKUP YOUR DATA

    When your phone is connected to Windows, search for all .jpg, .mp3, .mp4 files on your phone and make copies on your PC.

    Then, with an app like Backupyourmobile, backup all your SMS, MMS, contacts.
    Make sure the backup is located on microSD card.


    4 ) UNLOCK BOOTLOADER

    Update your Moto G to the latest official Android 5.1 Lollipop.
    In Android, go to Settings > About > Updates. Make sure you have latest version.

    Then, go to Motorola website (shortcut in my archive or right below):
    [/URL]
    Subscribe using your Google Account or email.

    Shut down phone.
    Power it on in fastboot mode: Hold Power et Volume- during 3-4 secondes and release.
    Screen is black with lines of text, starting with AP Fastboot Flash Mode (S).
    Connect phone to USB2, wait for fastboot drivers to install.

    In Windows, select the /flash subfolder you unzipped from my archive.
    On keyboard, make a combo Shift + right click -> Open command windows here.
    Write this command in Windows terminal :
    Code:
    fastboot oem get_unlock_data
    confirm using Enter.
    Command sends back a message like this :
    Code:
    $ fastboot oem get_unlock_data
    (bootloader) 0A40040192024205#4C4D3556313230
    (bootloader) 30373731363031303332323239#BD00
    (bootloader) 8A672BA4746C2CE02328A2AC0C39F95
    (bootloader) 1A3E5#1F53280002000000000000000
    (bootloader) 0000000
    OKAY [  0.146s]

    Select all text -> right click -> select all.
    Open a notepad editor, and paste text.
    Rework the text to get it on 1 line, and remove all spaces and "(bootloader)" messages.
    It should look like this : 0A40040192024205#4C4D355631323030373731363031303332323239#BD008A672BA4746C2CE02328A2AC0C39F951A3E5#1F532800020000000000000000000000

    Now, copy this text line and paste it in Motorola website : https://motorola-global-portal.custhelp.com/app/standalone/bootloader/unlock-your-device-b
    Below, click on Verify Eligibility.
    Next, I Agree.
    You get the unlock key by email, looking like : 56ITMEJ2BFHX5JVXMA4J

    Use this unlock key in the following Windows command :
    Code:
    fastboot oem unlock YOUR_UNLOCK_CODE
    Confirm with enter and wait a moment ... till success is confirmed : "Unclock Completed, wait to reboot",
    don't disconnect it from PC !
    phone reboots to Android with a blank screen "Warning, Bootloader unlocked".
    Keep Windows command opened.


    4 ) FLASH RECOVERY & BOOTLOADER LOGO

    Shutdown phone again.
    Power on in fastboot mode: Hold Power et Volume- during 3-4 secondes and release.
    In Windows command, use this command:
    Code:
    fastboot flash recovery twrp-3.5.0_9-0-peregrine.img
    confirm with Enter.
    Terminal confirms : "Finished. Total time: 0.670s".
    ### In bootloader screen, you see error "mismatched partition size (recovery)" ? No problem. TWRP is smaller than stock recovery.
    ### For future TWRP updates, TWRP binary can be flashed from TWRP recovery itself (Install > Install Image)

    Now, on the phone in fastboot mode, press Volume- to select the Recovery option. Confirm with Volume+.
    Welcome to TWRP 3.5 recovery.
    TWRP asks for Keep System Read Only ? -> check "Never show this screen during boot again" and Swipe to Allow Modifications.
    ### You don't see this waring screen? Then you'll get "TWRP unable to mount storage" while trying to wipe partitions.
    ### > in TWRP, go to Reboot > Recovery so Recovery will refresh and popup the partition writing privilege.


    5 ) WIPE PARTITIONS

    In TWRP home screen, go to Wipe > Format data.
    Type yes and confirm to format partition.

    Go to Wipe > Advanced wipe,
    select Dalvik, Cache, System, Data, Internal Storage (if you really made a backup from step 2), then Swipe to Wipe,
    then back.

    ### Don't try F2FS, it won't work.

    Go to Reboot > Recovery.
    Let phone reboot.


    6 ) FLASH ROM, OPENGAPPS AND BOOTLOGO

    Back to TWRP Home menu. Then tap on Install > choose lineage*.zip,
    (if you don't see the files, tap on Select Storage and make sure Micro SDCard is active).
    then Add more Zips > BiTGApps*.zip,
    optional: then Add more Zips > logo*.zip,
    then Swipe to confirm Flash.
    Wait for operation to end.
    ### Don't flash Magisk now

    Then tap Wipe cache/dalvik, swipe to confirm,
    then Reboot System.

    Wait for the phone to boot during 10 minutes.


    7 ) ROOT ACCESS AND DEVELOPER MENU

    With Magisk, you are root once phone is started. No extra manipulation needed.

    For developer menu: open the Settings menu > About Phone.
    Tap on the "Build number" entry seven times. You should be notified, that the developer settings are now active.
    Now go to Settings menu > System > Developer settings.
    Switch Advanced restart on.

    Now use menus to Restart > Recovery.

    Back to TWRP, go to Install > magisk*.zip
    Reboot.
    You are root.


    8 ) ENHANCE PHONE

    Go to Settings > Developer options
    In drawing, set Windows animation scale, Transition animation scale to Animation off (or 0.5x).

    Install Greenify, grant Superuser privileges and follow tutorial to set as System app.
    Switch on:
    - Smart hibernation > Enabled
    - Light hibernation
    - Aggressive sleep
    - Automatic hibernation

    That's it.

    ### When I play music, it comes out of the phone speaker but not the headphone jack.
    Use stock AudioFX app to fix this.

    Enjoy,
    djibe
    2
    Hi guys, tutorial updated to enjoy Android 9 on your old Moto G 4G !!!
    Enjoy
    1
    New version of tutorial to obtain the Google Play Certification.
    1
    Added download links for older Android versions if needed
    1
    OK I fixed it
    I think I still had kitkat bootloader , so
    I downloaded the bootloader flash tool here : Tool

    This automatically upgrades the bootloader version to 411A

    Great , now is flashing
    Super great news !!!