Patchwork [5/5] grub-efi.bbclass: Add serial and graphics menu options

login
register
mail settings
Submitter Jason Wessel
Date Sept. 12, 2013, 5:19 p.m.
Message ID <1379006387-20186-6-git-send-email-jason.wessel@windriver.com>
Download mbox | patch
Permalink /patch/57911/
State New
Headers show

Comments

Jason Wessel - Sept. 12, 2013, 5:19 p.m.
The syslinux.bbclass already has support for automatically generated
serial and graphics menu choices.  This patch adds the same concept to
the grub-efi menu.  That makes it possible to generate a single image
which can boot on a PCBIOS or EFI firmware with consistent looking
boot options.

[YOCTO #4100]

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
---
 meta/classes/grub-efi.bbclass     |   41 ++++++++++++++++++++++++-------------
 meta/conf/machine/qemux86-64.conf |    2 +-
 meta/conf/machine/qemux86.conf    |    2 ++
 3 files changed, 30 insertions(+), 15 deletions(-)
Saul Wold - Sept. 12, 2013, 6:01 p.m.
On 09/12/2013 10:19 AM, Jason Wessel wrote:
> The syslinux.bbclass already has support for automatically generated
> serial and graphics menu choices.  This patch adds the same concept to
> the grub-efi menu.  That makes it possible to generate a single image
> which can boot on a PCBIOS or EFI firmware with consistent looking
> boot options.
>
> [YOCTO #4100]
>
> Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
> ---
>   meta/classes/grub-efi.bbclass     |   41 ++++++++++++++++++++++++-------------
>   meta/conf/machine/qemux86-64.conf |    2 +-
>   meta/conf/machine/qemux86.conf    |    2 ++
>   3 files changed, 30 insertions(+), 15 deletions(-)
>
> diff --git a/meta/classes/grub-efi.bbclass b/meta/classes/grub-efi.bbclass
> index c6f5d4e..c07e4a1 100644
> --- a/meta/classes/grub-efi.bbclass
> +++ b/meta/classes/grub-efi.bbclass
> @@ -9,6 +9,7 @@
>   # External variables
>   # ${INITRD} - indicates a filesystem image to use as an initrd (optional)
>   # ${ROOTFS} - indicates a filesystem image to include as the root filesystem (optional)
> +# ${GRUB_GFXSERIAL} - set this to 1 to have graphics and serial in the boot menu
>   # ${LABELS} - a list of targets for the automatic config
>   # ${APPEND} - an override list of append strings for each label
>   # ${GRUB_OPTS} - additional options to add to the config, ';' delimited # (optional)
> @@ -16,6 +17,7 @@
>
>   do_bootimg[depends] += "grub-efi-${TRANSLATED_TARGET_ARCH}-native:do_deploy"
>
> +GRUB_SERIAL ?= "console=ttyS0,115200"
>   GRUBCFG = "${S}/grub.cfg"
>   GRUB_TIMEOUT ?= "10"
>   #FIXME: build this from the machine config
> @@ -55,6 +57,8 @@ python build_grub_cfg() {
>           bb.error("WORKDIR not defined, unable to package")
>           return
>
> +    gfxserial = d.getVar('GRUB_GFXSERIAL', True) or ""
> +
>       labels = d.getVar('LABELS', True)
>       if not labels:
>           bb.debug(1, "LABELS not defined, nothing to do")
> @@ -88,6 +92,12 @@ python build_grub_cfg() {
>       else:
>           cfgfile.write('timeout=50\n')
>
> +    if gfxserial == "1":
> +        btypes = [ [ " graphics console", "console=tty0" ],
> +            [ " serial console", d.getVar('GRUB_SERIAL', True) or "" ] ]
> +    else:
> +        btypes = [ [ "", "" ] ]
> +
>       for label in labels.split():
>           localdata = d.createCopy()
>
> @@ -95,24 +105,27 @@ python build_grub_cfg() {
>           if not overrides:
>               raise bb.build.FuncFailed('OVERRIDES not defined')
>
> -        localdata.setVar('OVERRIDES', label + ':' + overrides)
> -        bb.data.update_data(localdata)
> +        for btype in btypes:
> +            localdata.setVar('OVERRIDES', label + ':' + overrides)
> +            bb.data.update_data(localdata)
>
> -        cfgfile.write('\nmenuentry \'%s\'{\n' % (label))
> -        if label == "install":
> -            label = "install-efi"
> -        cfgfile.write('linux /vmlinuz LABEL=%s' % (label))
> +            cfgfile.write('\nmenuentry \'%s%s\'{\n' % (label, btype[0]))
> +            lb = label
> +            if label == "install":
> +                lb = "install-efi"
> +            cfgfile.write('linux /vmlinuz LABEL=%s' % (lb))
>
> -        append = localdata.getVar('APPEND', True)
> -        initrd = localdata.getVar('INITRD', True)
> +            append = localdata.getVar('APPEND', True)
> +            initrd = localdata.getVar('INITRD', True)
>
> -        if append:
> -            cfgfile.write('%s' % (append))
> -        cfgfile.write('\n')
> +            if append:
> +                cfgfile.write('%s' % (append))
> +            cfgfile.write(' %s' % btype[1])
> +            cfgfile.write('\n')
>
> -        if initrd:
> -            cfgfile.write('initrd /initrd')
> -        cfgfile.write('\n}\n')
> +            if initrd:
> +                cfgfile.write('initrd /initrd')
> +            cfgfile.write('\n}\n')
>
>       cfgfile.close()
>   }
> diff --git a/meta/conf/machine/qemux86-64.conf b/meta/conf/machine/qemux86-64.conf
> index c572225..6f68410 100644
> --- a/meta/conf/machine/qemux86-64.conf
> +++ b/meta/conf/machine/qemux86-64.conf
> @@ -21,6 +21,6 @@ XSERVER = "xserver-xorg \
>              xf86-input-evdev \
>              xf86-video-vmware"
>
> -MACHINE_FEATURES += "x86"
> +MACHINE_FEATURES += "x86 efi"
>
>   MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "v86d"
> diff --git a/meta/conf/machine/qemux86.conf b/meta/conf/machine/qemux86.conf
> index 94ee573..57a9a50 100644
> --- a/meta/conf/machine/qemux86.conf
> +++ b/meta/conf/machine/qemux86.conf
> @@ -22,5 +22,7 @@ XSERVER = "xserver-xorg \
>              xf86-video-vmware"
>
>   MACHINE_FEATURES += "x86"
> +MACHINE_FEATURES += "efi"
> +#MACHINE_FEATURES += "pcbios"
>
Did you intend to keep the commented out like vs what you did above in 
x86-64?

>   MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "v86d"
>

Will this affect the genericx86* also?

Sau!
Jason Wessel - Sept. 12, 2013, 6:06 p.m.
On 09/12/2013 01:01 PM, Saul Wold wrote:
> On 09/12/2013 10:19 AM, Jason Wessel wrote:
>> The syslinux.bbclass already has support for automatically generated
>> serial and graphics menu choices.  This patch adds the same concept to
>> the grub-efi menu.  That makes it possible to generate a single image
>> which can boot on a PCBIOS or EFI firmware with consistent looking
>> boot options.
>>
>> [YOCTO #4100]
>>
>> Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
>> ---
>>   meta/classes/grub-efi.bbclass     |   41 ++++++++++++++++++++++++-------------
>>   meta/conf/machine/qemux86-64.conf |    2 +-
>>   meta/conf/machine/qemux86.conf    |    2 ++
>>   3 files changed, 30 insertions(+), 15 deletions(-)
>>
>> diff --git a/meta/classes/grub-efi.bbclass b/meta/classes/grub-efi.bbclass
>> index c6f5d4e..c07e4a1 100644
>> --- a/meta/classes/grub-efi.bbclass
>> +++ b/meta/classes/grub-efi.bbclass
>> @@ -9,6 +9,7 @@
>>   # External variables
>>   # ${INITRD} - indicates a filesystem image to use as an initrd (optional)
>>   # ${ROOTFS} - indicates a filesystem image to include as the root filesystem (optional)
>> +# ${GRUB_GFXSERIAL} - set this to 1 to have graphics and serial in the boot menu
>>   # ${LABELS} - a list of targets for the automatic config
>>   # ${APPEND} - an override list of append strings for each label
>>   # ${GRUB_OPTS} - additional options to add to the config, ';' delimited # (optional)
>> @@ -16,6 +17,7 @@
>>
>>   do_bootimg[depends] += "grub-efi-${TRANSLATED_TARGET_ARCH}-native:do_deploy"
>>
>> +GRUB_SERIAL ?= "console=ttyS0,115200"
>>   GRUBCFG = "${S}/grub.cfg"
>>   GRUB_TIMEOUT ?= "10"
>>   #FIXME: build this from the machine config
>> @@ -55,6 +57,8 @@ python build_grub_cfg() {
>>           bb.error("WORKDIR not defined, unable to package")
>>           return
>>
>> +    gfxserial = d.getVar('GRUB_GFXSERIAL', True) or ""
>> +
>>       labels = d.getVar('LABELS', True)
>>       if not labels:
>>           bb.debug(1, "LABELS not defined, nothing to do")
>> @@ -88,6 +92,12 @@ python build_grub_cfg() {
>>       else:
>>           cfgfile.write('timeout=50\n')
>>
>> +    if gfxserial == "1":
>> +        btypes = [ [ " graphics console", "console=tty0" ],
>> +            [ " serial console", d.getVar('GRUB_SERIAL', True) or "" ] ]
>> +    else:
>> +        btypes = [ [ "", "" ] ]
>> +
>>       for label in labels.split():
>>           localdata = d.createCopy()
>>
>> @@ -95,24 +105,27 @@ python build_grub_cfg() {
>>           if not overrides:
>>               raise bb.build.FuncFailed('OVERRIDES not defined')
>>
>> -        localdata.setVar('OVERRIDES', label + ':' + overrides)
>> -        bb.data.update_data(localdata)
>> +        for btype in btypes:
>> +            localdata.setVar('OVERRIDES', label + ':' + overrides)
>> +            bb.data.update_data(localdata)
>>
>> -        cfgfile.write('\nmenuentry \'%s\'{\n' % (label))
>> -        if label == "install":
>> -            label = "install-efi"
>> -        cfgfile.write('linux /vmlinuz LABEL=%s' % (label))
>> +            cfgfile.write('\nmenuentry \'%s%s\'{\n' % (label, btype[0]))
>> +            lb = label
>> +            if label == "install":
>> +                lb = "install-efi"
>> +            cfgfile.write('linux /vmlinuz LABEL=%s' % (lb))
>>
>> -        append = localdata.getVar('APPEND', True)
>> -        initrd = localdata.getVar('INITRD', True)
>> +            append = localdata.getVar('APPEND', True)
>> +            initrd = localdata.getVar('INITRD', True)
>>
>> -        if append:
>> -            cfgfile.write('%s' % (append))
>> -        cfgfile.write('\n')
>> +            if append:
>> +                cfgfile.write('%s' % (append))
>> +            cfgfile.write(' %s' % btype[1])
>> +            cfgfile.write('\n')
>>
>> -        if initrd:
>> -            cfgfile.write('initrd /initrd')
>> -        cfgfile.write('\n}\n')
>> +            if initrd:
>> +                cfgfile.write('initrd /initrd')
>> +            cfgfile.write('\n}\n')
>>
>>       cfgfile.close()
>>   }
>> diff --git a/meta/conf/machine/qemux86-64.conf b/meta/conf/machine/qemux86-64.conf
>> index c572225..6f68410 100644
>> --- a/meta/conf/machine/qemux86-64.conf
>> +++ b/meta/conf/machine/qemux86-64.conf
>> @@ -21,6 +21,6 @@ XSERVER = "xserver-xorg \
>>              xf86-input-evdev \
>>              xf86-video-vmware"
>>
>> -MACHINE_FEATURES += "x86"
>> +MACHINE_FEATURES += "x86 efi"
>>
>>   MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "v86d"
>> diff --git a/meta/conf/machine/qemux86.conf b/meta/conf/machine/qemux86.conf
>> index 94ee573..57a9a50 100644
>> --- a/meta/conf/machine/qemux86.conf
>> +++ b/meta/conf/machine/qemux86.conf
>> @@ -22,5 +22,7 @@ XSERVER = "xserver-xorg \
>>              xf86-video-vmware"
>>
>>   MACHINE_FEATURES += "x86"
>> +MACHINE_FEATURES += "efi"
>> +#MACHINE_FEATURES += "pcbios"
>>
> Did you intend to keep the commented out like vs what you did above in 
> x86-64?
>
>>   MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "v86d"
>>
> Will this affect the genericx86* also?


Doh!  That isn't even supposed to be in there.   I was just using the qemu targets to build some generic images and then run them on qemu + some real hw + Tiano UEFI core images.   It is possible that we can just start building pcbios and efi on the qemu BSPs, but I don't think that is the intent since we do not currently have Tiano core roms, tboot or anything of the like for use with runqemu.

I'll fix this up along with your other comments and Darren's in a v2 series.

Jason.
Darren Hart - Sept. 12, 2013, 6:11 p.m.
On Thu, 2013-09-12 at 11:01 -0700, Saul Wold wrote:
> On 09/12/2013 10:19 AM, Jason Wessel wrote:
> > The syslinux.bbclass already has support for automatically generated
> > serial and graphics menu choices.  This patch adds the same concept to
> > the grub-efi menu.  That makes it possible to generate a single image
> > which can boot on a PCBIOS or EFI firmware with consistent looking
> > boot options.
> >
> > [YOCTO #4100]
> >
> > Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
> > ---
> >   meta/classes/grub-efi.bbclass     |   41 ++++++++++++++++++++++++-------------
> >   meta/conf/machine/qemux86-64.conf |    2 +-
> >   meta/conf/machine/qemux86.conf    |    2 ++
> >   3 files changed, 30 insertions(+), 15 deletions(-)
> >
> > diff --git a/meta/classes/grub-efi.bbclass b/meta/classes/grub-efi.bbclass
> > index c6f5d4e..c07e4a1 100644
> > --- a/meta/classes/grub-efi.bbclass
> > +++ b/meta/classes/grub-efi.bbclass
> > @@ -9,6 +9,7 @@
> >   # External variables
> >   # ${INITRD} - indicates a filesystem image to use as an initrd (optional)
> >   # ${ROOTFS} - indicates a filesystem image to include as the root filesystem (optional)
> > +# ${GRUB_GFXSERIAL} - set this to 1 to have graphics and serial in the boot menu
> >   # ${LABELS} - a list of targets for the automatic config
> >   # ${APPEND} - an override list of append strings for each label
> >   # ${GRUB_OPTS} - additional options to add to the config, ';' delimited # (optional)
> > @@ -16,6 +17,7 @@
> >
> >   do_bootimg[depends] += "grub-efi-${TRANSLATED_TARGET_ARCH}-native:do_deploy"
> >
> > +GRUB_SERIAL ?= "console=ttyS0,115200"
> >   GRUBCFG = "${S}/grub.cfg"
> >   GRUB_TIMEOUT ?= "10"
> >   #FIXME: build this from the machine config
> > @@ -55,6 +57,8 @@ python build_grub_cfg() {
> >           bb.error("WORKDIR not defined, unable to package")
> >           return
> >
> > +    gfxserial = d.getVar('GRUB_GFXSERIAL', True) or ""
> > +
> >       labels = d.getVar('LABELS', True)
> >       if not labels:
> >           bb.debug(1, "LABELS not defined, nothing to do")
> > @@ -88,6 +92,12 @@ python build_grub_cfg() {
> >       else:
> >           cfgfile.write('timeout=50\n')
> >
> > +    if gfxserial == "1":
> > +        btypes = [ [ " graphics console", "console=tty0" ],
> > +            [ " serial console", d.getVar('GRUB_SERIAL', True) or "" ] ]
> > +    else:
> > +        btypes = [ [ "", "" ] ]
> > +
> >       for label in labels.split():
> >           localdata = d.createCopy()
> >
> > @@ -95,24 +105,27 @@ python build_grub_cfg() {
> >           if not overrides:
> >               raise bb.build.FuncFailed('OVERRIDES not defined')
> >
> > -        localdata.setVar('OVERRIDES', label + ':' + overrides)
> > -        bb.data.update_data(localdata)
> > +        for btype in btypes:
> > +            localdata.setVar('OVERRIDES', label + ':' + overrides)
> > +            bb.data.update_data(localdata)
> >
> > -        cfgfile.write('\nmenuentry \'%s\'{\n' % (label))
> > -        if label == "install":
> > -            label = "install-efi"
> > -        cfgfile.write('linux /vmlinuz LABEL=%s' % (label))
> > +            cfgfile.write('\nmenuentry \'%s%s\'{\n' % (label, btype[0]))
> > +            lb = label
> > +            if label == "install":
> > +                lb = "install-efi"
> > +            cfgfile.write('linux /vmlinuz LABEL=%s' % (lb))
> >
> > -        append = localdata.getVar('APPEND', True)
> > -        initrd = localdata.getVar('INITRD', True)
> > +            append = localdata.getVar('APPEND', True)
> > +            initrd = localdata.getVar('INITRD', True)
> >
> > -        if append:
> > -            cfgfile.write('%s' % (append))
> > -        cfgfile.write('\n')
> > +            if append:
> > +                cfgfile.write('%s' % (append))
> > +            cfgfile.write(' %s' % btype[1])
> > +            cfgfile.write('\n')
> >
> > -        if initrd:
> > -            cfgfile.write('initrd /initrd')
> > -        cfgfile.write('\n}\n')
> > +            if initrd:
> > +                cfgfile.write('initrd /initrd')
> > +            cfgfile.write('\n}\n')
> >
> >       cfgfile.close()
> >   }
> > diff --git a/meta/conf/machine/qemux86-64.conf b/meta/conf/machine/qemux86-64.conf
> > index c572225..6f68410 100644
> > --- a/meta/conf/machine/qemux86-64.conf
> > +++ b/meta/conf/machine/qemux86-64.conf
> > @@ -21,6 +21,6 @@ XSERVER = "xserver-xorg \
> >              xf86-input-evdev \
> >              xf86-video-vmware"
> >
> > -MACHINE_FEATURES += "x86"
> > +MACHINE_FEATURES += "x86 efi"
> >
> >   MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "v86d"
> > diff --git a/meta/conf/machine/qemux86.conf b/meta/conf/machine/qemux86.conf
> > index 94ee573..57a9a50 100644
> > --- a/meta/conf/machine/qemux86.conf
> > +++ b/meta/conf/machine/qemux86.conf
> > @@ -22,5 +22,7 @@ XSERVER = "xserver-xorg \
> >              xf86-video-vmware"
> >
> >   MACHINE_FEATURES += "x86"
> > +MACHINE_FEATURES += "efi"
> > +#MACHINE_FEATURES += "pcbios"
> >

This can just be one line:

MACHINE_FEATURES += "x86 pcbios efi"

> Did you intend to keep the commented out like vs what you did above in 
> x86-64?
> 
> >   MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "v86d"
> >
> 
> Will this affect the genericx86* also?

No, both genericx86 machines have efi and pcbios in their machine
features.

> 
> Sau!
>
Darren Hart - Sept. 12, 2013, 6:16 p.m.
On Thu, 2013-09-12 at 12:19 -0500, Jason Wessel wrote:
> The syslinux.bbclass already has support for automatically generated
> serial and graphics menu choices.  This patch adds the same concept to
> the grub-efi menu.  That makes it possible to generate a single image
> which can boot on a PCBIOS or EFI firmware with consistent looking
> boot options.
> 
> [YOCTO #4100]
> 
> Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
> ---
>  meta/classes/grub-efi.bbclass     |   41 ++++++++++++++++++++++++-------------
>  meta/conf/machine/qemux86-64.conf |    2 +-
>  meta/conf/machine/qemux86.conf    |    2 ++
>  3 files changed, 30 insertions(+), 15 deletions(-)
> 
> diff --git a/meta/classes/grub-efi.bbclass b/meta/classes/grub-efi.bbclass
> index c6f5d4e..c07e4a1 100644
> --- a/meta/classes/grub-efi.bbclass
> +++ b/meta/classes/grub-efi.bbclass
> @@ -9,6 +9,7 @@
>  # External variables
>  # ${INITRD} - indicates a filesystem image to use as an initrd (optional)
>  # ${ROOTFS} - indicates a filesystem image to include as the root filesystem (optional)
> +# ${GRUB_GFXSERIAL} - set this to 1 to have graphics and serial in the boot menu
>  # ${LABELS} - a list of targets for the automatic config
>  # ${APPEND} - an override list of append strings for each label
>  # ${GRUB_OPTS} - additional options to add to the config, ';' delimited # (optional)
> @@ -16,6 +17,7 @@
>  
>  do_bootimg[depends] += "grub-efi-${TRANSLATED_TARGET_ARCH}-native:do_deploy"
>  
> +GRUB_SERIAL ?= "console=ttyS0,115200"
>  GRUBCFG = "${S}/grub.cfg"
>  GRUB_TIMEOUT ?= "10"
>  #FIXME: build this from the machine config
> @@ -55,6 +57,8 @@ python build_grub_cfg() {
>          bb.error("WORKDIR not defined, unable to package")
>          return
>  
> +    gfxserial = d.getVar('GRUB_GFXSERIAL', True) or ""
> +
>      labels = d.getVar('LABELS', True)
>      if not labels:
>          bb.debug(1, "LABELS not defined, nothing to do")
> @@ -88,6 +92,12 @@ python build_grub_cfg() {
>      else:
>          cfgfile.write('timeout=50\n')
>  
> +    if gfxserial == "1":
> +        btypes = [ [ " graphics console", "console=tty0" ],
> +            [ " serial console", d.getVar('GRUB_SERIAL', True) or "" ] ]
> +    else:
> +        btypes = [ [ "", "" ] ]
> +
>      for label in labels.split():
>          localdata = d.createCopy()
>  
> @@ -95,24 +105,27 @@ python build_grub_cfg() {
>          if not overrides:
>              raise bb.build.FuncFailed('OVERRIDES not defined')
>  
> -        localdata.setVar('OVERRIDES', label + ':' + overrides)
> -        bb.data.update_data(localdata)
> +        for btype in btypes:
> +            localdata.setVar('OVERRIDES', label + ':' + overrides)
> +            bb.data.update_data(localdata)
>  
> -        cfgfile.write('\nmenuentry \'%s\'{\n' % (label))
> -        if label == "install":
> -            label = "install-efi"
> -        cfgfile.write('linux /vmlinuz LABEL=%s' % (label))
> +            cfgfile.write('\nmenuentry \'%s%s\'{\n' % (label, btype[0]))
> +            lb = label
> +            if label == "install":
> +                lb = "install-efi"
> +            cfgfile.write('linux /vmlinuz LABEL=%s' % (lb))
>  
> -        append = localdata.getVar('APPEND', True)
> -        initrd = localdata.getVar('INITRD', True)
> +            append = localdata.getVar('APPEND', True)
> +            initrd = localdata.getVar('INITRD', True)
>  
> -        if append:
> -            cfgfile.write('%s' % (append))
> -        cfgfile.write('\n')
> +            if append:
> +                cfgfile.write('%s' % (append))
> +            cfgfile.write(' %s' % btype[1])
> +            cfgfile.write('\n')
>  
> -        if initrd:
> -            cfgfile.write('initrd /initrd')
> -        cfgfile.write('\n}\n')
> +            if initrd:
> +                cfgfile.write('initrd /initrd')
> +            cfgfile.write('\n}\n')
>  
>      cfgfile.close()
>  }

I'm not very familiar with the cfgfile for menus and such, so I don't
have much to add. The one thing that catches me by surprise is the need
for the serial device. On EFI systems, grub here uses the EFI console
service, so if that uses the serial port you get it for free, no need
for GRUB to try and use it directly. In fact.... does the above not
cause some kind of conflict between the EFI console service and grub
serial?

Both of the following should be in a separate patch. In fact, they
should probably have a qemux86-common.inc which took care of most of
this (as was done recently for genericx86-common.inc).

> diff --git a/meta/conf/machine/qemux86-64.conf b/meta/conf/machine/qemux86-64.conf
> index c572225..6f68410 100644
> --- a/meta/conf/machine/qemux86-64.conf
> +++ b/meta/conf/machine/qemux86-64.conf
> @@ -21,6 +21,6 @@ XSERVER = "xserver-xorg \
>             xf86-input-evdev \
>             xf86-video-vmware"
>  
> -MACHINE_FEATURES += "x86"
> +MACHINE_FEATURES += "x86 efi"
>  
>  MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "v86d"
> diff --git a/meta/conf/machine/qemux86.conf b/meta/conf/machine/qemux86.conf
> index 94ee573..57a9a50 100644
> --- a/meta/conf/machine/qemux86.conf
> +++ b/meta/conf/machine/qemux86.conf
> @@ -22,5 +22,7 @@ XSERVER = "xserver-xorg \
>             xf86-video-vmware"
>  
>  MACHINE_FEATURES += "x86"
> +MACHINE_FEATURES += "efi"
> +#MACHINE_FEATURES += "pcbios"
>  
>  MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "v86d"
Jason Wessel - Sept. 12, 2013, 7:52 p.m.
On 09/12/2013 01:16 PM, Darren Hart wrote:
> On Thu, 2013-09-12 at 12:19 -0500, Jason Wessel wrote:
>> The syslinux.bbclass already has support for automatically generated
>> serial and graphics menu choices.  This patch adds the same concept to
>> the grub-efi menu.  That makes it possible to generate a single image
>> which can boot on a PCBIOS or EFI firmware with consistent looking
>> boot options.
>>
>> [YOCTO #4100]
>>
>> Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
>> ---
>>  meta/classes/grub-efi.bbclass     |   41 ++++++++++++++++++++++++-------------
>>  meta/conf/machine/qemux86-64.conf |    2 +-
>>  meta/conf/machine/qemux86.conf    |    2 ++
>>  3 files changed, 30 insertions(+), 15 deletions(-)
>>
>> diff --git a/meta/classes/grub-efi.bbclass b/meta/classes/grub-efi.bbclass
>> index c6f5d4e..c07e4a1 100644
>> --- a/meta/classes/grub-efi.bbclass
>> +++ b/meta/classes/grub-efi.bbclass
>> @@ -9,6 +9,7 @@
>>  # External variables
>>  # ${INITRD} - indicates a filesystem image to use as an initrd (optional)
>>  # ${ROOTFS} - indicates a filesystem image to include as the root filesystem (optional)
>> +# ${GRUB_GFXSERIAL} - set this to 1 to have graphics and serial in the boot menu
>>  # ${LABELS} - a list of targets for the automatic config
>>  # ${APPEND} - an override list of append strings for each label
>>  # ${GRUB_OPTS} - additional options to add to the config, ';' delimited # (optional)
>> @@ -16,6 +17,7 @@
>>  
>>  do_bootimg[depends] += "grub-efi-${TRANSLATED_TARGET_ARCH}-native:do_deploy"
>>  
>> +GRUB_SERIAL ?= "console=ttyS0,115200"
>>  GRUBCFG = "${S}/grub.cfg"
>>  GRUB_TIMEOUT ?= "10"
>>  #FIXME: build this from the machine config
>> @@ -55,6 +57,8 @@ python build_grub_cfg() {
>>          bb.error("WORKDIR not defined, unable to package")
>>          return
>>  
>> +    gfxserial = d.getVar('GRUB_GFXSERIAL', True) or ""
>> +
>>      labels = d.getVar('LABELS', True)
>>      if not labels:
>>          bb.debug(1, "LABELS not defined, nothing to do")
>> @@ -88,6 +92,12 @@ python build_grub_cfg() {
>>      else:
>>          cfgfile.write('timeout=50\n')
>>  
>> +    if gfxserial == "1":
>> +        btypes = [ [ " graphics console", "console=tty0" ],
>> +            [ " serial console", d.getVar('GRUB_SERIAL', True) or "" ] ]
>> +    else:
>> +        btypes = [ [ "", "" ] ]
>> +
>>      for label in labels.split():
>>          localdata = d.createCopy()
>>  
>> @@ -95,24 +105,27 @@ python build_grub_cfg() {
>>          if not overrides:
>>              raise bb.build.FuncFailed('OVERRIDES not defined')
>>  
>> -        localdata.setVar('OVERRIDES', label + ':' + overrides)
>> -        bb.data.update_data(localdata)
>> +        for btype in btypes:
>> +            localdata.setVar('OVERRIDES', label + ':' + overrides)
>> +            bb.data.update_data(localdata)
>>  
>> -        cfgfile.write('\nmenuentry \'%s\'{\n' % (label))
>> -        if label == "install":
>> -            label = "install-efi"
>> -        cfgfile.write('linux /vmlinuz LABEL=%s' % (label))
>> +            cfgfile.write('\nmenuentry \'%s%s\'{\n' % (label, btype[0]))
>> +            lb = label
>> +            if label == "install":
>> +                lb = "install-efi"
>> +            cfgfile.write('linux /vmlinuz LABEL=%s' % (lb))
>>  
>> -        append = localdata.getVar('APPEND', True)
>> -        initrd = localdata.getVar('INITRD', True)
>> +            append = localdata.getVar('APPEND', True)
>> +            initrd = localdata.getVar('INITRD', True)
>>  
>> -        if append:
>> -            cfgfile.write('%s' % (append))
>> -        cfgfile.write('\n')
>> +            if append:
>> +                cfgfile.write('%s' % (append))
>> +            cfgfile.write(' %s' % btype[1])
>> +            cfgfile.write('\n')
>>  
>> -        if initrd:
>> -            cfgfile.write('initrd /initrd')
>> -        cfgfile.write('\n}\n')
>> +            if initrd:
>> +                cfgfile.write('initrd /initrd')
>> +            cfgfile.write('\n}\n')
>>  
>>      cfgfile.close()
>>  }
> 
> I'm not very familiar with the cfgfile for menus and such, so I don't
> have much to add. The one thing that catches me by surprise is the need
> for the serial device. On EFI systems, grub here uses the EFI console
> service, so if that uses the serial port you get it for free, no need
> for GRUB to try and use it directly. In fact.... does the above not
> cause some kind of conflict between the EFI console service and grub
> serial?
> 

In part that is why it is optional.   With respect to the serial bits, these are only the kernel boot arguments we are talking about.  It doesn't seem that there is a "primary" display interface for the HCDP in the EFI firmware I have.   Additionally, the kernel throws the EFI serial console under the bus at ACPI probe time, while this certainly could also be a bug in the firmware I have on my test board, the only way to keep the serial port alive for a login and the kernel boot information was to specify console=ttyS0...

I have yet another system I need to try this on which has a much newer UEFI and a serial port, but I thought it would be best to get something out there that covers the "buggy firmwares" as well which can be built optionally. 


> Both of the following should be in a separate patch. In fact, they
> should probably have a qemux86-common.inc which took care of most of
> this (as was done recently for genericx86-common.inc).


So I am not sure that we want to patch up the qemux86* conf files at all.  Do we want to enable EFI + PCBIOS all the time now that we have a way to generate images (noting these images will work with runqemu)?  I figured I would just drop those modifications entirely.  I would expect something like a "all encompassing" white box BSP to select both, but for the qemux86*, I don't think it makes sense.

Cheers,
Jason.


> 
>> diff --git a/meta/conf/machine/qemux86-64.conf b/meta/conf/machine/qemux86-64.conf
>> index c572225..6f68410 100644
>> --- a/meta/conf/machine/qemux86-64.conf
>> +++ b/meta/conf/machine/qemux86-64.conf
>> @@ -21,6 +21,6 @@ XSERVER = "xserver-xorg \
>>             xf86-input-evdev \
>>             xf86-video-vmware"
>>  
>> -MACHINE_FEATURES += "x86"
>> +MACHINE_FEATURES += "x86 efi"
>>  
>>  MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "v86d"
>> diff --git a/meta/conf/machine/qemux86.conf b/meta/conf/machine/qemux86.conf
>> index 94ee573..57a9a50 100644
>> --- a/meta/conf/machine/qemux86.conf
>> +++ b/meta/conf/machine/qemux86.conf
>> @@ -22,5 +22,7 @@ XSERVER = "xserver-xorg \
>>             xf86-video-vmware"
>>  
>>  MACHINE_FEATURES += "x86"
>> +MACHINE_FEATURES += "efi"
>> +#MACHINE_FEATURES += "pcbios"
>>  
>>  MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "v86d"
>
Darren Hart - Sept. 12, 2013, 8:09 p.m.
On Thu, 2013-09-12 at 14:52 -0500, Jason Wessel wrote:
> On 09/12/2013 01:16 PM, Darren Hart wrote:
> > On Thu, 2013-09-12 at 12:19 -0500, Jason Wessel wrote:
> >> The syslinux.bbclass already has support for automatically generated
> >> serial and graphics menu choices.  This patch adds the same concept to
> >> the grub-efi menu.  That makes it possible to generate a single image
> >> which can boot on a PCBIOS or EFI firmware with consistent looking
> >> boot options.
> >>
> >> [YOCTO #4100]
> >>
> >> Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
> >> ---
> >>  meta/classes/grub-efi.bbclass     |   41 ++++++++++++++++++++++++-------------
> >>  meta/conf/machine/qemux86-64.conf |    2 +-
> >>  meta/conf/machine/qemux86.conf    |    2 ++
> >>  3 files changed, 30 insertions(+), 15 deletions(-)
> >>
> >> diff --git a/meta/classes/grub-efi.bbclass b/meta/classes/grub-efi.bbclass
> >> index c6f5d4e..c07e4a1 100644
> >> --- a/meta/classes/grub-efi.bbclass
> >> +++ b/meta/classes/grub-efi.bbclass
> >> @@ -9,6 +9,7 @@
> >>  # External variables
> >>  # ${INITRD} - indicates a filesystem image to use as an initrd (optional)
> >>  # ${ROOTFS} - indicates a filesystem image to include as the root filesystem (optional)
> >> +# ${GRUB_GFXSERIAL} - set this to 1 to have graphics and serial in the boot menu
> >>  # ${LABELS} - a list of targets for the automatic config
> >>  # ${APPEND} - an override list of append strings for each label
> >>  # ${GRUB_OPTS} - additional options to add to the config, ';' delimited # (optional)
> >> @@ -16,6 +17,7 @@
> >>  
> >>  do_bootimg[depends] += "grub-efi-${TRANSLATED_TARGET_ARCH}-native:do_deploy"
> >>  
> >> +GRUB_SERIAL ?= "console=ttyS0,115200"

...

> > I'm not very familiar with the cfgfile for menus and such, so I don't
> > have much to add. The one thing that catches me by surprise is the need
> > for the serial device. On EFI systems, grub here uses the EFI console
> > service, so if that uses the serial port you get it for free, no need
> > for GRUB to try and use it directly. In fact.... does the above not
> > cause some kind of conflict between the EFI console service and grub
> > serial?
> > 
> 
> In part that is why it is optional.   With respect to the serial bits,
> these are only the kernel boot arguments we are talking about.  It


Hrm.... this should be handled with APPEND parameter from the machine
configs, not a new GRUB_SERIAL statement....


>  doesn't seem that there is a "primary" display interface for the HCDP
> in the EFI firmware I have.   Additionally, the kernel throws the EFI
> serial console under the bus at ACPI probe time, while this certainly
> could also be a bug in the firmware I have on my test board, the only
> way to keep the serial port alive for a login and the kernel boot
> information was to specify console=ttyS0...

Hrm.... interesting. I guess we'll just need to test more broadly.
Indeed the kernel should be using it's own console= parameter, but
again, that should come from the APPEND_machine variable.


> I have yet another system I need to try this on which has a much newer
> UEFI and a serial port, but I thought it would be best to get
> something out there that covers the "buggy firmwares" as well which
> can be built optionally.

Agreed, so long as it doesn't break the common case.


> > Both of the following should be in a separate patch. In fact, they
> > should probably have a qemux86-common.inc which took care of most of
> > this (as was done recently for genericx86-common.inc).
> 
> 
> So I am not sure that we want to patch up the qemux86* conf files at
> all.  Do we want to enable EFI + PCBIOS all the time now that we have
> a way to generate images (noting these images will work with runqemu)?
> I figured I would just drop those modifications entirely.  I would
> expect something like a "all encompassing" white box BSP to select
> both, but for the qemux86*, I don't think it makes sense.
> 

At some point we want qemux86* to boot with OVMF, but we can add "efi"
to MACHINE_FEATURES when/if that becomes doable with oe-core. So yeah,
go ahead and just drop these entirely for now.

...
Jason Wessel - Sept. 13, 2013, 9:58 p.m.
On 09/12/2013 03:09 PM, Darren Hart wrote:
> On Thu, 2013-09-12 at 14:52 -0500, Jason Wessel wrote:
>> On 09/12/2013 01:16 PM, Darren Hart wrote:
>>> On Thu, 2013-09-12 at 12:19 -0500, Jason Wessel wrote:
>>>> The syslinux.bbclass already has support for automatically generated
>>>> serial and graphics menu choices.  This patch adds the same concept to
>>>> the grub-efi menu.  That makes it possible to generate a single image
>>>> which can boot on a PCBIOS or EFI firmware with consistent looking
>>>> boot options.
>>>>
>>>> [YOCTO #4100]
>>>>
>>>> Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
>>>> ---
>>>>  meta/classes/grub-efi.bbclass     |   41 ++++++++++++++++++++++++-------------
>>>>  meta/conf/machine/qemux86-64.conf |    2 +-
>>>>  meta/conf/machine/qemux86.conf    |    2 ++
>>>>  3 files changed, 30 insertions(+), 15 deletions(-)
>>>>
>>>> diff --git a/meta/classes/grub-efi.bbclass b/meta/classes/grub-efi.bbclass
>>>> index c6f5d4e..c07e4a1 100644
>>>> --- a/meta/classes/grub-efi.bbclass
>>>> +++ b/meta/classes/grub-efi.bbclass
>>>> @@ -9,6 +9,7 @@
>>>>  # External variables
>>>>  # ${INITRD} - indicates a filesystem image to use as an initrd (optional)
>>>>  # ${ROOTFS} - indicates a filesystem image to include as the root filesystem (optional)
>>>> +# ${GRUB_GFXSERIAL} - set this to 1 to have graphics and serial in the boot menu
>>>>  # ${LABELS} - a list of targets for the automatic config
>>>>  # ${APPEND} - an override list of append strings for each label
>>>>  # ${GRUB_OPTS} - additional options to add to the config, ';' delimited # (optional)
>>>> @@ -16,6 +17,7 @@
>>>>  
>>>>  do_bootimg[depends] += "grub-efi-${TRANSLATED_TARGET_ARCH}-native:do_deploy"
>>>>  
>>>> +GRUB_SERIAL ?= "console=ttyS0,115200"
> 
> ...
> 
>>> I'm not very familiar with the cfgfile for menus and such, so I don't
>>> have much to add. The one thing that catches me by surprise is the need
>>> for the serial device. On EFI systems, grub here uses the EFI console
>>> service, so if that uses the serial port you get it for free, no need
>>> for GRUB to try and use it directly. In fact.... does the above not
>>> cause some kind of conflict between the EFI console service and grub
>>> serial?
>>>
>>
>> In part that is why it is optional.   With respect to the serial bits,
>> these are only the kernel boot arguments we are talking about.  It
> 
> 
> Hrm.... this should be handled with APPEND parameter from the machine
> configs, not a new GRUB_SERIAL statement....
> 


Well there is a problem with that.  You only have 1 APPEND, but I need 2 options.  The whole point is the ability to add SERIAL or Graphics console access for early boot all the way through user space hand off and seamlessly picking things up later in user space with mingetty etc...

This option is mainly used for the installer media and to provide a consistent look and feel regardless if you come from EFI or a PCIBIOS + syslinux.


> 
>>  doesn't seem that there is a "primary" display interface for the HCDP
>> in the EFI firmware I have.   Additionally, the kernel throws the EFI
>> serial console under the bus at ACPI probe time, while this certainly
>> could also be a bug in the firmware I have on my test board, the only
>> way to keep the serial port alive for a login and the kernel boot
>> information was to specify console=ttyS0...
> 
> Hrm.... interesting. I guess we'll just need to test more broadly.
> Indeed the kernel should be using it's own console= parameter, but
> again, that should come from the APPEND_machine variable.
> 
> 
>> I have yet another system I need to try this on which has a much newer
>> UEFI and a serial port, but I thought it would be best to get
>> something out there that covers the "buggy firmwares" as well which
>> can be built optionally.
> 
> Agreed, so long as it doesn't break the common case.


The common case is not broken.  This is something you have to turn on in the image or local.conf. 

The new patches will available soon for the whole series as soon as all the test hardware has booted in legacy and efi mode.

Cheers,
Jason.
Darren Hart - Sept. 16, 2013, 5:49 p.m.
On Fri, 2013-09-13 at 16:58 -0500, Jason Wessel wrote:
> On 09/12/2013 03:09 PM, Darren Hart wrote:
> > On Thu, 2013-09-12 at 14:52 -0500, Jason Wessel wrote:
> >> On 09/12/2013 01:16 PM, Darren Hart wrote:
> >>> On Thu, 2013-09-12 at 12:19 -0500, Jason Wessel wrote:
...

 
> >>>> +GRUB_SERIAL ?= "console=ttyS0,115200"
> > 
> > ...
> > 
> >>> I'm not very familiar with the cfgfile for menus and such, so I don't
> >>> have much to add. The one thing that catches me by surprise is the need
> >>> for the serial device. On EFI systems, grub here uses the EFI console
> >>> service, so if that uses the serial port you get it for free, no need
> >>> for GRUB to try and use it directly. In fact.... does the above not
> >>> cause some kind of conflict between the EFI console service and grub
> >>> serial?
> >>>
> >>
> >> In part that is why it is optional.   With respect to the serial bits,
> >> these are only the kernel boot arguments we are talking about.  It
> > 
> > 
> > Hrm.... this should be handled with APPEND parameter from the machine
> > configs, not a new GRUB_SERIAL statement....
> > 
> 
> 
> Well there is a problem with that.  You only have 1 APPEND, but I need
> 2 options.  The whole point is the ability to add SERIAL or Graphics


I don't follow. Do you mean you need both serial and VGA? That is still
handled by the single variable. Take the FRI2 for example:

APPEND += "console=ttyPCH1,115200 console=tty0"

With what you have here, it seems to me this will be ignored and GRUB
will instead pass console=ttyS0,115200 - which will not work on the
FRI2.

>  console access for early boot all the way through user space hand off
> and seamlessly picking things up later in user space with mingetty
> etc...
> 
> This option is mainly used for the installer media and to provide a
> consistent look and feel regardless if you come from EFI or a PCIBIOS
> + syslinux.

SYSLINUX also has some recipe-specific console options, but those are
due to the syntax differences and are used to specify how syslinux talks
to the device, while this appears to be Linux kernel syntax
("console=ttyS0") rather than grub syntax ("serial --unit=0
--speed=115200")... and yet I don't see the "console=ttyS0" being passed
to the kernel.... so I am confused. Where does the GRUB_SERIAL content
actually get used? I mean besides the creation of the btypes array....

--
Darren

> 
> 
> > 
> >>  doesn't seem that there is a "primary" display interface for the HCDP
> >> in the EFI firmware I have.   Additionally, the kernel throws the EFI
> >> serial console under the bus at ACPI probe time, while this certainly
> >> could also be a bug in the firmware I have on my test board, the only
> >> way to keep the serial port alive for a login and the kernel boot
> >> information was to specify console=ttyS0...
> > 
> > Hrm.... interesting. I guess we'll just need to test more broadly.
> > Indeed the kernel should be using it's own console= parameter, but
> > again, that should come from the APPEND_machine variable.
> > 
> > 
> >> I have yet another system I need to try this on which has a much newer
> >> UEFI and a serial port, but I thought it would be best to get
> >> something out there that covers the "buggy firmwares" as well which
> >> can be built optionally.
> > 
> > Agreed, so long as it doesn't break the common case.
> 
> 
> The common case is not broken.  This is something you have to turn on
> in the image or local.conf. 
> 
> The new patches will available soon for the whole series as soon as
> all the test hardware has booted in legacy and efi mode.
> 
> Cheers,
> Jason.
Jason Wessel - Sept. 17, 2013, 12:19 p.m.
On 09/16/2013 12:49 PM, Darren Hart wrote:
> On Fri, 2013-09-13 at 16:58 -0500, Jason Wessel wrote:
>> On 09/12/2013 03:09 PM, Darren Hart wrote:
>>> On Thu, 2013-09-12 at 14:52 -0500, Jason Wessel wrote:
>>>> On 09/12/2013 01:16 PM, Darren Hart wrote:
>>>>> On Thu, 2013-09-12 at 12:19 -0500, Jason Wessel wrote:
> ...
>
>  
>>>>>> +GRUB_SERIAL ?= "console=ttyS0,115200"
>>> ...
>>>
>>>>> I'm not very familiar with the cfgfile for menus and such, so I don't
>>>>> have much to add. The one thing that catches me by surprise is the need
>>>>> for the serial device. On EFI systems, grub here uses the EFI console
>>>>> service, so if that uses the serial port you get it for free, no need
>>>>> for GRUB to try and use it directly. In fact.... does the above not
>>>>> cause some kind of conflict between the EFI console service and grub
>>>>> serial?
>>>>>
>>>> In part that is why it is optional.   With respect to the serial bits,
>>>> these are only the kernel boot arguments we are talking about.  It
>>>
>>> Hrm.... this should be handled with APPEND parameter from the machine
>>> configs, not a new GRUB_SERIAL statement....
>>>
>>
>> Well there is a problem with that.  You only have 1 APPEND, but I need
>> 2 options.  The whole point is the ability to add SERIAL or Graphics
>
> I don't follow. Do you mean you need both serial and VGA? That is still
> handled by the single variable. Take the FRI2 for example:
>
> APPEND += "console=ttyPCH1,115200 console=tty0"
>
> With what you have here, it seems to me this will be ignored and GRUB
> will instead pass console=ttyS0,115200 - which will not work on the
> FRI2.


This is fixed in the new series. 

The auto menu is intended to offer the end user the choice of which is their default console.  Obviously you can emit text to both, but you only get one selected as the default input device.

It might not be obvious but we use mingetty and selectively use the console.   The whole alternate boot thing is completely optional.  Now if you set the SERIAL stuff to be "".

It might even be better to point this out more directly by changing the variable names to something like ALT_CONSOLE...


>
>>  console access for early boot all the way through user space hand off
>> and seamlessly picking things up later in user space with mingetty
>> etc...
>>
>> This option is mainly used for the installer media and to provide a
>> consistent look and feel regardless if you come from EFI or a PCIBIOS
>> + syslinux.
> SYSLINUX also has some recipe-specific console options, but those are
> due to the syntax differences and are used to specify how syslinux talks
> to the device, while this appears to be Linux kernel syntax
> ("console=ttyS0") rather than grub syntax ("serial --unit=0
> --speed=115200")... and yet I don't see the "console=ttyS0" being passed
> to the kernel.... so I am confused. Where does the GRUB_SERIAL content
> actually get used? I mean besides the creation of the btypes array....


This is addressed to, but we may yet go another round to clean up the understanding of things.  A v3 to arrive soon.

Cheers,
Jason.

Patch

diff --git a/meta/classes/grub-efi.bbclass b/meta/classes/grub-efi.bbclass
index c6f5d4e..c07e4a1 100644
--- a/meta/classes/grub-efi.bbclass
+++ b/meta/classes/grub-efi.bbclass
@@ -9,6 +9,7 @@ 
 # External variables
 # ${INITRD} - indicates a filesystem image to use as an initrd (optional)
 # ${ROOTFS} - indicates a filesystem image to include as the root filesystem (optional)
+# ${GRUB_GFXSERIAL} - set this to 1 to have graphics and serial in the boot menu
 # ${LABELS} - a list of targets for the automatic config
 # ${APPEND} - an override list of append strings for each label
 # ${GRUB_OPTS} - additional options to add to the config, ';' delimited # (optional)
@@ -16,6 +17,7 @@ 
 
 do_bootimg[depends] += "grub-efi-${TRANSLATED_TARGET_ARCH}-native:do_deploy"
 
+GRUB_SERIAL ?= "console=ttyS0,115200"
 GRUBCFG = "${S}/grub.cfg"
 GRUB_TIMEOUT ?= "10"
 #FIXME: build this from the machine config
@@ -55,6 +57,8 @@  python build_grub_cfg() {
         bb.error("WORKDIR not defined, unable to package")
         return
 
+    gfxserial = d.getVar('GRUB_GFXSERIAL', True) or ""
+
     labels = d.getVar('LABELS', True)
     if not labels:
         bb.debug(1, "LABELS not defined, nothing to do")
@@ -88,6 +92,12 @@  python build_grub_cfg() {
     else:
         cfgfile.write('timeout=50\n')
 
+    if gfxserial == "1":
+        btypes = [ [ " graphics console", "console=tty0" ],
+            [ " serial console", d.getVar('GRUB_SERIAL', True) or "" ] ]
+    else:
+        btypes = [ [ "", "" ] ]
+
     for label in labels.split():
         localdata = d.createCopy()
 
@@ -95,24 +105,27 @@  python build_grub_cfg() {
         if not overrides:
             raise bb.build.FuncFailed('OVERRIDES not defined')
 
-        localdata.setVar('OVERRIDES', label + ':' + overrides)
-        bb.data.update_data(localdata)
+        for btype in btypes:
+            localdata.setVar('OVERRIDES', label + ':' + overrides)
+            bb.data.update_data(localdata)
 
-        cfgfile.write('\nmenuentry \'%s\'{\n' % (label))
-        if label == "install":
-            label = "install-efi"
-        cfgfile.write('linux /vmlinuz LABEL=%s' % (label))
+            cfgfile.write('\nmenuentry \'%s%s\'{\n' % (label, btype[0]))
+            lb = label
+            if label == "install":
+                lb = "install-efi"
+            cfgfile.write('linux /vmlinuz LABEL=%s' % (lb))
 
-        append = localdata.getVar('APPEND', True)
-        initrd = localdata.getVar('INITRD', True)
+            append = localdata.getVar('APPEND', True)
+            initrd = localdata.getVar('INITRD', True)
 
-        if append:
-            cfgfile.write('%s' % (append))
-        cfgfile.write('\n')
+            if append:
+                cfgfile.write('%s' % (append))
+            cfgfile.write(' %s' % btype[1])
+            cfgfile.write('\n')
 
-        if initrd:
-            cfgfile.write('initrd /initrd')
-        cfgfile.write('\n}\n')
+            if initrd:
+                cfgfile.write('initrd /initrd')
+            cfgfile.write('\n}\n')
 
     cfgfile.close()
 }
diff --git a/meta/conf/machine/qemux86-64.conf b/meta/conf/machine/qemux86-64.conf
index c572225..6f68410 100644
--- a/meta/conf/machine/qemux86-64.conf
+++ b/meta/conf/machine/qemux86-64.conf
@@ -21,6 +21,6 @@  XSERVER = "xserver-xorg \
            xf86-input-evdev \
            xf86-video-vmware"
 
-MACHINE_FEATURES += "x86"
+MACHINE_FEATURES += "x86 efi"
 
 MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "v86d"
diff --git a/meta/conf/machine/qemux86.conf b/meta/conf/machine/qemux86.conf
index 94ee573..57a9a50 100644
--- a/meta/conf/machine/qemux86.conf
+++ b/meta/conf/machine/qemux86.conf
@@ -22,5 +22,7 @@  XSERVER = "xserver-xorg \
            xf86-video-vmware"
 
 MACHINE_FEATURES += "x86"
+MACHINE_FEATURES += "efi"
+#MACHINE_FEATURES += "pcbios"
 
 MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "v86d"