Embedding initramfs images during kernel build.
v2 cover Embedding initramfs images during kernel build.
* Sync with org.openembedded.dev and allow the inclusion of
* lzma and xz compressed initramfs images.
*
* Provide a convenient way to include an initramfs by setting
* INITRAMFS_IMAGE = "your_initramfs_image.bb"
* and specifying the chosen output format in the initramfs image recipe, e.g.
* IMAGE_FSTYPES = "cpio.gz cpio.lzma"
Andrea Adami (2):
kernel.bbclass: handle embedding of initramfs images image_types.bbclass: support xz compressed initramfs.cpio and
tarballs
meta/classes/image_types.bbclass | 11 +++++++++++ meta/classes/kernel.bbclass | 16 ++++++++++++++++ 2 files changed, 27 insertions(+), 0 deletions(-)
Signature · 1 line
1.7.3.4
PATCH v2 1/2 kernel.bbclass: handle embedding of initramfs images
* "All 2.6 Linux kernels contain a gzipped "cpio" format archive, which is
* extracted into rootfs when the kernel boots up."
* (http://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt)
*
* In some cases it can be useful to take advantage of this ability and embed your
* customized rootfs ("the move to early userspace is necessary because finding
* and mounting the real root device is complex").
*
* Therefore, some code was added and since 2009 OpenEmbedded metadata
* provides a convenient way to include your initramfs by setting
* INITRAMFS_IMAGE = "your_initramfs_image.bb"
* and specifying the chosen output format in the initramfs image recipe, e.g.
* IMAGE_FSTYPES = "cpio.gz cpio.lzma"
*
*
* Patch was imported from the OpenEmbedded git server
* (git://git.openembedded.org/openembedded)
*
* Add satndalone task "builtin_initramfs".
* commit 72761e468bb3e905459f2b81ce1bc4d80419481f
* Signed-off-by:Paul Sokolovsky <[email protected]>
*
* 'Remove usage of non-standard variables (DEPLOY_TO) and random renaming
* of output.'
* commit 456ba7ffd159821e86ad7ad4b66ec7d5790bd054
* Richard Purdie <[email protected]>
*
* 'Fis typo in do_builtin_initramfs.'
* commit 37f2fe4b801df832e93553a08eff24fec736c7d4
* Signed-off-by:Paul Sokolovsky <[email protected]>
*
* 'comment initramfs stuff till rootfs locking works properly (initramfs
* should be optional as well)'
* commit 2818d8b7be1a0d9a59ad3528091d47517d59328b
* Signed-off-by: Koen Kooi <[email protected]>
*
* 'get initramfs stuff working
* commit 1642b3e8fc81c666713951fdd4e7ff9a50d1c5a8
* Signed-off-by: Thomas Kunze <[email protected]>
*
* 'Fix INITRAMFS logic to stop breaking builds for people not using it'
* commit dcf3049eb9eedf0838af59969b3f70a43298d3d7
* Signed-off-by: Richard Purdie <[email protected]>
*
* '-change initramfs-logic'
* commit 3e3f297457138e96e2b652658675796853eb0293
* Signed-off-by: Thomas Kunze <[email protected]>
*
* 'move initramfs stuff to configure so we can do postprocessing
* on it with do_configure_append'
* commit fc03e2be0b4470748a8b7707cea7293303adc424
* Signed-off-by: Koen Kooi <[email protected]>
*
* 'copy gz, lzo, lzma initramfs cpio images.'
* commit 572abc3fdd1076ca35d8c15d269cc9d862101805
* Signed-off-by: Andrea Adami <[email protected]>
*
* 'move the kernel size check to linux-kexecboot.inc.'
* commit 45f82a941c77e9d747814fa1e337ba803475d327
* Signed-off-by: Andrea Adami <[email protected]>
*
* Finally, two refinements as discussed on openembedded-core
* mailing list:
* - replace "if image != '' and image is not None:" with "if image"
* - add cpio.xz support
--- meta/classes/kernel.bbclass | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
meta/classes/kernel.bbclass +16 -0
@@ -7,6 +7,8 @@ DEPENDS += "virtual/${TARGET_PREFIX}gcc virtual/${TARGET_PREFIX}depmod virtual/$ INHIBIT_DEFAULT_DEPS = "1" KERNEL_IMAGETYPE ?= "zImage" +INITRAMFS_IMAGE ?= "" +INITRAMFS_TASK ?= "" python __anonymous () { kerneltype = bb.data.getVar('KERNEL_IMAGETYPE', d, 1) or ''
@@ -14,6 +16,10 @@ python __anonymous () { depends = bb.data.getVar("DEPENDS", d, 1) depends = "%s u-boot-mkimage-native" % depends bb.data.setVar("DEPENDS", depends, d) + + image = bb.data.getVar('INITRAMFS_IMAGE', d, True) + if image: + bb.data.setVar('INITRAMFS_TASK', '${INITRAMFS_IMAGE}:do_rootfs', d) } inherit kernel-arch deploy
@@ -179,8 +185,18 @@ kernel_do_configure() { cp "${WORKDIR}/defconfig" "${S}/.config" fi yes '' | oe_runmake oldconfig + + if [ ! -z "${INITRAMFS_IMAGE}" ]; then + for img in cpio.gz cpio.lzo cpio.lzma cpio.xz; do + if [ -e "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img" + cp "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$i + fi + done + fi } +kernel_do_configure[depends] += "${INITRAMFS_TASK}" + do_menuconfig() { export DISPLAY='${DISPLAY}' export DBUS_SESSION_BUS_ADDRESS='${DBUS_SESSION_BUS_ADDRESS}'
Signature · 1 line
1.7.3.4
PATCH v2 2/2 image_types.bbclass: add support for tar.xz, cpio.xz, cpio.lzma
In reply to Andrea Adami* Once we add support for building kernel containing initramfs images
* we expect compressed cpio archives.
* Thus, add support for lzma and xz compressors for the initramfs images.
* While there, add support for tar.xz as done in org.openembedded.dev. *
* Patch was imported from the OpenEmbedded git server
* (git://git.openembedded.org/openembedded)
*
* 'bitbake.conf: add cpio and ext4 .xz support'
* commit 7977d3325a09e2edf4a8a1b02f48085f88f7a631
* Signed-off-by: Bernhard Reutner-Fischer <[email protected]> *
* 'bitbake.conf: Define tar.xz image types.'
* 1fca8dc50a821f4589fa5e339e6e279dd3c0dafe
* Signed-off-by: Tom Rini <[email protected]>
*
* 'bitbake.conf: add XZ_INTEGRITY_CHECK and LZMA_COMPRESSION_LEVEL variables'
* commit 312b42bcf2cc9b11266ba497ade68e8ddabb3007
* Signed-off-by: Otavio Salvador <[email protected]>
*
* 'bitbake.conf: unbreak and improve lzma image compression handling and adapt
* linux-kexecboot.inc'
* commit c382a9ce64bf4291572665652138aa01b2e54306
* Signed-off-by: Otavio Salvador <[email protected]>
* Signed-off-by: Denis 'GNUtoo' Carikli <[email protected]>
--- meta/classes/image_types.bbclass | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
meta/classes/image_types.bbclass +11 -0
@@ -20,6 +20,10 @@ runimagecmd () { ln -s ${IMAGE_NAME}.rootfs.${type} ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.${type} } + +XZ_COMPRESSION_LEVEL ?= "-e -9" +XZ_INTEGRITY_CHECK ?= "crc32" + IMAGE_CMD_jffs2 = "mkfs.jffs2 --root=${IMAGE_ROOTFS} --faketime --output=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.jffs2 ${EXTRA_IMAGECMD}" IMAGE_CMD_cramfs = "mkcramfs ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cramfs ${EXTRA_IMAGECMD}"
@@ -55,8 +59,12 @@ IMAGE_CMD_squashfs-lzma = "mksquashfs-lzma ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/$ IMAGE_CMD_tar = "cd ${IMAGE_ROOTFS} && tar -cvf ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.tar ." IMAGE_CMD_tar.gz = "cd ${IMAGE_ROOTFS} && tar -zcvf ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.tar.gz ." IMAGE_CMD_tar.bz2 = "cd ${IMAGE_ROOTFS} && tar -jcvf ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.tar.bz2 ." +IMAGE_CMD_tar.xz = "cd ${IMAGE_ROOTFS} && tar --xz -cvf ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.tar.xz ." IMAGE_CMD_cpio = "cd ${IMAGE_ROOTFS} && (find . | cpio -o -H newc >${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cpio)" IMAGE_CMD_cpio.gz = "cd ${IMAGE_ROOTFS} && (find . | cpio -o -H newc | gzip -c -9 >${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cpio.gz)" +IMAGE_CMD_cpio.xz = "type cpio >/dev/null; cd ${IMAGE_ROOTFS} && (find . | cpio -o -H newc | xz -c ${XZ_COMPRESSION_LEVEL} --check=${XZ_INTEGRITY_CHECK} > ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cpio.xz) ${EXTRA_IMAGECMD}" +IMAGE_CMD_cpio.lzma = "type cpio >/dev/null; cd ${IMAGE_ROOTFS} && (find . | cpio -o -H newc | xz --format=lzma -c ${XZ_COMPRESSION_LEVEL} --check=${XZ_INTEGRITY_CHECK} >${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cpio.lzma) ${EXTRA_IMAGECMD}" + IMAGE_CMD_ubi () { echo \[ubifs\] > ubinize.cfg echo mode=ubi >> ubinize.cfg
@@ -88,6 +96,9 @@ IMAGE_DEPENDS_ext3.gz = "genext2fs-native e2fsprogs-native" IMAGE_DEPENDS_btrfs = "btrfs-tools-native" IMAGE_DEPENDS_squashfs = "squashfs-tools-native" IMAGE_DEPENDS_squashfs-lzma = "squashfs-lzma-tools-native" +IMAGE_DEPENDS_tar.xz = "tar-native xz-native" +IMAGE_DEPENDS_cpio.lzma = "xz-native" +IMAGE_DEPENDS_cpio.xz = "xz-native" IMAGE_DEPENDS_ubi = "mtd-utils-native" IMAGE_DEPENDS_ubifs = "mtd-utils-native"
Signature · 1 line
1.7.3.4
Richard Purdie
AppliedQuoted 8 lines · Andrea Adami
* Sync with org.openembedded.dev and allow the inclusion of
* lzma and xz compressed initramfs images.
*
* Provide a convenient way to include an initramfs by setting
*INITRAMFS_IMAGE= "your_initramfs_image.bb"
* and specifying the chosen output format in the initramfs image recipe, e.g.
*IMAGE_FSTYPES= "cpio.gz cpio.lzma"
Quoted 4 lines
Andrea Adami (2):
kernel.bbclass: handle embedding of initramfs images image_types.bbclass: support xz compressed initramfs.cpio and
tarballs
Merged to master, thanks.
Richard
For some reasons one line has been horribly truncated:
cp "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$i ^
below the correct line:
kernel_do_configure() {
yes '' | oe_runmake oldconfig
if [ ! -z "${INITRAMFS_IMAGE}" ]; then
for img in cpio.gz cpio.lzo cpio.lzma; do
if [ -e "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img" ]; then
cp "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img" initramfs.$img
fi
done
fiSorry
Andrea
Quoted 24 lines · Richard Purdie
Quoted 8 lines · Andrea Adami
* Sync with org.openembedded.dev and allow the inclusion of
* lzma and xz compressed initramfs images.
*
* Provide a convenient way to include an initramfs by setting
*INITRAMFS_IMAGE= "your_initramfs_image.bb"
* and specifying the chosen output format in the initramfs image recipe, e.g.
*IMAGE_FSTYPES= "cpio.gz cpio.lzma"Quoted 4 lines
Andrea Adami (2):
kernel.bbclass: handle embedding of initramfs images image_types.bbclass: support xz compressed initramfs.cpio and tarballsMerged to master, thanks.
Richard
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core