summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-yocto/conf/local.conf.sample.extended22
-rw-r--r--meta/classes/image.bbclass12
-rw-r--r--meta/classes/kernel.bbclass96
3 files changed, 118 insertions, 12 deletions
diff --git a/meta-yocto/conf/local.conf.sample.extended b/meta-yocto/conf/local.conf.sample.extended
index 06d7abc01b..a2cb81bc1c 100644
--- a/meta-yocto/conf/local.conf.sample.extended
+++ b/meta-yocto/conf/local.conf.sample.extended
@@ -241,3 +241,25 @@ FORTRAN_forcevariable = ",fortran"
241RUNTIMETARGET_append_pn-gcc-runtime = " libquadmath libgfortran" 241RUNTIMETARGET_append_pn-gcc-runtime = " libquadmath libgfortran"
242export BUILD_FC = "${CCACHE}${BUILD_PREFIX}gfortran ${BUILD_CC_ARCH}" 242export BUILD_FC = "${CCACHE}${BUILD_PREFIX}gfortran ${BUILD_CC_ARCH}"
243export FC = "${CCACHE}${HOST_PREFIX}gfortran ${HOST_CC_ARCH}" 243export FC = "${CCACHE}${HOST_PREFIX}gfortran ${HOST_CC_ARCH}"
244
245#
246# Kernel image features
247#
248# The INITRAMFS_IMAGE image variable will cause an additional recipe to
249# be built as a dependency to the what ever rootfs recipe you might be
250# using such as core-image-sato. The initramfs might be needed for
251# the initial boot of of the target system such as to load kernel
252# modules prior to mounting the root file system.
253#
254# INITRAMFS_IMAGE_BUNDLE variable controls if the image recipe
255# specified by the INITRAMFS_IMAGE will be run through an extra pass
256# through the kernel compilation in order to build a single binary
257# which contains both the kernel image and the initramfs. The
258# combined binary will be deposited into the tmp/deploy directory.
259# NOTE: You can set INITRAMFS_IMAGE in an image recipe, but
260# INITRAMFS_IMAGE_BUNDLE can only be set in a conf file.
261#
262#INITRAMFS_IMAGE = "core-image-minimal-initramfs"
263#INITRAMFS_IMAGE_BUNDLE = "1"
264
265
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 84f638c099..4a0946c8e3 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -130,6 +130,10 @@ python () {
130 d.setVar('MULTILIB_VENDORS', ml_vendor_list) 130 d.setVar('MULTILIB_VENDORS', ml_vendor_list)
131 131
132 check_image_features(d) 132 check_image_features(d)
133 initramfs_image = d.getVar('INITRAMFS_IMAGE', True) or ""
134 if initramfs_image != "":
135 d.appendVarFlag('do_build', 'depends', " %s:do_bundle_initramfs" % d.getVar('PN', True))
136 d.appendVarFlag('do_bundle_initramfs', 'depends', " %s:do_rootfs" % initramfs_image)
133} 137}
134 138
135# 139#
@@ -629,3 +633,11 @@ do_package_write_deb[noexec] = "1"
629do_package_write_rpm[noexec] = "1" 633do_package_write_rpm[noexec] = "1"
630 634
631addtask rootfs before do_build 635addtask rootfs before do_build
636# Allow the kernel to be repacked with the initramfs and boot image file as a single file
637do_bundle_initramfs[depends] += "virtual/kernel:do_bundle_initramfs"
638do_bundle_initramfs[nostamp] = "1"
639do_bundle_initramfs[noexec] = "1"
640do_bundle_initramfs () {
641 :
642}
643addtask bundle_initramfs after do_rootfs
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index e039dfc15c..8cf66ce7dc 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -9,6 +9,7 @@ INHIBIT_DEFAULT_DEPS = "1"
9KERNEL_IMAGETYPE ?= "zImage" 9KERNEL_IMAGETYPE ?= "zImage"
10INITRAMFS_IMAGE ?= "" 10INITRAMFS_IMAGE ?= ""
11INITRAMFS_TASK ?= "" 11INITRAMFS_TASK ?= ""
12INITRAMFS_IMAGE_BUNDLE ?= ""
12 13
13python __anonymous () { 14python __anonymous () {
14 kerneltype = d.getVar('KERNEL_IMAGETYPE', True) or '' 15 kerneltype = d.getVar('KERNEL_IMAGETYPE', True) or ''
@@ -19,7 +20,15 @@ python __anonymous () {
19 20
20 image = d.getVar('INITRAMFS_IMAGE', True) 21 image = d.getVar('INITRAMFS_IMAGE', True)
21 if image: 22 if image:
22 d.setVar('INITRAMFS_TASK', '${INITRAMFS_IMAGE}:do_rootfs') 23 d.appendVarFlag('do_bundle_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_rootfs')
24
25 # NOTE: setting INITRAMFS_TASK is for backward compatibility
26 # The preferred method is to set INITRAMFS_IMAGE, because
27 # this INITRAMFS_TASK has circular dependency problems
28 # if the initramfs requires kernel modules
29 image_task = d.getVar('INITRAMFS_TASK', True)
30 if image_task:
31 d.appendVarFlag('do_configure', 'depends', ' ${INITRAMFS_TASK}')
23} 32}
24 33
25inherit kernel-arch deploy 34inherit kernel-arch deploy
@@ -72,9 +81,82 @@ KERNEL_SRC_PATH = "/usr/src/kernel"
72 81
73KERNEL_IMAGETYPE_FOR_MAKE = "${@(lambda s: s[:-3] if s[-3:] == ".gz" else s)(d.getVar('KERNEL_IMAGETYPE', True))}" 82KERNEL_IMAGETYPE_FOR_MAKE = "${@(lambda s: s[:-3] if s[-3:] == ".gz" else s)(d.getVar('KERNEL_IMAGETYPE', True))}"
74 83
84copy_initramfs() {
85 echo "Copying initramfs into ./usr ..."
86 # Find and use the first initramfs image archive type we find
87 rm -f ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.cpio
88 for img in cpio.gz cpio.lzo cpio.lzma cpio.xz; do
89 if [ -e "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img" ]; then
90 cp ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img ${B}/usr/.
91 case $img in
92 *gz)
93 echo "gzip decompressing image"
94 gunzip -f ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.$img
95 break
96 ;;
97 *lzo)
98 echo "lzo decompressing image"
99 lzop -df ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.$img
100 break
101 ;;
102 *lzma)
103 echo "lzma decompressing image"
104 lzmash -df ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.$img
105 break
106 ;;
107 *xz)
108 echo "xz decompressing image"
109 xz -df ${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.$img
110 break
111 ;;
112 esac
113 fi
114 done
115 echo "Finished copy of initramfs into ./usr"
116}
117
118INITRAMFS_BASE_NAME = "${KERNEL_IMAGETYPE}-initramfs-${PV}-${PR}-${MACHINE}-${DATETIME}"
119INITRAMFS_BASE_NAME[vardepsexclude] = "DATETIME"
120do_bundle_initramfs () {
121 if [ ! -z "${INITRAMFS_IMAGE}" -a x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then
122 echo "Creating a kernel image with a bundled initramfs..."
123 copy_initramfs
124 if [ -e ${KERNEL_OUTPUT} ] ; then
125 mv -f ${KERNEL_OUTPUT} ${KERNEL_OUTPUT}.bak
126 fi
127 use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.cpio
128 kernel_do_compile
129 mv -f ${KERNEL_OUTPUT} ${KERNEL_OUTPUT}.initramfs
130 mv -f ${KERNEL_OUTPUT}.bak ${KERNEL_OUTPUT}
131 # Update install area
132 echo "There is kernel image bundled with initramfs: ${B}/${KERNEL_OUTPUT}.initramfs"
133 install -m 0644 ${B}/${KERNEL_OUTPUT}.initramfs ${D}/boot/${KERNEL_IMAGETYPE}-initramfs-${MACHINE}.bin
134 echo "${B}/${KERNEL_OUTPUT}.initramfs"
135 cd ${B}
136 # Update deploy directory
137 if [ -e "${KERNEL_OUTPUT}.initramfs" ]; then
138 echo "Copying deploy kernel-initramfs image and setting up links..."
139 initramfs_base_name=${INITRAMFS_BASE_NAME}
140 initramfs_symlink_name=${KERNEL_IMAGETYPE}-initramfs-${MACHINE}
141 install -m 0644 ${KERNEL_OUTPUT}.initramfs ${DEPLOY_DIR_IMAGE}/${initramfs_base_name}.bin
142 cd ${DEPLOY_DIR_IMAGE}
143 ln -sf ${initramfs_base_name}.bin ${initramfs_symlink_name}.bin
144 fi
145 fi
146}
147do_bundle_initramfs[nostamp] = "1"
148addtask bundle_initramfs after do_compile
149
75kernel_do_compile() { 150kernel_do_compile() {
76 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE 151 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
77 oe_runmake ${KERNEL_IMAGETYPE_FOR_MAKE} ${KERNEL_ALT_IMAGETYPE} CC="${KERNEL_CC}" LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS} 152 # The $use_alternate_initrd is only set from
153 # do_bundle_initramfs() This variable is specifically for the
154 # case where we are making a second pass at the kernel
155 # compilation and we want to force the kernel build to use a
156 # different initramfs image. The way to do that in the kernel
157 # is to specify:
158 # make ...args... CONFIG_INITRAMFS_SOURCE=some_other_initramfs.cpio
159 oe_runmake ${KERNEL_IMAGETYPE_FOR_MAKE} ${KERNEL_ALT_IMAGETYPE} CC="${KERNEL_CC}" LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS} $use_alternate_initrd
78 if test "${KERNEL_IMAGETYPE_FOR_MAKE}.gz" = "${KERNEL_IMAGETYPE}"; then 160 if test "${KERNEL_IMAGETYPE_FOR_MAKE}.gz" = "${KERNEL_IMAGETYPE}"; then
79 gzip -9c < "${KERNEL_IMAGETYPE_FOR_MAKE}" > "${KERNEL_OUTPUT}" 161 gzip -9c < "${KERNEL_IMAGETYPE_FOR_MAKE}" > "${KERNEL_OUTPUT}"
80 fi 162 fi
@@ -219,18 +301,8 @@ kernel_do_configure() {
219 cp "${WORKDIR}/defconfig" "${B}/.config" 301 cp "${WORKDIR}/defconfig" "${B}/.config"
220 fi 302 fi
221 yes '' | oe_runmake oldconfig 303 yes '' | oe_runmake oldconfig
222
223 if [ ! -z "${INITRAMFS_IMAGE}" ]; then
224 for img in cpio.gz cpio.lzo cpio.lzma cpio.xz; do
225 if [ -e "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img" ]; then
226 cp "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img" initramfs.$img
227 fi
228 done
229 fi
230} 304}
231 305
232do_configure[depends] += "${INITRAMFS_TASK}"
233
234do_savedefconfig() { 306do_savedefconfig() {
235 oe_runmake savedefconfig 307 oe_runmake savedefconfig
236} 308}