-
Notifications
You must be signed in to change notification settings - Fork 5
kernel_build_instructions
This document describes how to build a kernel from lll-project GIT repository. Currently, we support only X86_32 and X86_64 architectures.
WARNING: Update your toolchain before building the lll-kernel (click here for instructions).
PRJ_DIR="$HOME/src/lll-project"
mkdir -p $PRJ_DIR
cd $PRJ_DIR
git clone https://github.com/lll-project/kernel
export LANG=C
export LC_ALL=C
MAKE="make"
MAKE_VERBOSE="make V=1"
CC_FOR_BUILD="clang"
HOSTCC_FOR_BUILD="clang"
NOTE-1: Please, adapt /path/to/clang if necessary.
NOTE-2: "make V=1" gives you the full line of each compiler/binutils call which might be helpful to dig into build issues.
cd kernel
cp -v /path/to/kernel-config-file .config
yes "" | $MAKE CC=$CC_FOR_BUILD HOSTCC=$HOSTCC_FOR_BUILD oldconfig
HINT: Use the kernel-config of the running kernel /boot/config-$(uname -r) as .config file.
[ OPTIONAL ]
$MAKE CC=$CC_FOR_BUILD HOSTCC=$HOSTCC_FOR_BUILD menuconfig
TODO-1: This list is still incomplete!
TODO-2: Offer "working" kernel-config files for download (be user-friendly as possible)!
- CONFIG_DEBUG_INFO=y (required for gdb)
- CONFIG_EARLY_PRINTK=y (helpful for qemu + gdb)
XXX: Currently empty
$MAKE CC=$CC_FOR_BUILD HOSTCC=$HOSTCC_FOR_BUILD 2>&1 | tee ../make.log
$MAKE CC=$CC_FOR_BUILD HOSTCC=$HOSTCC_FOR_BUILD modules 2>&1 | tee ../modules.log
OR ALTERNATIVELY:
$MAKE CC=$CC_FOR_BUILD HOSTCC=$HOSTCC_FOR_BUILD all 2>&1 | tee ../make-all.log
root# $MAKE CC=$CC_FOR_BUILD HOSTCC=$HOSTCC_FOR_BUILD modules_install 2>&1 | tee ../modules_install.log
root# $MAKE CC=$CC_FOR_BUILD HOSTCC=$HOSTCC_FOR_BUILD install 2>&1 | tee ../install.log
OR ALTERNATIVELY:
root# $MAKE CC=$CC_FOR_BUILD HOSTCC=$HOSTCC_FOR_BUILD all install 2>&1 | tee ../install-all.log
Create Initial RAM-Disk (initrd.img) file:
mkinitramfs -o initrd.img $(make kernelversion)+
Move (and rename) initrd.img to /boot directory:
root# mv initrd.img /boot/initrd.img-$(make kernelversion)+
INFO: "$(make kernelversion)+" results currently in "2.6.38.2-lll+"
NOTE: An Initial RAM-Disk is optional. It highly depends on your kernel-config settings, especially if you build essential parts of the kernel - like the filesystem of the root-partition - as a kernel-module or leave built-in.
root# update-grub
export DEBFULLNAME="Sedat Dilek"
export DEBEMAIL="sedat.dilek@gmail.com"
uploader="dileks"
version=$(awk '/^VERSION = / {print $3}' Makefile)
patchlevel=$(awk '/^PATCHLEVEL = / {print $3}' Makefile)
sublevel=$(awk '/^SUBLEVEL = / {print $3}' Makefile)
extraversion=$(awk '/^EXTRAVERSION = / {print $3}' Makefile)
kversion="${version}.${patchlevel}.${sublevel}${extraversion}"
DEBIAN_VERSION="${kversion}-1~${uploader}.1"
$MAKE CC=$CC_FOR_BUILD HOSTCC=$HOSTCC_FOR_BUILD deb-pkg KDEB_PKGVERSION="${DEBIAN_VERSION}" 2>&1 | tee ../deb-pkg.log
NOTE: This produces linux-image, linux-headers, linux-firmware-image and linux-libc-dev Debian packages.
$MAKE CC=$CC_FOR_BUILD HOSTCC=$HOSTCC_FOR_BUILD EXTRAVERSION="${extraversion}-dbg" deb-pkg KDEB_PKGVERSION="${DEBIAN_VERSION}" 2>&1 | tee ../deb-pkg.log
...which is equivalent to hardcoded EXTRAVERSION:
$MAKE CC=$CC_FOR_BUILD HOSTCC=$HOSTCC_FOR_BUILD EXTRAVERSION=".2-lll-dbg" deb-pkg KDEB_PKGVERSION="${DEBIAN_VERSION}" 2>&1 | tee ../deb-pkg.log
INFO: EXTRAVERSION=.2-lll is currently default.
WARNING: With CONFIG_DEBUG_INFO=y the linux-image Debian package can have a huge filesize (minimal kernel-config: >=40MiB vs. >=8MiB without debug-info)!
root# dpkg -i ../linux-image*.deb ../linux-headers*.deb
Find and list important files:
cd kernel
for i in bzImage vmlinux System.map ; do find ./ -name $i -exec ls -l "{}" ";" ; done
Archive important files:
mkdir ../archive
cp -av arch/x86/boot/bzImage vmlinux System.map ../archive