diff mbox series

[v4] default-distrovars: Have KERNEL_CONSOLE reference SERIAL_CONSOLES

Message ID 20241001134322.1166436-1-jdmason@kudzu.us
State New
Headers show
Series [v4] default-distrovars: Have KERNEL_CONSOLE reference SERIAL_CONSOLES | expand

Commit Message

Jon Mason Oct. 1, 2024, 1:43 p.m. UTC
Currently, KERNEL_CONSOLE has a default value of "ttyS0".  However, Arm
machines and those using virtio serial prefer to use "ttyAMA0" or "hvc0"
(or something else).  These are usually defined by the machine config
file as SERIAL_CONSOLES, which has one or more entries.  Take the first
one of those instead of ttyS0, but default back to ttyS0 if nothing is
set.

Also, use this variable in the efi wic file instead of "ttyS0".
Of note, this changes the default speed of the default kernel console
from undefined (9600) to 115200.  This allows for users of the
mkefidisk.wks to work as before but any users of this variable could see
changed behavior and would now need to define this as:
KERNEL_CONSOLE ?= "ttyS0,9600"

This includes revisions suggested by Quentin Schulz and Ross Burton.

Signed-off-by: Jon Mason <jdmason@kudzu.us>
---
 meta/classes-recipe/image_types_wic.bbclass     | 1 +
 meta/conf/distro/include/default-distrovars.inc | 3 ++-
 scripts/lib/wic/canned-wks/mkefidisk.wks        | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

Comments

Richard Purdie Oct. 1, 2024, 1:56 p.m. UTC | #1
On Tue, 2024-10-01 at 09:43 -0400, Jon Mason via lists.openembedded.org
wrote:
> Currently, KERNEL_CONSOLE has a default value of "ttyS0".  However,
> Arm
> machines and those using virtio serial prefer to use "ttyAMA0" or
> "hvc0"
> (or something else).  These are usually defined by the machine config
> file as SERIAL_CONSOLES, which has one or more entries.  Take the
> first
> one of those instead of ttyS0, but default back to ttyS0 if nothing
> is
> set.
> 
> Also, use this variable in the efi wic file instead of "ttyS0".
> Of note, this changes the default speed of the default kernel console
> from undefined (9600) to 115200.  This allows for users of the
> mkefidisk.wks to work as before but any users of this variable could
> see
> changed behavior and would now need to define this as:
> KERNEL_CONSOLE ?= "ttyS0,9600"
> 
> This includes revisions suggested by Quentin Schulz and Ross Burton.
> 
> Signed-off-by: Jon Mason <jdmason@kudzu.us>
> ---
>  meta/classes-recipe/image_types_wic.bbclass     | 1 +
>  meta/conf/distro/include/default-distrovars.inc | 3 ++-
>  scripts/lib/wic/canned-wks/mkefidisk.wks        | 2 +-
>  3 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/meta/classes-recipe/image_types_wic.bbclass
> b/meta/classes-recipe/image_types_wic.bbclass
> index 86f40633ebcb..db598e874ad7 100644
> --- a/meta/classes-recipe/image_types_wic.bbclass
> +++ b/meta/classes-recipe/image_types_wic.bbclass
> @@ -26,6 +26,7 @@ WICVARS ?= "\
>  	INITRD \
>  	INITRD_LIVE \
>  	ISODIR \
> +        KERNEL_CONSOLE \

I'll fix that whitespace rather than ask for a v5...

Cheers,

