[Galaxy Note 3 Android Development] Wootever:
[MENTION=3160325]zroice[/MENTION]

About ramdisk, copy this code into txt file named mkboot and use chmod 755 (credits to xiaolu)

#!/bin/bash
#
# 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.
#
#boot.img tool
#by xiaolu
trap "clean" 2 3 4
workdir=$(pwd)
toolpath=$(readlink -f $0)
tooldir=$(dirname $toolpath)
mkbootimg_dtb=$tooldir/mkbootimg_dtb
mkbootimg_old=$tooldir/mkbootimg

C_OUT="\033[0;0m"
C_ERR="\033[31;1m"
C_CLEAR="\033[0;0m"

pout() {
printf "${C_OUT}${*}${C_CLEAR}\n"
}
perr() {
printf "${C_ERR}${*}${C_CLEAR}\n"
}
clean()
{
rm -rf /tmp/mkboot.*
pout "..."
exit
}

usage()
{
pout "<Unpack and repack boot.img tool>\n"
pout "Not enough parameters or parameter error!"
pout "unpack boot.img & decompress ramdisk：\n $(basename $0) [img] [output dir]"
pout " $(basename $0) boot.img boot20130905"
pout "Use the unpacked directory repack boot.img(img_info)：\n $(basename $0) [unpacked dir] [newbootfile]"
pout " $(basename $0) boot20130905 newboot.img"
pout "Use the boot.img and new ramdisk repack boot.img：\n $(basename $0) [img] [ramdisk.gz or ramdisk dir] [newbootfile]"
pout " $(basename $0) boot.img boot20130905/ramdisk newboot.img"
clean
}

print_info()
{
pout " kernel : $kernel"
pout " ramdisk : $ramdisk"
pout " page_size : $page_size"
pout " base_addr : $base_addr"
pout " kernel size : $kernel_size"
pout " kernel_addr : $kernel_addr"
pout " ramdisk_size : $ramdisk_size"
pout " ramdisk_addr : $ramdisk_addr"
[ -z $second_size ] || pout " second_size : $second_size"
[ -z $second_addr ] || pout " second_addr : $second_addr"
if [ $dtb_size -gt 0 ]; then
pout " dtb_size : $dtb_size"
pout " dtb_img : $dt"
pout " tags_addr : $tags_addr"
fi
pout " cmdline : $cmd_line"
}

mkboot_img()
{
error=0
if [ $dtb_size -gt 0 ]; then
$mkbootimg_dtb --kernel $kernel --ramdisk $ramdisk \
--base $base_addr --offset $ramdisk_addr \
--tags-addr $tags_addr --cmdline "$cmd_line" \
--dt $dt -o $1 || error=1
else
$mkbootimg_old --kernel $kernel --ramdisk $ramdisk \
--base $base_addr --ramdiskaddr $ramdisk_addr \
--cmdline "$cmd_line" -o $1 || error=1
fi
[ $error -eq 1 ] && return $error
ramdisksize=$(stat -c "%s" $ramdisk)
bootsize=$(stat -c "%s" $1)
pout "Kernel size: $kernel_size, new ramdisk size: $ramdisksize, $(basename $1): $bootsize."
pout "$(basename $1) has been created."
}

