Patchwork [1/2,v4] image_types: Add elf image type

login
register
mail settings
Submitter Raymond Danks
Date July 2, 2012, 8:51 p.m.
Message ID <1341262285-30288-1-git-send-email-ray.danks@se-eng.com>
Download mbox | patch
Permalink /patch/31003/
State New
Headers show

Comments

Raymond Danks - July 2, 2012, 8:51 p.m.
On x86, an ELF image file may be stored as a coreboot payload.
The image file is constructed, using the mkelfimage utility,
from a kernel and an initrd.

Signed-off-by: Raymond Danks <ray.danks@se-eng.com>
Acked-by: Darren Hart <dvhart@linux.intel.com>
---
This was originally submitted to the openembedded project:
http://patches.openembedded.org/patch/7689/

v3:
 Include DEPLOY_DIR_IMAGE and KERNEL_IMAGETYPE for location of ELF_KERNEL

v4:
 Quotes must surround ELF_KERNEL defintion with newer versions of bitbake.

 meta/classes/image_types.bbclass |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)
Saul Wold - July 5, 2012, 5:35 p.m.
On 07/02/2012 01:51 PM, Raymond Danks wrote:
> On x86, an ELF image file may be stored as a coreboot payload.
> The image file is constructed, using the mkelfimage utility,
> from a kernel and an initrd.
>
> Signed-off-by: Raymond Danks <ray.danks@se-eng.com>
> Acked-by: Darren Hart <dvhart@linux.intel.com>
> ---
> This was originally submitted to the openembedded project:
> http://patches.openembedded.org/patch/7689/
>
> v3:
>   Include DEPLOY_DIR_IMAGE and KERNEL_IMAGETYPE for location of ELF_KERNEL
>
> v4:
>   Quotes must surround ELF_KERNEL defintion with newer versions of bitbake.
>
>   meta/classes/image_types.bbclass |   18 +++++++++++++++++-
>   1 files changed, 17 insertions(+), 1 deletions(-)
>
Merged both parts of this patch set (v4 from here and v3 2/2)

Thanks
	Sau!

