[GUIDE] How to build CWM-based Recovery from source in Ubuntu LTS with CM-11.0

Status
Not open for further replies.
Search This thread

Eversmile23

Senior Member
Aug 15, 2014
308
41
Rourkela
Since we are talking about compiling CWM based recovery, or official CWM, we will move to cyanogenmod guide.
So do what they say to sync the cm-11.0 repo. I usually do this in a folder named CM11-0, but you can use what name you want, or as they say "/android/system". Wait to finish the repo sync (depends on internet connection, computer performances, etc) - for me it takes about four hours.
.

Can I use portable Ubuntu on my Windows 7 laptop for compiling the CWM recovery?
 

BlueFlame4

Retired Recognized Developer
Mar 10, 2011
1,866
4,403
32
Dresden, Germany
Wow, what a great tutorial! Thanks a ton, carliv!

Just one thing: Looks like newer MediaTek (6752, 6753, ...) images are packed correctly with gzip.. Can someone confirm?
 

suraj-b

Senior Member
Jun 14, 2016
97
30
can anyone help me with this

grep: build/target/board/generic/recovery.fstab: No such file or directory
find: ‘out/target/common/docs/gen’: No such file or directory
find: ‘out/target/common/docs/gen’: No such file or directory
find: ‘out/target/common/docs/gen’: No such file or directory
find: ‘out/target/common/docs/gen’: No such file or directory
find: ‘out/target/common/docs/gen’: No such file or directory
build/core/prebuilt.mk:123: *** recipe commences before first target. Stop.

---------- Post added at 04:54 AM ---------- Previous post was at 04:53 AM ----------

can anyone help me with this

grep: build/target/board/generic/recovery.fstab: No such file or directory
find: ‘out/target/common/docs/gen’: No such file or directory
find: ‘out/target/common/docs/gen’: No such file or directory
find: ‘out/target/common/docs/gen’: No such file or directory
find: ‘out/target/common/docs/gen’: No such file or directory
find: ‘out/target/common/docs/gen’: No such file or directory
build/core/prebuilt.mk:123: *** recipe commences before first target. Stop.
 

kirito9

Inactive Recognized Contributor
Oct 30, 2013
3,127
1,367
can anyone help me with this

grep: build/target/board/generic/recovery.fstab: No such file or directory
find: ‘out/target/common/docs/gen’: No such file or directory
find: ‘out/target/common/docs/gen’: No such file or directory
find: ‘out/target/common/docs/gen’: No such file or directory
find: ‘out/target/common/docs/gen’: No such file or directory
find: ‘out/target/common/docs/gen’: No such file or directory
build/core/prebuilt.mk:123: *** recipe commences before first target. Stop.


Did you select your device tree before compiling? This looks to be one of the templates in the CM11 source.
 

CodeElixir

Senior Member
Jul 11, 2016
99
712
Hyderabad
Unable to boot into recovery

I followed steps you mentioned and build was successful. But, When i flash into my device and reboot into recovery, It stuck at boot logo and after sometime it restarts normally. I cant understand where i go wrong. Can u please help regarding this issue?

Am using Lenevo k3 note(MT6752). I performed build using cm 13 sources in Ubuntu 16.04 LTS.
 

suraj-b

Senior Member
Jun 14, 2016
97
30
sir i gave up building cwm..can anyone compile cwm for me.no rev support for this

---------- Post added at 05:15 PM ---------- Previous post was at 05:14 PM ----------

device

---------- Post added at 05:16 PM ---------- Previous post was at 05:15 PM ----------

device
 

therealtaynak

Member
Jul 21, 2013
33
3
So if you want to add some init files in recovery ramdisk root (init.usb.rc or init.ssd.rc, etc.) there is another way. For cm11, you have to create a subfolder "recovery" in device tree - which you did already, and in that folder to create subfolders that match recovery ramdisk folders (ex. etc, res, sbin...), and for files that have to be in root create a root subfolder. The building process will take those, if they are in res or root subfolder and place them in corresponding folders in recovery ramdisk. for the other subfolders (etc, sbin) you have to create an Android.mk file in recovery folder defining every file as local module and to use device_xxxx.mk to add them as product packages. This method with locale module is also recommended for boot image ramdisk. For building recovery we don't need that, but I mention it for further developments.
Now it's time to add some files in recovery folder. A custom init.rc and fstab, named after your hardware: if it is qualcomm will be init.qualcomm.rc and fstab.qualcomm, if it is a MTK phone will be init.mt6589.rc and fstab.mt6589 or whatever is your MTK hardware, and so on. This fstab will be placed in /recovery/root folder and init file will remain in recovery folder. Another way is to name init.{hardware}.rc as init.recovery.{hardware}.rc and to place it in /recovery/root folder too, and to not use a custom init.rc for recovery, because that one will be called in default init.rc, but I prefer only one init.rc file in ramdisk.

This is where im having a bit of a problem. I have unpacked the boot and recovery from stock with your kitchen. I had to chown the fstab.qcom and init.rc. Is it these files i copy to the /device/vendorid/deviceid/recovery/root ? or am i supposed to be creating new files entirely?

