Commit b540e6a0 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

Switched to only single kernel compile if initramfs was previously built

- initramfs lags 1 build behind but it only affect the kernel modules which
  we don't have in initramfs - it's only used for NAND flash boot
  to mount overlayfs and switch_root there
parent 03761fd8
...@@ -14,7 +14,8 @@ require conf/machine/include/soc-family.inc ...@@ -14,7 +14,8 @@ require conf/machine/include/soc-family.inc
# Linux Configuration # Linux Configuration
KERNEL_IMAGETYPE ?= "uImage" KERNEL_IMAGETYPE ?= "uImage"
KERNEL_IMAGETYPES += "zImage" # Don't need zImage
#KERNEL_IMAGETYPES += "zImage"
# Set default load address. # Set default load address.
# Override with KERNEL_EXTRA_ARGS_<board> += "..." in machine file if required # Override with KERNEL_EXTRA_ARGS_<board> += "..." in machine file if required
......
...@@ -116,35 +116,22 @@ do_deploy_append(){ ...@@ -116,35 +116,22 @@ do_deploy_append(){
fi fi
# copy initramfs image over initramfsless image - why? # copy initramfs image over initramfsless image - why?
# because we need a proper init script to handle overlayfs
if [ -f ${DEPLOYDIR}/uImage-${INITRAMFS_IMAGE_NAME}.bin ]; then echo "INITRAMFS IMAGE NAME = ${DEPLOYDIR}/uImage-initramfs-${MACHINE}.bin"
if [ -f ${DEPLOYDIR}/uImage-initramfs-${MACHINE}.bin ]; then
if [ -f ${DEPLOY_DIR_IMAGE}/${RLOC}/${PRODUCTION_KERNEL} ]; then if [ -f ${DEPLOY_DIR_IMAGE}/${RLOC}/${PRODUCTION_KERNEL} ]; then
rm ${DEPLOY_DIR_IMAGE}/${RLOC}/${PRODUCTION_KERNEL} rm ${DEPLOY_DIR_IMAGE}/${RLOC}/${PRODUCTION_KERNEL}
fi fi
cp ${DEPLOYDIR}/uImage-${INITRAMFS_IMAGE_NAME}.bin ${DEPLOY_DIR_IMAGE}/${RLOC}/${PRODUCTION_KERNEL} cp -L ${DEPLOYDIR}/uImage-initramfs-${MACHINE}.bin ${DEPLOY_DIR_IMAGE}/${RLOC}/${PRODUCTION_KERNEL}
fi fi
done done
} }
# OLD: Override do_bundle_initramfs (kernel.bbclass) # 1. copied the whole task from kernel.bbclass
do_bundle_initramfs_old () { # 2. replaced mv's with cp's - quick and dirty
if [ ! -z "${INITRAMFS_IMAGE}" -a x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then # 3. added skipping of the extra compile step based on the file indicator
echo "Creating a kernel image with a bundled initramfs..."
copy_initramfs
#if [ -e ${KERNEL_OUTPUT} ] ; then
# mv -f ${KERNEL_OUTPUT} ${KERNEL_OUTPUT}.bak
#fi
#use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE}-$#{MACHINE}.cpio
#kernel_do_compile
cp ${KERNEL_OUTPUT} ${KERNEL_OUTPUT}.initramfs
#mv -f ${KERNEL_OUTPUT}.bak ${KERNEL_OUTPUT}
# Update install area
echo "There is kernel image bundled with initramfs: ${B}/${KERNEL_OUTPUT}.initramfs"
install -m 0644 ${B}/${KERNEL_OUTPUT}.initramfs ${D}/boot/${KERNEL_IMAGETYPE}-initramfs-${MACHINE}.bin
echo "${B}/${KERNEL_OUTPUT}.initramfs"
fi
}
do_bundle_initramfs () { do_bundle_initramfs () {
if [ ! -z "${INITRAMFS_IMAGE}" -a x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then if [ ! -z "${INITRAMFS_IMAGE}" -a x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then
echo "Creating a kernel image with a bundled initramfs..." echo "Creating a kernel image with a bundled initramfs..."
...@@ -156,18 +143,19 @@ do_bundle_initramfs () { ...@@ -156,18 +143,19 @@ do_bundle_initramfs () {
linkpath=`readlink -n ${KERNEL_OUTPUT_DIR}/$imageType` linkpath=`readlink -n ${KERNEL_OUTPUT_DIR}/$imageType`
realpath=`readlink -fn ${KERNEL_OUTPUT_DIR}/$imageType` realpath=`readlink -fn ${KERNEL_OUTPUT_DIR}/$imageType`
cp -f $realpath $realpath.bak cp -f $realpath $realpath.bak
#mv -f $realpath $realpath.bak
tmp_path=$tmp_path" "$imageType"#"$linkpath"#"$realpath tmp_path=$tmp_path" "$imageType"#"$linkpath"#"$realpath
elif [ -f ${KERNEL_OUTPUT_DIR}/$imageType ]; then elif [ -f ${KERNEL_OUTPUT_DIR}/$imageType ]; then
#mv -f ${KERNEL_OUTPUT_DIR}/$imageType ${KERNEL_OUTPUT_DIR}/$imageType.bak
cp -f ${KERNEL_OUTPUT_DIR}/$imageType ${KERNEL_OUTPUT_DIR}/$imageType.bak cp -f ${KERNEL_OUTPUT_DIR}/$imageType ${KERNEL_OUTPUT_DIR}/$imageType.bak
tmp_path=$tmp_path" "$imageType"##" tmp_path=$tmp_path" "$imageType"##"
fi fi
done done
use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio
# Disable if [ -f "${WORKDIR}/initramfs_is_bundled" ]; then
#kernel_do_compile echo "There was an old initramfs. It got bundled with the kernel. Skipping to save time."
else
kernel_do_compile
fi
# Restoring kernel image # Restoring kernel image
for tp in $tmp_path ; do for tp in $tmp_path ; do
...@@ -175,44 +163,40 @@ do_bundle_initramfs () { ...@@ -175,44 +163,40 @@ do_bundle_initramfs () {
linkpath=`echo $tp|cut -d "#" -f 2` linkpath=`echo $tp|cut -d "#" -f 2`
realpath=`echo $tp|cut -d "#" -f 3` realpath=`echo $tp|cut -d "#" -f 3`
if [ -n "$realpath" ]; then if [ -n "$realpath" ]; then
mv -f $realpath $realpath.initramfs cp -f $realpath $realpath.initramfs
mv -f $realpath.bak $realpath cp -f $realpath.bak $realpath
ln -sf $linkpath.initramfs ${B}/${KERNEL_OUTPUT_DIR}/$imageType.initramfs ln -sf $linkpath.initramfs ${B}/${KERNEL_OUTPUT_DIR}/$imageType.initramfs
else else
mv -f ${KERNEL_OUTPUT_DIR}/$imageType ${KERNEL_OUTPUT_DIR}/$imageType.initramfs cp -f ${KERNEL_OUTPUT_DIR}/$imageType ${KERNEL_OUTPUT_DIR}/$imageType.initramfs
mv -f ${KERNEL_OUTPUT_DIR}/$imageType.bak ${KERNEL_OUTPUT_DIR}/$imageType cp -f ${KERNEL_OUTPUT_DIR}/$imageType.bak ${KERNEL_OUTPUT_DIR}/$imageType
fi fi
done done
fi fi
} }
# Override kernel_do_compile used by do_bundle_initramfs in kernel.bbclass kernel_do_compile_prepend() {
# Added ${PARALLEL_MAKE} only
kernel_do_compile_old() { # 1. Docs: https://www.yoctoproject.org/docs/2.7.1/mega-manual/mega-manual.html#var-INITRAMFS_IMAGE_BUNDLE
unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE #
# 2. ${INITRAMFS_TASK}"!="" - is some kind of an inactive old branch.
# The $use_alternate_initrd is only set from #
# do_bundle_initramfs() This variable is specifically for the # 3. Our initramfs does not include any kernel modules so, we can
# case where we are making a second pass at the kernel # reuse an old one and this will save a lot of time (around 2-3x times quicker)
# compilation and we want to force the kernel build to use a
# different initramfs image. The way to do that in the kernel if [ "$use_alternate_initrd" = "" ] && [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ] ; then
# is to specify: # if it was built at some point - just bundle whatever is there
# make ...args... CONFIG_INITRAMFS_SOURCE=some_other_initramfs.cpio
if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ] ; then
echo "ONLY ONE RUN!"
# The old style way of copying an prebuilt image and building it
# is turned on via INTIRAMFS_TASK != ""
copy_initramfs copy_initramfs
if [ ! -f ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.cpio ] ; then if [ ! -f ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.cpio ] ; then
echo "This might be the very first kernel build (or deploy dir is empty) - initramfs is not there yet. Will have to compile kernel twice" echo "${INITRAMFS_IMAGE}-${MACHINE}.cpio is not found"
#oe_runmake ${KERNEL_IMAGETYPE_FOR_MAKE} ${PARALLEL_MAKE} ${KERNEL_ALT_IMAGETYPE} CC="${KERNEL_CC}" LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS} echo "Unfortunately we will have to rebuild it and bundle in the do_bundle_initramfs task"
echo "This will take a ton of time... :("
else else
use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.cpio echo "There's the old ${INITRAMFS_IMAGE}-${MACHINE}.cpio from a previous build"
fi echo "Let's happily bundle it and save a lot of time."
use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio
# indicate to do_bundle_initramfs() task that initramfs was bundled
touch "${WORKDIR}/initramfs_is_bundled"
fi fi
oe_runmake ${KERNEL_IMAGETYPE_FOR_MAKE} ${PARALLEL_MAKE} ${KERNEL_ALT_IMAGETYPE} CC="${KERNEL_CC}" LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS} $use_alternate_initrd
if test "${KERNEL_IMAGETYPE_FOR_MAKE}.gz" = "${KERNEL_IMAGETYPE}"; then
gzip -9c < "${KERNEL_IMAGETYPE_FOR_MAKE}" > "${KERNEL_OUTPUT}"
fi fi
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment