[Android Q&A, Help & Troubleshooting] TheUltimateNoobist:
I'm tired of asking the same question again and again but for the thousandth and the last time I'll try my best to explain y'all the jeopardy I'm in.

I'm trying to build cm-10.2 from source for Sony Xperia E (nanhu) and everything started off just fine until I had to generate the skeleton files. I decided to use the mkvendor.sh to generate em. I have no clue why, but Sony seems to be in love with .elf files. And the best part, mkvendor only works with a standard boot.img file. Since I found mkvendor.sh the only convincing option, I decided to not use the other 2 options given here.

I extracted the kernel.sin from the ftf package of the kernel I downloaded, used flashtool to in turn extract kernel.sin which produced kernel.elf. I tried two things:

1) Unpack kernel.elf (flashtool elf extractor) and then pack em into a boot.img file (Failed as I couldn't pack em because I didn;t know how to use mkbootimg)

2) Rename kernel.elf to boot.img. as suggested by a developer of CM11 for Xperia E (Worked and was also accepted by mkvendor.sh)

I used mkvendor and it said that i don't have unpackbootimg binaries. I tried to make them by using:

make -j4 out/host/linux-x86/bin/unpackbootimg

Sadly I didn't know how to proceed so I got the binary from here and copied it to /usr/bin/ and made executable using:

sudo chmod a+x /usr/bin/unpackbootimg

Rebooted and it worked but you will see below that it isn't fixed 100% but it just works. I moved on and decided to use the script again on the renamed kernel.elf file(i.e. boot.img)

This is the following error I encounter while using mkvendor:

carbogen-chemist@carbogen-chemist:~/tools/FlashTool$ cd ~/source/cm/branch/cm-10.2

carbogen-chemist@carbogen-chemist:~/source/cm/branch/cm-10.2$ ./build/tools/device/mkvendor.sh sony nanhu ~/Desktop/boot.img

Arguments: sony nanhu /home/carbogen-chemist/Desktop/boot.img

Output will be in /home/carbogen-chemist/source/cm/branch/cm-10.2/device/sony/nanhu

*** Error in `unpackbootimg': free(): invalid next size (fast): 0x09793170 ***

./build/tools/device/mkvendor.sh: line 84: 3943 Aborted (core dumped) unpackbootimg -i $BOOTIMAGEFILE > /dev/null

gzip: ../boot.img-ramdisk.gz: No such file or directory

cpio: premature end of archive

cp: cannot stat ‘/tmp/carbogen-chemist/bootimg/boot.img-zImage’: No such file or directory

Creating initial git repository.

~/source/cm/branch/cm-10.2/device/sony/nanhu ~/source/cm/branch/cm-10.2

Initialized empty Git repository in /home/carbogen-chemist/source/cm/branch/cm-10.2/device/sony/nanhu/.git/

[master (root-commit) d49b660] mkvendor.sh: Initial commit of nanhu

7 files changed, 95 insertions(+)

create mode 100644 AndroidBoard.mk

create mode 100644 AndroidProducts.mk

create mode 100644 BoardConfig.mk

create mode 100644 cm.mk

create mode 100644 device_nanhu.mk

create mode 100644 recovery.fstab

create mode 100644 system.prop

~/source/cm/branch/cm-10.2

Done!

Use the following command to set up your build environment:

lunch cm_nanhu-eng

And use the follwowing command to build a recovery:

. build/tools/device/makerecoveries.sh cm_nanhu-eng

Since the script seems to look up for boot.img-ramdisk.gz and boot.img-zImage, I decided to investigate a bit further. I renamed boot.img to kernel.elf and used flashtool elf extractor to unzip kernel.elf. I obtained four files as a result of the extraction:

1) kernel.elf.bootcmd

2) kernel.elf.cert

3) kernel.elf.Image

4) kernel.elf.ramdisk.gz

Since mkvendor needed boot.img-ramdisk.gz and boot.img-zImage, I renamed all the files:

1) kernel.elf.bootcmd	>> kernel.img-bootcmd

2) kernel.elf.cert	>> kernel.img-cert

3) kernel.elf.Image	>> kernel.img-zImage

4) kernel.elf.ramdisk.gz	>> kernel.img-ramdisk.gz

Now I repackaged them using mkelf.py script. Since I couldn't find any command specific to nanhu, I edited it to fit for the device:

python mkelf.py -o edited.elf kernel.img-zImage@0x80208000 kernel.img-ramdisk.gz@0x81400000,ramdisk kernel.img-bootcmd@0x00000000,cmdline

This command throws no error and produces edited.elf. All of the files are packed in except kernel.img-cert as I didn't know the arguments for it (kernel.img-cert@?x????????,cert). I rename the edited.elf to boot2.img.

But I get the same error as the one I get when I use the unedited kernel (boot.img)

What should I do to get out of this format abyss? Would I have better luck with mkbootimg? If so, could you point me out to a thread or tell me here itself how to use it?

Thank you all!