I managed to get the boot and recovery from the Note 3 AT&T. The n900a, vendor is samsung, device is hlteatt.

just need to work out stock rom recovery for cwm. thats all i want. Even an AOSP will suffice. Just want to get it on a custome recovery. Have all the files that are needed.
 

therealtaynak

Member
Jul 21, 2013
33
3
clarify please

I switched my building study to an Envizen Tablet to hopefully get more response...

If you don't know your hardware, get it with adb:
Code:
adb shell cat /proc/cpuinfo
and you will find the hardware.
For me it is:
Code:
[COLOR="Blue"]Hardware[/COLOR]	: [COLOR="Red"]MT6589[/COLOR]
[/QUOTE]

What if it says both qualcomm and a mtk number/??

Hardware	: Qualcomm MSM8212
Revision	: 0000
Serial		: 0000000000000000


also my bootloader board name line is this... 

TARGET_BOOTLOADER_BOARD_NAME := msm8610



Here is my whole " adb shell cat /proc/cpuinfo "

Processor	: ARMv7 Processor rev 3 (v7l)
processor	: 0
BogoMIPS	: 38.40

processor	: 1
BogoMIPS	: 38.40

processor	: 2
BogoMIPS	: 38.40

processor	: 3
BogoMIPS	: 38.40

Features	: swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt 
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x0
CPU part	: 0xc07
CPU revision	: 3

Hardware	: Qualcomm MSM8212
Revision	: 0000
Serial		: 0000000000000000
 
Last edited:

modaristis

Member
Nov 14, 2012
9
0
Patra
Allwinner A33

I'm trying to build a CWM recovery for my Allwinner A33 tablet. It's the Turbo-x Twister IV (by a Greek company called Plaisio) and here are the specs:
Code:
VENDOR	: Unknown				 	      
CODENAME	: astar-inet					      
CPU		: Allwinner A33 Quad-Core ARM Cortex A7 @ 1.2GHz      
GPU		: Mali400 MP2					      
RAM		: 1GB LPDDR3/DDR3				      
ROM		: 8GB						      
SCREEN	: 7" IPS 1024x600p				      
STOCK FIRMWARE: Android 4.4.2 (A33_U70_U708HC_1412005_20141202.img)
Cpuinfo:
Code:
root@astar-inet:/ # cat /proc/cpuinfo
Processor	: ARMv7 Processor rev 5 (v7l)
processor	: 0
BogoMIPS	: 74951.62

Features	: swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpv4 idiva idivt 
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x0
CPU part	: 0xc07
CPU revision	: 5

Hardware	: sun8i
Revision	: 0000
Serial		: 034c1a49079500000000
I followed the guide, built the recovery and flashed it with:
Code:
adb push recovery.img /mnt/extsd/
adb shell "cat /mnt/extsd/recovery.img > /dev/block/nandg
but when I boot to recovery the tablet reboots and boots to regular android. If I force boot to recovery via adb the tablet keeps restarting.
My partitions are the same like here. Only the size change.
Can anyone help? I can post anything you need.
 
Status
Not open for further replies.