#decide action
[ $# -lt 2 ] || [ $# -gt 3 ] && usage
if [ $# -eq 2 ] && [ -d $1 ]; then
mkboot_from_dir=1
elif [ $# -eq 2 ] && [ -s $1 ]; then
split_boot_to_dir=1
elif [ $# -eq 3 ] && [ -s $1 ] && [ -e $2 ]; then
mkboot_from_img_dir=1
else
usage
fi

#mkboot_from_dir, img_info
if [ ! -z $mkboot_from_dir ]; then
pout "mkbootimg from $1/img_info."
unpacked_dir=$(readlink -f $1)
new_img=$(readlink -f $2)
cd $unpacked_dir
if [ ! -s img_info ]; then
pout "not found img_info file! can't rebuild img."
clean
fi
eval $(cat img_info)
if [ -z $kernel ] || [ -z $ramdisk ] || [ -z $ramdisk_addr ] || [ -z $base_addr ]; then
pout "img_info file have not enough parameters."
clean
fi
kernel=$(readlink -f $kernel)
if [ -d $ramdisk ]; then
cd $ramdisk
find . | cpio -R 0:0 -H newc -o 2>/dev/null | gzip > $unpacked_dir/new_ramdisk.gz
#mkbootfs $ramdisk | gzip > $unpacked_dir/new_ramdisk.gz
ramdisk=$unpacked_dir/new_ramdisk.gz
fi
cd $unpacked_dir
print_info
rm -f $new_img
mkboot_img $new_img || perr "Make boot.img Error! pls check img_info file."
rm -f new_ramdisk.gz
clean
fi

#split_boot_to_dir.
if [ ! -z $split_boot_to_dir ]; then
if [ -e $2 ]; then
read -p "$2 exists, delete?(N/y)" reply
case $reply in
y | Y)
rm -rf $2
;;
*)
exit
;;
esac
fi
tempdir="$(readlink -f $2)"
mkdir -p $tempdir
pout "Unpack & decompress $1 to $2"
else
tempdir=$(mktemp -d /tmp/mkboot.XXXX)
pout "Repack $1 & ramdisk $2 to $3"
fi

cp -f $1 $tempdir/
cd $tempdir
bootimg=$(basename $1)
offset=$(grep -abo ANDROID! $bootimg | cut -f 1 -d :)
[ -z $offset ] && clean
if [ $offset -gt 0 ]; then
dd if=$bootimg of=bootimg bs=$offset skip=1 2>/dev/null
bootimg=bootimg
fi
kernel_size=$(od -A n -D -j 8 -N 4 $bootimg | sed 's/ //g')
kernel_addr=0x$(od -A n -H -j 12 -N 4 $bootimg | sed 's/ //g')
base_addr=0x$(od -A n -h -j 14 -N 2 $bootimg | sed 's/ //g')0000
ramdisk_size=$(od -A n -D -j 16 -N 4 $bootimg | sed 's/ //g')
ramdisk_addr=0x$(od -A n -H -j 20 -N 4 $bootimg | sed 's/ //g')
second_size=$(od -A n -D -j 24 -N 4 $bootimg | sed 's/ //g')
second_addr=0x$(od -A n -H -j 28 -N 4 $bootimg | sed 's/ //g')
tags_addr=0x$(od -A n -H -j 32 -N 4 $bootimg | sed 's/ //g')
page_size=$(od -A n -D -j 36 -N 4 $bootimg | sed 's/ //g')
dtb_size=$(od -A n -D -j 40 -N 4 $bootimg | sed 's/ //g')
cmd_line=$(od -A n --strings -j 64 -N 512 $bootimg)

k_count=$(((kernel_size+page_size-1)/page_size))
r_count=$(((ramdisk_size+page_size-1)/page_size))
s_count=$(((second_size+page_size-1)/page_size))
d_count=$(((dtb_size+page_size-1)/page_size))
k_offset=1
r_offset=$((k_offset+k_count))
s_offset=$((r_offset+r_count))
d_offset=$((s_offset+s_count))

dd if=$bootimg of=zImage_tmp bs=$page_size skip=$k_offset count=$k_count 2>/dev/null
dd if=zImage_tmp of=zImage bs=$kernel_size count=1	2>/dev/null
if [ ! -z $split_boot_to_dir ]; then
dd if=$bootimg of=ramdisk_tmp bs=$page_size skip=$r_offset count=$r_count 2>/dev/null
dd if=ramdisk_tmp of=ramdisk.gz bs=$ramdisk_size count=1	2>/dev/null
fi
if [ $dtb_size -gt 0 ]; then
dd if=$bootimg of=dt.img_tmp bs=$page_size skip=$d_offset count=$d_count 2>/dev/null
dd if=dt.img_tmp of=dt.img bs=$dtb_size count=1	2>/dev/null
dt="$tempdir/dt.img"
fi
rm -f *_tmp $(basename $1) $bootimg

kernel="$tempdir/zImage"
ramdisk=$tempdir/ramdisk.gz
[ ! -s $kernel ] && clean
#print boot.img info
print_info

#decompression ramdisk.gz
if [ ! -z $split_boot_to_dir ]; then
if [ ! -z $dt ]; then
dt=$(basename $dt)
fi
printf "kernel=$(basename $kernel)\nramdisk=ramdisk\npage_size=$page_size\nbase_addr=$base_addr\n\
kernel_size=$kernel_size\nkernel_addr=$kernel_addr\nramdisk_size=$ramdisk_size\nramdisk_addr=$ramdisk_addr\n\
dt=$dt\ndtb_size=$dtb_size\ntags_addr=$tags_addr\ncmd_line=\"$cmd_line\"\n" > img_info
mkdir ramdisk
cd ramdisk
gzip -d -c ../ramdisk.gz | cpio -i -d -m --no-absolute-filenames 2>/dev/null
#Unpack Finish to exit.
pout "Unpack completed."
exit
fi
cd $workdir
ramdisk=$2
#if ramdisk is a directory,create ramdisk.gz
if [ -d $ramdisk ]; then
cd $ramdisk
find . | cpio -R 0:0 -H newc -o 2>/dev/null | gzip > $tempdir/ramdisk.gz
ramdisksize=$(stat -c "%s" $tempdir/ramdisk.gz)
ramdisk="$tempdir/ramdisk.gz"
cd $workdir
fi
rm -f $3
mkboot_img $3 || perr "Make boot.img Error! pls check."
clean

Now you can extract the ramdisk from samsung kernel image:

./mkboot boot.img output

Download the toolchain - extract it - rename the folder to linaro-4.8 and move it to /home/toolchain

linaro-toolchain-binaries 4.8

Open a command shell - enable ccache and set architecture to arm:

export USE_CCACHE=1
export ARCH=arm

Set path for toolchain binaries:

export PATH=$PATH:/home/toolchain/linaro-4.8/bin
export CROSS_COMPILE=arm-linux-gnueabihf-

Enter the kernel folder and cleanup :

cd /home/kernel-samsung-n9005
make mrproper

Create defconfig (out/kernel is the output folder):

mkdir -p out/kernel
make O=out/kernel hlte-custom_defconfig

Build kernel (j4 sets four tasks that run simultaneously, to utilize the capacity of multicore cpus)

make -j4 O=out/kernel

If everything goes well the last line should be:

Kernel: arch/arm/boot/zImage is ready

Install the device-tree-compiler (thanks [MENTION=3986004]civato[/MENTION])

sudo apt-get install device-tree-compiler

Create the device tree binary:

./scripts/dtbTool -o out/dt.img out/kernel/arch/arm/boot/

Copy the compressed kernel image to folder /out:

cp out/kernel/arch/arm/boot/zImage out

Compress your ramdisk into gzip format (ramdisk folder need to be at /home/ramdisk):

./scripts/mkbootfs /home/ramdisk | gzip > out/ramdisk.gz

Create the final boot image:

./scripts/mkbootimg --kernel out/zImage --ramdisk out/ramdisk.gz --dt out/dt.img --cmdline "console=null androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x3F" --base 0x00000000 --offset 0x02000000 --tags-addr 0x01e00000 --pagesize 2048 -o out/boot.img