[Nexus 7 (2013) General] Chady:
<Making Progress> Compile 2013 Nexus 7 – Flash to device – Stuck a Google boot screen

I am using the following device: 2013 Nexus 7

Android version: 4.3

Kernel version: __3.4.0-g6537a16androidbuild@vpbs1.mtv.corp.google.com__ #1

Build number: JSS15Q

The problem:

When I try to flash a new boot.img file that contains my own recompiled kernel I am unable to boot the system – it sticks at the Google boot screen (and does not make it to the color X screen)

Below I have detailed out the steps I have taken. Please take a look and tell me if you notice if I am doing something wrong.

The following step were taken while running Ubuntu 12.04 LTS

*******************************************************************************************

Unlocking the 2013 Nexus 7 (Flo=wifi)

Rooting the 2013 Nexus 7 (Flo=wifi)

*** Compile/Recompile the kernel ***

*** Create a new boot.img file ***

….. contains instructions for getting root access

*** Flashing a new boot.img file ***

*******************************************************************************************

Unlocking the 2013 Nexus 7 (Flo=wifi)

Open a terminal and make sure that your system can see the Nexus 7, run:

$ ./adb devices

If you see the Nexus 7, run:

$. /adb reboot bootloader

When the bootloader screen has reappeared, run:

$ sudo ./fastboot devices

-If you can see the Nexus 7, run:

$ sudo ./fastboot oem unlock

-Look at the Nexus 7, a screen should appear asking you if you want to “Unlock the bootloader” – choose Yes.

You will need to use volume up/down to choose a response and press the power button to select.

- The device will flash a new image and exit to prompt

Next, reboot the device:

$ sudo ./fastboot reboot

The device is now unlocked.

*******************************************************************************************

Rooting the 2013 Nexus 7 (Flo=wifi)

*** Compile/Recompile the kernel ***

In the following steps you will be compiling/recompileing a kernel for the Nexus 7.

*Make sure that libncurses5-dev is installed (needed for make menuconfig)

Starting out I am at the following location

user@system:/home/user $

In your home directory create a folder named “Razor_Flo”:

$ mkdir Razor_Flo

Move into the new folder:

$ cd Razor_Flo

You should be here – user@system:/home/user/Razor_Flo $

In the Razor_Flo directory, create a sub directory named “Kernel”:

$ mkdir Kernel

Move into the new folder:

$ cd Kernel

You should be here – user@system:/home/user/Razor_Flo/Kernel $

[----------------- For the next steps, I used the following website to determine what files I needed -----------------]

__http__://source.android.com/source/building-kernels.html

Figuring out which kernel to build

[----------------------------------------------------------------------------------------------------------------------------------------------]

In the Kernel folder, download the following files:

$ git clone __https__://android.googlesource.com/device/asus/flo-kernel

$ cd flo-kernel

You should be here – user@system:/home/user/Razor_Flo/Kernel/flo-kernel $

$ git log --max-count=1 kernel

-- Log information will be displayed, under the “flo: prebuilt kernel” you will see a set of numbers and letters that will look like 365a6e0, note that number for future use.

Back out of the flo-kernel folder

$ cd ..

You should be here – user@system:/home/user/Razor_Flo/Kernel $

Once you are in the Kernel folder, download the following files:

$ git clone __https__://android.googlesource.com/kernel/msm.git

-- This command will create an msm directory

Move into the msm folder

$ cd msm

You should be here – user@system:/home/user/Razor_Flo/Kernel/msm $

[---------------------- For the next step, I used the following website to acquire the files I needed --------------------]

__http__://source.android.com/source/building-kernels.html

On a linux host, if you don't have an Android source tree, you can download the prebuilt toolchain from:

$ git clone __https__://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6

[-----------------------------------------------------------------------------------------------------------------------------------------------]

Export the path to the prebuilt gcc files

$ export PATH=$PATH: <link to files>

Additional exports

$ export ARCH=arm

$ export SUBARCH=arm

$ export CROSS_COMPILE=arm-eabi-

Checkout the correct kernel files

$ git checkout 365a6e0 <-- the number you noted above

Make the Kernel

$ make flo_defconfig

* At this point you can use “make menuconfig” to make any changes to the .config file you need (i.e. kernel modifications)

$ make

* When the make is complete a file named zImage will be created here:

.../arch/arm/boot/zImage <-- Note this, you will need the file later

The kernel compile/recompile is now complete

*** Create a new boot.img file ***

In the following steps you will be taking apart the “Factory boot.img” so that you can create a “Modified boot.img” which will contain your modified and rooted kernel.

You should be here – user@system:/home/user/Razor_Flo/Kernel/msm $

Move up two directories

$ cd ../../

You should be here – user@system:/home/user/Razor_Flo $

[------------------------------------------------------- Tools need for next step -------------------------------------------------------]

You will need to download the following files.

-- split_bootimg.pl