Richard
Jon Mason Oct. 1, 2024, 6:47 p.m. UTC | #2
On Tue, Oct 01, 2024 at 02:56:14PM +0100, Richard Purdie wrote:
> On Tue, 2024-10-01 at 09:43 -0400, Jon Mason via lists.openembedded.org
> wrote:
> > Currently, KERNEL_CONSOLE has a default value of "ttyS0".� However,
> > Arm
> > machines and those using virtio serial prefer to use "ttyAMA0" or
> > "hvc0"
> > (or something else).� These are usually defined by the machine config
> > file as SERIAL_CONSOLES, which has one or more entries.� Take the
> > first
> > one of those instead of ttyS0, but default back to ttyS0 if nothing
> > is
> > set.
> > 
> > Also, use this variable in the efi wic file instead of "ttyS0".
> > Of note, this changes the default speed of the default kernel console
> > from undefined (9600) to 115200.� This allows for users of the
> > mkefidisk.wks to work as before but any users of this variable could
> > see
> > changed behavior and would now need to define this as:
> > KERNEL_CONSOLE ?= "ttyS0,9600"
> > 
> > This includes revisions suggested by Quentin Schulz and Ross Burton.
> > 
> > Signed-off-by: Jon Mason <jdmason@kudzu.us>
> > ---
> > �meta/classes-recipe/image_types_wic.bbclass���� | 1 +
> > �meta/conf/distro/include/default-distrovars.inc | 3 ++-
> > �scripts/lib/wic/canned-wks/mkefidisk.wks������� | 2 +-
> > �3 files changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/meta/classes-recipe/image_types_wic.bbclass
> > b/meta/classes-recipe/image_types_wic.bbclass
> > index 86f40633ebcb..db598e874ad7 100644
> > --- a/meta/classes-recipe/image_types_wic.bbclass
> > +++ b/meta/classes-recipe/image_types_wic.bbclass
> > @@ -26,6 +26,7 @@ WICVARS ?= "\
> > �	INITRD \
> > �	INITRD_LIVE \
> > �	ISODIR \
> > +������� KERNEL_CONSOLE \
> 
> I'll fix that whitespace rather than ask for a v5...

I changed this version to be tabs, which was a comment Peter Kjellerstedt made on v3.

Thanks,
Jon

> 
> Cheers,
> 
> Richard
>
diff mbox series

Patch

diff --git a/meta/classes-recipe/image_types_wic.bbclass b/meta/classes-recipe/image_types_wic.bbclass
index 86f40633ebcb..db598e874ad7 100644
--- a/meta/classes-recipe/image_types_wic.bbclass
+++ b/meta/classes-recipe/image_types_wic.bbclass
@@ -26,6 +26,7 @@  WICVARS ?= "\
 	INITRD \
 	INITRD_LIVE \
 	ISODIR \
+        KERNEL_CONSOLE \
 	KERNEL_IMAGETYPE \
 	MACHINE \
 	PSEUDO_IGNORE_PATHS \
diff --git a/meta/conf/distro/include/default-distrovars.inc b/meta/conf/distro/include/default-distrovars.inc
index 7554081e8b1a..85835c4c6179 100644
--- a/meta/conf/distro/include/default-distrovars.inc
+++ b/meta/conf/distro/include/default-distrovars.inc
@@ -1,7 +1,8 @@ 
 QA_LOGFILE = "${TMPDIR}/qa.log"
 
 OEINCLUDELOGS ?= "yes"
-KERNEL_CONSOLE ?= "ttyS0"
+# if SERIAL_CONSOLES is set, take the first device entry.  Otherwise use ttyS0 as the default
+KERNEL_CONSOLE ?= "${@','.join(d.getVar('SERIAL_CONSOLES').split(' ')[0].split(';')[::-1]) or 'ttyS0,115200'}"
 KEEPUIMAGE ??= "yes"
 
 DEFAULT_IMAGE_LINGUAS = "en-us en-gb"
diff --git a/scripts/lib/wic/canned-wks/mkefidisk.wks b/scripts/lib/wic/canned-wks/mkefidisk.wks
index 9f534fe18471..5fa6682a9e10 100644
--- a/scripts/lib/wic/canned-wks/mkefidisk.wks
+++ b/scripts/lib/wic/canned-wks/mkefidisk.wks
@@ -8,4 +8,4 @@  part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024
 
 part swap --ondisk sda --size 44 --label swap1 --fstype=swap
 
-bootloader --ptable gpt --timeout=5 --append="rootfstype=ext4 console=ttyS0,115200 console=tty0"
+bootloader --ptable gpt --timeout=5 --append="rootfstype=ext4 console=${KERNEL_CONSOLE} console=tty0"