Skip to contentSkip to conversation

Add gummiboot boot manager alongside grub-efi

PATCH In review Stefan Stanacar 5 participants 14 messages Mar 6, 2014 – Mar 12, 2014

lore
Share & tools
lore
#0 lore raw

cover Add gummiboot boot manager alongside grub-efi

Hello,

This series adds recipes for gummiboot and a class allowing it to be used as the boot loader for live/hddimg images.
Without changing EFI_PROVIDER, we have the same behaviour for EFI machines. Using EFI_PROVIDER = "gummiboot" an installed image will use gummiboot instead of grub-efi as it's boot manager.

I've tested this on FRI2, NUC and minnow (live USB boot and install from USB and boot) with EFI_PROVIDER = "gummiboot" and KERNEL_FEATURES_append = " cfg/efi-ext" in local.conf

This is a partial fix for YB#4082.

Cheers,
Stefan

The following changes since commit a01af0202558e6ed9d16590b3a8d1dd1b95c0374:

recipes: bump PRs (2014-03-05 17:36:37 +0000)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib stefans/gummiboot
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=stefans/gummiboot

Stefan Stanacar (3):
recipes-bsp: Add gummiboot and gnu-efi recipes bootimg/grub-efi.bbclass: allow using a different class for EFI images
classes: Add gummiboot class

 meta/classes/boot-directdisk.bbclass               |   7 +-
 meta/classes/bootimg.bbclass                       |   9 +-
 meta/classes/grub-efi.bbclass                      |   6 ++
 meta/classes/gummiboot.bbclass                     | 112 +++++++++++++++++++++
 .../gnu-efi/gnu-efi/parallel-make-archives.patch   |  48 +++++++++
 .../gnu-efi/gnu-efi/parallel-make.patch            |  22 ++++
 meta/recipes-bsp/gnu-efi/gnu-efi_3.0u.bb           |  33 ++++++
 meta/recipes-bsp/gummiboot/gummiboot_git.bb        |  25 +++++
 .../initrdscripts/files/init-install-efi.sh        |  51 +++++++---
 9 files changed, 290 insertions(+), 23 deletions(-)
 create mode 100644 meta/classes/gummiboot.bbclass
 create mode 100644 meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make-archives.patch
 create mode 100644 meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make.patch
 create mode 100644 meta/recipes-bsp/gnu-efi/gnu-efi_3.0u.bb
 create mode 100644 meta/recipes-bsp/gummiboot/gummiboot_git.bb
Signature · 1 line
1.8.5.3
#1 lore raw

PATCH 1/3 recipes-bsp: Add gummiboot and gnu-efi recipes

gummiboot is is a simple UEFI boot manager (not a boot loader ;-) )

These recipes are imported from meta-intel with these changes:
- drop PR and update configure options
- gummiboot was upgraded to latest version

A couple of notes:
- If you wish you can install the gummiboot package on the target and
use 'gummiboot install' to add the payload to the ESP (see gummiboot --help, just make sure the ESP partition has the boot flag on as gummiboot won't accept it otherwise). However the point of this recipe is to be used by bootimg.bbclass and generate images with gummiboot instead of grub-efi.
- You need a kernel which has CONFIG_EFI_STUB=y at least
- The default linux-yocto kernel config does not enable that, easiest way
to enable is to build with KERNEL_FEATURES_append = " cfg/efi-ext" in local.conf

---
 .../gnu-efi/gnu-efi/parallel-make-archives.patch   | 48 ++++++++++++++++++++++
 .../gnu-efi/gnu-efi/parallel-make.patch            | 22 ++++++++++
 meta/recipes-bsp/gnu-efi/gnu-efi_3.0u.bb           | 33 +++++++++++++++
 meta/recipes-bsp/gummiboot/gummiboot_git.bb        | 25 +++++++++++
 4 files changed, 128 insertions(+)
 create mode 100644 meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make-archives.patch
 create mode 100644 meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make.patch
 create mode 100644 meta/recipes-bsp/gnu-efi/gnu-efi_3.0u.bb
 create mode 100644 meta/recipes-bsp/gummiboot/gummiboot_git.bb
meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make-archives.patch new file +48 -0
new file mode 100644
index 0000000..e5b47c1
@@ -0,0 +1,48 @@
+Fix parallel make failure for archives
+
+Upstream-Status: Pending
+
+The lib and gnuefi makefiles were using the lib.a() form which compiles
+and ar's as a pair instead of compiling all and then ar'ing which can
+parallelize better. This was resulting in build failures on larger values
+of -j.
+
+See http://www.chemie.fu-berlin.de/chemnet/use/info/make/make_toc.html#TOC105
+for details.
+
+Signed-off-by: Saul Wold <[email protected]>
+Signed-off-by: Darren Hart <[email protected]>
+---
+---
+ gnuefi/Makefile |    3 ++-
+ lib/Makefile    |    3 ++-
+ 2 files changed, 4 insertions(+), 2 deletions(-)
+
+Index: gnu-efi-3.0/lib/Makefile
+===================================================================
+--- gnu-efi-3.0.orig/lib/Makefile
++++ gnu-efi-3.0/lib/Makefile
+@@ -66,7 +66,8 @@ all: libsubdirs libefi.a
+ libsubdirs:
+ 	for sdir in $(SUBDIRS); do mkdir -p $$sdir; done
+ 
+-libefi.a: $(patsubst %,libefi.a(%),$(OBJS))
++libefi.a: $(OBJS)
++	$(AR) rv $@ $(OBJS)
+ 
+ clean:
+ 	rm -f libefi.a *~ $(OBJS) */*.o
+Index: gnu-efi-3.0/gnuefi/Makefile
+===================================================================
+--- gnu-efi-3.0.orig/gnuefi/Makefile
++++ gnu-efi-3.0/gnuefi/Makefile
+@@ -51,7 +51,8 @@ TARGETS	= crt0-efi-$(ARCH).o libgnuefi.a
+ 
+ all:	$(TARGETS)
+ 
+-libgnuefi.a: $(patsubst %,libgnuefi.a(%),$(OBJS))
++libgnuefi.a: $(OBJS)
++	$(AR) rv $@ $(OBJS)
+ 
+ clean:
+ 	rm -f $(TARGETS) *~ *.o $(OBJS)
meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make.patch new file +22 -0
new file mode 100644
index 0000000..27c94e8
@@ -0,0 +1,22 @@
+Fix parallel make failure
+
+Upstream-Status: Submitted [Maintainer directly]
+
+Add a missing dependency which resulted in a race leading to failure
+on larger values of -j.
+
+Signed-off-by: Darren Hart <[email protected]>
+
+Index: gnu-efi-3.0/Makefile
+===================================================================
+--- gnu-efi-3.0.orig/Makefile
++++ gnu-efi-3.0/Makefile
+@@ -42,6 +42,8 @@ include $(SRCDIR)/Make.defaults
+ 
+ SUBDIRS = lib gnuefi inc apps
+ 
++gnuefi: lib
++
+ all:	check_gcc $(SUBDIRS)
+ 
+ $(SUBDIRS):
meta/recipes-bsp/gnu-efi/gnu-efi_3.0u.bb new file +33 -0
new file mode 100644
index 0000000..0dbdba2
@@ -0,0 +1,33 @@
+SUMMARY = "Libraries for producing EFI binaries"
+HOMEPAGE = "http://sourceforge.net/projects/gnu-efi/"
+SECTION = "devel"
+LICENSE = "GPLv2+"
+LIC_FILES_CHKSUM = "file://debian/copyright;md5=5fb358a180f484b285b0d99acdc29666"
+
+SRC_URI = "http://downloads.sourceforge.net/gnu-efi/gnu-efi_3.0u.orig.tar.gz \
+           file://parallel-make.patch \
+           file://parallel-make-archives.patch \
+          "
+SRC_URI[md5sum] = "d15d3c700e79a1e2938544d73edc572d"
+SRC_URI[sha256sum] = "3c0d450d5829204ca05dcb3b2aae772e52c379b7c7e09146759c6315606f934e"
+
+COMPATIBLE_HOST = "(x86_64.*|i.86.*)-linux"
+
+S = "${WORKDIR}/gnu-efi-3.0"
+
+def gnu_efi_arch(d):
+    import re
+    tarch = d.getVar("TARGET_ARCH", True)
+    if re.match("i[3456789]86", tarch):
+        return "ia32"
+    return tarch
+
+EXTRA_OEMAKE = "'ARCH=${@gnu_efi_arch(d)}' 'CC=${CC}' 'AS=${AS}' 'LD=${LD}' 'AR=${AR}' \
+                'RANLIB=${RANLIB}' 'OBJCOPY=${OBJCOPY}' 'PREFIX=${prefix}'\
+                "
+
+do_install() {
+        oe_runmake install INSTALLROOT="${D}"
+}
+
+FILES_${PN} += "${libdir}/*.lds"
meta/recipes-bsp/gummiboot/gummiboot_git.bb new file +25 -0
new file mode 100644
index 0000000..b55064f
@@ -0,0 +1,25 @@
+SUMMARY = "Gummiboot is a simple UEFI boot manager which executes configured EFI images."
+HOMEPAGE = "http://freedesktop.org/wiki/Software/gummiboot"
+
+LICENSE = "LGPLv2.1"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=4fbd65380cdd255951079008b364516c"
+
+DEPENDS = "gnu-efi util-linux"
+
+inherit autotools
+inherit deploy
+
+PV = "43+git${SRCPV}"
+SRCREV = "4062c51075ba054d4949c714fe06123f9ad3097d"
+SRC_URI = "git://anongit.freedesktop.org/gummiboot"
+
+S = "${WORKDIR}/git"
+
+EXTRA_OECONF = "--disable-manpages --with-efi-includedir=${STAGING_INCDIR} \
+                --with-efi-ldsdir=${STAGING_LIBDIR} \
+                --with-efi-libdir=${STAGING_LIBDIR}"
+
+do_deploy () {
+        install ${S}/gummiboot*.efi ${DEPLOYDIR}/
+}
+addtask deploy before do_build after do_compile
Signature · 1 line
1.8.5.3
#5 lore raw

PATCH 2/3 bootimg/grub-efi.bbclass: allow using a different class for EFI images

In reply to Stefan Stanacar

Abstract away some names so one can select using EFI_PROVIDER a different class than grub-efi for populating live images, basically allowing the use of a different bootloader than grub-efi.

---
 meta/classes/boot-directdisk.bbclass | 7 ++++---
 meta/classes/bootimg.bbclass         | 9 +++++----
 meta/classes/grub-efi.bbclass        | 6 ++++++
 3 files changed, 15 insertions(+), 7 deletions(-)
meta/classes/boot-directdisk.bbclass +4 -3
index 42b3415..c35b4bb 100644
@@ -32,7 +32,8 @@ BOOTDD_VOLUME_ID   ?= "boot"
 BOOTDD_EXTRA_SPACE ?= "16384"
 
 EFI = "${@base_contains("MACHINE_FEATURES", "efi", "1", "0", d)}"
-EFI_CLASS = "${@base_contains("MACHINE_FEATURES", "efi", "grub-efi", "", d)}"
+EFI_PROVIDER ?= "grub-efi"
+EFI_CLASS = "${@base_contains("MACHINE_FEATURES", "efi", "${EFI_PROVIDER}", "", d)}"
 
 # Include legacy boot if MACHINE_FEATURES includes "pcbios" or if it does not
 # contain "efi". This way legacy is supported by default if neither is
@@ -87,7 +88,7 @@ build_boot_dd() {
 		syslinux_hddimg_populate $HDDDIR
 	fi
 	if [ "${EFI}" = "1" ]; then
-		grubefi_hddimg_populate $HDDDIR
+		${EFICLASS_FUNC_PREFIX}_hddimg_populate $HDDDIR
 	fi
 
 	if [ "${IS_VMDK}" = "true" ]; then
@@ -154,7 +155,7 @@ python do_bootdirectdisk() {
     if d.getVar("PCBIOS", True) == "1":
         bb.build.exec_func('build_syslinux_cfg', d)
     if d.getVar("EFI", True) == "1":
-        bb.build.exec_func('build_grub_cfg', d)
+        bb.build.exec_func('build_efi_cfg', d)
     bb.build.exec_func('build_boot_dd', d)
 }
 
meta/classes/bootimg.bbclass +5 -4
index c370bd6..f8cfd37 100644
@@ -42,7 +42,8 @@ BOOTIMG_VOLUME_ID   ?= "boot"
 BOOTIMG_EXTRA_SPACE ?= "512"
 
 EFI = "${@base_contains("MACHINE_FEATURES", "efi", "1", "0", d)}"
-EFI_CLASS = "${@base_contains("MACHINE_FEATURES", "efi", "grub-efi", "", d)}"
+EFI_PROVIDER ?= "grub-efi"
+EFI_CLASS = "${@base_contains("MACHINE_FEATURES", "efi", "${EFI_PROVIDER}", "", d)}"
 
 # Include legacy boot if MACHINE_FEATURES includes "pcbios" or if it does not
 # contain "efi". This way legacy is supported by default if neither is
@@ -89,7 +90,7 @@ build_iso() {
 		syslinux_iso_populate ${ISODIR}
 	fi
 	if [ "${EFI}" = "1" ]; then
-		grubefi_iso_populate ${ISODIR}
+		${EFICLASS_FUNC_PREFIX}_iso_populate ${ISODIR}
 		build_fat_img ${EFIIMGDIR} ${ISODIR}/efi.img
 	fi
 
@@ -206,7 +207,7 @@ build_hddimg() {
 			syslinux_hddimg_populate ${HDDDIR}
 		fi
 		if [ "${EFI}" = "1" ]; then
-			grubefi_hddimg_populate ${HDDDIR}
+			${EFICLASS_FUNC_PREFIX}_hddimg_populate ${HDDDIR}
 		fi
 
 		build_fat_img ${HDDDIR} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hddimg
@@ -227,7 +228,7 @@ python do_bootimg() {
     if d.getVar("PCBIOS", True) == "1":
         bb.build.exec_func('build_syslinux_cfg', d)
     if d.getVar("EFI", True) == "1":
-        bb.build.exec_func('build_grub_cfg', d)
+        bb.build.exec_func('build_efi_cfg', d)
     bb.build.exec_func('build_hddimg', d)
     bb.build.exec_func('build_iso', d)
 }
meta/classes/grub-efi.bbclass +6 -0
index 71bd00f..f7fe8d8 100644
@@ -15,6 +15,8 @@
 # ${GRUB_OPTS} - additional options to add to the config, ';' delimited # (optional)
 # ${GRUB_TIMEOUT} - timeout before executing the deault label (optional)
 
+EFICLASS_FUNC_PREFIX = "grubefi"
+
 do_bootimg[depends] += "grub-efi:do_deploy"
 do_bootdirectdisk[depends] += "grub-efi:do_deploy"
 
@@ -139,3 +141,7 @@ python build_grub_cfg() {
 
     cfgfile.close()
 }
+
+python build_efi_cfg() {
+    bb.build.exec_func("build_grub_cfg", d)
+}
Signature · 1 line
1.8.5.3
#7 lore raw

PATCH 3/3 classes: Add gummiboot class

In reply to Stefan Stanacar

Adds a gummiboot class similar to grub-efi class and makes the necessary changes so it can be used for live/hddimg images as well.

One can set EFI_PROVIDER = "gummiboot" in local.conf to use gummiboot instead of grub-efi. Gummiboot requires some kernel options that are not enabled by default, so one has to build with KERNEL_FEATURES_append = " cfg/efi-ext".

The install scripts have been updated too, keeping the old behaviour around,
but accounting for the new boot loader config files (if they exist).
It can be argued that the installer and bootimg are a bit wierd and not necessarily correct, but I wanted to have the exact same behviour with gummiboot.
With the default EFI_PROVIDER = "grub-efi" nothing changes, everthing should be just as before.

I've tested live boot, install and normal boot on:
- FRI2
- genericx86-64 on NUC
with:
EFI_PROVIDER = "gummiboot" KERNEL_FEATURES_append = " cfg/efi-ext"
in local.conf.

---
 meta/classes/gummiboot.bbclass                     | 112 +++++++++++++++++++++
 .../initrdscripts/files/init-install-efi.sh        |  51 +++++++---
 2 files changed, 147 insertions(+), 16 deletions(-)
 create mode 100644 meta/classes/gummiboot.bbclass
meta/classes/gummiboot.bbclass new file +112 -0
new file mode 100644
index 0000000..5c11286
@@ -0,0 +1,112 @@
+EFICLASS_FUNC_PREFIX = "gummiboot"
+
+do_bootimg[depends] += "gummiboot:do_deploy"
+do_bootdirectdisk[depends] += "gummiboot:do_deploy"
+
+EFIDIR = "/EFI/BOOT"
+
+GUMMIBOOT_CFG ?= "${S}/loader.conf"
+GUMMIBOOT_ENTRIES ?= ""
+GUMMIBOOT_TIMEOUT ?= "10"
+
+gummiboot_populate() {
+        DEST=$1
+
+        EFI_IMAGE="gummibootia32.efi"
+        DEST_EFI_IMAGE="bootia32.efi"
+        if [ "${TARGET_ARCH}" = "x86_64" ]; then
+            EFI_IMAGE="gummibootx64.efi"
+            DEST_EFI_IMAGE="bootx64.efi"
+        fi
+
+        install -d ${DEST}${EFIDIR}
+        # gummiboot requires these paths for configuration files
+        # they are not customizable so no point in new vars
+        install -d ${DEST}/loader
+        install -d ${DEST}/loader/entries
+        install -m 0644 ${DEPLOY_DIR_IMAGE}/${EFI_IMAGE} ${DEST}${EFIDIR}/${DEST_EFI_IMAGE}
+        install -m 0644 ${GUMMIBOOT_CFG} ${DEST}/loader/loader.conf
+        for i in ${GUMMIBOOT_ENTRIES}; do
+            install -m 0644 ${i} ${DEST}/loader/entries
+        done
+}
+
+gummiboot_iso_populate() {
+        iso_dir=$1
+        gummiboot_populate $iso_dir
+        mkdir -p ${EFIIMGDIR}/${EFIDIR}
+        cp $iso_dir/${EFIDIR}/* ${EFIIMGDIR}${EFIDIR}
+        cp $iso_dir/vmlinuz ${EFIIMGDIR}
+        echo "${DEST_EFI_IMAGE}" > ${EFIIMGDIR}/startup.nsh
+        if [ -f "$iso_dir/initrd" ] ; then
+            cp $iso_dir/initrd ${EFIIMGDIR}
+        fi
+}
+
+gummiboot_hddimg_populate() {
+        gummiboot_populate $1
+}
+
+python build_gummiboot_cfg() {
+    s = d.getVar("S", True)
+    labels = d.getVar('LABELS', True)
+    if not labels:
+        bb.debug(1, "LABELS not defined, nothing to do")
+        return
+
+    if labels == []:
+        bb.debug(1, "No labels, nothing to do")
+        return
+
+    cfile = d.getVar('GUMMIBOOT_CFG', True)
+    try:
+         cfgfile = open(cfile, 'w')
+    except OSError:
+        raise bb.build.funcFailed('Unable to open %s' % (cfile))
+
+    cfgfile.write('# Automatically created by OE\n')
+    cfgfile.write('default %s\n' % (labels.split()[0]))
+    timeout = d.getVar('GUMMIBOOT_TIMEOUT', True)
+    if timeout:
+        cfgfile.write('timeout %s\n' % timeout)
+    else:
+        cfgfile.write('timeout 10\n')
+    cfgfile.close()
+
+    for label in labels.split():
+        localdata = d.createCopy()
+
+        overrides = localdata.getVar('OVERRIDES', True)
+        if not overrides:
+            raise bb.build.FuncFailed('OVERRIDES not defined')
+
+        entryfile = "%s/%s.conf" % (s, label)
+        d.appendVar("GUMMIBOOT_ENTRIES", " " + entryfile)
+        try:
+            entrycfg = open(entryfile, "w")
+        except OSError:
+            raise bb.build.funcFailed('Unable to open %s' % (entryfile))
+        localdata.setVar('OVERRIDES', label + ':' + overrides)
+        bb.data.update_data(localdata)
+
+        entrycfg.write('title %s\n' % label)
+        entrycfg.write('linux /vmlinuz\n')
+
+        append = localdata.getVar('APPEND', True)
+        initrd = localdata.getVar('INITRD', True)
+
+        if initrd:
+            entrycfg.write('initrd /initrd\n')
+        lb = label
+        if label == "install":
+            lb = "install-efi"
+        entrycfg.write('options LABEL=%s ' % lb)
+        if append:
+            entrycfg.write('%s' % append)
+        entrycfg.write('\n')
+        entrycfg.close()
+}
+
+python build_efi_cfg() {
+    bb.build.exec_func("build_gummiboot_cfg", d)
+}
meta/recipes-core/initrdscripts/files/init-install-efi.sh +35 -16

64 lines not on this page · raw message

Signature · 1 line
1.8.5.3
Acked-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] recipes-bsp: Add gummiboot and gnu-efi recipes

In reply to Stefan Stanacar
Quoted 20 lines · Stefan Stanacar

gummiboot is is a simple UEFI boot manager (not a boot loader ;-) )

These recipes are imported from meta-intel with these changes:
- drop PR and update configure options
- gummiboot was upgraded to latest version

A couple of notes:
- If you wish you can install the gummiboot package on the target and use 'gummiboot install' to add the payload to the ESP (see gummiboot --help,
just make sure the ESP partition has the boot flag on as gummiboot won't accept it
otherwise). However the point of this recipe is to be used by bootimg.bbclass and
generate images with gummiboot instead of grub-efi.
- You need a kernel which has CONFIG_EFI_STUB=y at least
- The default linux-yocto kernel config does not enable that, easiest way to enable is to build with KERNEL_FEATURES_append = " cfg/efi-ext" in local.conf

Quoted 1 line

I don't know if Saul or RP would prefer gnu-efi and gummiboot to arrive as separate patches, probably a good idea. But in general, I agree with this direction:

Note: Added Koen on Cc, as he happens to also have been working on something similar in his "spare" time.

Quoted 182 lines

---
.../gnu-efi/gnu-efi/parallel-make-archives.patch | 48
++++++++++++++++++++++

.../gnu-efi/gnu-efi/parallel-make.patch            | 22 ++++++++++
meta/recipes-bsp/gnu-efi/gnu-efi_3.0u.bb           | 33 +++++++++++++++
meta/recipes-bsp/gummiboot/gummiboot_git.bb        | 25 +++++++++++
4 files changed, 128 insertions(+)

create mode 100644 meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make-archives.patch create mode 100644 meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make.patch create mode 100644 meta/recipes-bsp/gnu-efi/gnu-efi_3.0u.bb create mode 100644 meta/recipes-bsp/gummiboot/gummiboot_git.bb

(quoted diff) +0 -0

a/meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make-archives.patch b/meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make-archives.patch new file mode 100644
index 0000000..e5b47c1

meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make-archives.patch new file +10 -0
@@ -0,0 +1,48 @@
+Fix parallel make failure for archives
+
+Upstream-Status: Pending
+
+The lib and gnuefi makefiles were using the lib.a() form which compiles
+and ar's as a pair instead of compiling all and then ar'ing which can
+parallelize better. This was resulting in build failures on larger values
+of -j.
+
+See 

http://www.chemie.fu-berlin.de/chemnet/use/info/make/make_toc.html#TOC105

meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make-archives.patch new file +38 -0
+for details.
+
+Signed-off-by: Saul Wold <[email protected]>
+Signed-off-by: Darren Hart <[email protected]>
+---
+---
+ gnuefi/Makefile |    3 ++-
+ lib/Makefile    |    3 ++-
+ 2 files changed, 4 insertions(+), 2 deletions(-)
+
+Index: gnu-efi-3.0/lib/Makefile
+===================================================================
+--- gnu-efi-3.0.orig/lib/Makefile
++++ gnu-efi-3.0/lib/Makefile
+@@ -66,7 +66,8 @@ all: libsubdirs libefi.a
+ libsubdirs:
+ 	for sdir in $(SUBDIRS); do mkdir -p $$sdir; done
+ 
+-libefi.a: $(patsubst %,libefi.a(%),$(OBJS))
++libefi.a: $(OBJS)
++	$(AR) rv $@ $(OBJS)
+ 
+ clean:
+ 	rm -f libefi.a *~ $(OBJS) */*.o
+Index: gnu-efi-3.0/gnuefi/Makefile
+===================================================================
+--- gnu-efi-3.0.orig/gnuefi/Makefile
++++ gnu-efi-3.0/gnuefi/Makefile
+@@ -51,7 +51,8 @@ TARGETS	= crt0-efi-$(ARCH).o libgnuefi.a
+ 
+ all:	$(TARGETS)
+ 
+-libgnuefi.a: $(patsubst %,libgnuefi.a(%),$(OBJS))
++libgnuefi.a: $(OBJS)
++	$(AR) rv $@ $(OBJS)
+ 
+ clean:
+ 	rm -f $(TARGETS) *~ *.o $(OBJS)
meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make.patch new file +22 -0
new file mode 100644
index 0000000..27c94e8
@@ -0,0 +1,22 @@
+Fix parallel make failure
+
+Upstream-Status: Submitted [Maintainer directly]
+
+Add a missing dependency which resulted in a race leading to failure
+on larger values of -j.
+
+Signed-off-by: Darren Hart <[email protected]>
+
+Index: gnu-efi-3.0/Makefile
+===================================================================
+--- gnu-efi-3.0.orig/Makefile
++++ gnu-efi-3.0/Makefile
+@@ -42,6 +42,8 @@ include $(SRCDIR)/Make.defaults
+ 
+ SUBDIRS = lib gnuefi inc apps
+ 
++gnuefi: lib
++
+ all:	check_gcc $(SUBDIRS)
+ 
+ $(SUBDIRS):
meta/recipes-bsp/gnu-efi/gnu-efi_3.0u.bb new file +5 -0
new file mode 100644
index 0000000..0dbdba2
@@ -0,0 +1,33 @@
+SUMMARY = "Libraries for producing EFI binaries"
+HOMEPAGE = "http://sourceforge.net/projects/gnu-efi/"
+SECTION = "devel"
+LICENSE = "GPLv2+"
+LIC_FILES_CHKSUM =

"file://debian/copyright;md5=5fb358a180f484b285b0d99acdc29666"

meta/recipes-bsp/gnu-efi/gnu-efi_3.0u.bb new file +2 -0
+
+SRC_URI = 

"http://downloads.sourceforge.net/gnu-efi/gnu-efi_3.0u.orig.tar.gz \

meta/recipes-bsp/gnu-efi/gnu-efi_3.0u.bb new file +5 -0
+           file://parallel-make.patch \
+           file://parallel-make-archives.patch \
+          "
+SRC_URI[md5sum] = "d15d3c700e79a1e2938544d73edc572d"
+SRC_URI[sha256sum] =

"3c0d450d5829204ca05dcb3b2aae772e52c379b7c7e09146759c6315606f934e"

meta/recipes-bsp/gnu-efi/gnu-efi_3.0u.bb new file +13 -0
+
+COMPATIBLE_HOST = "(x86_64.*|i.86.*)-linux"
+
+S = "${WORKDIR}/gnu-efi-3.0"
+
+def gnu_efi_arch(d):
+    import re
+    tarch = d.getVar("TARGET_ARCH", True)
+    if re.match("i[3456789]86", tarch):
+        return "ia32"
+    return tarch
+
+EXTRA_OEMAKE = "'ARCH=${@gnu_efi_arch(d)}' 'CC=${CC}' 'AS=${AS}'

'LD=${LD}' 'AR=${AR}' \
+ 'RANLIB=${RANLIB}' 'OBJCOPY=${OBJCOPY}'
'PREFIX=${prefix}'\

meta/recipes-bsp/gnu-efi/gnu-efi_3.0u.bb new file +7 -0
+                "
+
+do_install() {
+        oe_runmake install INSTALLROOT="${D}"
+}
+
+FILES_${PN} += "${libdir}/*.lds"
meta/recipes-bsp/gummiboot/gummiboot_git.bb new file +1 -0
new file mode 100644
index 0000000..b55064f
@@ -0,0 +1,25 @@
+SUMMARY = "Gummiboot is a simple UEFI boot manager which executes

configured EFI images."

meta/recipes-bsp/gummiboot/gummiboot_git.bb new file +24 -1
+HOMEPAGE = "http://freedesktop.org/wiki/Software/gummiboot"
+
+LICENSE = "LGPLv2.1"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=4fbd65380cdd255951079008b364516c"
+
+DEPENDS = "gnu-efi util-linux"
+
+inherit autotools
+inherit deploy
+
+PV = "43+git${SRCPV}"
+SRCREV = "4062c51075ba054d4949c714fe06123f9ad3097d"
+SRC_URI = "git://anongit.freedesktop.org/gummiboot"
+
+S = "${WORKDIR}/git"
+
+EXTRA_OECONF = "--disable-manpages
--with-efi-includedir=${STAGING_INCDIR} \
+                --with-efi-ldsdir=${STAGING_LIBDIR} \
+                --with-efi-libdir=${STAGING_LIBDIR}"
+
+do_deploy () {
+        install ${S}/gummiboot*.efi ${DEPLOYDIR}/
+}
+addtask deploy before do_build after do_compile
Signature · 1 line
1.8.5.3
Signature · 3 lines
Darren Hart
Yocto Project - Linux Kernel
Intel Open Source Technology Center
#6 lore raw

Re: [PATCH 2/3] bootimg/grub-efi.bbclass: allow using a different class for EFI images

In reply to Stefan Stanacar
Quoted 30 lines · Stefan Stanacar

Abstract away some names so one can select using EFI_PROVIDER a different class than grub-efi for populating live images, basically allowing the use of a different bootloader than grub-efi.

---

meta/classes/boot-directdisk.bbclass | 7 ++++---
meta/classes/bootimg.bbclass         | 9 +++++----
meta/classes/grub-efi.bbclass        | 6 ++++++
3 files changed, 15 insertions(+), 7 deletions(-)
meta/classes/boot-directdisk.bbclass +0 -0
index 42b3415..c35b4bb 100644
@@ -32,7 +32,8 @@ BOOTDD_VOLUME_ID   ?= "boot"

BOOTDD_EXTRA_SPACE ?= "16384"

EFI = "${@base_contains("MACHINE_FEATURES", "efi", "1", "0", d)}" -EFI_CLASS = "${@base_contains("MACHINE_FEATURES", "efi", "grub-efi", "", d)}"

meta/classes/boot-directdisk.bbclass +2 -0
+EFI_PROVIDER ?= "grub-efi"
+EFI_CLASS = "${@base_contains("MACHINE_FEATURES", "efi",

"${EFI_PROVIDER}", "", d)}"