__http__://code.google.com/p/zen-droid/downloads/detail?name=split_bootimg.pl

-- mkbootimg

__http__://code.google.com/p/zen-droid/downloads/detail?name=mkbootimg

-- 2013 Nexus Factory Images

__https__://dl.google.com/dl/android/aosp/razor-jss15q-factory-4f77b811.tgz

* You will need to copy this file to a unique location so that you can extract the “boot.img” that is located with it.

[------------------------------------------------------------------------------------------------------------------------------------------------]

Create a new folder named Workspace

$ mkdir Workspace

Enter the Workspace directory

You should be here – user@system:/home/user/Razor_Flo/Workspace $

Make two new folders in this directory

$ mkdir Original

$ mkdir Hacked

Move into the Hacked folder

You should be here – user@system:/home/user/Razor_Flo/Workspace/Hacked $

Create a new folders named Hacked_ramdisk

$ mkdir Hacked_ramdisk

Move up two directories – to the Workspace folder

$ cd ../../

You should be here – user@system:/home/user/Razor_Flo/Workspace $

Copy the 2013 Nexus 7 factory boot.img file into the ..Workspace/Original folder

-- can be found within the factory tgz file:

Copy the split_bootimg.pl file to the ..Workspace/Original folder

Copy the mkbootimg file to the ..Workspace/Hacked folder

Move the zIamge file to the ..Workspace/Hacked folder

Move to the Hacked folder

You should be here – user@system:/home/user/Razor_Flo/Workspace/Hacked $

Rename the zImage file to boot.img-kernel

Move up one directory - to the Workspace folder

You should be here – user@system:/home/user/Razor_Flo/Workspace $

Move to the Original folder

You should be here – user@system:/home/user/Razor_Flo/Workspace/Original $

Run the following command:

$ ./split_bootimg.pl boot.img

This will create two files, copy the boot.img-kernel and boot.img-ramdisk.gz

Copy the boot.img-ramdisk.gz file to the “Hacked/Hacked_ramdisk” folder

Move to the Hacked/Hacked_ramdisk folder

You should be here – user@system:/home/user/Razor_Flo/Workspace/Hacked/Hacked_ramdisk $

Run the following command:

$ sudo gzip -cd boot.img-ramdisk.gz | cpio -i

This will extract all the files with in the boot.img-ramdisk.gz file.

Delete the original boot.img-ramdisk.gz file that you just extracted the files from.

Edit the default.prop file

change ro.secure=1 to ro.secure=0

change ro.adb.secure=1 to ro.adb.secure=0

Save changes and close the file.

Run the following command :

$ find .| cpio -o -H newc | gzip > insecure_boot.img-ramdisk.gz

This will create a new file named insecure_boot.img-ramdisk.gz.

Rename the insecure_boot.img-ramdisk.gz. file to boot.img-ramdisk.gz and copy it up one folder in the hierarchy to the “Hacked” folder.

Move up one directory - ../Workspace/Hacked

You should be here – user@system:/home/user/Razor_Flo/Workspace/Hacked $

List the files in the ../Workspace/Hacked directory, there should be three files:

(1) boot.img-kernel, (2) boot.img-ramdisk.gz, & (3) mkbootimg

Run the following command from within the “Hacked” folder

$ ./mkbootimg --cmdline 'no_console_suspend=1 console=null' --kernel boot.img-kernel --ramdisk boot.img-ramdisk.gz -o mynewimage.img

Rename mynewimage.img to boot.img and flash on the device.

The new boot image is now complete and ready to flash.

*** Flashing a new boot.img file ***

[------------------------------------------------------- Tools need for next step -------------------------------------------------------]

You will need to download the following file.

-- 2013 Nexus Factory Images

__https__://dl.google.com/dl/android/aosp/razor-jss15q-factory-4f77b811.tgz

* You will need to copy this file to a unique location so that you can extract the “system.img” file that is located with it.

--- Android SDK (I used the 64-bit version)

__http__://dl.google.com/android/android-sdk_r22.0.5-linux.tgz

[------------------------------------------------------------------------------------------------------------------------------------------------]

You will need to use both the adb and fastboot utilites that come in the Android SDK application.

You will need two image to complete this task

1. boot.img <--file you just created, located in the ../Workspace/Hacked directory

2. system.img <-- can be found within the factory tgz file:

Starting out I am at the following location

user@system:/home/user/android-sdk/platform-tools $

Place both the boot.img and system.img files into the same folder as the adb and fastboot utilites.

Verify that you can see the Nexus 7 device that you are about to flash

$ sudo ./adb devices

*if you cannot see the device, make sure that you have checked the “enable USB Debugging” in the developer options.

Run the following commands

$ sudo ./adb reboot bootloader

$ sudo ./fastboot flash boot boot.img

$ sudo ./fastboot flash system system.img

$ sudo ./fastboot format cache

$ sudo ./fastboot format userdata

$ sudo ./fastboot restart

At this point the system should be unlocked and rooted.