Top Liked Posts

  • There are no posts matching your filters.
  • 31
    D
    Deleted member 5186178
    I know there are so many guides about building recovery from source, but from my perspective they are incomplete or quite old. There are some parts missing like how to set up a device tree, and others.
    I wanted to write this guide to help people to build by themself a Clockworkmod or other custom recovery.
    I will not reproduce the good informations from other guides, instead I will post the links to them, and I will highlight those parts that I consider are missing. And extra, I provided specific informations for MTK phones; for easy separation the text for MTK is colored in DarkRed. If your phone is not MTK powered you can skip those parts.
    One important note: my guide will cover only the building of recovery from source, not the full ROM, but it can be used as start, or base for further development.

    For start you need a PC with ubuntu 12.04 or 14.04 x64 installed (or use a virtual machine) - this is the recommended distribution on Android official guide. You can follow that guide to setup the building environment. In the same time, I have few things to add up, so at every step in that guide take a look here too.

    Other things you need:
    - A good configuration for your computer (you can't do these things with a bad computer);
    - Geany software or a good IDE;
    - a stock boot.img for your phone;
    - a stock recovery.img for your phone;
    - unpack-repack CarlivImageKitchen;

    Credits:
    - Clockworkmod;
    - Cyanogenmod;
    - bgcngm for his mtk tools;
    - chrmhoffmann for the custom boot image maker;
    - Android-Dls;

    IMPORTANT:
    I used a real making example during the guide, recreating all steps for my phone, for images. So, when you follow my guide keep in mind that "carliv" is my username and you should use yours; "lenovo" is my phone brand/manufacturer and you should use yours; "P780" is my phone model and you should use yours.
    So, where you see that in examples, codes or commands, don't copy from here and paste in your terminal. First copy them in a text editor, change these data with yours and after that copy and paste in terminal - if you don't want to type much.

    15
    D
    Deleted member 5186178
    First open a terminal window and type this:
    Code:
    sudo apt-get update
    If you have installed the latest Ubuntu 12.04.5 x64 with latest HWE stack, instead of the resources listed on Android guide, use these:
    Code:
    sudo apt-get install git gnupg flex bison gperf build-essential zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev libreadline6-dev libgl1-mesa-dri-lts-trusty:i386 libgl1-mesa-dev-lts-trusty g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386 lzop ccache gnupg python gcc g++ cpp
    and:
    Code:
    sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
    Then install this:
    Code:
    sudo apt-get install ia32-libs
    If you have installed the latest Ubuntu 14.04.1 x64, instead of the resources listed on Android guide, use these:
    Code:
    sudo apt-get install bison g++-multilib git gperf libxml2-utils
    then
    Code:
    sudo apt-get install gnupg ccache lzop flex build-essential zip curl zlib1g-dev zlib1g-dev:i386 libc6-dev lib32bz2-1.0 lib32ncurses5-dev x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 lib32z1-dev libgl1-mesa-glx:i386 libgl1-mesa-dev mingw32 tofrodos python-markdown xsltproc libreadline6-dev lib32readline-gplv2-dev libncurses5-dev bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev lib32bz2-dev squashfs-tools pngcrush pngquant schedtool dpkg-dev
    and:
    Code:
    sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

    For 51-android.rules:
    For USB rules check here to see how they look for google devices and here to see a list with vendor Ids for different brands and here for a cyanogenmod template.
    MTK
    - if you use a MTK device add these lines to that file too:
    Code:
    #MTK
    SUBSYSTEM=="usb", ATTR{idVendor}=="0e8d", MODE="0666", GROUP="plugdev", OWNER="your_username"
    #MTK adb and mass storage
    SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", [COLOR="Red"]ATTR{idProduct}=="0c03"[/COLOR], MODE="0666", GROUP="plugdev", OWNER="your_username"
    Why you need to add idProduct as well? Because idVendor "0bb4" is already used by HTC, and that will make the difference between the two.

    Attached is my 51-android.rules file.
    Next, download Android-sdk and unpack it in your home directory:
    Code:
    tar xzf $HOME/Downloads/android-sdk_[COLOR="Red"]rxx[/COLOR]-linux.tgz
    where "rxx" is the release name (current is r24.0.2, but check the number when you download it, because it will be changed probably), and rename android-sdk-linux folder as android-sdk, or what name you want (keep in mind that this will be added in bashrc file in path), then in tools subfolder double click "android" script to start it (select run, not run in terminal) and install at least one android platform, to get sdk tools like adb, fastboot, etc.
    For java I have my way. Because of the new instructions for openjdk in Android source, and because the new cyanogenmod 12 requires that too, I will present a new way of setting java.
    Old way dual java:
    MTK:
    In official guide is recommended openjdk-7, but if you want to build for MTK phones and you have access to full building sources, you will notice that openjdk is not supported; in fact you will see exact this error message:
    Code:
    "openjdk is not supported" and "FAIL"
    First uninstall in synaptic package manager the libreoffice completely, because if you don't you will not be able to uninstall openjdk (libreoffice requires java, and if you uninstall openjdk7 it will be a prompt to install openjdk6 and viceversa). This is a computer for building not office, but if you need an office solution try WPS Office for linux, or install abiword and gnumeric. After that remove completely openjdk and icedtea plugins:
    Code:
    sudo apt-get purge openjdk-\* icedtea-\* icedtea-6-\* icedtea-7-\*
    and check if there is any trace left:
    Code:
    sudo dpkg --list | grep -i jdk
    Next go to this page and download jdk-7u67-linux-x64.tar.gz and jdk-6u45-linux-x64.bin.
    Move both in your home folder (/home/username), or use
    Code:
    mv $HOME/Downloads/jdk-7u67-linux-x64.tar.gz $HOME && mv $HOME/Downloads/jdk-6u45-linux-x64.bin $HOME
    After that use these commands to install java:
    Code:
    sudo mkdir -p /opt/java
    Code:
    sudo tar -zxf jdk-7u67-linux-x64.tar.gz -C /opt/java
    Code:
    chmod u+x jdk-6u45-linux-x64.bin
    Code:
    ./jdk-6u45-linux-x64.bin
    Code:
    sudo mv jdk1.6.0_45 /opt/java
    Code:
    sudo rm jdk-6u45-linux-x64.bin jdk-7u67-linux-x64.tar.gz
    At this point java is installed in /opt/java folder, but you need to setup java alternatives.
    Type these one by one:
    Code:
    sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/jdk1.7.0_67/bin/java" 1
    Code:
    sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/java/jdk1.7.0_67/bin/javac" 1
    Code:
    sudo update-alternatives --install "/usr/bin/javadoc" "javadoc" "/opt/java/jdk1.7.0_67/bin/javadoc" 1
    Code:
    sudo update-alternatives --install "/usr/bin/javah" "javah" "/opt/java/jdk1.7.0_67/bin/javah" 1
    Code:
    sudo update-alternatives --install "/usr/bin/javap" "javap" "/opt/java/jdk1.7.0_67/bin/javap" 1
    Code:
    sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/opt/java/jdk1.7.0_67/bin/javaws" 1
    That will setup jdk 1.7 as your main java alternative, but if you need to work with jdk 1.6, type these too:
    Code:
    sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/jdk1.6.0_45/bin/java" 2
    Code:
    sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/java/jdk1.6.0_45/bin/javac" 2
    Code:
    sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/opt/java/jdk1.6.0_45/bin/javaws" 2
    For building with jdk 1.6, these three are all you need.
    Check again the java alternatives:
    Code:
    ls -la /etc/alternatives/java*
    uc

    If they are not all with jdk 1.7, which will be your main java jdk (required by kitkat, or latest apktool), use these to select jdk 1.7:
    Code:
    sudo update-alternatives --config java
    Code:
    sudo update-alternatives --config javac
    Code:
    sudo update-alternatives --config javaws
    Other thing you can do is to install java plugin for your browsers (not building related, but useful):
    Code:
    sudo ln -s /opt/java/jdk1.7.0_67/jre/lib/amd64/libnpjp2.so /usr/lib/mozilla/plugins/libnpjp2.so
    Code:
    sudo ln -s /opt/java/jdk1.7.0_67/jre/lib/amd64/libnpjp2.so /usr/lib/chromium-browser/plugins/libnpjp2.so
    Code:
    sudo ln -s /opt/java/jdk1.7.0_67/jre/lib/amd64/libnpjp2.so /usr/lib/opera/plugins/libnpjp2.so
    That depends on what browser you have installed.
    So, if you have to build with jdk 1.6, update those three alternatives and also in bashrc file comment "export JAVA_HOME" for jdk 1.7, and uncomment for jdk 1.6:
    Code:
    export JAVA_HOME=/opt/java/jdk1.6.0_45
    [COLOR="Red"]#[/COLOR] export JAVA_HOME=/opt/java/jdk1.7.0_67
    Everything else remain the same. Then reboot and you will be using jdk 1.6 for building. Same to revert.
    Ok, you have dual java on your computer.
    Ah, if you see in terminal an error like this:
    Code:
    (gedit:7129): Gtk-CRITICAL **: gtk_tree_selection_get_selected: assertion `GTK_IS_TREE_SELECTION (selection)' failed
    when you close the gedit with bashrc file, then open again gedit with this command in terminal:
    Code:
    sudo gedit
    in Edit menu, open Preferences > Plugins and deselect File Browser Panel plugin. Next time you open gedit in terminal you won't see that error anymore.
    For removing these manual java installations, type these commands one by one:
    Code:
    sudo rm -rf /opt/java/jdk1.6.0_45
    sudo rm -rf /opt/java/jdk1.7.0_67
    
    sudo update-alternatives --remove "java" "/usr/bin/java"
    sudo update-alternatives --remove "javac" "/usr/bin/javac"
    sudo update-alternatives --remove "javadoc" "/usr/bin/javadoc"
    sudo update-alternatives --remove "javah" "/usr/bin/javah"
    sudo update-alternatives --remove "javap" "/usr/bin/javap"
    sudo update-alternatives --remove "javaws" "/usr/bin/javaws"
    
    sudo update-alternatives --config java
    sudo update-alternatives --config javac
    sudo update-alternatives --config javadoc
    sudo update-alternatives --config javah
    sudo update-alternatives --config javap
    sudo update-alternatives --config javaws
    
    sudo rm /usr/lib/mozilla/plugins/libnpjp2.so
    sudo rm /usr/lib/chromium-browser/plugins/libnpjp2.so
    sudo rm /usr/lib/opera/plugins/libnpjp2.so
    and delete from bashrc file
    Code:
    #export JAVA_HOME=/opt/java/jdk1.6.0_45
    export JAVA_HOME=/opt/java/jdk1.7.0_67
    Then reinstall openjdk-7 and icedtea plugin:
    Code:
    sudo apt-get update
    sudo apt-get install openjdk-7-jdk icedtea-netx

    You can use OpenJDK 7 now, if you are not building for MTK phones.
    For those of you that need to use either sun jdk 1.6 or 1.7, you have to install it manually as I show above. Then, after installation, you don't have to add it to java alternatives, since the MTK building source doesn't care about your path. Instead you have to edit "mbldenv.sh" file and to replace the java path with yours.
    Although, if you want you can use jdk 1.7 or 1.6 in dual setup with openjdk-7. Just install these two alternatives:
    Code:
    sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/jdk1.7.0_67/bin/java" 1
    sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/java/jdk1.7.0_67/bin/javac" 1
    or
    Code:
    sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/jdk1.6.0_45/bin/java" 2
    sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/java/jdk1.6.0_45/bin/javac" 2
    and ad it to bashrc file in path:
    Code:
    #export JAVA_HOME=/opt/java/jdk1.7.0_67
    export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
    or
    Code:
    #export JAVA_HOME=/opt/java/jdk1.6.0_45
    export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
    switching between the two with these:
    Code:
    sudo update-alternatives --config java
    sudo update-alternatives --config javac
    and editing the path in bashrc, then restart the computer. Same to revert.


    Next you need to add java in your path. In Android guide for setup building environment you can see how to create the bin folder for repo file. Then how to add that folder in path. We will complete that now:
    Code:
    sudo gedit ~/.bashrc
    And at the end add these:
    Code:
    export PATH=~/bin:$PATH
    
    #export JAVA_HOME=/opt/java/jdk1.7.0_67
    export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
    export JRE_HOME=JAVA_HOME/jre
    export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
    export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
    
    export PATH=$HOME/bin:$HOME/android-sdk/platform-tools/:$HOME/android-sdk/tools:$PATH
    
    export USE_CCACHE=1

    To check if java is installed and is in path type these in terminal:
    Code:
    java -version
    which java
    echo $JAVA_HOME

    You can see here also the android sdk path, which I named android-sdk/, usually is android-sdk-linux/. You need sdk for adb and fastboot to work. And, if you have only OpenJDK, remove the jdk 1.7 line.
    This is a complete building environment set up.
    13
    D
    Deleted member 5186178
    Set up a device tree.

    Of course if you don't have one, because nobody created it before.
    Following the clockworkmod guide, you can see how to start this by using mkvendor.sh script.
    So place the recovery.img from your stock ROM in that repo folder (CM11-0 for me), and let's take as example my phone Lenovo P780.
    uc

    With any root explorer take a look at build.prop from "system" and notice these lines:
    Code:
    ro.product.manufacturer=[COLOR="Red"]LENOVO[/COLOR]
    ro.product.device=[COLOR="Red"]P780[/COLOR]
    I have lenovo (I will use lower-case) and P780.
    And the command will be
    Code:
    ./build/tools/device/mkvendor.sh lenovo P780 recovery.img
    But, at this point I always get an error message:
    Code:
    "[COLOR="Red"]unpackbootimg[/COLOR] not found. Is your android build environment set up and have the host tools been built?"
    In that guide they say to do
    Code:
    . build/envsetup.sh
    make -j4 otatools
    in cm11 folder, and the unpackbootimg will be compiled. What they don't say (or I never found it) is that even after otatools are created, that error still appear. And if we take a look in the script, we see it is searching for unpakbootimg executable:
    Code:
    UNPACKBOOTIMG=[COLOR="Red"]$(which unpackbootimg)[/COLOR]
    The which command won't display anything if the module is not in path. So either you add "$HOME/CM11_folder/out/host/linux-x86/bin" in path, or run this in terminal after otatools make is finished:
    Code:
    cp $HOME/CM11_folder/out/host/linux-x86/bin/unpackbootimg $HOME/bin
    where CM11_folder is the name of the folder with cm-11.0 building tree. After that the unpackbootimg will be in bin folder, which is in path, and everytime you need to run it, will be found. You can check that in terminal typing
    Code:
    which unpackbootimg
    uc

    Now back to my example for device tree. Open a terminal window in CM11-0 folder, or open terminal and type
    Code:
    cd CM11-0
    then type that command to create the device tree.
    Code:
    ./build/tools/device/mkvendor.sh lenovo P780 recovery.img
    After script is executed you will see the new device folder in device list, lenovo with subfolder P780.
    uc

    For a regular phone that will be ok, and you can start working on that device tree,
    but for a MTK phone that is not good.
    Why? Because MTK use a header appended to kernel and ramdisk, and the script won't be able to properly unpack it.
    uc

    It will be an error about ramdisk not being in gzip format for a MTK phone.
    The result will be that instead of real recovery.fstab and some other data in device tree files, we will get generic default values. As an example, this is the recovery.fstab I've got for my phone after that command:
    Code:
    # mount point	fstype    device    	[device2]
    
    /boot       mtd         boot
    /cache      yaffs2      cache
    /data       yaffs2      userdata
    /misc       mtd         misc
    /recovery   mtd         recovery
    /sdcard     vfat        /dev/block/mmcblk0p1        /dev/block/mmcblk0
    /system     yaffs2      system
    /sd-ext     ext4        /dev/block/mmcblk0p2
    That is not the real one (my device is emmc not mtd type) and so, for MTK phones, we need to do some extra things. First get my CarlivImageKitchen and unpack it somewhere in your home folder. The utility contains few unpack and repack scripts for boot/recovery images created using instructions from here.
    Then copy the stock recovery image to those utilities folder and open a terminal window in it.
    Type
    Code:
    ./unpack_MTK_img recovery.img
    What you have to do now is to repack the recovery using the regular script instead of MTK script (CarlivImageKitchen strips off the Mediatek header during unpack).
    So, just type
    Code:
    ./repack_img recovery
    and choose the name recovery for the new image.
    At the end take the recovery.img an move it to cm11-0 folder.
    Back to cm11 folder, open a terminal window and type mkvendor command
    Code:
    ./build/tools/device/mkvendor.sh lenovo P780 recovery.img
    The result? Well take a look at this recovery.fstab:
    Code:
    boot       		/boot       emmc      defaults        defaults
    /dev/block/mmcblk0p2      /cache      ext4      defaults        defaults
    /dev/block/mmcblk0p3      /data       ext4      defaults        defaults
    misc      				  /misc       emmc      defaults        defaults
    recovery  				  /recovery   emmc      defaults        defaults
    /dev/block/mmcblk0p4      /sdcard     vfat      defaults        defaults
    /dev/block/mmcblk0p6      /system     ext4      defaults        defaults
    This is the real one from stock recovery. It can't be used for CWM but it proves that the ramdisk was unpacked correct.

    Anyway this is only the beginning, because we need to check every file from device tree and to add some files too.
    12
    D
    Deleted member 5186178
    For the fstab you have to unpack a stock boot.img for your phone. Using CarlivImageKitchen from before, copy your boot.img in that folder and type:
    Code:
    ./unpack_img boot.img
    or if your phone is a MTK powered one, type this
    Code:
    ./unpack_MTK_img boot.img
    Open the ramdisk folder and copy the fstab file to your device /recovery/root folder and then rename it as I said before - fstab.{hardware}. Then go to cm11 building tree folder, open /bootable/recovery/etc folder and copy init.rc file to your device /recovery folder, then change the name to init.{hardware}.rc.
    Since the recovery in cm11 is using the fstab version 2, you can use same content for fstab.{hardware} and recovery.fstab, but this content is specific to your device. Try to find on github a device folder for a phone with same platform CPU and take a look, then compare with your stock fstab and try to find in your phone with a root explorer the correct paths for partitions. This one can't be standardized. As an example here is a fstab for a HTC M7:
    Code:
    # Copyright (C) 2014 The CyanogenMod Project
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    #
    # http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    #<src> <mnt_point> <type> <mnt_flags> <fs_mgr_flags>
    #/dev/block/platform/msm_sdcc.1/by-name/dsps /firmware_dsps vfat ro,shortname=lower wait
    /dev/block/platform/msm_sdcc.1/by-name/radio /firmware_radio vfat ro,shortname=lower wait
    /dev/block/platform/msm_sdcc.1/by-name/adsp /firmware_q6 vfat ro,shortname=lower wait
    #/dev/block/platform/msm_sdcc.1/by-name/wcnss /firmware_wcnss vfat ro,shortname=lower wait
    /dev/block/platform/msm_sdcc.1/by-name/boot /boot emmc defaults defaults
    /dev/block/platform/msm_sdcc.1/by-name/recovery /recovery emmc defaults defaults
    /dev/block/platform/msm_sdcc.1/by-name/misc /misc emmc defaults defaults
    /dev/block/platform/msm_sdcc.1/by-name/devlog /devlog ext4 noatime,nosuid,nodev,barrier=0 wait
    /dev/block/platform/msm_sdcc.1/by-name/system /system ext4 ro,noatime,barrier=0 wait
    /dev/block/platform/msm_sdcc.1/by-name/cache /cache ext4 noatime,nosuid,nodev,barrier=0 wait
    /dev/block/platform/msm_sdcc.1/by-name/userdata /data ext4 noatime,nosuid,nodev,noauto_da_alloc,barrier=0 wait,encryptable=/dev/block/platform/msm_sdcc.1/by-name/extra
    # SD card
    /devices/platform/msm_sdcc.1/mmc_host/mmc0 auto auto defaults voldmanaged=sdcard0:36,noemulatedsd
    # USB storage
    /devices/platform/msm_hsusb_host/usb auto auto defaults voldmanaged=usbdisk:auto
    and this is the recovery.fstab for my MTK Lenovo P780
    Code:
    # Android fstab file.
    # The filesystem that contains the filesystem checker binary (typically /system) cannot
    # specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
    #<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
    /emmc@android /system ext4 ro,noatime wait
    /emmc@cache /cache ext4 noatime,nosuid,nodev,noauto_da_alloc wait
    /emmc@usrdata /data ext4 noatime,nosuid,nodev,noauto_da_alloc wait,encryptable=footer
    # vold-managed volumes
    /devices/platform/mtk-msdc.0/mmc_host/mmc0 auto auto defaults voldmanaged=sdcard1:8,
    /devices/platform/mtk-msdc.1/mmc_host/mmc1 auto auto defaults voldmanaged=sdcard0:auto
    /dev/bootimg /boot emmc defaults defaults
    /dev/nvram /nvram emmc defaults defaults
    /dev/recovery /recovery emmc defaults defaults
    /dev/uboot /uboot emmc defaults defaults
    /dev/misc /misc emmc defaults defaults
    in fstab.mt6589 It has two more partitions (security)
    Code:
    # Android fstab file.
    # The filesystem that contains the filesystem checker binary (typically /system) cannot
    # specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
    #<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
    /emmc@android /system ext4 ro,noatime wait
    /emmc@cache /cache ext4 noatime,nosuid,nodev,noauto_da_alloc wait
    /emmc@usrdata /data ext4 noatime,nosuid,nodev,noauto_da_alloc wait,encryptable=footer
    [COLOR="Red"]/emmc@protect_f /protect_f ext4 noatime,nosuid,nodev,noauto_da_alloc wait,check
    /emmc@protect_s /protect_s ext4 noatime,nosuid,nodev,noauto_da_alloc wait,check[/COLOR]
    # vold-managed volumes
    /devices/platform/mtk-msdc.0/mmc_host/mmc0 auto auto defaults voldmanaged=sdcard0:8
    /devices/platform/mtk-msdc.1/mmc_host/mmc1 auto auto defaults voldmanaged=sdcard1:auto
    /devices/platform/mt_usb/sda/sda1 auto auto defaults voldmanaged=usbotg:auto
    /dev/bootimg /boot emmc defaults defaults
    /dev/nvram /nvram emmc defaults defaults
    /dev/recovery /recovery emmc defaults defaults
    /dev/uboot /uboot emmc defaults defaults
    /dev/misc /misc emmc defaults defaults
    but the rest is the same with recovery.fstab. So, this is something you have to figure out by yourself from your device. Here is another example for a MTK phone with Ubifs file system:
    Code:
    # Android fstab file.
    # The filesystem that contains the filesystem checker binary (typically /system) cannot
    # specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
    
    #<src>          <mnt_point>        <type>       <mnt_flags and options>       <fs_mgr_flags>
    
    /ubi@system       /system       ubifs      ro,noatime      wait
    /ubi@cache       /cache        ubifs      noatime,nosuid,nodev,noauto_da_alloc     wait
    /ubi@userdata       /data         ubifs      noatime,nosuid,nodev,noauto_da_alloc     wait,encryptable=footer
    
    # vold-managed volumes
    /devices/platform/mtk-msdc.0/mmc_host/mmc0      auto     auto    defaults voldmanaged=sdcard0:8,
    /devices/platform/mtk-msdc.1/mmc_host/mmc1      auto     auto    defaults voldmanaged=sdcard1:auto
    
    /dev/mtd/mtd6      /boot             mtd         defaults                     defaults
    /dev/mtd/mtd2        /nvram            mtd         defaults                     defaults
    /dev/mtd/mtd7     /recovery         mtd         defaults                     defaults
    /dev/mtd/mtd5        /uboot            mtd         defaults                     defaults
    /dev/mtd/mtd9         /misc             mtd         defaults                     defaults

    To find more about partitions, mount points, paths related to your device, run this command in terminal:
    Code:
    adb shell ls /proc
    and pay attention to the files names you see - ignore folders (numbers) at start. Then one by one run
    Code:
    adb shell cat /proc/[COLOR="Red"]the_name_you_see[/COLOR]
    and choose the names that can give you partitions informations.
    Here is my "proc list":
    Code:
    C:\Users\carliv>adb shell ls /proc
    * daemon not running. starting it now on port 5037 *
    * daemon started successfully *
    [HIDE]1
    ........
    98[/HIDE] [COLOR="Red"]<- ignored[/COLOR]
    aed
    asound
    audio
    batdrv_log
    boot_mode
    bootprof
    buddyinfo
    bus
    cgroups
    clkmgr
    cmdline
    consoles
    cpu
    cpu_ss
    cpufreq
    cpuinfo
    crypto
    [COLOR="Red"]devices[/COLOR]
    diskstats
    dma-mappings
    driver
    [COLOR="Red"]dumchar_info[/COLOR]
    emifreq
    [COLOR="Red"]emmc[/COLOR]
    execdomains
    fat
    fb
    fgadc_log
    filesystems
    fm
    freqhopping
    fs
    golden_setting
    gpt_stat
    gpufreq
    interrupts
    iomem
    ioports
    irq
    kallsyms
    kmsg
    kpagecount
    kpageflags
    last_kmsg
    lk_env
    loadavg
    locks
    log_ts
    mcdi
    meminfo
    misc
    modules
    [COLOR="Red"]mounts[/COLOR]
    msdc_FT
    msdc_debug
    msdc_help
    msdc_tune
    msdc_tune_flag
    mt_hotplug_test
    mtd
    mtk_battery_cmd
    mtk_mdm_txpwr
    mtk_sched
    mtkcooler
    mtkfb_size
    mtktsbattery
    mtktscpu
    mtktspa
    mtktspmic
    mtktz
    mtprof
    net
    nt35590_hd720_dsi_vdo_truly
    pagetypeinfo
    [COLOR="Red"]partitions[/COLOR]
    pm_init
    ptp
    pvr
    rid
    sched_debug
    schedstat
    scsi
    sd_upgrade
    self
    softirqs
    stat
    swaps
    sys
    sysram
    sysram_flag
    timer_list
    tty
    uid_stat
    uptime
    version
    vmallocinfo
    vmstat
    wdk
    wmt_tm
    xlog
    yaffs
    zoneinfo
    
    C:\Users\carliv>
    11
    D
    Deleted member 5186178
    Sync a building repo.

    Since we are talking about compiling CWM based recovery, or official CWM, we will move to cyanogenmod guide.
    So do what they say to sync the cm-11.0 repo. I usually do this in a folder named CM11-0, but you can use what name you want, or as they say "/android/system". Wait to finish the repo sync (depends on internet connection, computer performances, etc) - for me it takes about four hours.
    A side note: most of the Custom Android ROMs have an instruction on manifest with default number of jobs for repo sync. Something like this:
    Code:
     <default revision="refs/heads/cm-11.0"
    remote="github"
    sync-c="true"
    sync-j=[COLOR="Red"]"4"[/COLOR] />
    But during sync process you will see sometimes "curl errors" about not permitting clone bundle. That's because google sources refuses jobs setted up to high. You have an option: after all sync process is done, run a repo sync again, but overwriting the number of jobs:
    Code:
    repo sync -j1
    This is permitted by google git repositories and it will fix any missing sources in your cloned repo. Don't do it from start because it will take forever to download the sources. Do it like I said only after first repo sync is finished.

    AMENDMENT:
    OpenJDK 7 is now recommended inAndroid and mandatory in cyanogenmod 12, but will throw an error in cyanogenmod 11. A solution can be to edit /build/core/main.mk file in cyanogenmod 11 building tree, and to add new java check requirements. Instead of this:
    Code:
    # Check for the correct version of java
    java_version := $(shell java -version 2>&1 | head -n 1 | grep '^java .*[ "]1\.[67][\. "$$]')
    ifneq ($(shell java -version 2>&1 | grep -i openjdk),)
    java_version :=
    endif
    ifeq ($(strip $(java_version)),)
    $(info ************************************************************)
    $(info You are attempting to build with an unsupported version)
    $(info of java.)
    $(info $(space))
    $(info Your version is: $(shell java -version 2>&1 | head -n 1).)
    $(info The correct version is: Java SE 1.6 or 1.7.)
    $(info $(space))
    $(info Please follow the machine setup instructions at)
    $(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
    $(info ************************************************************)
    endif
    
    # Check for the correct version of javac
    javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1\.[67][\. "$$]')
    ifeq ($(strip $(javac_version)),)
    $(info ************************************************************)
    $(info You are attempting to build with the incorrect version)
    $(info of javac.)
    $(info $(space))
    $(info Your version is: $(shell javac -version 2>&1 | head -n 1).)
    $(info The correct version is: 1.6 or 1.7.)
    $(info $(space))
    $(info Please follow the machine setup instructions at)
    $(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
    $(info ************************************************************)
    $(error stop)
    endif
    to add this:
    Code:
    java_version_str := $(shell unset _JAVA_OPTIONS && java -version 2>&1)
    javac_version_str := $(shell unset _JAVA_OPTIONS && javac -version 2>&1)
    
    # Check for the correct version of java, should be 1.7 by
    # default, and 1.6 if LEGACY_USE_JAVA6 is set.
    ifeq ($(LEGACY_USE_JAVA6),)
    required_version := "1.7.x"
    required_javac_version := "1.7"
    java_version := $(shell echo '$(java_version_str)' | grep '^java .*[ "]1\.7[\. "$$]')
    javac_version := $(shell echo '$(javac_version_str)' | grep '[ "]1\.7[\. "$$]')
    else # if LEGACY_USE_JAVA6
    required_version := "1.6.x"
    required_javac_version := "1.6"
    java_version := $(shell echo '$(java_version_str)' | grep '^java .*[ "]1\.6[\. "$$]')
    javac_version := $(shell echo '$(javac_version_str)' | grep '[ "]1\.6[\. "$$]')
    endif # if LEGACY_USE_JAVA6
    
    ifeq ($(strip $(java_version)),)
    $(info ************************************************************)
    $(info You are attempting to build with the incorrect version)
    $(info of java.)
    $(info $(space))
    $(info Your version is: $(java_version_str).)
    $(info The required version is: $(required_version))
    $(info $(space))
    $(info Please follow the machine setup instructions at)
    $(info $(space)$(space)$(space)$(space)https://source.android.com/source/initializing.html)
    $(info ************************************************************)
    $(error stop)
    endif
    
    # Check for the current JDK.
    #
    # For Java 1.7, we require OpenJDK on linux and Oracle JDK on Mac OS.
    # For Java 1.6, we require Oracle for all host OSes.
    requires_openjdk := false
    ifeq ($(LEGACY_USE_JAVA6),)
    ifeq ($(HOST_OS), linux)
    requires_openjdk := true
    endif
    endif
    
    
    # Check for the current jdk
    ifeq ($(requires_openjdk), true)
    # The user asked for java7 openjdk, so check that the host
    # java version is really openjdk
    ifeq ($(shell echo '$(java_version_str)' | grep -i openjdk),)
    $(info ************************************************************)
    $(info You asked for an OpenJDK 7 build but your version is)
    $(info $(java_version_str).)
    $(info ************************************************************)
    $(error stop)
    endif # java version is not OpenJdk
    else # if requires_openjdk
    ifneq ($(shell echo '$(java_version_str)' | grep -i openjdk),)
    $(info ************************************************************)
    $(info You are attempting to build with an unsupported JDK.)
    $(info $(space))
    $(info You use OpenJDK but only Sun/Oracle JDK is supported.)
    $(info Please follow the machine setup instructions at)
    $(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
    $(info ************************************************************)
    $(error stop)
    endif # java version is not Sun Oracle JDK
    endif # if requires_openjdk
    
    # Check for the correct version of javac
    ifeq ($(strip $(javac_version)),)
    $(info ************************************************************)
    $(info You are attempting to build with the incorrect version)
    $(info of javac.)
    $(info $(space))
    $(info Your version is: $(javac_version_str).)
    $(info The required version is: $(required_javac_version))
    $(info $(space))
    $(info Please follow the machine setup instructions at)
    $(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
    $(info ************************************************************)
    $(error stop)
    endif
    but I can't tell you it will work flawless, since I can't test the building of a full ROM (for recovery it works without problems).