mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 21:09:03 +02:00

Some distros may want to provide alternate kernel "flavors" via feeds or within bootable images. For example, readily available builds which provide certain diagnostic features can enable developers and testers to more quickly resolve issues by avoiding lengthy kernel builds. This change allows for building multiple flavors of the kernel and module packages by templatizing kernel package names via a new KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to the old name of "kernel", but can be overridden by certain recipes providing alternate kernel flavors. To maintain compatibility, recipes providing alternate kernel flavors cannot be the "preferred provider" for virtual/kernel. This is because OE puts the preferred provider's build and source at "tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and "tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of "tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes using the default KERNEL_PACKAGE_NAME="kernel" follows the old semantics -- build in the old location and may be preferred provider -- while recipes using all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and don't provide "virtual/kernel". Testing: 1. Add `KERNEL_PACKAGE_NAME_pn-linux-yocto-tiny = "tiny-linux"` to local.conf so that linux-yocto-tiny may build alongside the main kernel (linux-yocto). 2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel flavors. 3. Verified image and modules IPKs exist for both: tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-tiny 4. Verified linux-yocto is the "preferred provider", and was built in shared directory: tmp-glibc/work-shared/qemux86/kernel-* 5. Add `CORE_IMAGE_BASE_INSTALL_append_pn-core-image-base = "tiny-linux"` to local.conf to install both kernel flavors in core-image-base. 6. `bitbake core-image-base` to build an image. 7. Verified image contains two bzImage's under /boot/, with "yocto-standard" (linux-yocto recipe) selected to boot via symlink. Discussion threads: http://lists.openembedded.org/pipermail/openembedded-core/2015-December/thread.html#114122 http://lists.openembedded.org/pipermail/openembedded-core/2017-July/thread.html#139130 [YOCTO #11363] (From OE-Core rev: 6c8c899849d101fd1b86aad0b8eed05c7c785924) Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com> Signed-off-by: Gratian Crisan <gratian.crisan@ni.com> Signed-off-by: Haris Okanovic <haris.okanovic@ni.com> Coauthored-by: Gratian Crisan <gratian.crisan@ni.com> Coauthored-by: Haris Okanovic <haris.okanovic@ni.com> Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
113 lines
4.1 KiB
Plaintext
113 lines
4.1 KiB
Plaintext
# Support for device tree generation
|
|
PACKAGES_append = " \
|
|
${KERNEL_PACKAGE_NAME}-devicetree \
|
|
${@[d.getVar('KERNEL_PACKAGE_NAME') + '-image-zimage-bundle', ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
|
|
"
|
|
FILES_${KERNEL_PACKAGE_NAME}-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb /${KERNEL_IMAGEDEST}/*.dtbo"
|
|
FILES_${KERNEL_PACKAGE_NAME}-image-zimage-bundle = "/${KERNEL_IMAGEDEST}/zImage-*.dtb.bin"
|
|
|
|
# Generate kernel+devicetree bundle
|
|
KERNEL_DEVICETREE_BUNDLE ?= "0"
|
|
|
|
normalize_dtb () {
|
|
DTB="$1"
|
|
if echo ${DTB} | grep -q '/dts/'; then
|
|
bbwarn "${DTB} contains the full path to the the dts file, but only the dtb name should be used."
|
|
DTB=`basename ${DTB} | sed 's,\.dts$,.dtb,g'`
|
|
fi
|
|
echo "${DTB}"
|
|
}
|
|
|
|
get_real_dtb_path_in_kernel () {
|
|
DTB="$1"
|
|
DTB_PATH="${B}/arch/${ARCH}/boot/dts/${DTB}"
|
|
if [ ! -e "${DTB_PATH}" ]; then
|
|
DTB_PATH="${B}/arch/${ARCH}/boot/${DTB}"
|
|
fi
|
|
echo "${DTB_PATH}"
|
|
}
|
|
|
|
do_configure_append() {
|
|
if [ "${KERNEL_DEVICETREE_BUNDLE}" = "1" ]; then
|
|
if echo ${KERNEL_IMAGETYPE_FOR_MAKE} | grep -q 'zImage'; then
|
|
case "${ARCH}" in
|
|
"arm")
|
|
config="${B}/.config"
|
|
if ! grep -q 'CONFIG_ARM_APPENDED_DTB=y' $config; then
|
|
bbwarn 'CONFIG_ARM_APPENDED_DTB is NOT enabled in the kernel. Enabling it to allow the kernel to boot with the Device Tree appended!'
|
|
sed -i "/CONFIG_ARM_APPENDED_DTB[ =]/d" $config
|
|
echo "CONFIG_ARM_APPENDED_DTB=y" >> $config
|
|
echo "# CONFIG_ARM_ATAG_DTB_COMPAT is not set" >> $config
|
|
fi
|
|
;;
|
|
*)
|
|
bberror "KERNEL_DEVICETREE_BUNDLE is not supported for ${ARCH}. Currently it is only supported for 'ARM'."
|
|
esac
|
|
else
|
|
bberror 'The KERNEL_DEVICETREE_BUNDLE requires the KERNEL_IMAGETYPE to contain zImage.'
|
|
fi
|
|
fi
|
|
}
|
|
|
|
do_compile_append() {
|
|
for DTB in ${KERNEL_DEVICETREE}; do
|
|
DTB=`normalize_dtb "${DTB}"`
|
|
oe_runmake ${DTB}
|
|
done
|
|
}
|
|
|
|
do_install_append() {
|
|
for DTB in ${KERNEL_DEVICETREE}; do
|
|
DTB=`normalize_dtb "${DTB}"`
|
|
DTB_EXT=${DTB##*.}
|
|
DTB_PATH=`get_real_dtb_path_in_kernel "${DTB}"`
|
|
DTB_BASE_NAME=`basename ${DTB} ."${DTB_EXT}"`
|
|
install -m 0644 ${DTB_PATH} ${D}/${KERNEL_IMAGEDEST}/${DTB_BASE_NAME}.${DTB_EXT}
|
|
for type in ${KERNEL_IMAGETYPE_FOR_MAKE}; do
|
|
symlink_name=${type}"-"${KERNEL_IMAGE_SYMLINK_NAME}
|
|
DTB_SYMLINK_NAME=`echo ${symlink_name} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"`
|
|
ln -sf ${DTB_BASE_NAME}.${DTB_EXT} ${D}/${KERNEL_IMAGEDEST}/devicetree-${DTB_SYMLINK_NAME}.${DTB_EXT}
|
|
|
|
if [ "$type" = "zImage" ] && [ "${KERNEL_DEVICETREE_BUNDLE}" = "1" ]; then
|
|
cat ${D}/${KERNEL_IMAGEDEST}/$type \
|
|
${D}/${KERNEL_IMAGEDEST}/${DTB_BASE_NAME}.${DTB_EXT} \
|
|
> ${D}/${KERNEL_IMAGEDEST}/$type-${DTB_BASE_NAME}.${DTB_EXT}.bin
|
|
fi
|
|
done
|
|
done
|
|
}
|
|
|
|
do_deploy_append() {
|
|
for DTB in ${KERNEL_DEVICETREE}; do
|
|
DTB=`normalize_dtb "${DTB}"`
|
|
DTB_EXT=${DTB##*.}
|
|
DTB_BASE_NAME=`basename ${DTB} ."${DTB_EXT}"`
|
|
for type in ${KERNEL_IMAGETYPE_FOR_MAKE}; do
|
|
base_name=${type}"-"${KERNEL_IMAGE_BASE_NAME}
|
|
symlink_name=${type}"-"${KERNEL_IMAGE_SYMLINK_NAME}
|
|
DTB_NAME=`echo ${base_name} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"`
|
|
DTB_SYMLINK_NAME=`echo ${symlink_name} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"`
|
|
DTB_PATH=`get_real_dtb_path_in_kernel "${DTB}"`
|
|
install -d ${DEPLOYDIR}
|
|
install -m 0644 ${DTB_PATH} ${DEPLOYDIR}/${DTB_NAME}.${DTB_EXT}
|
|
ln -sf ${DTB_NAME}.${DTB_EXT} ${DEPLOYDIR}/${DTB_SYMLINK_NAME}.${DTB_EXT}
|
|
ln -sf ${DTB_NAME}.${DTB_EXT} ${DEPLOYDIR}/${DTB_BASE_NAME}.${DTB_EXT}
|
|
|
|
if [ "$type" = "zImage" ] && [ "${KERNEL_DEVICETREE_BUNDLE}" = "1" ]; then
|
|
cat ${DEPLOYDIR}/$type \
|
|
${DEPLOYDIR}/${DTB_NAME}.${DTB_EXT} \
|
|
> ${DEPLOYDIR}/${DTB_NAME}.${DTB_EXT}.bin
|
|
ln -sf ${DTB_NAME}.${DTB_EXT}.bin ${DEPLOYDIR}/$type-${DTB_BASE_NAME}.${DTB_EXT}.bin
|
|
|
|
if [ -e "${KERNEL_OUTPUT_DIR}/${type}.initramfs" ]; then
|
|
cat ${KERNEL_OUTPUT_DIR}/${type}.initramfs \
|
|
${DEPLOYDIR}/${DTB_NAME}.${DTB_EXT} \
|
|
> ${DEPLOYDIR}/${type}-${INITRAMFS_BASE_NAME}-${DTB_BASE_NAME}.${DTB_EXT}.bin
|
|
ln -sf ${type}-${INITRAMFS_BASE_NAME}-${DTB_BASE_NAME}.${DTB_EXT}.bin \
|
|
${DEPLOYDIR}/${type}-initramfs-${DTB_BASE_NAME}.${DTB_EXT}-${MACHINE}.bin
|
|
fi
|
|
fi
|
|
done
|
|
done
|
|
}
|