# Include legacy boot if MACHINE_FEATURES includes "pcbios" or if it does not

# contain "efi". This way legacy is supported by default if neither is

meta/classes/boot-directdisk.bbclass build_boot_dd() { · line 91

Quoted 5 lines
meta/classes/boot-directdisk.bbclass +1 -1
@@ -87,7 +88,7 @@ build_boot_dd() {
 		syslinux_hddimg_populate $HDDDIR
 	fi
 	if [ "${EFI}" = "1" ]; then
-		grubefi_hddimg_populate $HDDDIR
+		${EFICLASS_FUNC_PREFIX}_hddimg_populate $HDDDIR

This seems like an odd way to call a function, via a constructed function name. Would it make more sense to define an efi interface and only one bbclass that implemented that interface? Such as grub-efi.bbclass or gummiboot.bbclass?

This isn't my area of expertise, maybe some recipe/bitbake experts can weigh in here...

Signature · 3 lines
Darren Hart
Yocto Project - Linux Kernel
Intel Open Source Technology Center
#8 lore raw

Re: [PATCH 3/3] classes: Add gummiboot class

In reply to Stefan Stanacar
Quoted 8 lines · Stefan Stanacar

Adds a gummiboot class similar to grub-efi class and makes the necessary changes so it can be used for live/hddimg images as well.

One can set EFI_PROVIDER = "gummiboot" in local.conf to use gummiboot instead of grub-efi.
Gummiboot requires some kernel options that are not enabled by default, so one has to build
with KERNEL_FEATURES_append = " cfg/efi-ext".

cfg/efi is insufficient?

Quoted 18 lines

The install scripts have been updated too, keeping the old behaviour around,
but accounting for the new boot loader config files (if they exist). It can be argued that the installer and bootimg are a bit wierd and not necessarily correct,
but I wanted to have the exact same behviour with gummiboot. With the default EFI_PROVIDER = "grub-efi" nothing changes, everthing should be just as before.

I've tested live boot, install and normal boot on:
- FRI2
- genericx86-64 on NUC
with:
EFI_PROVIDER = "gummiboot" KERNEL_FEATURES_append = " cfg/efi-ext"
in local.conf.

Quoted 1 line

Generally looks good. My only reservation is the same as for 2/3, should we define an EFI interface rather than having to construct function names in the consumers of this class?

--
Darren

Quoted 205 lines

---
meta/classes/gummiboot.bbclass | 112
+++++++++++++++++++++
.../initrdscripts/files/init-install-efi.sh | 51 +++++++---

2 files changed, 147 insertions(+), 16 deletions(-)

create mode 100644 meta/classes/gummiboot.bbclass

meta/classes/gummiboot.bbclass new file +27 -0
new file mode 100644
index 0000000..5c11286
@@ -0,0 +1,112 @@
+EFICLASS_FUNC_PREFIX = "gummiboot"
+
+do_bootimg[depends] += "gummiboot:do_deploy"
+do_bootdirectdisk[depends] += "gummiboot:do_deploy"
+
+EFIDIR = "/EFI/BOOT"
+
+GUMMIBOOT_CFG ?= "${S}/loader.conf"
+GUMMIBOOT_ENTRIES ?= ""
+GUMMIBOOT_TIMEOUT ?= "10"
+
+gummiboot_populate() {
+        DEST=$1
+
+        EFI_IMAGE="gummibootia32.efi"
+        DEST_EFI_IMAGE="bootia32.efi"
+        if [ "${TARGET_ARCH}" = "x86_64" ]; then
+            EFI_IMAGE="gummibootx64.efi"
+            DEST_EFI_IMAGE="bootx64.efi"
+        fi
+
+        install -d ${DEST}${EFIDIR}
+        # gummiboot requires these paths for configuration files
+        # they are not customizable so no point in new vars
+        install -d ${DEST}/loader
+        install -d ${DEST}/loader/entries
+        install -m 0644 ${DEPLOY_DIR_IMAGE}/${EFI_IMAGE}

${DEST}${EFIDIR}/${DEST_EFI_IMAGE}

meta/classes/gummiboot.bbclass new file +85 -0
+        install -m 0644 ${GUMMIBOOT_CFG} ${DEST}/loader/loader.conf
+        for i in ${GUMMIBOOT_ENTRIES}; do
+            install -m 0644 ${i} ${DEST}/loader/entries
+        done
+}
+
+gummiboot_iso_populate() {
+        iso_dir=$1
+        gummiboot_populate $iso_dir
+        mkdir -p ${EFIIMGDIR}/${EFIDIR}
+        cp $iso_dir/${EFIDIR}/* ${EFIIMGDIR}${EFIDIR}
+        cp $iso_dir/vmlinuz ${EFIIMGDIR}
+        echo "${DEST_EFI_IMAGE}" > ${EFIIMGDIR}/startup.nsh
+        if [ -f "$iso_dir/initrd" ] ; then
+            cp $iso_dir/initrd ${EFIIMGDIR}
+        fi
+}
+
+gummiboot_hddimg_populate() {
+        gummiboot_populate $1
+}
+
+python build_gummiboot_cfg() {
+    s = d.getVar("S", True)
+    labels = d.getVar('LABELS', True)
+    if not labels:
+        bb.debug(1, "LABELS not defined, nothing to do")
+        return
+
+    if labels == []:
+        bb.debug(1, "No labels, nothing to do")
+        return
+
+    cfile = d.getVar('GUMMIBOOT_CFG', True)
+    try:
+         cfgfile = open(cfile, 'w')
+    except OSError:
+        raise bb.build.funcFailed('Unable to open %s' % (cfile))
+
+    cfgfile.write('# Automatically created by OE\n')
+    cfgfile.write('default %s\n' % (labels.split()[0]))
+    timeout = d.getVar('GUMMIBOOT_TIMEOUT', True)
+    if timeout:
+        cfgfile.write('timeout %s\n' % timeout)
+    else:
+        cfgfile.write('timeout 10\n')
+    cfgfile.close()
+
+    for label in labels.split():
+        localdata = d.createCopy()
+
+        overrides = localdata.getVar('OVERRIDES', True)
+        if not overrides:
+            raise bb.build.FuncFailed('OVERRIDES not defined')
+
+        entryfile = "%s/%s.conf" % (s, label)
+        d.appendVar("GUMMIBOOT_ENTRIES", " " + entryfile)
+        try:
+            entrycfg = open(entryfile, "w")
+        except OSError:
+            raise bb.build.funcFailed('Unable to open %s' % (entryfile))
+        localdata.setVar('OVERRIDES', label + ':' + overrides)
+        bb.data.update_data(localdata)
+
+        entrycfg.write('title %s\n' % label)
+        entrycfg.write('linux /vmlinuz\n')
+
+        append = localdata.getVar('APPEND', True)
+        initrd = localdata.getVar('INITRD', True)
+
+        if initrd:
+            entrycfg.write('initrd /initrd\n')
+        lb = label
+        if label == "install":
+            lb = "install-efi"
+        entrycfg.write('options LABEL=%s ' % lb)
+        if append:
+            entrycfg.write('%s' % append)
+        entrycfg.write('\n')
+        entrycfg.close()
+}
+
+python build_efi_cfg() {
+    bb.build.exec_func("build_gummiboot_cfg", d)
+}
meta/recipes-core/initrdscripts/files/init-install-efi.sh +0 -0
index 9846637..ed3221b 100644
@@ -104,6 +104,7 @@ parted /dev/${device} mklabel gpt
 

echo "Creating boot partition on $bootfs" parted /dev/${device} mkpart primary 0% $boot_size +parted /dev/${device} set 1 boot on

echo "Creating rootfs partition on $rootfs"
parted /dev/${device} mkpart primary $rootfs_start $rootfs_end

meta/recipes-core/initrdscripts/files/init-install-efi.sh +0 -0
@@ -149,23 +150,41 @@ mount $bootfs /ssd
 

EFIDIR="/ssd/EFI/BOOT"
mkdir -p $EFIDIR

meta/recipes-core/initrdscripts/files/init-install-efi.sh +0 -2
-GRUBCFG="$EFIDIR/grub.cfg"
-

cp /media/$1/vmlinuz /ssd

meta/recipes-core/initrdscripts/files/init-install-efi.sh +0 -14
-# Copy the efi loader and config (booti*.efi and grub.cfg)
-cp /media/$1/EFI/BOOT/* $EFIDIR
-
-# Update grub config for the installed image
-# Delete the install entry
-sed -i "/menuentry 'install'/,/^}/d" $GRUBCFG
-# Delete the initrd lines
-sed -i "/initrd /d" $GRUBCFG
-# Delete any LABEL= strings
-sed -i "s/ LABEL=[^ ]*/ /" $GRUBCFG
-# Delete any root= strings
-sed -i "s/ root=[^ ]*/ /" $GRUBCFG
-# Add the root= and other standard boot options
-sed -i "s@linux /vmlinuz *@linux /vmlinuz root=$rootfs rw $rootwait

quiet @" $GRUBCFG

meta/recipes-core/initrdscripts/files/init-install-efi.sh +17 -0
+# Copy the efi loader
+cp /media/$1/EFI/BOOT/*.efi $EFIDIR
+
+if [ -f /media/$1/EFI/BOOT/grub.cfg ]; then
+    GRUBCFG="$EFIDIR/grub.cfg"
+    cp /media/$1/EFI/BOOT/grub.cfg $GRUBCFG
+    # Update grub config for the installed image
+    # Delete the install entry
+    sed -i "/menuentry 'install'/,/^}/d" $GRUBCFG
+    # Delete the initrd lines
+    sed -i "/initrd /d" $GRUBCFG
+    # Delete any LABEL= strings
+    sed -i "s/ LABEL=[^ ]*/ /" $GRUBCFG
+    # Delete any root= strings
+    sed -i "s/ root=[^ ]*/ /" $GRUBCFG
+    # Add the root= and other standard boot options
+    sed -i "s@linux /vmlinuz *@linux /vmlinuz root=$rootfs rw $rootwait

quiet @" $GRUBCFG

meta/recipes-core/initrdscripts/files/init-install-efi.sh +16 -0
+fi
+
+if [ -d /media/$1/loader ]; then
+    GUMMIBOOT_CFGS="/ssd/loader/entries/*.conf"
+    # copy config files for gummiboot
+    cp -dr /media/$1/loader /ssd
+    # delete the install entry
+    rm -f /ssd/loader/entries/install.conf
+    # delete the initrd lines
+    sed -i "/initrd /d" $GUMMIBOOT_CFGS
+    # delete any LABEL= strings
+    sed -i "s/ LABEL=[^ ]*/ /" $GUMMIBOOT_CFGS
+    # delete any root= strings
+    sed -i "s/ root=[^ ]*/ /" $GUMMIBOOT_CFGS
+    # add the root= and other standard boot options
+    sed -i "s@options *@options root=$rootfs rw $rootwait quiet @"

$GUMMIBOOT_CFGS
+fi

umount /ssd
sync

Signature · 1 line
1.8.5.3
Signature · 3 lines
Darren Hart
Yocto Project - Linux Kernel
Intel Open Source Technology Center
#9 lore raw

Re: [PATCH 3/3] classes: Add gummiboot class

Quoted 5 lines · Darren Hart
Quoted 3 lines · Stefan Stanacar

Adds a gummiboot class similar to grub-efi class and makes the necessary changes so it can be used for live/hddimg images as well.

Quoted 8 lines
Quoted 5 lines

One can set EFI_PROVIDER = "gummiboot" in local.conf to use gummiboot instead of grub-efi.
Gummiboot requires some kernel options that are not enabled by default, so one has to build
with KERNEL_FEATURES_append = " cfg/efi-ext".

cfg/efi is insufficient?

cfg/efi doesn't have CONFIG_EFI_STUB=y which is required by gummiboot. cfg/efi-ext adds more than that, it's true.

It's also a good idea to enable CONFIG_EFIVARS_FS, which is the newer/better interface than CONFIG_EFI_VARS that cfg/efi-ext enables.

Quoted 18 lines
Quoted 18 lines

The install scripts have been updated too, keeping the old behaviour around,
but accounting for the new boot loader config files (if they exist). It can be argued that the installer and bootimg are a bit wierd and not necessarily correct,
but I wanted to have the exact same behviour with gummiboot. With the default EFI_PROVIDER = "grub-efi" nothing changes, everthing should be just as before.

I've tested live boot, install and normal boot on:
- FRI2
- genericx86-64 on NUC
with:
EFI_PROVIDER = "gummiboot" KERNEL_FEATURES_append = " cfg/efi-ext"
in local.conf.

Quoted 6 lines
Quoted 1 line

Generally looks good. My only reservation is the same as for 2/3, should we define an EFI interface rather than having to construct function names in the consumers of this class?

I don't have a strong opinion here, it just seemed the simplest way atm, then adding another interface.

Cheers,
Stefan

Quoted 211 lines

--
Darren

Quoted 205 lines

---
meta/classes/gummiboot.bbclass | 112
+++++++++++++++++++++
.../initrdscripts/files/init-install-efi.sh | 51 +++++++---

2 files changed, 147 insertions(+), 16 deletions(-)

create mode 100644 meta/classes/gummiboot.bbclass

meta/classes/gummiboot.bbclass new file +27 -0
new file mode 100644
index 0000000..5c11286
@@ -0,0 +1,112 @@
+EFICLASS_FUNC_PREFIX = "gummiboot"
+
+do_bootimg[depends] += "gummiboot:do_deploy"
+do_bootdirectdisk[depends] += "gummiboot:do_deploy"
+
+EFIDIR = "/EFI/BOOT"
+
+GUMMIBOOT_CFG ?= "${S}/loader.conf"
+GUMMIBOOT_ENTRIES ?= ""
+GUMMIBOOT_TIMEOUT ?= "10"
+
+gummiboot_populate() {
+        DEST=$1
+
+        EFI_IMAGE="gummibootia32.efi"
+        DEST_EFI_IMAGE="bootia32.efi"
+        if [ "${TARGET_ARCH}" = "x86_64" ]; then
+            EFI_IMAGE="gummibootx64.efi"
+            DEST_EFI_IMAGE="bootx64.efi"
+        fi
+
+        install -d ${DEST}${EFIDIR}
+        # gummiboot requires these paths for configuration files
+        # they are not customizable so no point in new vars
+        install -d ${DEST}/loader
+        install -d ${DEST}/loader/entries
+        install -m 0644 ${DEPLOY_DIR_IMAGE}/${EFI_IMAGE}

${DEST}${EFIDIR}/${DEST_EFI_IMAGE}

meta/classes/gummiboot.bbclass new file +85 -0
+        install -m 0644 ${GUMMIBOOT_CFG} ${DEST}/loader/loader.conf
+        for i in ${GUMMIBOOT_ENTRIES}; do
+            install -m 0644 ${i} ${DEST}/loader/entries
+        done
+}
+
+gummiboot_iso_populate() {
+        iso_dir=$1
+        gummiboot_populate $iso_dir
+        mkdir -p ${EFIIMGDIR}/${EFIDIR}
+        cp $iso_dir/${EFIDIR}/* ${EFIIMGDIR}${EFIDIR}
+        cp $iso_dir/vmlinuz ${EFIIMGDIR}
+        echo "${DEST_EFI_IMAGE}" > ${EFIIMGDIR}/startup.nsh
+        if [ -f "$iso_dir/initrd" ] ; then
+            cp $iso_dir/initrd ${EFIIMGDIR}
+        fi
+}
+
+gummiboot_hddimg_populate() {
+        gummiboot_populate $1
+}
+
+python build_gummiboot_cfg() {
+    s = d.getVar("S", True)
+    labels = d.getVar('LABELS', True)
+    if not labels:
+        bb.debug(1, "LABELS not defined, nothing to do")
+        return
+
+    if labels == []:
+        bb.debug(1, "No labels, nothing to do")
+        return
+
+    cfile = d.getVar('GUMMIBOOT_CFG', True)
+    try:
+         cfgfile = open(cfile, 'w')
+    except OSError:
+        raise bb.build.funcFailed('Unable to open %s' % (cfile))
+
+    cfgfile.write('# Automatically created by OE\n')
+    cfgfile.write('default %s\n' % (labels.split()[0]))
+    timeout = d.getVar('GUMMIBOOT_TIMEOUT', True)
+    if timeout:
+        cfgfile.write('timeout %s\n' % timeout)
+    else:
+        cfgfile.write('timeout 10\n')
+    cfgfile.close()
+
+    for label in labels.split():
+        localdata = d.createCopy()
+
+        overrides = localdata.getVar('OVERRIDES', True)
+        if not overrides:
+            raise bb.build.FuncFailed('OVERRIDES not defined')
+
+        entryfile = "%s/%s.conf" % (s, label)
+        d.appendVar("GUMMIBOOT_ENTRIES", " " + entryfile)
+        try:
+            entrycfg = open(entryfile, "w")
+        except OSError:
+            raise bb.build.funcFailed('Unable to open %s' % (entryfile))
+        localdata.setVar('OVERRIDES', label + ':' + overrides)
+        bb.data.update_data(localdata)
+
+        entrycfg.write('title %s\n' % label)
+        entrycfg.write('linux /vmlinuz\n')
+
+        append = localdata.getVar('APPEND', True)
+        initrd = localdata.getVar('INITRD', True)
+
+        if initrd:
+            entrycfg.write('initrd /initrd\n')
+        lb = label
+        if label == "install":
+            lb = "install-efi"
+        entrycfg.write('options LABEL=%s ' % lb)
+        if append:
+            entrycfg.write('%s' % append)
+        entrycfg.write('\n')
+        entrycfg.close()
+}
+
+python build_efi_cfg() {
+    bb.build.exec_func("build_gummiboot_cfg", d)
+}
meta/recipes-core/initrdscripts/files/init-install-efi.sh +0 -0
index 9846637..ed3221b 100644
@@ -104,6 +104,7 @@ parted /dev/${device} mklabel gpt
 

echo "Creating boot partition on $bootfs" parted /dev/${device} mkpart primary 0% $boot_size +parted /dev/${device} set 1 boot on

echo "Creating rootfs partition on $rootfs"
parted /dev/${device} mkpart primary $rootfs_start $rootfs_end

meta/recipes-core/initrdscripts/files/init-install-efi.sh +0 -0
@@ -149,23 +150,41 @@ mount $bootfs /ssd
 

EFIDIR="/ssd/EFI/BOOT"
mkdir -p $EFIDIR

meta/recipes-core/initrdscripts/files/init-install-efi.sh +0 -2
-GRUBCFG="$EFIDIR/grub.cfg"
-

cp /media/$1/vmlinuz /ssd

meta/recipes-core/initrdscripts/files/init-install-efi.sh +0 -14
-# Copy the efi loader and config (booti*.efi and grub.cfg)
-cp /media/$1/EFI/BOOT/* $EFIDIR
-
-# Update grub config for the installed image
-# Delete the install entry
-sed -i "/menuentry 'install'/,/^}/d" $GRUBCFG
-# Delete the initrd lines
-sed -i "/initrd /d" $GRUBCFG
-# Delete any LABEL= strings
-sed -i "s/ LABEL=[^ ]*/ /" $GRUBCFG
-# Delete any root= strings
-sed -i "s/ root=[^ ]*/ /" $GRUBCFG
-# Add the root= and other standard boot options
-sed -i "s@linux /vmlinuz *@linux /vmlinuz root=$rootfs rw $rootwait

quiet @" $GRUBCFG

meta/recipes-core/initrdscripts/files/init-install-efi.sh +17 -0
+# Copy the efi loader
+cp /media/$1/EFI/BOOT/*.efi $EFIDIR
+
+if [ -f /media/$1/EFI/BOOT/grub.cfg ]; then
+    GRUBCFG="$EFIDIR/grub.cfg"
+    cp /media/$1/EFI/BOOT/grub.cfg $GRUBCFG
+    # Update grub config for the installed image
+    # Delete the install entry
+    sed -i "/menuentry 'install'/,/^}/d" $GRUBCFG
+    # Delete the initrd lines
+    sed -i "/initrd /d" $GRUBCFG
+    # Delete any LABEL= strings
+    sed -i "s/ LABEL=[^ ]*/ /" $GRUBCFG
+    # Delete any root= strings
+    sed -i "s/ root=[^ ]*/ /" $GRUBCFG
+    # Add the root= and other standard boot options
+    sed -i "s@linux /vmlinuz *@linux /vmlinuz root=$rootfs rw $rootwait

quiet @" $GRUBCFG

meta/recipes-core/initrdscripts/files/init-install-efi.sh +16 -0
+fi
+
+if [ -d /media/$1/loader ]; then
+    GUMMIBOOT_CFGS="/ssd/loader/entries/*.conf"
+    # copy config files for gummiboot
+    cp -dr /media/$1/loader /ssd
+    # delete the install entry
+    rm -f /ssd/loader/entries/install.conf
+    # delete the initrd lines
+    sed -i "/initrd /d" $GUMMIBOOT_CFGS
+    # delete any LABEL= strings
+    sed -i "s/ LABEL=[^ ]*/ /" $GUMMIBOOT_CFGS
+    # delete any root= strings
+    sed -i "s/ root=[^ ]*/ /" $GUMMIBOOT_CFGS
+    # add the root= and other standard boot options
+    sed -i "s@options *@options root=$rootfs rw $rootwait quiet @"

$GUMMIBOOT_CFGS
+fi

umount /ssd
sync

Signature · 1 line
1.8.5.3
#3 lore raw

Re: [PATCH 1/3] recipes-bsp: Add gummiboot and gnu-efi recipes

In reply to Stefan Stanacar
Quoted 169 lines · Stefan Stanacar

gummiboot is is a simple UEFI boot manager (not a boot loader ;-) )

These recipes are imported from meta-intel with these changes:
- drop PR and update configure options
- gummiboot was upgraded to latest version

A couple of notes:
- If you wish you can install the gummiboot package on the target and
use 'gummiboot install' to add the payload to the ESP (see gummiboot --help, just make sure the ESP partition has the boot flag on as gummiboot won't accept it otherwise). However the point of this recipe is to be used by bootimg.bbclass and generate images with gummiboot instead of grub-efi.
- You need a kernel which has CONFIG_EFI_STUB=y at least
- The default linux-yocto kernel config does not enable that, easiest way
to enable is to build with KERNEL_FEATURES_append = " cfg/efi-ext" in local.conf

---
  .../gnu-efi/gnu-efi/parallel-make-archives.patch   | 48 ++++++++++++++++++++++
  .../gnu-efi/gnu-efi/parallel-make.patch            | 22 ++++++++++
  meta/recipes-bsp/gnu-efi/gnu-efi_3.0u.bb           | 33 +++++++++++++++
  meta/recipes-bsp/gummiboot/gummiboot_git.bb        | 25 +++++++++++
  4 files changed, 128 insertions(+)

create mode 100644 meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make-archives.patch create mode 100644 meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make.patch create mode 100644 meta/recipes-bsp/gnu-efi/gnu-efi_3.0u.bb
create mode 100644 meta/recipes-bsp/gummiboot/gummiboot_git.bb

meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make-archives.patch new file +48 -0
new file mode 100644
index 0000000..e5b47c1
@@ -0,0 +1,48 @@
+Fix parallel make failure for archives
+
+Upstream-Status: Pending
+
+The lib and gnuefi makefiles were using the lib.a() form which compiles
+and ar's as a pair instead of compiling all and then ar'ing which can
+parallelize better. This was resulting in build failures on larger values
+of -j.
+
+See http://www.chemie.fu-berlin.de/chemnet/use/info/make/make_toc.html#TOC105
+for details.
+
+Signed-off-by: Saul Wold <[email protected]>
+Signed-off-by: Darren Hart <[email protected]>
+---
+---
+ gnuefi/Makefile |    3 ++-
+ lib/Makefile    |    3 ++-
+ 2 files changed, 4 insertions(+), 2 deletions(-)
+
+Index: gnu-efi-3.0/lib/Makefile
+===================================================================
+--- gnu-efi-3.0.orig/lib/Makefile
++++ gnu-efi-3.0/lib/Makefile
+@@ -66,7 +66,8 @@ all: libsubdirs libefi.a
+ libsubdirs:
+ 	for sdir in $(SUBDIRS); do mkdir -p $$sdir; done
+
+-libefi.a: $(patsubst %,libefi.a(%),$(OBJS))
++libefi.a: $(OBJS)
++	$(AR) rv $@ $(OBJS)
+
+ clean:
+ 	rm -f libefi.a *~ $(OBJS) */*.o
+Index: gnu-efi-3.0/gnuefi/Makefile
+===================================================================
+--- gnu-efi-3.0.orig/gnuefi/Makefile
++++ gnu-efi-3.0/gnuefi/Makefile
+@@ -51,7 +51,8 @@ TARGETS	= crt0-efi-$(ARCH).o libgnuefi.a
+
+ all:	$(TARGETS)
+
+-libgnuefi.a: $(patsubst %,libgnuefi.a(%),$(OBJS))
++libgnuefi.a: $(OBJS)
++	$(AR) rv $@ $(OBJS)
+
+ clean:
+ 	rm -f $(TARGETS) *~ *.o $(OBJS)
meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make.patch new file +22 -0
new file mode 100644
index 0000000..27c94e8
@@ -0,0 +1,22 @@
+Fix parallel make failure
+
+Upstream-Status: Submitted [Maintainer directly]
+
+Add a missing dependency which resulted in a race leading to failure
+on larger values of -j.
+
+Signed-off-by: Darren Hart <[email protected]>
+
+Index: gnu-efi-3.0/Makefile
+===================================================================
+--- gnu-efi-3.0.orig/Makefile
++++ gnu-efi-3.0/Makefile
+@@ -42,6 +42,8 @@ include $(SRCDIR)/Make.defaults
+
+ SUBDIRS = lib gnuefi inc apps
+
++gnuefi: lib
++
+ all:	check_gcc $(SUBDIRS)
+
+ $(SUBDIRS):
meta/recipes-bsp/gnu-efi/gnu-efi_3.0u.bb new file +33 -0
new file mode 100644
index 0000000..0dbdba2
@@ -0,0 +1,33 @@
+SUMMARY = "Libraries for producing EFI binaries"
+HOMEPAGE = "http://sourceforge.net/projects/gnu-efi/"
+SECTION = "devel"
+LICENSE = "GPLv2+"
+LIC_FILES_CHKSUM = "file://debian/copyright;md5=5fb358a180f484b285b0d99acdc29666"
+
+SRC_URI = "http://downloads.sourceforge.net/gnu-efi/gnu-efi_3.0u.orig.tar.gz \
+           file://parallel-make.patch \
+           file://parallel-make-archives.patch \
+          "
+SRC_URI[md5sum] = "d15d3c700e79a1e2938544d73edc572d"
+SRC_URI[sha256sum] = "3c0d450d5829204ca05dcb3b2aae772e52c379b7c7e09146759c6315606f934e"
+
+COMPATIBLE_HOST = "(x86_64.*|i.86.*)-linux"
+
+S = "${WORKDIR}/gnu-efi-3.0"
+
+def gnu_efi_arch(d):
+    import re
+    tarch = d.getVar("TARGET_ARCH", True)
+    if re.match("i[3456789]86", tarch):
+        return "ia32"
+    return tarch
+
+EXTRA_OEMAKE = "'ARCH=${@gnu_efi_arch(d)}' 'CC=${CC}' 'AS=${AS}' 'LD=${LD}' 'AR=${AR}' \
+                'RANLIB=${RANLIB}' 'OBJCOPY=${OBJCOPY}' 'PREFIX=${prefix}'\
+                "
+
+do_install() {
+        oe_runmake install INSTALLROOT="${D}"
+}
+
+FILES_${PN} += "${libdir}/*.lds"
meta/recipes-bsp/gummiboot/gummiboot_git.bb new file +14 -0
new file mode 100644
index 0000000..b55064f
@@ -0,0 +1,25 @@
+SUMMARY = "Gummiboot is a simple UEFI boot manager which executes configured EFI images."
+HOMEPAGE = "http://freedesktop.org/wiki/Software/gummiboot"
+
+LICENSE = "LGPLv2.1"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=4fbd65380cdd255951079008b364516c"
+
+DEPENDS = "gnu-efi util-linux"
+
+inherit autotools
+inherit deploy
+
+PV = "43+git${SRCPV}"
+SRCREV = "4062c51075ba054d4949c714fe06123f9ad3097d"
+SRC_URI = "git://anongit.freedesktop.org/gummiboot"

meta/recipes-bsp/gummiboot/gummiboot_git.bb line 24

Quoted 10 lines
meta/recipes-bsp/gummiboot/gummiboot_git.bb new file +10 -0
+
+S = "${WORKDIR}/git"
+
+EXTRA_OECONF = "--disable-manpages --with-efi-includedir=${STAGING_INCDIR} \
+                --with-efi-ldsdir=${STAGING_LIBDIR} \
+                --with-efi-libdir=${STAGING_LIBDIR}"
+
+do_deploy () {
+        install ${S}/gummiboot*.efi ${DEPLOYDIR}/
+}

With the potential introduction of split source (S) and build (B) directories, this should be ${B} not ${S}.

This should be 2 commit.

Sau!

Quoted 2 lines
meta/recipes-bsp/gummiboot/gummiboot_git.bb new file +1 -0
+addtask deploy before do_build after do_compile
#4 lore raw

Re: [PATCH 1/3] recipes-bsp: Add gummiboot and gnu-efi recipes

Quoted 184 lines · Saul Wold
Quoted 169 lines · Stefan Stanacar

gummiboot is is a simple UEFI boot manager (not a boot loader ;-) )

These recipes are imported from meta-intel with these changes:
- drop PR and update configure options
- gummiboot was upgraded to latest version

A couple of notes:
- If you wish you can install the gummiboot package on the target and
use 'gummiboot install' to add the payload to the ESP (see gummiboot --help, just make sure the ESP partition has the boot flag on as gummiboot won't accept it otherwise). However the point of this recipe is to be used by bootimg.bbclass and generate images with gummiboot instead of grub-efi.
- You need a kernel which has CONFIG_EFI_STUB=y at least
- The default linux-yocto kernel config does not enable that, easiest way
to enable is to build with KERNEL_FEATURES_append = " cfg/efi-ext" in local.conf

---
  .../gnu-efi/gnu-efi/parallel-make-archives.patch   | 48 ++++++++++++++++++++++
  .../gnu-efi/gnu-efi/parallel-make.patch            | 22 ++++++++++
  meta/recipes-bsp/gnu-efi/gnu-efi_3.0u.bb           | 33 +++++++++++++++
  meta/recipes-bsp/gummiboot/gummiboot_git.bb        | 25 +++++++++++
  4 files changed, 128 insertions(+)

create mode 100644 meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make-archives.patch create mode 100644 meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make.patch create mode 100644 meta/recipes-bsp/gnu-efi/gnu-efi_3.0u.bb
create mode 100644 meta/recipes-bsp/gummiboot/gummiboot_git.bb

meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make-archives.patch new file +48 -0
new file mode 100644
index 0000000..e5b47c1
@@ -0,0 +1,48 @@
+Fix parallel make failure for archives
+
+Upstream-Status: Pending
+
+The lib and gnuefi makefiles were using the lib.a() form which compiles
+and ar's as a pair instead of compiling all and then ar'ing which can
+parallelize better. This was resulting in build failures on larger values
+of -j.
+
+See http://www.chemie.fu-berlin.de/chemnet/use/info/make/make_toc.html#TOC105
+for details.
+
+Signed-off-by: Saul Wold <[email protected]>
+Signed-off-by: Darren Hart <[email protected]>
+---
+---
+ gnuefi/Makefile |    3 ++-
+ lib/Makefile    |    3 ++-
+ 2 files changed, 4 insertions(+), 2 deletions(-)
+
+Index: gnu-efi-3.0/lib/Makefile
+===================================================================
+--- gnu-efi-3.0.orig/lib/Makefile
++++ gnu-efi-3.0/lib/Makefile
+@@ -66,7 +66,8 @@ all: libsubdirs libefi.a
+ libsubdirs:
+ 	for sdir in $(SUBDIRS); do mkdir -p $$sdir; done
+
+-libefi.a: $(patsubst %,libefi.a(%),$(OBJS))
++libefi.a: $(OBJS)
++	$(AR) rv $@ $(OBJS)
+
+ clean:
+ 	rm -f libefi.a *~ $(OBJS) */*.o
+Index: gnu-efi-3.0/gnuefi/Makefile
+===================================================================
+--- gnu-efi-3.0.orig/gnuefi/Makefile
++++ gnu-efi-3.0/gnuefi/Makefile
+@@ -51,7 +51,8 @@ TARGETS	= crt0-efi-$(ARCH).o libgnuefi.a
+
+ all:	$(TARGETS)
+
+-libgnuefi.a: $(patsubst %,libgnuefi.a(%),$(OBJS))
++libgnuefi.a: $(OBJS)
++	$(AR) rv $@ $(OBJS)
+
+ clean:
+ 	rm -f $(TARGETS) *~ *.o $(OBJS)
meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make.patch new file +22 -0
new file mode 100644
index 0000000..27c94e8
@@ -0,0 +1,22 @@
+Fix parallel make failure
+
+Upstream-Status: Submitted [Maintainer directly]
+
+Add a missing dependency which resulted in a race leading to failure
+on larger values of -j.
+
+Signed-off-by: Darren Hart <[email protected]>
+
+Index: gnu-efi-3.0/Makefile
+===================================================================
+--- gnu-efi-3.0.orig/Makefile
++++ gnu-efi-3.0/Makefile
+@@ -42,6 +42,8 @@ include $(SRCDIR)/Make.defaults
+
+ SUBDIRS = lib gnuefi inc apps
+
++gnuefi: lib
++
+ all:	check_gcc $(SUBDIRS)
+
+ $(SUBDIRS):
meta/recipes-bsp/gnu-efi/gnu-efi_3.0u.bb new file +33 -0
new file mode 100644
index 0000000..0dbdba2
@@ -0,0 +1,33 @@
+SUMMARY = "Libraries for producing EFI binaries"
+HOMEPAGE = "http://sourceforge.net/projects/gnu-efi/"
+SECTION = "devel"
+LICENSE = "GPLv2+"
+LIC_FILES_CHKSUM = "file://debian/copyright;md5=5fb358a180f484b285b0d99acdc29666"
+
+SRC_URI = "http://downloads.sourceforge.net/gnu-efi/gnu-efi_3.0u.orig.tar.gz \
+           file://parallel-make.patch \
+           file://parallel-make-archives.patch \
+          "
+SRC_URI[md5sum] = "d15d3c700e79a1e2938544d73edc572d"
+SRC_URI[sha256sum] = "3c0d450d5829204ca05dcb3b2aae772e52c379b7c7e09146759c6315606f934e"
+
+COMPATIBLE_HOST = "(x86_64.*|i.86.*)-linux"
+
+S = "${WORKDIR}/gnu-efi-3.0"
+
+def gnu_efi_arch(d):
+    import re
+    tarch = d.getVar("TARGET_ARCH", True)
+    if re.match("i[3456789]86", tarch):
+        return "ia32"
+    return tarch
+
+EXTRA_OEMAKE = "'ARCH=${@gnu_efi_arch(d)}' 'CC=${CC}' 'AS=${AS}' 'LD=${LD}' 'AR=${AR}' \
+                'RANLIB=${RANLIB}' 'OBJCOPY=${OBJCOPY}' 'PREFIX=${prefix}'\
+                "
+
+do_install() {
+        oe_runmake install INSTALLROOT="${D}"
+}
+
+FILES_${PN} += "${libdir}/*.lds"
meta/recipes-bsp/gummiboot/gummiboot_git.bb new file +14 -0
new file mode 100644
index 0000000..b55064f
@@ -0,0 +1,25 @@
+SUMMARY = "Gummiboot is a simple UEFI boot manager which executes configured EFI images."
+HOMEPAGE = "http://freedesktop.org/wiki/Software/gummiboot"
+
+LICENSE = "LGPLv2.1"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=4fbd65380cdd255951079008b364516c"
+
+DEPENDS = "gnu-efi util-linux"
+
+inherit autotools
+inherit deploy
+
+PV = "43+git${SRCPV}"
+SRCREV = "4062c51075ba054d4949c714fe06123f9ad3097d"
+SRC_URI = "git://anongit.freedesktop.org/gummiboot"

meta/recipes-bsp/gummiboot/gummiboot_git.bb line 24

Quoted 10 lines
meta/recipes-bsp/gummiboot/gummiboot_git.bb new file +10 -0
+
+S = "${WORKDIR}/git"
+
+EXTRA_OECONF = "--disable-manpages --with-efi-includedir=${STAGING_INCDIR} \
+                --with-efi-ldsdir=${STAGING_LIBDIR} \
+                --with-efi-libdir=${STAGING_LIBDIR}"
+
+do_deploy () {
+        install ${S}/gummiboot*.efi ${DEPLOYDIR}/
+}

With the potential introduction of split source (S) and build (B) directories, this should be ${B} not ${S}.

Quoted 1 line

This should be 2 commit.

Okay, v2 incoming soon with:
- change that to ${B} in deploy
- split this in two commits, one for each recipe
- change the function names in bootimg/grub-efi instead of using a
prefix, as Darren suggested.

Cheers,
Stefan

Quoted 5 lines

Sau!

Quoted 2 lines
meta/recipes-bsp/gummiboot/gummiboot_git.bb new file +1 -0
+addtask deploy before do_build after do_compile
#10 lore raw

Re: [PATCH 3/3] classes: Add gummiboot class

In reply to Stanacar, StefanX
Quoted 16 lines · StefanX
Quoted 12 lines · Darren Hart
Quoted 1 line · Stefan Stanacar

Adds a gummiboot class similar to grub-efi class and makes the

necessary

Quoted 7 lines

changes so it can be used for live/hddimg images as well.

One can set EFI_PROVIDER = "gummiboot" in local.conf to use gummiboot instead of grub-efi.
Gummiboot requires some kernel options that are not enabled by default, so one has to build
with KERNEL_FEATURES_append = " cfg/efi-ext".

Quoted 5 lines
Quoted 2 lines

cfg/efi is insufficient?

cfg/efi doesn't have CONFIG_EFI_STUB=y which is required by gummiboot. cfg/efi-ext adds more than that, it's true.

Weird... Although the STUB should probably be in efi rather than efi-ext. I'm surprised gummiboot requires STUB... Since STUB is there to allow the kernel to be booted directly, no bootloader required. I guess gummiboot is slightly less than a boot loader :-)

I'd Ack a patch to move STUB from efi-ext to efi.

Quoted 3 lines

It's also a good idea to enable CONFIG_EFIVARS_FS, which is the newer/better interface than CONFIG_EFI_VARS that cfg/efi-ext enables.

Hrm... OK, perhaps time to revisit those fragments and update them for current usage.

--
Darren

Quoted 247 lines
Quoted 18 lines
Quoted 18 lines

The install scripts have been updated too, keeping the old behaviour around,
but accounting for the new boot loader config files (if they exist). It can be argued that the installer and bootimg are a bit wierd and not necessarily correct,
but I wanted to have the exact same behviour with gummiboot. With the default EFI_PROVIDER = "grub-efi" nothing changes, everthing should be just as before.

I've tested live boot, install and normal boot on:
- FRI2
- genericx86-64 on NUC
with:
EFI_PROVIDER = "gummiboot" KERNEL_FEATURES_append = " cfg/efi-ext"
in local.conf.

Quoted 7 lines
Quoted 1 line

Generally looks good. My only reservation is the same as for 2/3, should we define an EFI interface rather than having to construct function names
in the consumers of this class?

I don't have a strong opinion here, it just seemed the simplest way atm, then adding another interface.

Cheers,
Stefan

Quoted 213 lines

--
Darren

Quoted 93 lines

---
meta/classes/gummiboot.bbclass | 112
+++++++++++++++++++++
.../initrdscripts/files/init-install-efi.sh | 51 +++++++---

2 files changed, 147 insertions(+), 16 deletions(-)

create mode 100644 meta/classes/gummiboot.bbclass

meta/classes/gummiboot.bbclass new file +27 -0
new file mode 100644
index 0000000..5c11286
@@ -0,0 +1,112 @@
+EFICLASS_FUNC_PREFIX = "gummiboot"
+
+do_bootimg[depends] += "gummiboot:do_deploy"
+do_bootdirectdisk[depends] += "gummiboot:do_deploy"
+
+EFIDIR = "/EFI/BOOT"
+
+GUMMIBOOT_CFG ?= "${S}/loader.conf"
+GUMMIBOOT_ENTRIES ?= ""
+GUMMIBOOT_TIMEOUT ?= "10"
+
+gummiboot_populate() {
+        DEST=$1
+
+        EFI_IMAGE="gummibootia32.efi"
+        DEST_EFI_IMAGE="bootia32.efi"
+        if [ "${TARGET_ARCH}" = "x86_64" ]; then
+            EFI_IMAGE="gummibootx64.efi"
+            DEST_EFI_IMAGE="bootx64.efi"
+        fi
+
+        install -d ${DEST}${EFIDIR}
+        # gummiboot requires these paths for configuration files
+        # they are not customizable so no point in new vars
+        install -d ${DEST}/loader
+        install -d ${DEST}/loader/entries
+        install -m 0644 ${DEPLOY_DIR_IMAGE}/${EFI_IMAGE}

${DEST}${EFIDIR}/${DEST_EFI_IMAGE}

meta/classes/gummiboot.bbclass new file +51 -0
+        install -m 0644 ${GUMMIBOOT_CFG} ${DEST}/loader/loader.conf
+        for i in ${GUMMIBOOT_ENTRIES}; do
+            install -m 0644 ${i} ${DEST}/loader/entries
+        done
+}
+
+gummiboot_iso_populate() {
+        iso_dir=$1
+        gummiboot_populate $iso_dir
+        mkdir -p ${EFIIMGDIR}/${EFIDIR}
+        cp $iso_dir/${EFIDIR}/* ${EFIIMGDIR}${EFIDIR}
+        cp $iso_dir/vmlinuz ${EFIIMGDIR}
+        echo "${DEST_EFI_IMAGE}" > ${EFIIMGDIR}/startup.nsh
+        if [ -f "$iso_dir/initrd" ] ; then
+            cp $iso_dir/initrd ${EFIIMGDIR}
+        fi
+}
+
+gummiboot_hddimg_populate() {
+        gummiboot_populate $1
+}
+
+python build_gummiboot_cfg() {
+    s = d.getVar("S", True)
+    labels = d.getVar('LABELS', True)
+    if not labels:
+        bb.debug(1, "LABELS not defined, nothing to do")
+        return
+
+    if labels == []:
+        bb.debug(1, "No labels, nothing to do")
+        return
+
+    cfile = d.getVar('GUMMIBOOT_CFG', True)
+    try:
+         cfgfile = open(cfile, 'w')
+    except OSError:
+        raise bb.build.funcFailed('Unable to open %s' % (cfile))
+
+    cfgfile.write('# Automatically created by OE\n')
+    cfgfile.write('default %s\n' % (labels.split()[0]))
+    timeout = d.getVar('GUMMIBOOT_TIMEOUT', True)
+    if timeout:
+        cfgfile.write('timeout %s\n' % timeout)
+    else:
+        cfgfile.write('timeout 10\n')
+    cfgfile.close()
+
+    for label in labels.split():
+        localdata = d.createCopy()
+

meta/classes/gummiboot.bbclass

Quoted 10 lines
meta/classes/gummiboot.bbclass new file +10 -0
+        overrides = localdata.getVar('OVERRIDES', True)
+        if not overrides:
+            raise bb.build.FuncFailed('OVERRIDES not defined')
+
+        entryfile = "%s/%s.conf" % (s, label)
+        d.appendVar("GUMMIBOOT_ENTRIES", " " + entryfile)
+        try:
+            entrycfg = open(entryfile, "w")
+        except OSError:
+            raise bb.build.funcFailed('Unable to open %s' %

(entryfile))

Quoted 66 lines
meta/classes/gummiboot.bbclass new file +24 -0
+        localdata.setVar('OVERRIDES', label + ':' + overrides)
+        bb.data.update_data(localdata)
+
+        entrycfg.write('title %s\n' % label)
+        entrycfg.write('linux /vmlinuz\n')
+
+        append = localdata.getVar('APPEND', True)
+        initrd = localdata.getVar('INITRD', True)
+
+        if initrd:
+            entrycfg.write('initrd /initrd\n')
+        lb = label
+        if label == "install":
+            lb = "install-efi"
+        entrycfg.write('options LABEL=%s ' % lb)
+        if append:
+            entrycfg.write('%s' % append)
+        entrycfg.write('\n')
+        entrycfg.close()
+}
+
+python build_efi_cfg() {
+    bb.build.exec_func("build_gummiboot_cfg", d)
+}
meta/recipes-core/initrdscripts/files/init-install-efi.sh +0 -0
index 9846637..ed3221b 100644
@@ -104,6 +104,7 @@ parted /dev/${device} mklabel gpt
 

echo "Creating boot partition on $bootfs" parted /dev/${device} mkpart primary 0% $boot_size +parted /dev/${device} set 1 boot on

echo "Creating rootfs partition on $rootfs"
parted /dev/${device} mkpart primary $rootfs_start $rootfs_end

meta/recipes-core/initrdscripts/files/init-install-efi.sh +0 -0
@@ -149,23 +150,41 @@ mount $bootfs /ssd
 

EFIDIR="/ssd/EFI/BOOT"
mkdir -p $EFIDIR

meta/recipes-core/initrdscripts/files/init-install-efi.sh +0 -2
-GRUBCFG="$EFIDIR/grub.cfg"
-

cp /media/$1/vmlinuz /ssd

meta/recipes-core/initrdscripts/files/init-install-efi.sh +0 -14
-# Copy the efi loader and config (booti*.efi and grub.cfg)
-cp /media/$1/EFI/BOOT/* $EFIDIR
-
-# Update grub config for the installed image
-# Delete the install entry
-sed -i "/menuentry 'install'/,/^}/d" $GRUBCFG
-# Delete the initrd lines
-sed -i "/initrd /d" $GRUBCFG
-# Delete any LABEL= strings
-sed -i "s/ LABEL=[^ ]*/ /" $GRUBCFG
-# Delete any root= strings
-sed -i "s/ root=[^ ]*/ /" $GRUBCFG
-# Add the root= and other standard boot options
-sed -i "s@linux /vmlinuz *@linux /vmlinuz root=$rootfs rw $rootwait

quiet @" $GRUBCFG

meta/recipes-core/initrdscripts/files/init-install-efi.sh +7 -0
+# Copy the efi loader
+cp /media/$1/EFI/BOOT/*.efi $EFIDIR
+
+if [ -f /media/$1/EFI/BOOT/grub.cfg ]; then
+    GRUBCFG="$EFIDIR/grub.cfg"
+    cp /media/$1/EFI/BOOT/grub.cfg $GRUBCFG
+    # Update grub config for the installed image

meta/recipes-core/initrdscripts/files/init-install-efi.sh mount $bootfs /ssd

Quoted 10 lines
meta/recipes-core/initrdscripts/files/init-install-efi.sh +10 -0
+    # Delete the install entry
+    sed -i "/menuentry 'install'/,/^}/d" $GRUBCFG
+    # Delete the initrd lines
+    sed -i "/initrd /d" $GRUBCFG
+    # Delete any LABEL= strings
+    sed -i "s/ LABEL=[^ ]*/ /" $GRUBCFG
+    # Delete any root= strings
+    sed -i "s/ root=[^ ]*/ /" $GRUBCFG
+    # Add the root= and other standard boot options
+    sed -i "s@linux /vmlinuz *@linux /vmlinuz root=$rootfs rw

$rootwait

Quoted 26 lines

quiet @" $GRUBCFG

meta/recipes-core/initrdscripts/files/init-install-efi.sh +16 -0
+fi
+
+if [ -d /media/$1/loader ]; then
+    GUMMIBOOT_CFGS="/ssd/loader/entries/*.conf"
+    # copy config files for gummiboot
+    cp -dr /media/$1/loader /ssd
+    # delete the install entry
+    rm -f /ssd/loader/entries/install.conf
+    # delete the initrd lines
+    sed -i "/initrd /d" $GUMMIBOOT_CFGS
+    # delete any LABEL= strings
+    sed -i "s/ LABEL=[^ ]*/ /" $GUMMIBOOT_CFGS
+    # delete any root= strings
+    sed -i "s/ root=[^ ]*/ /" $GUMMIBOOT_CFGS
+    # add the root= and other standard boot options
+    sed -i "s@options *@options root=$rootfs rw $rootwait quiet @"

$GUMMIBOOT_CFGS
+fi

umount /ssd
sync

Signature · 1 line
1.8.5.3
Signature · 3 lines
Darren Hart
Yocto Project - Linux Kernel
Intel Open Source Technology Center
#11 lore raw

Re: [PATCH 3/3] classes: Add gummiboot class

Op 11 mrt. 2014, om 22:38 heeft Darren Hart <[email protected]> het volgende geschreven:

Quoted 21 lines · StefanX
Quoted 20 lines · Darren Hart
Quoted 14 lines · Stefan Stanacar
Quoted 2 lines

Adds a gummiboot class similar to grub-efi class and makes the

necessary

Quoted 7 lines

changes so it can be used for live/hddimg images as well.

One can set EFI_PROVIDER = "gummiboot" in local.conf to use gummiboot instead of grub-efi.
Gummiboot requires some kernel options that are not enabled by default, so one has to build
with KERNEL_FEATURES_append = " cfg/efi-ext".

cfg/efi is insufficient?

Quoted 7 lines
Quoted 2 lines

cfg/efi doesn't have CONFIG_EFI_STUB=y which is required by gummiboot. cfg/efi-ext adds more than that, it's true.

Weird... Although the STUB should probably be in efi rather than efi-ext. I'm surprised gummiboot requires STUB... Since STUB is there to allow the kernel to be booted directly, no bootloader required. I guess gummiboot is slightly less than a boot loader :-)

The gummiboot docs still claim to support both 'linux' and 'efi', so it's supposed to work.

regards,

Koen

Quoted 269 lines

I'd Ack a patch to move STUB from efi-ext to efi.

Quoted 3 lines

It's also a good idea to enable CONFIG_EFIVARS_FS, which is the newer/better interface than CONFIG_EFI_VARS that cfg/efi-ext enables.

Hrm... OK, perhaps time to revisit those fragments and update them for current usage.

--
Darren

Quoted 247 lines
Quoted 18 lines
Quoted 18 lines

The install scripts have been updated too, keeping the old behaviour around,
but accounting for the new boot loader config files (if they exist). It can be argued that the installer and bootimg are a bit wierd and not necessarily correct,
but I wanted to have the exact same behviour with gummiboot. With the default EFI_PROVIDER = "grub-efi" nothing changes, everthing should be just as before.

I've tested live boot, install and normal boot on:
- FRI2
- genericx86-64 on NUC
with:
EFI_PROVIDER = "gummiboot" KERNEL_FEATURES_append = " cfg/efi-ext"
in local.conf.

Quoted 7 lines
Quoted 1 line

Generally looks good. My only reservation is the same as for 2/3, should we define an EFI interface rather than having to construct function names
in the consumers of this class?

I don't have a strong opinion here, it just seemed the simplest way atm, then adding another interface.

Cheers,
Stefan

Quoted 213 lines

--
Darren

Quoted 93 lines

---
meta/classes/gummiboot.bbclass | 112
+++++++++++++++++++++
.../initrdscripts/files/init-install-efi.sh | 51 +++++++---

2 files changed, 147 insertions(+), 16 deletions(-)

create mode 100644 meta/classes/gummiboot.bbclass

meta/classes/gummiboot.bbclass new file +27 -0
new file mode 100644
index 0000000..5c11286
@@ -0,0 +1,112 @@
+EFICLASS_FUNC_PREFIX = "gummiboot"
+
+do_bootimg[depends] += "gummiboot:do_deploy"
+do_bootdirectdisk[depends] += "gummiboot:do_deploy"
+
+EFIDIR = "/EFI/BOOT"
+
+GUMMIBOOT_CFG ?= "${S}/loader.conf"
+GUMMIBOOT_ENTRIES ?= ""
+GUMMIBOOT_TIMEOUT ?= "10"
+
+gummiboot_populate() {
+        DEST=$1
+
+        EFI_IMAGE="gummibootia32.efi"
+        DEST_EFI_IMAGE="bootia32.efi"
+        if [ "${TARGET_ARCH}" = "x86_64" ]; then
+            EFI_IMAGE="gummibootx64.efi"
+            DEST_EFI_IMAGE="bootx64.efi"
+        fi
+
+        install -d ${DEST}${EFIDIR}
+        # gummiboot requires these paths for configuration files
+        # they are not customizable so no point in new vars
+        install -d ${DEST}/loader
+        install -d ${DEST}/loader/entries
+        install -m 0644 ${DEPLOY_DIR_IMAGE}/${EFI_IMAGE}

${DEST}${EFIDIR}/${DEST_EFI_IMAGE}

meta/classes/gummiboot.bbclass new file +51 -0
+        install -m 0644 ${GUMMIBOOT_CFG} ${DEST}/loader/loader.conf
+        for i in ${GUMMIBOOT_ENTRIES}; do
+            install -m 0644 ${i} ${DEST}/loader/entries
+        done
+}
+
+gummiboot_iso_populate() {
+        iso_dir=$1
+        gummiboot_populate $iso_dir
+        mkdir -p ${EFIIMGDIR}/${EFIDIR}
+        cp $iso_dir/${EFIDIR}/* ${EFIIMGDIR}${EFIDIR}
+        cp $iso_dir/vmlinuz ${EFIIMGDIR}
+        echo "${DEST_EFI_IMAGE}" > ${EFIIMGDIR}/startup.nsh
+        if [ -f "$iso_dir/initrd" ] ; then
+            cp $iso_dir/initrd ${EFIIMGDIR}
+        fi
+}
+
+gummiboot_hddimg_populate() {
+        gummiboot_populate $1
+}
+
+python build_gummiboot_cfg() {
+    s = d.getVar("S", True)
+    labels = d.getVar('LABELS', True)
+    if not labels:
+        bb.debug(1, "LABELS not defined, nothing to do")
+        return
+
+    if labels == []:
+        bb.debug(1, "No labels, nothing to do")
+        return
+
+    cfile = d.getVar('GUMMIBOOT_CFG', True)
+    try:
+         cfgfile = open(cfile, 'w')
+    except OSError:
+        raise bb.build.funcFailed('Unable to open %s' % (cfile))
+
+    cfgfile.write('# Automatically created by OE\n')
+    cfgfile.write('default %s\n' % (labels.split()[0]))
+    timeout = d.getVar('GUMMIBOOT_TIMEOUT', True)
+    if timeout:
+        cfgfile.write('timeout %s\n' % timeout)
+    else:
+        cfgfile.write('timeout 10\n')
+    cfgfile.close()
+
+    for label in labels.split():
+        localdata = d.createCopy()
+

meta/classes/gummiboot.bbclass

Quoted 10 lines
meta/classes/gummiboot.bbclass new file +10 -0
+        overrides = localdata.getVar('OVERRIDES', True)
+        if not overrides:
+            raise bb.build.FuncFailed('OVERRIDES not defined')
+
+        entryfile = "%s/%s.conf" % (s, label)
+        d.appendVar("GUMMIBOOT_ENTRIES", " " + entryfile)
+        try:
+            entrycfg = open(entryfile, "w")
+        except OSError:
+            raise bb.build.funcFailed('Unable to open %s' %

(entryfile))

Quoted 66 lines
meta/classes/gummiboot.bbclass new file +24 -0
+        localdata.setVar('OVERRIDES', label + ':' + overrides)
+        bb.data.update_data(localdata)
+
+        entrycfg.write('title %s\n' % label)
+        entrycfg.write('linux /vmlinuz\n')
+
+        append = localdata.getVar('APPEND', True)
+        initrd = localdata.getVar('INITRD', True)
+
+        if initrd:
+            entrycfg.write('initrd /initrd\n')
+        lb = label
+        if label == "install":
+            lb = "install-efi"
+        entrycfg.write('options LABEL=%s ' % lb)
+        if append:
+            entrycfg.write('%s' % append)
+        entrycfg.write('\n')
+        entrycfg.close()
+}
+
+python build_efi_cfg() {
+    bb.build.exec_func("build_gummiboot_cfg", d)
+}
meta/recipes-core/initrdscripts/files/init-install-efi.sh +0 -0
index 9846637..ed3221b 100644
@@ -104,6 +104,7 @@ parted /dev/${device} mklabel gpt
 

echo "Creating boot partition on $bootfs" parted /dev/${device} mkpart primary 0% $boot_size +parted /dev/${device} set 1 boot on

echo "Creating rootfs partition on $rootfs"
parted /dev/${device} mkpart primary $rootfs_start $rootfs_end

meta/recipes-core/initrdscripts/files/init-install-efi.sh +0 -0
@@ -149,23 +150,41 @@ mount $bootfs /ssd
 

EFIDIR="/ssd/EFI/BOOT"
mkdir -p $EFIDIR

meta/recipes-core/initrdscripts/files/init-install-efi.sh +0 -2
-GRUBCFG="$EFIDIR/grub.cfg"
-

cp /media/$1/vmlinuz /ssd

meta/recipes-core/initrdscripts/files/init-install-efi.sh +0 -14
-# Copy the efi loader and config (booti*.efi and grub.cfg)
-cp /media/$1/EFI/BOOT/* $EFIDIR
-
-# Update grub config for the installed image
-# Delete the install entry
-sed -i "/menuentry 'install'/,/^}/d" $GRUBCFG
-# Delete the initrd lines
-sed -i "/initrd /d" $GRUBCFG
-# Delete any LABEL= strings
-sed -i "s/ LABEL=[^ ]*/ /" $GRUBCFG
-# Delete any root= strings
-sed -i "s/ root=[^ ]*/ /" $GRUBCFG
-# Add the root= and other standard boot options
-sed -i "s@linux /vmlinuz *@linux /vmlinuz root=$rootfs rw $rootwait

quiet @" $GRUBCFG

meta/recipes-core/initrdscripts/files/init-install-efi.sh +7 -0
+# Copy the efi loader
+cp /media/$1/EFI/BOOT/*.efi $EFIDIR
+
+if [ -f /media/$1/EFI/BOOT/grub.cfg ]; then
+    GRUBCFG="$EFIDIR/grub.cfg"
+    cp /media/$1/EFI/BOOT/grub.cfg $GRUBCFG
+    # Update grub config for the installed image

meta/recipes-core/initrdscripts/files/init-install-efi.sh mount $bootfs /ssd

Quoted 10 lines
meta/recipes-core/initrdscripts/files/init-install-efi.sh +10 -0
+    # Delete the install entry
+    sed -i "/menuentry 'install'/,/^}/d" $GRUBCFG
+    # Delete the initrd lines
+    sed -i "/initrd /d" $GRUBCFG
+    # Delete any LABEL= strings
+    sed -i "s/ LABEL=[^ ]*/ /" $GRUBCFG
+    # Delete any root= strings
+    sed -i "s/ root=[^ ]*/ /" $GRUBCFG
+    # Add the root= and other standard boot options
+    sed -i "s@linux /vmlinuz *@linux /vmlinuz root=$rootfs rw

$rootwait

Quoted 26 lines

quiet @" $GRUBCFG

meta/recipes-core/initrdscripts/files/init-install-efi.sh +16 -0
+fi
+
+if [ -d /media/$1/loader ]; then
+    GUMMIBOOT_CFGS="/ssd/loader/entries/*.conf"
+    # copy config files for gummiboot
+    cp -dr /media/$1/loader /ssd
+    # delete the install entry
+    rm -f /ssd/loader/entries/install.conf
+    # delete the initrd lines
+    sed -i "/initrd /d" $GUMMIBOOT_CFGS
+    # delete any LABEL= strings
+    sed -i "s/ LABEL=[^ ]*/ /" $GUMMIBOOT_CFGS
+    # delete any root= strings
+    sed -i "s/ root=[^ ]*/ /" $GUMMIBOOT_CFGS
+    # add the root= and other standard boot options
+    sed -i "s@options *@options root=$rootfs rw $rootwait quiet @"

$GUMMIBOOT_CFGS
+fi

umount /ssd
sync

Signature · 1 line
1.8.5.3
Signature · 3 lines
Darren Hart
Yocto Project - Linux Kernel
Intel Open Source Technology Center
#13 lore raw

Re: [PATCH 3/3] classes: Add gummiboot class

In reply to Darren Hart
Quoted 4 lines · Darren Hart

I'm surprised gummiboot requires STUB... Since STUB is there to allow the kernel to be booted directly, no bootloader required. I guess gummiboot is slightly less than a boot loader :-)

Gummiboot is an EFI application loader.

Since CONFIG_EFI_STUB sticks a PE/COFF header at the front of the bzImage, it appears as an EFI application which gummiboot knows how to load and run. This is also the reason you can execute the bzImage from the EFI shell (or Boot Manager).

Signature · 1 line
Matt Fleming, Intel Open Source Technology Center
#12 lore raw

Re: [PATCH 3/3] classes: Add gummiboot class

In reply to Koen Kooi
Quoted 26 lines · Koen Kooi

Op 11 mrt. 2014, om 22:38 heeft Darren Hart <[email protected]> het volgende geschreven:

Quoted 24 lines · StefanX
Quoted 22 lines · Darren Hart
Quoted 6 lines · Stefan Stanacar
Quoted 2 lines

Adds a gummiboot class similar to grub-efi class and makes the

necessary

Quoted 2 lines

changes so it can be used for live/hddimg images as well.

Quoted 8 lines
Quoted 5 lines

One can set EFI_PROVIDER = "gummiboot" in local.conf to use gummiboot instead of grub-efi.
Gummiboot requires some kernel options that are not enabled by default, so one has to build
with KERNEL_FEATURES_append = " cfg/efi-ext".

cfg/efi is insufficient?

cfg/efi doesn't have CONFIG_EFI_STUB=y which is required by gummiboot. cfg/efi-ext adds more than that, it's true.

Quoted 6 lines
Quoted 4 lines

Weird... Although the STUB should probably be in efi rather than efi-ext. I'm surprised gummiboot requires STUB... Since STUB is there to allow the kernel to be booted directly, no bootloader required. I guess gummiboot is slightly less than a boot loader :-)

The gummiboot docs still claim to support both 'linux' and 'efi', so it's supposed to work.

The site claims that Linux kernels need to be built with CONFIG_EFI_STUB, and without that for me it wouldn't boot.

What you're saying is for the config file
From the site:

efi executable EFI image
options options to pass to the EFI image / kernel command line
linux linux kernel image (gummiboot still requires the kernel to have an
EFI stub)
initrd initramfs image (gummiboot just adds this as option initrd=)

Cheers,
Stefan

Quoted 275 lines

regards,

Koen

Quoted 269 lines

I'd Ack a patch to move STUB from efi-ext to efi.

Quoted 3 lines

It's also a good idea to enable CONFIG_EFIVARS_FS, which is the newer/better interface than CONFIG_EFI_VARS that cfg/efi-ext enables.

Hrm... OK, perhaps time to revisit those fragments and update them for current usage.

--
Darren

Quoted 247 lines
Quoted 18 lines
Quoted 18 lines

The install scripts have been updated too, keeping the old behaviour around,
but accounting for the new boot loader config files (if they exist). It can be argued that the installer and bootimg are a bit wierd and not necessarily correct,
but I wanted to have the exact same behviour with gummiboot. With the default EFI_PROVIDER = "grub-efi" nothing changes, everthing should be just as before.

I've tested live boot, install and normal boot on:
- FRI2
- genericx86-64 on NUC
with:
EFI_PROVIDER = "gummiboot" KERNEL_FEATURES_append = " cfg/efi-ext"
in local.conf.

Quoted 7 lines
Quoted 1 line

Generally looks good. My only reservation is the same as for 2/3, should we define an EFI interface rather than having to construct function names
in the consumers of this class?

I don't have a strong opinion here, it just seemed the simplest way atm, then adding another interface.

Cheers,
Stefan

Quoted 213 lines

--
Darren

Quoted 93 lines

---
meta/classes/gummiboot.bbclass | 112
+++++++++++++++++++++
.../initrdscripts/files/init-install-efi.sh | 51 +++++++---

2 files changed, 147 insertions(+), 16 deletions(-)

create mode 100644 meta/classes/gummiboot.bbclass

meta/classes/gummiboot.bbclass new file +27 -0
new file mode 100644
index 0000000..5c11286
@@ -0,0 +1,112 @@
+EFICLASS_FUNC_PREFIX = "gummiboot"
+
+do_bootimg[depends] += "gummiboot:do_deploy"
+do_bootdirectdisk[depends] += "gummiboot:do_deploy"
+
+EFIDIR = "/EFI/BOOT"
+
+GUMMIBOOT_CFG ?= "${S}/loader.conf"
+GUMMIBOOT_ENTRIES ?= ""
+GUMMIBOOT_TIMEOUT ?= "10"
+
+gummiboot_populate() {
+        DEST=$1
+
+        EFI_IMAGE="gummibootia32.efi"
+        DEST_EFI_IMAGE="bootia32.efi"
+        if [ "${TARGET_ARCH}" = "x86_64" ]; then
+            EFI_IMAGE="gummibootx64.efi"
+            DEST_EFI_IMAGE="bootx64.efi"
+        fi
+
+        install -d ${DEST}${EFIDIR}
+        # gummiboot requires these paths for configuration files
+        # they are not customizable so no point in new vars
+        install -d ${DEST}/loader
+        install -d ${DEST}/loader/entries
+        install -m 0644 ${DEPLOY_DIR_IMAGE}/${EFI_IMAGE}

${DEST}${EFIDIR}/${DEST_EFI_IMAGE}

meta/classes/gummiboot.bbclass new file +51 -0
+        install -m 0644 ${GUMMIBOOT_CFG} ${DEST}/loader/loader.conf
+        for i in ${GUMMIBOOT_ENTRIES}; do
+            install -m 0644 ${i} ${DEST}/loader/entries
+        done
+}
+
+gummiboot_iso_populate() {
+        iso_dir=$1
+        gummiboot_populate $iso_dir
+        mkdir -p ${EFIIMGDIR}/${EFIDIR}
+        cp $iso_dir/${EFIDIR}/* ${EFIIMGDIR}${EFIDIR}
+        cp $iso_dir/vmlinuz ${EFIIMGDIR}
+        echo "${DEST_EFI_IMAGE}" > ${EFIIMGDIR}/startup.nsh
+        if [ -f "$iso_dir/initrd" ] ; then
+            cp $iso_dir/initrd ${EFIIMGDIR}
+        fi
+}
+
+gummiboot_hddimg_populate() {
+        gummiboot_populate $1
+}
+
+python build_gummiboot_cfg() {
+    s = d.getVar("S", True)
+    labels = d.getVar('LABELS', True)
+    if not labels:
+        bb.debug(1, "LABELS not defined, nothing to do")
+        return
+
+    if labels == []:
+        bb.debug(1, "No labels, nothing to do")
+        return
+
+    cfile = d.getVar('GUMMIBOOT_CFG', True)
+    try:
+         cfgfile = open(cfile, 'w')
+    except OSError:
+        raise bb.build.funcFailed('Unable to open %s' % (cfile))
+
+    cfgfile.write('# Automatically created by OE\n')
+    cfgfile.write('default %s\n' % (labels.split()[0]))
+    timeout = d.getVar('GUMMIBOOT_TIMEOUT', True)
+    if timeout:
+        cfgfile.write('timeout %s\n' % timeout)
+    else:
+        cfgfile.write('timeout 10\n')
+    cfgfile.close()
+
+    for label in labels.split():
+        localdata = d.createCopy()
+

meta/classes/gummiboot.bbclass

Quoted 10 lines
meta/classes/gummiboot.bbclass new file +10 -0
+        overrides = localdata.getVar('OVERRIDES', True)
+        if not overrides:
+            raise bb.build.FuncFailed('OVERRIDES not defined')
+
+        entryfile = "%s/%s.conf" % (s, label)
+        d.appendVar("GUMMIBOOT_ENTRIES", " " + entryfile)
+        try:
+            entrycfg = open(entryfile, "w")
+        except OSError:
+            raise bb.build.funcFailed('Unable to open %s' %

(entryfile))

Quoted 66 lines
meta/classes/gummiboot.bbclass new file +24 -0
+        localdata.setVar('OVERRIDES', label + ':' + overrides)
+        bb.data.update_data(localdata)
+
+        entrycfg.write('title %s\n' % label)
+        entrycfg.write('linux /vmlinuz\n')
+
+        append = localdata.getVar('APPEND', True)
+        initrd = localdata.getVar('INITRD', True)
+
+        if initrd:
+            entrycfg.write('initrd /initrd\n')
+        lb = label
+        if label == "install":
+            lb = "install-efi"
+        entrycfg.write('options LABEL=%s ' % lb)
+        if append:
+            entrycfg.write('%s' % append)
+        entrycfg.write('\n')
+        entrycfg.close()
+}
+
+python build_efi_cfg() {
+    bb.build.exec_func("build_gummiboot_cfg", d)
+}
meta/recipes-core/initrdscripts/files/init-install-efi.sh +0 -0
index 9846637..ed3221b 100644
@@ -104,6 +104,7 @@ parted /dev/${device} mklabel gpt
 

echo "Creating boot partition on $bootfs" parted /dev/${device} mkpart primary 0% $boot_size +parted /dev/${device} set 1 boot on

echo "Creating rootfs partition on $rootfs"
parted /dev/${device} mkpart primary $rootfs_start $rootfs_end

meta/recipes-core/initrdscripts/files/init-install-efi.sh +0 -0
@@ -149,23 +150,41 @@ mount $bootfs /ssd
 

EFIDIR="/ssd/EFI/BOOT"
mkdir -p $EFIDIR

meta/recipes-core/initrdscripts/files/init-install-efi.sh +0 -2
-GRUBCFG="$EFIDIR/grub.cfg"
-

cp /media/$1/vmlinuz /ssd

meta/recipes-core/initrdscripts/files/init-install-efi.sh +0 -14
-# Copy the efi loader and config (booti*.efi and grub.cfg)
-cp /media/$1/EFI/BOOT/* $EFIDIR
-
-# Update grub config for the installed image
-# Delete the install entry
-sed -i "/menuentry 'install'/,/^}/d" $GRUBCFG
-# Delete the initrd lines
-sed -i "/initrd /d" $GRUBCFG
-# Delete any LABEL= strings
-sed -i "s/ LABEL=[^ ]*/ /" $GRUBCFG
-# Delete any root= strings
-sed -i "s/ root=[^ ]*/ /" $GRUBCFG
-# Add the root= and other standard boot options
-sed -i "s@linux /vmlinuz *@linux /vmlinuz root=$rootfs rw $rootwait

quiet @" $GRUBCFG

meta/recipes-core/initrdscripts/files/init-install-efi.sh +7 -0
+# Copy the efi loader
+cp /media/$1/EFI/BOOT/*.efi $EFIDIR
+
+if [ -f /media/$1/EFI/BOOT/grub.cfg ]; then
+    GRUBCFG="$EFIDIR/grub.cfg"
+    cp /media/$1/EFI/BOOT/grub.cfg $GRUBCFG
+    # Update grub config for the installed image

meta/recipes-core/initrdscripts/files/init-install-efi.sh mount $bootfs /ssd

Quoted 10 lines
meta/recipes-core/initrdscripts/files/init-install-efi.sh +10 -0
+    # Delete the install entry
+    sed -i "/menuentry 'install'/,/^}/d" $GRUBCFG
+    # Delete the initrd lines
+    sed -i "/initrd /d" $GRUBCFG
+    # Delete any LABEL= strings
+    sed -i "s/ LABEL=[^ ]*/ /" $GRUBCFG
+    # Delete any root= strings
+    sed -i "s/ root=[^ ]*/ /" $GRUBCFG
+    # Add the root= and other standard boot options
+    sed -i "s@linux /vmlinuz *@linux /vmlinuz root=$rootfs rw

$rootwait

Quoted 26 lines

quiet @" $GRUBCFG

meta/recipes-core/initrdscripts/files/init-install-efi.sh +16 -0
+fi
+
+if [ -d /media/$1/loader ]; then
+    GUMMIBOOT_CFGS="/ssd/loader/entries/*.conf"
+    # copy config files for gummiboot
+    cp -dr /media/$1/loader /ssd
+    # delete the install entry
+    rm -f /ssd/loader/entries/install.conf
+    # delete the initrd lines
+    sed -i "/initrd /d" $GUMMIBOOT_CFGS
+    # delete any LABEL= strings
+    sed -i "s/ LABEL=[^ ]*/ /" $GUMMIBOOT_CFGS
+    # delete any root= strings
+    sed -i "s/ root=[^ ]*/ /" $GUMMIBOOT_CFGS
+    # add the root= and other standard boot options
+    sed -i "s@options *@options root=$rootfs rw $rootwait quiet @"

$GUMMIBOOT_CFGS
+fi

umount /ssd
sync

Signature · 1 line
1.8.5.3
Signature · 3 lines
Darren Hart
Yocto Project - Linux Kernel
Intel Open Source Technology Center