> diff --git a/meta/classes/image_types.bbclass b/meta/classes/image_types.bbclass
> index 55f122e..2873273 100644
> --- a/meta/classes/image_types.bbclass
> +++ b/meta/classes/image_types.bbclass
> @@ -7,6 +7,12 @@ def get_imagecmds(d):
>       ctypes = d.getVar('COMPRESSIONTYPES', True).split()
>       cimages = {}
>
> +    if "elf" in alltypes:
> +        alltypes.remove("elf")
> +        if "cpio.gz" not in alltypes:
> +                alltypes.append("cpio.gz")
> +        alltypes.append("elf")
> +
>       # Filter out all the compressed images from types
>       for type in alltypes:
>           basetype = None
> @@ -173,6 +179,14 @@ IMAGE_CMD_cpio () {
>   	cd ${IMAGE_ROOTFS} && (find . | cpio -o -H newc >${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cpio)
>   }
>
> +ELF_KERNEL ?= "${STAGING_DIR_HOST}/kernel/${KERNEL_IMAGETYPE}"
> +ELF_APPEND ?= "ramdisk_size=32768 root=/dev/ram0 rw console="
> +
> +IMAGE_CMD_elf () {
> +	test -f ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.elf && rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.elf
> +	mkelfImage --kernel=${ELF_KERNEL} --initrd=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cpio.gz --output=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.elf --append='${ELF_APPEND}' ${EXTRA_IMAGECMD}
> +}
> +
>   UBI_VOLNAME ?= "${MACHINE}-rootfs"
>
>   IMAGE_CMD_ubi () {
> @@ -199,6 +213,7 @@ EXTRA_IMAGECMD_ext2 ?= "-i 8192"
>   EXTRA_IMAGECMD_ext3 ?= "-i 8192"
>   EXTRA_IMAGECMD_ext4 ?= "-i 8192"
>   EXTRA_IMAGECMD_btrfs ?= ""
> +EXTRA_IMAGECMD_elf ?= ""
>
>   IMAGE_DEPENDS = ""
>   IMAGE_DEPENDS_jffs2 = "mtd-utils-native"
> @@ -210,11 +225,12 @@ IMAGE_DEPENDS_ext4 = "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_elf = "virtual/kernel mkelfimage-native"
>   IMAGE_DEPENDS_ubi = "mtd-utils-native"
>   IMAGE_DEPENDS_ubifs = "mtd-utils-native"
>
>   # This variable is available to request which values are suitable for IMAGE_FSTYPES
> -IMAGE_TYPES = "jffs2 sum.jffs2 cramfs ext2 ext2.gz ext2.bz2 ext3 ext3.gz ext2.lzma btrfs live squashfs squashfs-lzma ubi tar tar.gz tar.bz2 tar.xz cpio cpio.gz cpio.xz cpio.lzma vmdk"
> +IMAGE_TYPES = "jffs2 sum.jffs2 cramfs ext2 ext2.gz ext2.bz2 ext3 ext3.gz ext2.lzma btrfs live squashfs squashfs-lzma ubi tar tar.gz tar.bz2 tar.xz cpio cpio.gz cpio.xz cpio.lzma vmdk elf"
>
>   COMPRESSIONTYPES = "gz bz2 lzma xz"
>   COMPRESS_CMD_lzma = "lzma -k -f -7 ${IMAGE_NAME}.rootfs.${type}"
>

Patch

diff --git a/meta/classes/image_types.bbclass b/meta/classes/image_types.bbclass
index 55f122e..2873273 100644
--- a/meta/classes/image_types.bbclass
+++ b/meta/classes/image_types.bbclass
@@ -7,6 +7,12 @@  def get_imagecmds(d):
     ctypes = d.getVar('COMPRESSIONTYPES', True).split()
     cimages = {}
 
+    if "elf" in alltypes:
+        alltypes.remove("elf")
+        if "cpio.gz" not in alltypes:
+                alltypes.append("cpio.gz")
+        alltypes.append("elf")
+
     # Filter out all the compressed images from types
     for type in alltypes:
         basetype = None
@@ -173,6 +179,14 @@  IMAGE_CMD_cpio () {
 	cd ${IMAGE_ROOTFS} && (find . | cpio -o -H newc >${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cpio)
 }
 
+ELF_KERNEL ?= "${STAGING_DIR_HOST}/kernel/${KERNEL_IMAGETYPE}"
+ELF_APPEND ?= "ramdisk_size=32768 root=/dev/ram0 rw console=" 
+
+IMAGE_CMD_elf () {
+	test -f ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.elf && rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.elf 
+	mkelfImage --kernel=${ELF_KERNEL} --initrd=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cpio.gz --output=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.elf --append='${ELF_APPEND}' ${EXTRA_IMAGECMD}
+}
+
 UBI_VOLNAME ?= "${MACHINE}-rootfs"
 
 IMAGE_CMD_ubi () {
@@ -199,6 +213,7 @@  EXTRA_IMAGECMD_ext2 ?= "-i 8192"
 EXTRA_IMAGECMD_ext3 ?= "-i 8192"
 EXTRA_IMAGECMD_ext4 ?= "-i 8192"
 EXTRA_IMAGECMD_btrfs ?= ""
+EXTRA_IMAGECMD_elf ?= ""
 
 IMAGE_DEPENDS = ""
 IMAGE_DEPENDS_jffs2 = "mtd-utils-native"
@@ -210,11 +225,12 @@  IMAGE_DEPENDS_ext4 = "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_elf = "virtual/kernel mkelfimage-native"
 IMAGE_DEPENDS_ubi = "mtd-utils-native"
 IMAGE_DEPENDS_ubifs = "mtd-utils-native"
 
 # This variable is available to request which values are suitable for IMAGE_FSTYPES
-IMAGE_TYPES = "jffs2 sum.jffs2 cramfs ext2 ext2.gz ext2.bz2 ext3 ext3.gz ext2.lzma btrfs live squashfs squashfs-lzma ubi tar tar.gz tar.bz2 tar.xz cpio cpio.gz cpio.xz cpio.lzma vmdk"
+IMAGE_TYPES = "jffs2 sum.jffs2 cramfs ext2 ext2.gz ext2.bz2 ext3 ext3.gz ext2.lzma btrfs live squashfs squashfs-lzma ubi tar tar.gz tar.bz2 tar.xz cpio cpio.gz cpio.xz cpio.lzma vmdk elf"
 
 COMPRESSIONTYPES = "gz bz2 lzma xz"
 COMPRESS_CMD_lzma = "lzma -k -f -7 ${IMAGE_NAME}.rootfs.${type}"