[Desire 626 Android Development] BigCountry907:
Backup the device boot.img & Unpack / Split the kernel + ramdisk + dt.img.

Now we are all on the same page. " Same Setup Fresh Install "

Lets get down to business. :D

I'm going to go through the steps that I use. If you plan to work along with this project I recommend that you keep the same directory structure that I have. This way all the commands I give you will work. You may wish to change the directory structure but if you do.... remember you will need to adjust the commands accordingly.

So from a brand new fresh install.

#1 install twrp recovery

#2 install supersu

#3 Open supersu on phone

#4 Make sure usb debugging is turned on ect. ect. ect.

#5 Lets get the boot.img from the device.

Connect the device to the computer

From this point forward all commands are executed in the Linux terminal shell.

adb shell

su

Copy boot partition to the external sd card.

dd if=/dev/block/bootdevice/by-name/boot of=sdcard2/Boot.img

Pull the boot.img to the computer.

If still in adb shell exit out.

exit
exit
adb pull /sdcard2/Boot.img

#6 Setup some directories and move the boot.img into our project.

mkdir ~/a32e-kernel-build/
mkdir ~/a32e-kernel-build/Device-Files/
mkdir ~/a32e-kernel-build/Device-Files/Boot
mkdir ~/a32e-kernel-build/Tools
mkdir ~/a32e-kernel-build/Tools/AIK-Linux/
mv Boot.img ~/a32e-kernel-build/Device-Files/Boot
cd ~/a32e-kernel-build/Tools/AIK-Linux/
cp ~/a32e-kernel-build/Device-Files/Boot/Boot.img ~/a32e-kernel-build/Tools/AIK-Linux/

#7 We need AIK-Linux boot tools. Download them from the link below.

http://xdaforums.com/showthread.php?t=2073775

Please do use these bootimg tools. You might have others but AIK-Linux unpacks and repacks the image files as "ROOT".

Using other tools or not unpacking / repacking as ROOT will cause a bootloop specifically in Marshmallow even if the boot.img is good.

mv ~/Downloads/AIK-Linux-v2.4-ALL.tar.gz ~/a32e-kernel-build/Tools/AIK-Linux
tar -xvzf ~/a32e-kernel-build/Tools/AIK-Linux/AIK-Linux-v2.4-ALL.tar.gz
rm -f ~/a32e-kernel-build/Tools/AIK-Linux/AIK-Linux-v2.4-ALL.tar.gz
mv -v ~/a32e-kernel-build/Tools/AIK-Linux/AIK-Linux/* ~/a32e-kernel-build/Tools/AIK-Linux/
rm -d ~/a32e-kernel-build/Tools/AIK-Linux/AIK-Linux

Ok I know ????????

You want to know what we need the boot image for anyway !!

The a32e_defconfig file that comes with the HTC-DEV source code is not the exact configuration that HTC used when they built the kernel.

We want to start out with the same configuration RIGHT!!

Yes we do...... and after we have a verified working Kernel.......then we can start making changes.

In a nutshell /proc/config.gz will not work to pull the existing configuration. HTC did not enable that option. Lucky for us there is another way to generate the configuration file & that's reason #1 that we need the boot.img. There is another reason but we will get to that later. ( Other than having a Backup of the boot.img LOL. :confused:)

#8 Unpack the boot.img

sudo ./unpackimg.sh Boot.img

Make sure you use "sudo" it is nessessary.

The output should be

~/a32e-kernel-build/Tools/AIK-Linux$ sudo ./unpackimg.sh Boot.img

Android Image Kitchen - UnpackImg Script

by osm0sis @ xda-developers

Supplied image: MM-Boot.img

Removing old work folders and files...

Setting up work folders...

Splitting image to "split_img/"...

BOARD_KERNEL_CMDLINE console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 user_debug=31 ehci-hcd.park=3 androidboot.bootdevice=7824900.sdhci lpm_levels.sleep_disabled=1 earlyprintk vmalloc=400m androidboot.selinux=enforcing androidboot.hardware=htc_a32e androidusb.pid=0x0668

BOARD_KERNEL_BASE 80000000

BOARD_NAME boot:0

BOARD_PAGE_SIZE 2048

BOARD_KERNEL_OFFSET 00008000

BOARD_RAMDISK_OFFSET 02000000

BOARD_TAGS_OFFSET 01e00000

BOARD_DT_SIZE 731136

Unpacking ramdisk to "ramdisk/"...

Compression used: gzip

6560 blocks

Done!

#9 Move our unpacked boot.img to our project folder.

sudo mv ramdisk ~/a32e-kernel-build/Device-Files/Boot/
sudo mv split_img ~/a32e-kernel-build/Device-Files/Boot/
sudo cp ~/a32e-kernel-build/Device-Files/Boot/split_img/Boot.img-dtb ~/a32e-kernel-build/Device-Files/Boot/Boot.img-dtb
sudo cp ~/a32e-kernel-build/Device-Files/Boot/split_img/Boot.img-zImage ~/a32e-kernel-build/Device-Files/Boot/Boot.img-zImage
sudo cp ~/a32e-kernel-build/Device-Files/Boot/Boot.img-zImage ~/a32e-kernel-build/Device-Files/Boot/kernel