nAOSP 6.0/5.1 Ultimate Flashing Procedure
So regarding the numbers of comments I will assume that I have not well explain how to flash the ROM, Gapps, Xposed, SuperSU etc...
Why it is more complicated than before ?
This is not the fault of devs but due mainly to security enforcement (new Android permissions system, new Selinux rules, new dm-verity on some devices to check that /system is not modified...).
So due to that :
- New SuperSU comes with a System and System-less installation
- OpenGapps need to be flashed with the ROM before the FIRST boot of the ROM.
- Some patches need to be integrated on AOSP.
(Of course it is not legal to integrate GApps directly to the ROM so don't ask me to do it. I will not
. Ask Google.)
Infortunately if we don't respect a STRICT flashing method it will fail. So let's go to explain that again
GApps Flashing
For nAOSP 6.0
How to flash Gapps is explained into the Flashing section below but you need to know that on nAOSP 6.0 since b12,
you need to DON'T flash PackageInstallerGoogle.
To do it the ROM include a file into /persist/gapps-config.txt that exclude this package to be installed by Gapps.
If you already have a file gapps-config.txt somewhere it will probably override the file provided with the ROM so you need to add on your custom file the input 'PackageInstallerGoogle'.
The reason is to don't remove the AOSP PackageInstaller that permit to manager Superuser permissions since 6.0 b12.
Flashing
If you WANT to flash nAOSP 5.1 before b29 or noemulated versions
I suppose that you have not changed partitions on your device. If this is not the case revert to partition layout with a separate /data (p14) and /sdcard (p15).
Go to 'Manual procedure' section below.
If you DON'T come from nAOSP 6.0 or 5.1-b29+ and want to install last nAOSP version (except noemulated)
You will have to repartition your device if it is not yet done. DON'T ask a solution without re-partitionning. You want the last Android version, you need to evolve with Google decision.
PLEASE READ CAREFULLY. This is not a complex procedure but you have to repartition the device if not yet done and to backup your data prior.
Backup:
We will format /data and /sdcard so you need to take backup and put it outside of the phone.
Use your current TWRP to backup your ROM (system/boot/data) into /sdcard
Once done, backup on your computer the /sdcard content (use a file browser with mtp or adb pull)
Recovery/TWRP:
Extract recovery.img from the Zip file
(Alternative to below procedure if you already have TWRP: start TWRP/Install/Select image/Select Boot/Reboot)
Enter the device into fastboot mode
flash the recovery.img into boot partition like a boot image (fastboot flash boot recovery.img)
restart the device (fastboot reboot)
You should be on the recovery (it can be a little bit long to start the first time)
Repartitionning:
Go to Mount on TWRP gui (uncheck system, data, cache etc)
Connect on the recovery with "adb shell"
fdisk -l /dev/block/mmcblk0
Copy the output of the command to a file with your backup. It will permit you to revert if needed and to help you if you have an issue (read carefully and you will not have)
Interesting parts are those in bold :
/dev/block/mmcblk0p14 42945 261695 7000024 83 Linux
/dev/block/mmcblk0p15 261696
954240 22161424 83 Linux
It can be not exactly the same values for you depending the size of your /data (p14) and /sdcard (p15)
so here we go (don't forget the section backup. this procedure will erase your data)
fdisk /dev/block/mmcblk0
Command (m for help): p
Command (m for help): d
Partition number (1-15): 15
Command (m for help): d
Partition number (1-14): 14
Command (m for help): n
First cylinder (769-954240, default 769):
42945
Last cylinder or +size or +sizeM or +sizeK (42945-954240, default
954240): (just press enter if the default value is the good one)
Using default value
954240
Command (m for help): t
Partition number (1-14): 14
Hex code (type L to list codes): 83
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table
(You can have an error message about old table used. This is because you have not un mount every partitions before. This is not a problem, just continue to read the procedure)
Once repartitioning done, do NOT do anything else and just reboot the device (to be sure that the partition table is take into account by the kernel)
Now we will convert /data and /cache to F2FS.
Ext4 is not supported anymore on nAOSP 6.0 (Ext4 is still supported on 5.1 but you should migrate to F2FS). You don't need to take care about the 16384 byte to reserve for encryption. TWRP will do it for you.
Into TWRP:
Wipe
Advanced Wipe
select Data
Repair or Change File system
Change File System
F2FS
Swipe to Change
Press Home and do the same procedure to convert Cache partition to F2FS
Once done, again, do NOT do anything else and just reboot the device (required by TWRP)
If you still see 0MB or a wrong size for data after the reboot, try to format data (Wipe/Format Data). In the worst case, convert data to ext4 and convert back to f2fs will do the job
Upload the ROM/Gapps/SuperSU...
Upload the ROM/Gapps and every zip that you want to flash into /sdcard (/data/media/). Use "adb push" for example.
Congratulation
If everything is fine you should be able to mount /cache and /data and to see a big /data volume arround 28 GiB.
Later you will be able to restore your data (Pictures, Music, ...) if you want.
Do not restore TWRP folder because previous TWRP backup are not compatible with the new partition layout.
Now please follow the
Manual procedure of this post just below
If you come from OneOfaKind or pure Marshmallow or another ROM than nAOSP
Don't asume that it will work to flash nAOSP if you already are in an similar system on another ROM.
Why ? At least selinux enforced can be your nightmare if you don't flash the ROM correctly.
So re-read from top and proceed with one of the 2 options.
Manual procedure
TWRP ?
The only supported TWRP version is the one included into nAOSP zip files. Please stop to flash something else it will not work correctly. Anyway the FOTA will be flashed automatically with last versions.
(previous recovery version should be able to flash a new ROM except in some cases that will be mentionned. With block flashing used, it's now avoid a lot of incompatibility issues but in the doubt please follow the procedure below to have the last supported recovery)
You are not sure about which TWRP version you have ?
Ok we will flash it before starting the update:
- Extract recovery.img from the Zip file
- (Alternative to below procedure: start TWRP/Install/Select image/Select Boot/Reboot)
- Enter the device into fastboot mode
- flash the recovery.img into boot partition like a boot image (fastboot flash boot recovery.img)
- restart the device (fastboot reboot)
- You should be on the recovery (it can be a little bit long to start the first time)
So we can flash now ?!
I want Xposed
Flash it no issue reported with it. Be aware that Xposed is only tested with SuperSU installed but there is no issue reported with the embedded Superuser.
I want SuperSU
Donwload the last stable version 2.65. Please don't use the BETA one.
SuperSU comes with 2 differents installation mode : system-less and system. We need on nAOSP to install it in SYSTEM mode.
Infortunatly, SuperSU thinks that it needs to be installed into systemless mode but this is wrong.
So to flash SuperSU 2.65 you need to:
- Mount /system
- Create a file /system/.supersu and put inside SYSTEMLESS=false (don't need to do it with last nAOSP versions)
- Flash SuperSU (You will see system mode displayed during the flashing. If you see system-less that means that you have a mistake on /system/.supersu or /system is not mounted)
I don't want to lose my theme files
Since nAOSP 6.0-b06 and 5.1-b29 you will not lost them

. If you want to clean flash without theme restoration, you will have to wipe /system before.
Can I flash ROM + Gapps + SuperSU + Xposed + ... together ?
In fact yes you can flash everything together in one shot but if you are not really familiar with the flashing process divide it in multiple steps to understand what can be wrong. (Note that on my side I'm only testing ROM+Gapps)
If you want to flash everything I suggest you to do it like that :
- Install ROM zip
- Install GApps (Only if you want it. Don't forget restriction mentionned)
- Install SuperSU (Only if you want it. Don't forget the /system/.supersu)
- Install Xposed
- Wipe cache/dalvik
- Reboot
ROM Updater
Are you still reading ? Hope so
Now you are able to flash correctly everything manually. It's not so complicated but ok it is not so simple.
So I propose you an alternative based on ROM Updater.
- Start the ROM (at least nAOSP 6.0-b05-f01 and 5.1-b29 versions)
- Go to Settings/About/Updates
- Enable backup before update (if you want an automatic backup. You should do it !)
- Select Post update
Post Update (before 6.0-b07)
Now you should have a dialog box (Post update) that ask you to enter some text.
Before doing anything you need to know that TWRP use OpenRecoveryScript to permit some automation. Documentation is available at
http://wiki.rootzwiki.com/OpenRecoveryScript
I will assume that you want to install Gapps, SuperSU and Xposed. Be free to remove what you don't want. So enter in the field this content :
install /data/media/0/gapps.zip
mount system
(SuperSU doesn't mount /system but try to read variables from /system/.supersu)
install /data/media/0/supersu.zip
(Don't forget the /system/.supersu)
install /data/media/0/xposed.zip
(of course you will have to change the path of your files to valid ones. Don't forget copy/paste possibility of your explorer to help you. The root path should be common if you have uploaded files on your own/primary android user: /data/media/0/)
Post Update (since 6.0-b07 and 5.1-b29)
Before doing anything you need to know that TWRP use OpenRecoveryScript to permit some automation. Documentation is available at
http://wiki.rootzwiki.com/OpenRecoveryScript
I will assume that you want to install Gapps, SuperSU and Xposed. Be free to remove what you don't want:
Select + / select Gapps.zip / OK
Select + / select SuperSU.zip / In the before field put 'mount system' / OK
(SuperSU doesn't mount /system but try to read variables from /system/.supersu)
Select + / select Xposed.zip / OK
If you need to add extra commands, use the additional script feature that will display a DialogBox.
That's it
Hope it will be easier for everyone now